really fix 044 and its use of _unexpected this time.
[xfstests-dev.git] / 002
1 #! /bin/sh
2 #
3 # XFS QA Test No. 002
4 # $Id: 1.1 $
5 #
6 # simple inode link count test for a regular file
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
10
11 # This program is free software; you can redistribute it and/or modify it
12 # under the terms of version 2 of the GNU General Public License as
13 # published by the Free Software Foundation.
14
15 # This program is distributed in the hope that it would be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
19 # Further, this software is distributed without any warranty that it is
20 # free of the rightful claim of any third person regarding infringement
21 # or the like.  Any license provided herein, whether implied or
22 # otherwise, applies only to this software file.  Patent licenses, if
23 # any, provided herein do not apply to combinations of this program with
24 # other software, or any other product whatsoever.
25
26 # You should have received a copy of the GNU General Public License along
27 # with this program; if not, write the Free Software Foundation, Inc., 59
28 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
29
30 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
31 # Mountain View, CA  94043, or:
32
33 # http://www.sgi.com 
34
35 # For further information regarding this notice, see: 
36
37 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
38 #-----------------------------------------------------------------------
39 #
40 # creator
41 owner=kenmcd@sgi.com
42
43 seq=`basename $0`
44 echo "QA output created by $seq"
45
46 # get standard environment, filters and checks
47 . ./common.rc
48 . ./common.filter
49
50 tmp=/tmp/$$
51 here=`pwd`
52 status=0        # success is the default!
53 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
54
55 # real QA test starts here
56
57 echo "Silence is goodness ..."
58
59 # ensure target directory exists
60 mkdir `dirname $TEST_DIR/$tmp` 2>/dev/null
61
62 touch $TEST_DIR/$tmp.1
63 for l in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
64 do
65     ln $TEST_DIR/$tmp.1 $TEST_DIR/$tmp.$l
66     x=`src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
67     if [ "$l" -ne $x ]
68     then
69         echo "Arrgh, created link #$l and lstat64 looks like ..."
70         src/lstat64 $TEST_DIR/$tmp.1
71         status=1
72     fi
73 done
74
75 for l in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
76 do
77     x=`src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
78     if [ "$l" -ne $x ]
79     then
80         echo "Arrgh, about to remove link #$l and lstat64 looks like ..."
81         src/lstat64 $TEST_DIR/$tmp.1
82         status=1
83     fi
84     rm -f $TEST_DIR/$tmp.$l
85 done
86
87 # success, all done
88 exit