From 3f161ba9bc43e68e5ac3dd9ef18309e6e88bee89 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Mon, 19 Apr 2021 13:01:59 +0200 Subject: test: make the test entrypoint scripts shellcheck-compliant --- test/TEST-55-OOMD/test.sh | 55 +++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'test/TEST-55-OOMD/test.sh') diff --git a/test/TEST-55-OOMD/test.sh b/test/TEST-55-OOMD/test.sh index 121aa8d56e..afc6706e32 100755 --- a/test/TEST-55-OOMD/test.sh +++ b/test/TEST-55-OOMD/test.sh @@ -1,47 +1,56 @@ #!/usr/bin/env bash set -e + TEST_DESCRIPTION="systemd-oomd Memory Pressure Test" -. $TEST_BASE_DIR/test-functions +# shellcheck source=test/test-functions +. "${TEST_BASE_DIR:?}/test-functions" check_result_nspawn() { + local workspace="${1:?}" local ret=1 local journald_report="" local pids="" - [[ -e $1/testok ]] && ret=0 - if [[ -e $1/skipped ]]; then + + [[ -e "$workspace/testok" ]] && ret=0 + if [[ -e "$workspace/skipped" ]]; then echo "TEST-56-OOMD was skipped:" - cat $1/skipped + cat "$workspace/skipped" ret=0 fi - [[ -f $1/failed ]] && cp -a $1/failed $TESTDIR - save_journal $1/var/log/journal - [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed - echo $JOURNAL_LIST - test -s $TESTDIR/failed && ret=$(($ret+1)) - [ -n "$TIMED_OUT" ] && ret=$(($ret+1)) - check_asan_reports "$1" || ret=$(($ret+1)) - _umount_dir $initdir + + [[ -f "$workspace/failed" ]] && cp -a "$workspace/failed" "${TESTDIR:?}" + save_journal "$workspace/var/log/journal" + [[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed" + echo "${JOURNAL_LIST:-No journals were saved}" + + test -s "$TESTDIR/failed" && ret=$((ret + 1)) + [ -n "${TIMED_OUT:=}" ] && ret=$((ret + 1)) + check_asan_reports "$workspace" || ret=$((ret + 1)) + _umount_dir "${initdir:?}" return $ret } check_result_qemu() { local ret=1 + mount_initdir - [[ -e $initdir/testok ]] && ret=0 - if [[ -e $initdir/skipped ]]; then + [[ -e "${initdir:?}/testok" ]] && ret=0 + if [[ -e "$initdir/skipped" ]]; then echo "TEST-56-OOMD was skipped:" - cat $initdir/skipped + cat "$initdir/skipped" ret=0 fi - [[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR - save_journal $initdir/var/log/journal - check_asan_reports "$initdir" || ret=$(($ret+1)) - _umount_dir $initdir - [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed - echo $JOURNAL_LIST - test -s $TESTDIR/failed && ret=$(($ret+1)) - [ -n "$TIMED_OUT" ] && ret=$(($ret+1)) + + [[ -f "$initdir/failed" ]] && cp -a "$initdir/failed" "${TESTDIR:?}" + save_journal "$initdir/var/log/journal" + check_asan_reports "$initdir" || ret=$((ret + 1)) + _umount_dir "$initdir" + [[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed" + echo "${JOURNAL_LIST:-No journals were saved}" + + test -s "$TESTDIR/failed" && ret=$((ret + 1)) + [ -n "${TIMED_OUT:=}" ] && ret=$((ret + 1)) return $ret } -- cgit v1.2.3