Skip to content

Commit 8dfe670

Browse files
authored
Merge pull request #1841 from petterreinholdtsen/tests-skip-sudo-option
Added runtests option -u to skip test requiring sudo access
2 parents 0ccb307 + eeb1fc0 commit 8dfe670

10 files changed

Lines changed: 41 additions & 3 deletions

File tree

scripts/runtests.in

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export RUNTESTS="$(readlink -f $0)"
4646
NUM=0
4747
FAIL=0; FAIL_NAMES=""
4848
XFAIL=0
49+
SKIP=0
4950
VERBOSE=0
5051

5152
clean () {
@@ -126,7 +127,16 @@ run_tests () {
126127
testdir=$(dirname $testname)
127128
if [ -e $testdir/skip ]; then
128129
if ! [ -x $testdir/skip ] || ! $testdir/skip; then
129-
echo "Skipping test: $testdir" 1>&2
130+
echo "Skipping disabled test: $testdir" 1>&2
131+
SKIP=$(($SKIP+1))
132+
continue
133+
fi
134+
fi
135+
if $NOSUDO && [ -e $testdir/control ] && \
136+
grep Restrictions: $testdir/control | grep -q sudo; then
137+
if ! [ -x $testdir/skip ] || ! $testdir/skip; then
138+
echo "Skipping sudo test: $testdir" 1>&2
139+
SKIP=$(($SKIP+1))
130140
continue
131141
fi
132142
fi
@@ -204,7 +214,7 @@ run_tests () {
204214
done < $TMPDIR/alltests
205215

206216
SUCC=$((NUM-FAIL-XFAIL))
207-
echo "Runtest: $NUM tests run, $SUCC successful, $FAIL failed + $XFAIL expected"
217+
echo "Runtest: $NUM tests run, $SUCC successful, $FAIL failed + $XFAIL expected, $SKIP skipped"
208218
if [ $FAIL -ne 0 ]; then
209219
echo "Failed: $FAIL_NAMES"
210220
exit 1;
@@ -227,19 +237,25 @@ Usage:
227237
$P -c tests
228238
Remove temporary files from an earlier test run.
229239
240+
$P -u
241+
Only run tests that require normal user access. Skip tests
242+
requiring root or sudo.
243+
230244
$P -v
231245
Show stdout and stderr (normally it's hidden).
232246
EOF
233247
}
234248

235249
CLEAN_ONLY=0
236250
NOCLEAN=0
251+
NOSUDO=false
237252
STOP=0
238253
PRINT=0
239-
while getopts cnvsph opt; do
254+
while getopts cnuvsph opt; do
240255
case "$opt" in
241256
c) CLEAN_ONLY=1 ;;
242257
n) NOCLEAN=1 ;;
258+
u) NOSUDO=true ;;
243259
v) VERBOSE=1 ;;
244260
s) STOP=1 ;;
245261
p) PRINT=1 ;;

tests/README

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ can be run by executing (from the top emc2 directory)
2929
scripts/runtests tests
3030
A subset of the tests can also be run:
3131
scripts/runtests tests/xyz tests/a*
32+
33+
To only run the tests that do not require root or sudo access, use the
34+
-u option:
35+
36+
scripts/runtests -u tests
37+
3238
The directories named on the commandline are searched recursively for
3339
'test.hal' or 'test.sh' files, and a directory with such a file is
3440
assumed to contain a regression test or a functional test.
@@ -93,3 +99,11 @@ and see if it indicates success.
9399

94100
The test passes if the command "checkresult actual" returns a shell
95101
success value (exit code 0). Otherwise, the test fails.
102+
103+
Tests requiring root or sudo access are flagged by creating a file
104+
named control in the test directory, with the 'sudo' flag in the
105+
Restrictions field:
106+
107+
Restrictions: sudo
108+
109+
Other restrictions might be added in the future
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restrictions: sudo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restrictions: sudo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restrictions: sudo

tests/realtime-math/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restrictions: sudo

tests/rtapi-shmem/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restrictions: sudo

tests/symbols.0/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restrictions: sudo

tests/symbols.1/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restrictions: sudo

tests/uspace/spawnv-root/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restrictions: sudo

0 commit comments

Comments
 (0)