From a5ef5f3104303ac5dfac6af4fa532940d7ff3adc Mon Sep 17 00:00:00 2001 From: Jacques de Laval Date: Wed, 24 Feb 2021 16:01:43 +0100 Subject: [PATCH] test: Fix make check Signed-off-by: Jacques de Laval --- test/Makefile.am | 2 ++ test/lib.sh | 6 ++---- test/setup_root.sh | 28 ++++++++++++++++++++-------- test/teardown_root.sh | 1 + test/test_root/Makefile | 1 - test/test_root/bin/chrootsetup.sh | 2 +- test/testenv_exec.sh | 1 - test/testenv_start.sh | 1 - 8 files changed, 26 insertions(+), 16 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index 992c68c3..ba325e35 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -10,6 +10,8 @@ EXTRA_DIST += test_start_stop_service/service.sh AM_TESTS_ENVIRONMENT = TESTS_ROOT='$(builddir)/test_root/'; AM_TESTS_ENVIRONMENT += export TESTS_ROOT; AM_TESTS_ENVIRONMENT += export LD_LIBRARY_PATH; +AM_TESTS_ENVIRONMENT += PREFIX=$(prefix); +AM_TESTS_ENVIRONMENT += export PREFIX; TESTS = checkself.sh TESTS += setup_root.sh diff --git a/test/lib.sh b/test/lib.sh index 7902bae1..8356976f 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -84,10 +84,8 @@ teardown() { trap teardown EXIT -FINIT_CONF=$(grep FINIT_CONF "$TESTS_ROOT/../config.h" | cut -d' ' -f3 | cut -d'"' -f2) -export FINIT_CONF -FINIT_CONF_DIR="$(dirname "$FINIT_CONF")"/finit.d -export FINIT_CONF_DIR +# shellcheck source=/dev/null +. "$TESTS_ROOT/../test.env" log "$color_reset" 'Test start' '' log "$color_reset" '--' '' diff --git a/test/setup_root.sh b/test/setup_root.sh index a00f1244..a1a4d5ae 100755 --- a/test/setup_root.sh +++ b/test/setup_root.sh @@ -3,13 +3,25 @@ set -eu # shellcheck disable=SC2154 -"$srcdir"/../configure --prefix=/ -make -make DESTDIR="$(pwd)/test_root/" install +if [ ! -f "$srcdir"/../config.status ]; then + "$srcdir"/../configure --prefix=/ + make + make DESTDIR="$(pwd)/test_root/" install -mkdir -p test_root/bin -cp "${srcdir}/test_root/bin/chrootsetup.sh" test_root/bin -cp "${srcdir}/test_root/busybox-x86_64.md5" test_root/ -cp "${srcdir}/test_root/Makefile" test_root/ + mkdir -p test_root/bin + cp "${srcdir}/test_root/bin/chrootsetup.sh" test_root/bin + cp "${srcdir}/test_root/busybox-x86_64.md5" test_root/ + cp "${srcdir}/test_root/Makefile" test_root/ + make -C test_root/ + config_h='./config.h' + echo "export PATH=/bin:/sbin" > test.env +else + # make + make -C ../ DESTDIR="$(pwd)/test_root/" install + FINITBIN=../../src/finit make -C test_root/ + config_h='../config.h' + echo "export PATH=/bin:/sbin:$PREFIX/sbin:$PREFIX/bin" > test.env +fi -make -C test_root/ +echo "export FINIT_CONF=$(grep FINIT_CONF $config_h | cut -d' ' -f3 | cut -d'"' -f2)" >> test.env +echo "export FINIT_RCSD=$(grep FINIT_RCSD $config_h | cut -d' ' -f3 | cut -d'"' -f2)" >> test.env diff --git a/test/teardown_root.sh b/test/teardown_root.sh index 5cf2eb1d..e0649cce 100755 --- a/test/teardown_root.sh +++ b/test/teardown_root.sh @@ -6,3 +6,4 @@ if [ -d test_root/var/lock ]; then chmod +r test_root/var/lock fi make -C test_root/ clean +rm -f test.env diff --git a/test/test_root/Makefile b/test/test_root/Makefile index 99b23c2e..b77947e9 100644 --- a/test/test_root/Makefile +++ b/test/test_root/Makefile @@ -3,7 +3,6 @@ ARCH ?= x86_64 FINITBIN ?= ./sbin/finit -INITCTLBIN ?= ./sbin/initctl BBVER ?= 1.31.0 BBBIN = busybox-$(ARCH) diff --git a/test/test_root/bin/chrootsetup.sh b/test/test_root/bin/chrootsetup.sh index fe4e0e4c..e4810294 100755 --- a/test/test_root/bin/chrootsetup.sh +++ b/test/test_root/bin/chrootsetup.sh @@ -22,7 +22,7 @@ mount -t tmpfs none /etc # mkdir -p /dev/pts # mount -t devpts none /dev/pts -mkdir -p "$FINIT_CONF_DIR" +mkdir -p "$FINIT_RCSD" tty=/dev/$(cat /sys/class/tty/console/active) mkfifo "$tty" diff --git a/test/testenv_exec.sh b/test/testenv_exec.sh index cfb51053..72e1db70 100755 --- a/test/testenv_exec.sh +++ b/test/testenv_exec.sh @@ -16,7 +16,6 @@ TESTS_ROOT="${TESTS_ROOT:-$(pwd)/${TEST_DIR}/test_root}" nsenter=$(command -v nsenter) chroot=$(command -v chroot) -export PATH=/sbin:/bin export PS1='\w \$ ' export PS2='> ' export PS3='#? ' diff --git a/test/testenv_start.sh b/test/testenv_start.sh index ebf7258c..04278de6 100755 --- a/test/testenv_start.sh +++ b/test/testenv_start.sh @@ -10,7 +10,6 @@ TESTS_ROOT="${TESTS_ROOT:-$(pwd)/${TEST_DIR}/test_root}" unshare=$(command -v unshare) chroot=$(command -v chroot) -export PATH=/sbin:/bin export PS1='\w \$ ' export PS2='> ' export PS3='#? '