aboutsummaryrefslogtreecommitdiff
path: root/testsuite/testing.sh
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/testing.sh')
-rwxr-xr-xtestsuite/testing.sh63
1 files changed, 45 insertions, 18 deletions
diff --git a/testsuite/testing.sh b/testsuite/testing.sh
index 08f4200c5..bec5976e1 100755
--- a/testsuite/testing.sh
+++ b/testsuite/testing.sh
@@ -56,45 +56,41 @@ optional()
56 56
57testing () 57testing ()
58{ 58{
59 NAME="$1"
60 [ -z "$1" ] && NAME=$2
61
59 if [ $# -ne 5 ] 62 if [ $# -ne 5 ]
60 then 63 then
61 echo "Test $1 has the wrong number of arguments ($# $*)" >&2 64 echo "Test $NAME has the wrong number of arguments ($# $*)" >&2
62 exit 65 exit
63 fi 66 fi
64 67
65 if [ -n "$DEBUG" ] ; then 68 [ -n "$DEBUG" ] && set -x
66 set -x
67 fi
68 69
69 if [ -n "$SKIP" ] 70 if [ -n "$SKIP" ]
70 then 71 then
71 echo "SKIPPED: $1" 72 echo "SKIPPED: $NAME"
72 return 0 73 return 0
73 fi 74 fi
74 75
75 echo -ne "$3" > expected 76 echo -ne "$3" > expected
76 echo -ne "$4" > input 77 echo -ne "$4" > input
77 echo -ne "$5" | eval "$COMMAND $2" > actual 78 [ -z "$VERBOSE" ] || echo "echo '$5' | $COMMAND $2"
79 echo -ne "$5" | eval "$2" > actual
78 RETVAL=$? 80 RETVAL=$?
79 81
80 cmp expected actual > /dev/null 82 cmp expected actual > /dev/null
81 if [ $? -ne 0 ] 83 if [ $? -ne 0 ]
82 then 84 then
83 FAILCOUNT=$[$FAILCOUNT+1] 85 FAILCOUNT=$[$FAILCOUNT+1]
84 echo "FAIL: $1" 86 echo "FAIL: $NAME"
85 if [ -n "$VERBOSE" ] 87 [ -n "$VERBOSE" ] && diff -u expected actual
86 then
87 diff -u expected actual
88 fi
89 else 88 else
90 echo "PASS: $1" 89 echo "PASS: $NAME"
91 fi 90 fi
92 rm -f input expected actual 91 rm -f input expected actual
93 92
94 if [ -n "$DEBUG" ] 93 [ -n "$DEBUG" ] && set +x
95 then
96 set +x
97 fi
98 94
99 return $RETVAL 95 return $RETVAL
100} 96}
@@ -108,6 +104,8 @@ function mkchroot
108{ 104{
109 [ $# -lt 2 ] && return 105 [ $# -lt 2 ] && return
110 106
107 echo -n .
108
111 dest=$1 109 dest=$1
112 shift 110 shift
113 for i in "$@" 111 for i in "$@"
@@ -119,9 +117,38 @@ function mkchroot
119 mkdir -p "$dest/$d" && 117 mkdir -p "$dest/$d" &&
120 cat "$i" > "$dest/$i" && 118 cat "$i" > "$dest/$i" &&
121 chmod +x "$dest/$i" 119 chmod +x "$dest/$i"
122 else
123 i="$dest/$i"
124 fi 120 fi
125 mkchroot "$dest" $(ldd "$i" | egrep -o '/.* ') 121 mkchroot "$dest" $(ldd "$i" | egrep -o '/.* ')
126 done 122 done
127} 123}
124
125# Set up a chroot environment and run commands within it.
126# Needed commands listed on command line
127# Script fed to stdin.
128
129function dochroot
130{
131 mkdir tmpdir4chroot
132 mount -t ramfs tmpdir4chroot tmpdir4chroot
133 mkdir -p tmpdir4chroot/{etc,sys,proc,tmp,dev}
134 cp -L testing.sh tmpdir4chroot
135
136 # Copy utilities from command line arguments
137
138 echo -n "Setup chroot"
139 mkchroot tmpdir4chroot $*
140 echo
141
142 mknod tmpdir4chroot/dev/tty c 5 0
143 mknod tmpdir4chroot/dev/null c 1 3
144 mknod tmpdir4chroot/dev/zero c 1 5
145
146 # Copy script from stdin
147
148 cat > tmpdir4chroot/test.sh
149 chmod +x tmpdir4chroot/test.sh
150 chroot tmpdir4chroot /test.sh
151 umount -l tmpdir4chroot
152 rmdir tmpdir4chroot
153}
154