From ef61313366e6ca42298c4a48ecbe50c50c125b12 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Sun, 18 Jul 2021 01:04:22 +0800 Subject: do not use UID hack for tester It's causing "root-tester namesis" (both have UID 0) if the tty is owned by root. To fix bash test, use Expect to spawn a new PTY for it. --- chapter08/bash.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'chapter08') diff --git a/chapter08/bash.xml b/chapter08/bash.xml index bb0f2b0fb..99ee2e3f4 100644 --- a/chapter08/bash.xml +++ b/chapter08/bash.xml @@ -76,8 +76,8 @@ Now, run the tests as the tester user: -su tester << EOF -PATH=$PATH make tests < $(tty) +su -s /usr/bin/expect tester << EOF +spawn make tests; expect EOF; EOF Install the package: -- cgit v1.2.3-54-g00ecf From d0725734644f7641a10011cf72f0e1d3d04f6f30 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Mon, 19 Jul 2021 21:01:45 +0800 Subject: bash: add an explanation why use expect to run the test --- chapter08/bash.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'chapter08') diff --git a/chapter08/bash.xml b/chapter08/bash.xml index 99ee2e3f4..7381c9e87 100644 --- a/chapter08/bash.xml +++ b/chapter08/bash.xml @@ -73,7 +73,10 @@ chown -Rv tester . - Now, run the tests as the The testsuite of the package is designed to be ran as a non-root + user, owning the terminal connected to standard input. To satisify the + requirement, spawn a new pseudoterminal using + Expect and run the tests as the tester user: su -s /usr/bin/expect tester << EOF -- cgit v1.2.3-54-g00ecf From 2d30be476b83ca5370c2a46d685eff1ed7733141 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Mon, 19 Jul 2021 21:10:06 +0800 Subject: bash: use eof in expect commands instead of EOF (for jhalfs) --- chapter08/bash.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'chapter08') diff --git a/chapter08/bash.xml b/chapter08/bash.xml index 7381c9e87..c2a5e807b 100644 --- a/chapter08/bash.xml +++ b/chapter08/bash.xml @@ -80,7 +80,7 @@ class="username">tester user: su -s /usr/bin/expect tester << EOF -spawn make tests; expect EOF; +spawn make tests; expect eof; EOF Install the package: -- cgit v1.2.3-54-g00ecf From 7d88d57dd38aa281d8aca387dda64aa576ac8246 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Mon, 19 Jul 2021 21:29:20 +0800 Subject: bash: disable timeout to prevent Expect from exiting early The default timeout is only 10 seconds, where the bash tests won't complete on most systems. Then expect will exit early, with bash tests running in background. We won't like this. --- chapter08/bash.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'chapter08') diff --git a/chapter08/bash.xml b/chapter08/bash.xml index c2a5e807b..275a63e68 100644 --- a/chapter08/bash.xml +++ b/chapter08/bash.xml @@ -80,7 +80,9 @@ class="username">tester user: su -s /usr/bin/expect tester << EOF -spawn make tests; expect eof; +set timeout -1 +spawn make tests +expect eof EOF Install the package: -- cgit v1.2.3-54-g00ecf From 94862dad6173cfd146f41cd1ca1b0149f8215451 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Mon, 19 Jul 2021 21:39:13 +0800 Subject: bash: pass "make test" exitcode through expect --- chapter08/bash.xml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'chapter08') diff --git a/chapter08/bash.xml b/chapter08/bash.xml index 275a63e68..5007c2d46 100644 --- a/chapter08/bash.xml +++ b/chapter08/bash.xml @@ -83,6 +83,8 @@ set timeout -1 spawn make tests expect eof +lassign [wait] _ _ _ value +exit $value EOF Install the package: -- cgit v1.2.3-54-g00ecf