xfstests: eliminate warnings under dmapi/src/suite1/cmd (3)
[xfstests-dev.git] / 002
1 #! /bin/bash
2 # FS QA Test No. 002
3 #
4 # simple inode link count test for a regular file
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24 # creator
25 owner=kenmcd@sgi.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 # get standard environment, filters and checks
31 . ./common.rc
32 . ./common.filter
33
34 tmp=/tmp/$$
35 here=`pwd`
36 status=0        # success is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 _cleanup()
40 {
41     rm -f $tmp.*
42     _cleanup_testdir
43 }
44
45 # real QA test starts here
46 _supported_fs generic
47 _supported_os IRIX Linux
48
49 _setup_testdir
50
51 echo "Silence is goodness ..."
52
53 # ensure target directory exists
54 mkdir `dirname $testdir/$tmp` 2>/dev/null
55
56 touch $testdir/$tmp.1
57 for l in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
58 do
59     ln $testdir/$tmp.1 $testdir/$tmp.$l
60     x=`src/lstat64 $testdir/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
61     if [ "$l" -ne $x ]
62     then
63         echo "Arrgh, created link #$l and lstat64 looks like ..."
64         src/lstat64 $testdir/$tmp.1
65         status=1
66     fi
67 done
68
69 for l in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
70 do
71     x=`src/lstat64 $testdir/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
72     if [ "$l" -ne $x ]
73     then
74         echo "Arrgh, about to remove link #$l and lstat64 looks like ..."
75         src/lstat64 $testdir/$tmp.1
76         status=1
77     fi
78     rm -f $testdir/$tmp.$l
79 done
80
81 # success, all done
82 exit