overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / xfs / 054
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 054
6 #
7 # Exercise the xfs_io inode command
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # remove previous $seqres.full before test
29 rm -f $seqres.full
30
31 # real QA test starts here
32
33 # Modify as appropriate.
34 _supported_fs xfs
35 _supported_os Linux
36 _require_test
37 _require_xfs_io_command "inode"
38
39 # We know the root inode is there
40 ROOT_INO=`ls -id $TEST_DIR | awk '{print $1}'`
41
42 touch $TEST_DIR/file
43
44 $XFS_IO_PROG -c "inode"       $TEST_DIR/file
45 $XFS_IO_PROG -c "inode -v"    $TEST_DIR/file | \
46                 grep -vw "^$ROOT_INO" | sed -e s/.*:/LAST:/
47
48 #  These should fail, -n requires an inode
49 $XFS_IO_PROG -c "inode -n"    $TEST_DIR/file 2>&1 | grep -q Query \
50                 || echo "bare -n succeeded"
51 $XFS_IO_PROG -c "inode -nv"   $TEST_DIR/file 2>&1 | grep -q Query \
52                 || echo "bare -nv succeeded"
53 $XFS_IO_PROG -c "inode -n -v" $TEST_DIR/file 2>&1 | grep -q Query \
54                 || echo "bare -n -v succeeded"
55
56 # These fail too, requires a valid inode number
57 $XFS_IO_PROG -c "inode       badnumber" $TEST_DIR/file | grep -q numeric \
58                 || echo "Bad inode number succeeded"
59 $XFS_IO_PROG -c "inode -v    badnumber" $TEST_DIR/file | grep -q numeric \
60                 || echo "Bad inode number succeeded"
61 $XFS_IO_PROG -c "inode -n    badnumber" $TEST_DIR/file | grep -q numeric \
62                 || echo "Bad inode number succeeded"
63 $XFS_IO_PROG -c "inode -nv   badnumber" $TEST_DIR/file | grep -q numeric \
64                 || echo "Bad inode number succeeded"
65 $XFS_IO_PROG -c "inode -n -v badnumber" $TEST_DIR/file | grep -q numeric \
66                 || echo "Bad inode number succeeded"
67
68 # These should all work, and return $ROOT_INO or the next inode...
69 # grep out ROOT_INO (which is incorrect) when we should be getting next inode
70 $XFS_IO_PROG -c "inode       $ROOT_INO" $TEST_DIR/file | \
71                 sed -e s/$ROOT_INO/ROOT_INO/
72 $XFS_IO_PROG -c "inode -v    $ROOT_INO" $TEST_DIR/file | \
73                 sed -e s/$ROOT_INO/ROOT_INO/
74 $XFS_IO_PROG -c "inode -n    $ROOT_INO" $TEST_DIR/file | \
75                 grep -vw "^$ROOT_INO" | sed -e s/.*/NEXT/
76 $XFS_IO_PROG -c "inode -nv   $ROOT_INO" $TEST_DIR/file | \
77                 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
78 $XFS_IO_PROG -c "inode -n -v $ROOT_INO" $TEST_DIR/file | \
79                 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
80
81 # Try one that doesn't exist, 2^64-2?  Should get 0
82 $XFS_IO_PROG -c "inode       18446744073709551614" $TEST_DIR/file
83 $XFS_IO_PROG -c "inode -v    18446744073709551614" $TEST_DIR/file
84 $XFS_IO_PROG -c "inode -n    18446744073709551614" $TEST_DIR/file
85 $XFS_IO_PROG -c "inode -nv   18446744073709551614" $TEST_DIR/file
86 $XFS_IO_PROG -c "inode -n -v 18446744073709551614" $TEST_DIR/file
87
88 status=0
89 exit