xfs: force file creation to the data device for certain layout tests
[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 _require_test
36 _require_xfs_io_command "inode"
37
38 # We know the root inode is there
39 ROOT_INO=`ls -id $TEST_DIR | awk '{print $1}'`
40
41 touch $TEST_DIR/file
42
43 $XFS_IO_PROG -c "inode"       $TEST_DIR/file
44 $XFS_IO_PROG -c "inode -v"    $TEST_DIR/file | \
45                 grep -vw "^$ROOT_INO" | sed -e s/.*:/LAST:/
46
47 #  These should fail, -n requires an inode
48 $XFS_IO_PROG -c "inode -n"    $TEST_DIR/file 2>&1 | grep -q Query \
49                 || echo "bare -n succeeded"
50 $XFS_IO_PROG -c "inode -nv"   $TEST_DIR/file 2>&1 | grep -q Query \
51                 || echo "bare -nv succeeded"
52 $XFS_IO_PROG -c "inode -n -v" $TEST_DIR/file 2>&1 | grep -q Query \
53                 || echo "bare -n -v succeeded"
54
55 # These fail too, requires a valid inode number
56 $XFS_IO_PROG -c "inode       badnumber" $TEST_DIR/file | grep -q numeric \
57                 || echo "Bad inode number succeeded"
58 $XFS_IO_PROG -c "inode -v    badnumber" $TEST_DIR/file | grep -q numeric \
59                 || echo "Bad inode number succeeded"
60 $XFS_IO_PROG -c "inode -n    badnumber" $TEST_DIR/file | grep -q numeric \
61                 || echo "Bad inode number succeeded"
62 $XFS_IO_PROG -c "inode -nv   badnumber" $TEST_DIR/file | grep -q numeric \
63                 || echo "Bad inode number succeeded"
64 $XFS_IO_PROG -c "inode -n -v badnumber" $TEST_DIR/file | grep -q numeric \
65                 || echo "Bad inode number succeeded"
66
67 # These should all work, and return $ROOT_INO or the next inode...
68 # grep out ROOT_INO (which is incorrect) when we should be getting next inode
69 $XFS_IO_PROG -c "inode       $ROOT_INO" $TEST_DIR/file | \
70                 sed -e s/$ROOT_INO/ROOT_INO/
71 $XFS_IO_PROG -c "inode -v    $ROOT_INO" $TEST_DIR/file | \
72                 sed -e s/$ROOT_INO/ROOT_INO/
73 $XFS_IO_PROG -c "inode -n    $ROOT_INO" $TEST_DIR/file | \
74                 grep -vw "^$ROOT_INO" | sed -e s/.*/NEXT/
75 $XFS_IO_PROG -c "inode -nv   $ROOT_INO" $TEST_DIR/file | \
76                 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
77 $XFS_IO_PROG -c "inode -n -v $ROOT_INO" $TEST_DIR/file | \
78                 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
79
80 # Try one that doesn't exist, 2^64-2?  Should get 0
81 $XFS_IO_PROG -c "inode       18446744073709551614" $TEST_DIR/file
82 $XFS_IO_PROG -c "inode -v    18446744073709551614" $TEST_DIR/file
83 $XFS_IO_PROG -c "inode -n    18446744073709551614" $TEST_DIR/file
84 $XFS_IO_PROG -c "inode -nv   18446744073709551614" $TEST_DIR/file
85 $XFS_IO_PROG -c "inode -n -v 18446744073709551614" $TEST_DIR/file
86
87 status=0
88 exit