"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
regress: do not use job control in a non-interactive shell
To:
gameoftrees@openbsd.org
Date:
Tue, 21 May 2024 22:09:50 +0200

Download raw body.

Thread
This has been sitting in my tree for a while now.  OK?

--------------------
regress: do not use job control in a non-interactive shell
 
Also do not use the non-standard timeout(1) utility.  Explicitly
terminate the background server process in all exit paths.

Restore the default SIGINT handling for asynchronous processes since
some shells (e.g. FreeBSD sh, bash) ignore it by default there.


diff refs/heads/main refs/heads/bg
commit - c6458e88f5a9085ec9206a60b93a713138b9b2fa
commit + 253944fc00a2ebde39eecfe48f664a4f789233f2
blob - 95b0e4aeb0e81d800561f45b18ef2f2c3e1b60b9
blob + e451b6b890d7c02b684ba45c9aea6b4c728d2c3c
--- regress/cmdline/clone.sh
+++ regress/cmdline/clone.sh
@@ -867,9 +867,8 @@ test_clone_basic_http() {
 	local testurl=http://127.0.0.1:${GOT_TEST_HTTP_PORT}
 	local commit_id=`git_show_head $testroot/repo`
 
-	timeout 5 ./http-server -p $GOT_TEST_HTTP_PORT $testroot \
-	    > $testroot/http-server.log &
-	trap "kill %1" HUP INT QUIT PIPE TERM
+	(trap - INT; exec ./http-server -p $GOT_TEST_HTTP_PORT $testroot \
+	    > $testroot/http-server.log) &
 
 	sleep 1 # server starts up
 
@@ -879,6 +878,8 @@ test_clone_basic_http() {
 	if [ $ret -ne 0 ]; then
 		echo "git clone command failed unexpectedly" >&2
 		test_done "$testroot" "$ret"
+		kill $!
+		wait # for http server
 		return 1
 	fi
 
@@ -888,11 +889,13 @@ test_clone_basic_http() {
 	if [ $ret -ne 0 ]; then
 		echo "got clone command failed unexpectedly" >&2
 		test_done "$testroot" "$ret"
+		kill $!
+		wait # for http server
 		return 1
 	fi
 
-	kill %1
-	wait %1 # wait for http-server
+	kill $!
+	wait # for http-server
 
 	got log -l0 -p -r $testroot/repo > $testroot/log-repo
 	ret=$?
blob - 928c5f4563e3de646b74ef37ef6fd2588857395d
blob + 8a9a288a37318ebc780742ef56dbfe03e20c44ad
--- regress/cmdline/fetch.sh
+++ regress/cmdline/fetch.sh
@@ -2025,9 +2025,8 @@ test_fetch_basic_http() {
 	local testurl=http://127.0.0.1:$GOT_TEST_HTTP_PORT
 	local commit_id=`git_show_head $testroot/repo`
 
-	timeout 5 ./http-server -p $GOT_TEST_HTTP_PORT $testroot \
-	    > $testroot/http-server.log &
-	trap "kill %1" HUP INT QUIT PIPE TERM
+	(trap - INT; exec ./http-server -p $GOT_TEST_HTTP_PORT $testroot \
+	    > $testroot/http-server.log) &
 
 	sleep 1 # server starts up
 
@@ -2036,6 +2035,8 @@ test_fetch_basic_http() {
 	if [ $ret -ne 0 ]; then
 		echo "got clone command failed unexpectedly" >&2
 		test_done "$testroot" "$ret"
+		kill $!
+		wait # for http server
 		return 1
 	fi
 
@@ -2048,6 +2049,8 @@ test_fetch_basic_http() {
 	if [ $ret -ne 0 ]; then
 		echo "got ref command failed unexpectedly" >&2
 		test_done "$testroot" "$ret"
+		kill $!
+		wait # for http-server
 		return 1
 	fi
 
@@ -2057,11 +2060,13 @@ test_fetch_basic_http() {
 	if [ $ret -ne 0 ]; then
 		echo "got fetch command failed unexpectedly" >&2
 		test_done "$testroot" "$ret"
+		kill $!
+		wait # for http-server
 		return 1
 	fi
 
-	kill %1
-	wait %1 # wait for http-server
+	kill $!
+	wait # for http-server
 
 	echo -n > $testroot/stdout.expected
 
blob - 6e41801df46b386834c2cd1d3bc4d5c039d5f809
blob + b28a8c4055c3b3c863c5c896045ff26b7029184a
--- regress/cmdline/send.sh
+++ regress/cmdline/send.sh
@@ -1670,9 +1670,8 @@ test_send_basic_http() {
 	local testurl=http://127.0.0.1:$GOT_TEST_HTTP_PORT
 	local commit_id=`git_show_head $testroot/repo`
 
-	timeout 5 ./http-server -p $GOT_TEST_HTTP_PORT $testroot \
-	    > $testroot/http-server.log &
-	trap "kill %1" HUP INT QUIT PIPE TERM
+	(trap - INT; exec ./http-server -p $GOT_TEST_HTTP_PORT $testroot \
+	    > $testroot/http-server.log) &
 
 	sleep 1 # server starts up
 
@@ -1681,6 +1680,8 @@ test_send_basic_http() {
 	if [ $ret -ne 0 ]; then
 		echo "got clone command failed unexpectedly" >&2
 		test_done "$testroot" "$ret"
+		kill $!
+		wait # for http server
 		return 1
 	fi
 	cat > $testroot/repo/.git/got.conf <<EOF
@@ -1709,11 +1710,13 @@ EOF
 	if [ $ret -eq 0 ]; then
 		echo "got send command succeeded unexpectedly" >&2
 		test_done "$testroot" "$ret"
+		kill $!
+		wait # for http server
 		return 1
 	fi
 
-	kill %1
-	wait %1 # wait for http-server
+	kill $!
+	wait # for http-server
 
 	echo "got: http: feature not implemented" > $testroot/stderr.expected
 	cmp -s $testroot/stderr $testroot/stderr.expected
-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de