aboutsummaryrefslogtreecommitdiff
path: root/tests/aux
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-06-02 11:57:42 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-06-02 11:57:42 +0300
commit685600d72b0c300f94c0c69dc0a16c4ebb230a21 (patch)
tree3a3ea6f43a8cdc543118e2cf81d29628dc82f61f /tests/aux
parentcc298a11a131b162f291d6ee27ba1d7598a1b6c4 (diff)
downloadpies-685600d72b0c300f94c0c69dc0a16c4ebb230a21.tar.gz
pies-685600d72b0c300f94c0c69dc0a16c4ebb230a21.tar.bz2
Rewrite the testsuite
The aim is to run pies in foreground if possible. Limit execution time using external wrapper. * src/pies.c: (_cb_redir): Consistently return 1 on errors. * tests/aux/sleepexit: New file. * tests/aux/startcheck: New file. * tests/aux/touchfile: Change arguments. * tests/aux/respawn: Rewrite. * tests/lines.c: New noinst program. * tests/to.c: New noinst program. * tests/.gitignore: Add new programs. * tests/Makefile.am: Update. * tests/env.at: Use to to avoid hanging forever. Add missing popdef. * tests/redirect.at: Use echo as component program. * tests/respawn.at: Run pies in foreground. Use to to limit execution time. * tests/shell.at: Likewise. * tests/shutdown.at: Likewise. * tests/startup.at: Likewise. * tests/ret-exec.at: Use sleepexit as component program. * tests/ret-notify.at: Likewise.
Diffstat (limited to 'tests/aux')
-rwxr-xr-xtests/aux/respawn75
-rwxr-xr-xtests/aux/sleepexit8
-rwxr-xr-xtests/aux/startcheck22
-rwxr-xr-xtests/aux/touchfile10
4 files changed, 52 insertions, 63 deletions
diff --git a/tests/aux/respawn b/tests/aux/respawn
index cd9687a..afed85b 100755
--- a/tests/aux/respawn
+++ b/tests/aux/respawn
@@ -1,63 +1,22 @@
#! /bin/sh
-# usage: respawn [-append] [-stderr FILE] [-stdout FILE] [-sleep TIME]
-# [-pid FILE] [-tag STRING] [-exit CODE]
+# usage: respawn FILE COUNT
-append=0
-unset name
-time=1
-tag=$0
-code=0
+file=${1:?}
+maxcount=${2:?}
-while [ $# -ne 0 ]
-do
- arg=$1
- shift
- case $arg in
- -append)
- append=1;;
- -stderr)
- name=${1:?missing argument for -stderr}
- shift
- if [ $append -eq 1 ]; then
- exec 2>>$name
- append=0
- else
- exec 2>$name
- fi;;
- -stdout)
- name=${1:?missing argument for -stdout}
- shift
- if [ $append -eq 1 ]; then
- exec >>$name
- append=0
- else
- exec >$name
- fi;;
- -sleep)
- time=${1:?missing argument for -sleep}
- shift;;
- -pid)
- name=${1:?missing argument for -pid}
- shift
- if [ $append -eq 1 ]; then
- echo $$ >>$name
- append=0
- else
- echo $$ >$name
- fi;;
- -tag)
- tag=${1:?missing argument for -tag}
- shift;;
- -exit)
- code=${1:?missing argument for -exit}
- shift;;
- *) echo >&2 "$tag: invalid argument: $arg"
- exit 1
- esac
-done
+count=0
-echo "$tag: start"
-sleep $time
-echo "$tag: stop"
-exit $code
+if [ -f $file ]; then
+ count=`cat $file`
+ if test -n "$count" && test $count -ge $maxcount; then
+ exit 1
+ fi
+fi
+
+count=$(($count + 1))
+echo "$count" > $file
+
+exit 0
+
+
diff --git a/tests/aux/sleepexit b/tests/aux/sleepexit
new file mode 100755
index 0000000..25a9a5b
--- /dev/null
+++ b/tests/aux/sleepexit
@@ -0,0 +1,8 @@
+#! /bin/sh
+t=${1:?}
+c=${2:?}
+if test -n "$3"; then
+ echo $$ > $3
+fi
+sleep $t
+exit $c
diff --git a/tests/aux/startcheck b/tests/aux/startcheck
new file mode 100755
index 0000000..6e84959
--- /dev/null
+++ b/tests/aux/startcheck
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# usage: startcheck FILE...
+
+for file
+do
+ if [ -f $file ]; then
+ echo "# $file"
+ cat $file
+ else
+ echo >&2 "$0: $file does not exist"
+ exit 1
+ fi
+done
+
+exit 0
+
+
+
+
+
+
diff --git a/tests/aux/touchfile b/tests/aux/touchfile
index b9d92a3..a3a2668 100755
--- a/tests/aux/touchfile
+++ b/tests/aux/touchfile
@@ -1,7 +1,7 @@
#!/bin/sh
-dir=${1:?}
-time=${2:?}
-tag=${3:?}
+file=${1:?}
+time=${2:-0}
+tag=${3:-$file}
-touch $dir/$tag
-sleep $time
+echo $tag > $file
+test $time -ne 0 && sleep $time

Return to:

Send suggestions and report system problems to the System administrator.