summaryrefslogtreecommitdiff
path: root/tests/xfs/054
blob: becb76ac09ec593b7579827401efb09b8c5b1249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
#
# FS QA Test 054
#
# Exercise the xfs_io inode command
#
. ./common/preamble
_begin_fstest auto quick

# Import common functions.
. ./common/filter

# real QA test starts here

# Modify as appropriate.
_supported_fs xfs
_require_test
_require_xfs_io_command "inode"

# We know the root inode is there
ROOT_INO=`ls -id $TEST_DIR | awk '{print $1}'`

touch $TEST_DIR/file

$XFS_IO_PROG -c "inode"       $TEST_DIR/file
$XFS_IO_PROG -c "inode -v"    $TEST_DIR/file | \
		grep -vw "^$ROOT_INO" | sed -e s/.*:/LAST:/

#  These should fail, -n requires an inode
$XFS_IO_PROG -c "inode -n"    $TEST_DIR/file 2>&1 | grep -q Query \
		|| echo "bare -n succeeded"
$XFS_IO_PROG -c "inode -nv"   $TEST_DIR/file 2>&1 | grep -q Query \
		|| echo "bare -nv succeeded"
$XFS_IO_PROG -c "inode -n -v" $TEST_DIR/file 2>&1 | grep -q Query \
		|| echo "bare -n -v succeeded"

# These fail too, requires a valid inode number
$XFS_IO_PROG -c "inode       badnumber" $TEST_DIR/file | grep -q numeric \
		|| echo "Bad inode number succeeded"
$XFS_IO_PROG -c "inode -v    badnumber" $TEST_DIR/file | grep -q numeric \
		|| echo "Bad inode number succeeded"
$XFS_IO_PROG -c "inode -n    badnumber" $TEST_DIR/file | grep -q numeric \
		|| echo "Bad inode number succeeded"
$XFS_IO_PROG -c "inode -nv   badnumber" $TEST_DIR/file | grep -q numeric \
		|| echo "Bad inode number succeeded"
$XFS_IO_PROG -c "inode -n -v badnumber" $TEST_DIR/file | grep -q numeric \
		|| echo "Bad inode number succeeded"

# These should all work, and return $ROOT_INO or the next inode...
# grep out ROOT_INO (which is incorrect) when we should be getting next inode
$XFS_IO_PROG -c "inode       $ROOT_INO" $TEST_DIR/file | \
		sed -e s/$ROOT_INO/ROOT_INO/
$XFS_IO_PROG -c "inode -v    $ROOT_INO" $TEST_DIR/file | \
		sed -e s/$ROOT_INO/ROOT_INO/
$XFS_IO_PROG -c "inode -n    $ROOT_INO" $TEST_DIR/file | \
		grep -vw "^$ROOT_INO" | sed -e s/.*/NEXT/
$XFS_IO_PROG -c "inode -nv   $ROOT_INO" $TEST_DIR/file | \
		grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
$XFS_IO_PROG -c "inode -n -v $ROOT_INO" $TEST_DIR/file | \
		grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/

# Try one that doesn't exist, 2^64-2?  Should get 0
$XFS_IO_PROG -c "inode       18446744073709551614" $TEST_DIR/file
$XFS_IO_PROG -c "inode -v    18446744073709551614" $TEST_DIR/file
$XFS_IO_PROG -c "inode -n    18446744073709551614" $TEST_DIR/file
$XFS_IO_PROG -c "inode -nv   18446744073709551614" $TEST_DIR/file
$XFS_IO_PROG -c "inode -n -v 18446744073709551614" $TEST_DIR/file

status=0
exit