Module Name: src
Committed By: christos
Date: Sun Aug 23 07:15:16 UTC 2015
Modified Files:
src/tests/bin/sh: t_wait.sh
Log Message:
another wait test.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/bin/sh/t_wait.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/bin/sh/t_wait.sh
diff -u src/tests/bin/sh/t_wait.sh:1.1 src/tests/bin/sh/t_wait.sh:1.2
--- src/tests/bin/sh/t_wait.sh:1.1 Sat Mar 17 12:33:11 2012
+++ src/tests/bin/sh/t_wait.sh Sun Aug 23 03:15:16 2015
@@ -1,4 +1,4 @@
-# $NetBSD: t_wait.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $
+# $NetBSD: t_wait.sh,v 1.2 2015/08/23 07:15:16 christos Exp $
#
# Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -32,28 +32,58 @@ individual_head() {
individual_body() {
# atf-sh confuses wait for some reason; work it around by creating
# a helper script that executes /bin/sh directly.
- cat >helper.sh <<EOF
+ cat >individualhelper.sh <<\EOF
sleep 3 &
sleep 1 &
wait %1
-if [ \$? -ne 0 ]; then
+if [ $? -ne 0 ]; then
echo "Waiting of first job failed"
exit 1
fi
wait %2
-if [ \$? -ne 0 ]; then
+if [ $? -ne 0 ]; then
echo "Waiting of second job failed"
exit 1
fi
exit 0
EOF
- output=$(/bin/sh helper.sh)
+ output=$(/bin/sh individualhelper.sh)
[ $? -eq 0 ] || atf_fail "${output}"
+ rm -f individualhelper.sh
+}
+
+atf_test_case kill
+kill_head() {
+ atf_set "descr" "Tests that killing the shell while in wait calls trap"
+}
+kill_body() {
+ # atf-sh confuses wait for some reason; work it around by creating
+ # a helper script that executes /bin/sh directly.
+ local s=$PWD/killhelper.sh
+ local z=/tmp/killhelper.$$
+ cat >$s <<\EOF
+#!/bin/sh
+trap "echo SIGHUP" 1
+sleep 10 &
+sl=$!
+wait
+echo $?
+EOF
+ chmod +x $s
+ $s > $z &
+ # XXX: built-in kill does not work?
+ /bin/kill -HUP $!
+ output="$(cat $z | tr '\n' ' ')"
+ rm -f $s $z
+ if [ "$output" != "SIGHUP 129 " ]; then
+ atf_fail "${output} != 'SIGHUP 129 '"
+ fi
}
atf_init_test_cases() {
atf_add_test_case individual
+ atf_add_test_case kill
}