annotate scripts/runtest.sh @ 1499:319e79bab052 draft

Separate more commands so single.sh can build them standalone.
author Rob Landley <rob@landley.net>
date Fri, 26 Sep 2014 18:42:23 -0500
parents 8700cbe1cb29
children e6a4ed6fc873
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
156
1e8f4b05cb65 Remove trailing whitespace (thanks to Charlie Shepherd), and a couple comment
Rob Landley <rob@landley.net>
parents: 103
diff changeset
1 # Simple test harness infrastructure
103
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
2 #
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 # Copyright 2005 by Rob Landley
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 # This file defines two functions, "testing" and "optionflag"
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 # The following environment variables enable optional behavior in "testing":
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 # DEBUG - Show every command run by test script.
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 # VERBOSE - Print the diff -u of each failed test case.
1449
0de09d7f503d Add VERBOSE=fail to "make tests", based on suggestion from Johan Bergstr?m.
Rob Landley <rob@landley.net>
parents: 782
diff changeset
10 # If equal to "fail", stop after first failed test.
103
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 # SKIP - do not perform this test (this is set by "optionflag")
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 #
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 # The "testing" function takes five arguments:
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 # $1) Description to display when running command
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 # $2) Command line arguments to command
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 # $3) Expected result (on stdout)
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 # $4) Data written to file "input"
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 # $5) Data written to stdin
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 #
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 # The exit value of testing is the exit value of the command it ran.
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 #
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 # The environment variable "FAILCOUNT" contains a cumulative total of the
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 # number of failed tests.
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
24
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 # The "optional" function is used to skip certain tests, ala:
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 # optionflag CFG_THINGY
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
27 #
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 # The "optional" function checks the environment variable "OPTIONFLAGS",
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 # which is either empty (in which case it always clears SKIP) or
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 # else contains a colon-separated list of features (in which case the function
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 # clears SKIP if the flag was found, or sets it to 1 if the flag was not found).
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
32
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 export FAILCOUNT=0
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 export SKIP=
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
35
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 # Helper functions
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
37
421
1ca548d46c8e Test suite comment tweaks.
Rob Landley <rob@landley.net>
parents: 301
diff changeset
38 # Check config to see if option is enabled, set SKIP if not.
1ca548d46c8e Test suite comment tweaks.
Rob Landley <rob@landley.net>
parents: 301
diff changeset
39
103
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
40 optional()
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
41 {
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 option=`echo "$OPTIONFLAGS" | egrep "(^|:)$1(:|\$)"`
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 # Not set?
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
44 if [ -z "$1" ] || [ -z "$OPTIONFLAGS" ] || [ ${#option} -ne 0 ]
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 then
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
46 SKIP=""
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
47 return
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 fi
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
49 SKIP=1
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
50 }
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
51
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
52 # The testing function
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
53
1485
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1449
diff changeset
54 testing()
103
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 {
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
56 NAME="$1"
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
57 [ -z "$1" ] && NAME=$2
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
58
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
59 if [ $# -ne 5 ]
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
60 then
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
61 echo "Test $NAME has the wrong number of arguments ($# $*)" >&2
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
62 exit
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
63 fi
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
64
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
65 [ -n "$DEBUG" ] && set -x
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
66
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
67 if [ -n "$SKIP" ]
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
68 then
301
2e2529e298ee Cosmetic tweak, only show skipped tests when VERBOSE set.
Rob Landley <rob@landley.net>
parents: 205
diff changeset
69 [ ! -z "$VERBOSE" ] && echo "SKIPPED: $NAME"
103
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
70 return 0
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
71 fi
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
72
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
73 echo -ne "$3" > expected
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
74 echo -ne "$4" > input
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
75 echo -ne "$5" | eval "$2" > actual
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
76 RETVAL=$?
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
77
782
3d7526f6115b Use basename() where appropriate.
Rob Landley <rob@landley.net>
parents: 421
diff changeset
78 cmp expected actual > /dev/null 2>&1
103
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
79 if [ $? -ne 0 ]
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
80 then
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
81 FAILCOUNT=$[$FAILCOUNT+1]
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
82 echo "FAIL: $NAME"
205
ea8149345b78 Tweak testing.sh so VERBOSE=1 is less noisy.
Rob Landley <rob@landley.net>
parents: 156
diff changeset
83 if [ -n "$VERBOSE" ]
ea8149345b78 Tweak testing.sh so VERBOSE=1 is less noisy.
Rob Landley <rob@landley.net>
parents: 156
diff changeset
84 then
ea8149345b78 Tweak testing.sh so VERBOSE=1 is less noisy.
Rob Landley <rob@landley.net>
parents: 156
diff changeset
85 echo "echo '$5' | $2"
ea8149345b78 Tweak testing.sh so VERBOSE=1 is less noisy.
Rob Landley <rob@landley.net>
parents: 156
diff changeset
86 diff -u expected actual
1449
0de09d7f503d Add VERBOSE=fail to "make tests", based on suggestion from Johan Bergstr?m.
Rob Landley <rob@landley.net>
parents: 782
diff changeset
87 [ "$VERBOSE" == fail ] && exit 1
205
ea8149345b78 Tweak testing.sh so VERBOSE=1 is less noisy.
Rob Landley <rob@landley.net>
parents: 156
diff changeset
88 fi
103
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
89 else
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
90 echo "PASS: $NAME"
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
91 fi
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
92 rm -f input expected actual
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
93
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
94 [ -n "$DEBUG" ] && set +x
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
95
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
96 return $RETVAL
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
97 }
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
98
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
99 # Recursively grab an executable and all the libraries needed to run it.
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
100 # Source paths beginning with / will be copied into destpath, otherwise
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
101 # the file is assumed to already be there and only its library dependencies
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
102 # are copied.
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
103
1485
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1449
diff changeset
104 mkchroot()
103
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
105 {
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
106 [ $# -lt 2 ] && return
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
107
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
108 echo -n .
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
109
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
110 dest=$1
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
111 shift
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
112 for i in "$@"
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
113 do
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
114 [ "${i:0:1}" == "/" ] || i=$(which $i)
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
115 [ -f "$dest/$i" ] && continue
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
116 if [ -e "$i" ]
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
117 then
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
118 d=`echo "$i" | grep -o '.*/'` &&
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
119 mkdir -p "$dest/$d" &&
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
120 cat "$i" > "$dest/$i" &&
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
121 chmod +x "$dest/$i"
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
122 else
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
123 echo "Not found: $i"
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
124 fi
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
125 mkchroot "$dest" $(ldd "$i" | egrep -o '/.* ')
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
126 done
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
127 }
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
128
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
129 # Set up a chroot environment and run commands within it.
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
130 # Needed commands listed on command line
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
131 # Script fed to stdin.
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
132
1485
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1449
diff changeset
133 dochroot()
103
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
134 {
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
135 mkdir tmpdir4chroot
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
136 mount -t ramfs tmpdir4chroot tmpdir4chroot
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
137 mkdir -p tmpdir4chroot/{etc,sys,proc,tmp,dev}
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
138 cp -L testing.sh tmpdir4chroot
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
139
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
140 # Copy utilities from command line arguments
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
141
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
142 echo -n "Setup chroot"
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
143 mkchroot tmpdir4chroot $*
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
144 echo
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
145
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
146 mknod tmpdir4chroot/dev/tty c 5 0
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
147 mknod tmpdir4chroot/dev/null c 1 3
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
148 mknod tmpdir4chroot/dev/zero c 1 5
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
149
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
150 # Copy script from stdin
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
151
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
152 cat > tmpdir4chroot/test.sh
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
153 chmod +x tmpdir4chroot/test.sh
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
154 chroot tmpdir4chroot /test.sh
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
155 umount -l tmpdir4chroot
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
156 rmdir tmpdir4chroot
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
157 }
417591818dcb An old test suite wrapper I wrote, cleaned up a bit and checked for copyrights.
Rob Landley <rob@landley.net>
parents:
diff changeset
158