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