fstests: move test group info to test files
[xfstests-dev.git] / tests / xfs / 160
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 160
6 #
7 # Check that we can upgrade a filesystem to support bigtime and that inode
8 # timestamps work properly after the upgrade.
9
10 . ./common/preamble
11 _begin_fstest auto quick bigtime
12
13 # Import common functions.
14 . ./common/filter
15
16 # real QA test starts here
17 _supported_fs xfs
18 _require_command "$XFS_ADMIN_PROG" "xfs_admin"
19 _require_scratch_xfs_bigtime
20 _require_xfs_repair_upgrade bigtime
21
22 date --date='Jan 1 00:00:00 UTC 2040' > /dev/null 2>&1 || \
23         _notrun "Userspace does not support dates past 2038."
24
25 # Make sure we can't upgrade a V4 filesystem
26 _scratch_mkfs -m crc=0 >> $seqres.full
27 _scratch_xfs_admin -O bigtime=1 2>> $seqres.full
28 _check_scratch_xfs_features BIGTIME
29
30 # Make sure we're required to specify a feature status
31 _scratch_mkfs -m crc=1,bigtime=0,inobtcount=0 >> $seqres.full
32 _scratch_xfs_admin -O bigtime 2>> $seqres.full
33
34 # Can we add bigtime and inobtcount at the same time?
35 _scratch_mkfs -m crc=1,bigtime=0,inobtcount=0 >> $seqres.full
36 _scratch_xfs_admin -O bigtime=1,inobtcount=1 2>> $seqres.full
37
38 # Format V5 filesystem without bigtime support and populate it
39 _scratch_mkfs -m crc=1,bigtime=0 >> $seqres.full
40 _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
41 _scratch_mount >> $seqres.full
42
43 touch -d 'Jan 9 19:19:19 UTC 1999' $SCRATCH_MNT/a
44 touch -d 'Jan 9 19:19:19 UTC 1999' $SCRATCH_MNT/b
45 ls -la $SCRATCH_MNT/* >> $seqres.full
46
47 echo before upgrade:
48 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
49 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
50
51 _scratch_unmount
52 _check_scratch_fs
53
54 # Now upgrade to bigtime support
55 _scratch_xfs_admin -O bigtime=1 2>> $seqres.full
56 _check_scratch_xfs_features BIGTIME
57 _check_scratch_fs
58 _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
59
60 # Mount again, look at our files
61 _scratch_mount >> $seqres.full
62 ls -la $SCRATCH_MNT/* >> $seqres.full
63
64 echo after upgrade:
65 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
66 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
67
68 # Bump one of the timestamps but stay under 2038
69 touch -d 'Jan 10 19:19:19 UTC 1999' $SCRATCH_MNT/a
70
71 echo after upgrade and bump:
72 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
73 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
74
75 _scratch_cycle_mount
76
77 # Did the bumped timestamp survive the remount?
78 ls -la $SCRATCH_MNT/* >> $seqres.full
79
80 echo after upgrade, bump, and remount:
81 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
82 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
83
84 # Modify the other timestamp to stretch beyond 2038
85 touch -d 'Feb 22 22:22:22 UTC 2222' $SCRATCH_MNT/b
86
87 echo after upgrade and extension:
88 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
89 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
90
91 _scratch_cycle_mount
92
93 # Did the timestamp survive the remount?
94 ls -la $SCRATCH_MNT/* >> $seqres.full
95
96 echo after upgrade, extension, and remount:
97 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
98 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
99
100 # success, all done
101 status=0
102 exit