mirror of
https://github.com/systemd/systemd
synced 2024-10-04 15:21:01 +00:00
test: merge check_nspawn() into run_nspawn()
This makes nspawn tests symmetric with run_qemu() which also exits with 1 if QEMU is not available.
This commit is contained in:
parent
b2ecd099dc
commit
7cad32bbde
|
@ -25,8 +25,7 @@ test_run() {
|
||||||
else
|
else
|
||||||
dwarn "can't run QEMU, skipping"
|
dwarn "can't run QEMU, skipping"
|
||||||
fi
|
fi
|
||||||
if check_nspawn; then
|
if run_nspawn; then
|
||||||
run_nspawn
|
|
||||||
check_result_nspawn || return 1
|
check_result_nspawn || return 1
|
||||||
else
|
else
|
||||||
dwarn "can't run systemd-nspawn, skipping"
|
dwarn "can't run systemd-nspawn, skipping"
|
||||||
|
|
|
@ -25,8 +25,7 @@ test_run() {
|
||||||
else
|
else
|
||||||
dwarn "can't run QEMU, skipping"
|
dwarn "can't run QEMU, skipping"
|
||||||
fi
|
fi
|
||||||
if check_nspawn; then
|
if run_nspawn; then
|
||||||
run_nspawn
|
|
||||||
check_result_nspawn || return 1
|
check_result_nspawn || return 1
|
||||||
else
|
else
|
||||||
dwarn "can't run systemd-nspawn, skipping"
|
dwarn "can't run systemd-nspawn, skipping"
|
||||||
|
|
|
@ -25,8 +25,7 @@ test_run() {
|
||||||
else
|
else
|
||||||
dwarn "can't run QEMU, skipping"
|
dwarn "can't run QEMU, skipping"
|
||||||
fi
|
fi
|
||||||
if check_nspawn; then
|
if run_nspawn; then
|
||||||
run_nspawn
|
|
||||||
check_result_nspawn || return 1
|
check_result_nspawn || return 1
|
||||||
else
|
else
|
||||||
dwarn "can't run systemd-nspawn, skipping"
|
dwarn "can't run systemd-nspawn, skipping"
|
||||||
|
|
|
@ -25,8 +25,7 @@ test_run() {
|
||||||
else
|
else
|
||||||
dwarn "can't run QEMU, skipping"
|
dwarn "can't run QEMU, skipping"
|
||||||
fi
|
fi
|
||||||
if check_nspawn; then
|
if run_nspawn; then
|
||||||
run_nspawn
|
|
||||||
check_result_nspawn || return 1
|
check_result_nspawn || return 1
|
||||||
else
|
else
|
||||||
dwarn "can't run systemd-nspawn, skipping"
|
dwarn "can't run systemd-nspawn, skipping"
|
||||||
|
|
|
@ -5,11 +5,11 @@ TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981"
|
||||||
|
|
||||||
. $TEST_BASE_DIR/test-functions
|
. $TEST_BASE_DIR/test-functions
|
||||||
|
|
||||||
|
NSPAWN_TIMEOUT=30s
|
||||||
|
|
||||||
test_run() {
|
test_run() {
|
||||||
dwarn "skipping QEMU"
|
dwarn "skipping QEMU"
|
||||||
if check_nspawn; then
|
if run_nspawn; then
|
||||||
NSPAWN_TIMEOUT=30s
|
|
||||||
run_nspawn
|
|
||||||
check_result_nspawn || return 1
|
check_result_nspawn || return 1
|
||||||
else
|
else
|
||||||
dwarn "can't run systemd-nspawn, skipping"
|
dwarn "can't run systemd-nspawn, skipping"
|
||||||
|
|
|
@ -6,8 +6,7 @@ TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171"
|
||||||
. $TEST_BASE_DIR/test-functions
|
. $TEST_BASE_DIR/test-functions
|
||||||
|
|
||||||
test_run() {
|
test_run() {
|
||||||
if check_nspawn; then
|
if run_nspawn; then
|
||||||
run_nspawn
|
|
||||||
check_result_nspawn || return 1
|
check_result_nspawn || return 1
|
||||||
else
|
else
|
||||||
dwarn "can't run systemd-nspawn, skipping"
|
dwarn "can't run systemd-nspawn, skipping"
|
||||||
|
|
|
@ -108,7 +108,11 @@ $KERNEL_APPEND \
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Return 0 if nspawn did run (then you must check the result state/logs for actual
|
||||||
|
# success), or 1 if nspawn is not available.
|
||||||
run_nspawn() {
|
run_nspawn() {
|
||||||
|
[[ -d /run/systemd/system ]] || return 1
|
||||||
|
|
||||||
local _nspawn_cmd="../../systemd-nspawn --register=no --kill-signal=SIGKILL --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND"
|
local _nspawn_cmd="../../systemd-nspawn --register=no --kill-signal=SIGKILL --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND"
|
||||||
if [[ "$NSPAWN_TIMEOUT" != "infinity" ]]; then
|
if [[ "$NSPAWN_TIMEOUT" != "infinity" ]]; then
|
||||||
_nspawn_cmd="timeout --foreground $NSPAWN_TIMEOUT $_nspawn_cmd"
|
_nspawn_cmd="timeout --foreground $NSPAWN_TIMEOUT $_nspawn_cmd"
|
||||||
|
@ -1284,11 +1288,6 @@ inst_libdir_file() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_nspawn() {
|
|
||||||
[[ -d /run/systemd/system ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
do_test() {
|
do_test() {
|
||||||
if [[ $UID != "0" ]]; then
|
if [[ $UID != "0" ]]; then
|
||||||
echo "TEST: $TEST_DESCRIPTION [SKIPPED]: not root" >&2
|
echo "TEST: $TEST_DESCRIPTION [SKIPPED]: not root" >&2
|
||||||
|
|
Loading…
Reference in a new issue