tests: remove udf/101
[xfstests-dev.git] / tests / generic / 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
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 tmp=/tmp/$$
34 here=`pwd`
35 status=0        # success is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
37
38 _cleanup()
39 {
40     rm -f $tmp.*
41 }
42
43 # real QA test starts here
44 _supported_fs generic
45 _supported_os IRIX Linux
46 _require_test
47
48 rm -f $seqres.full
49
50 echo "Silence is goodness ..."
51
52 # ensure target directory exists
53 mkdir `dirname $TEST_DIR/$tmp` 2>/dev/null
54
55 touch $TEST_DIR/$tmp.1
56 for l in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
57 do
58     ln $TEST_DIR/$tmp.1 $TEST_DIR/$tmp.$l
59     x=`src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
60     if [ "$l" -ne $x ]
61     then
62         echo "Arrgh, created link #$l and lstat64 looks like ..."
63         src/lstat64 $TEST_DIR/$tmp.1
64         status=1
65     fi
66 done
67
68 for l in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
69 do
70     x=`src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
71     if [ "$l" -ne $x ]
72     then
73         echo "Arrgh, about to remove link #$l and lstat64 looks like ..."
74         src/lstat64 $TEST_DIR/$tmp.1
75         status=1
76     fi
77     rm -f $TEST_DIR/$tmp.$l
78 done
79
80 # success, all done
81 exit