From 15a4662e8546f86a3941b2daf422c64a6bee6428 Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Sat, 25 Sep 2021 12:24:29 +0100 Subject: [PATCH] test/libcriu: print logs on fail run_test was trying to read criu logs on build failure instead of runtime error. This patch also removes the unnecessary subfolder with name "i" and resolves some of issues reported by shellcheck. Signed-off-by: Radostin Stoyanov --- test/others/libcriu/.gitignore | 2 +- test/others/libcriu/run.sh | 56 +++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/test/others/libcriu/.gitignore b/test/others/libcriu/.gitignore index 608f2209dfb..cf1342de2ae 100644 --- a/test/others/libcriu/.gitignore +++ b/test/others/libcriu/.gitignore @@ -4,5 +4,5 @@ test_notify test_self test_sub test_join_ns -wdir +output/ libcriu.so.* diff --git a/test/others/libcriu/run.sh b/test/others/libcriu/run.sh index 42760d978d8..f7d2f5c6f5c 100755 --- a/test/others/libcriu/run.sh +++ b/test/others/libcriu/run.sh @@ -1,45 +1,51 @@ #!/bin/bash set -x -source ../env.sh || exit 1 + +MAIN_DIR=$(dirname "$0") +OUTPUT_DIR="${MAIN_DIR}/output" +TEST_DIR="${OUTPUT_DIR}/$1" +TEST_LOG="${TEST_DIR}/test.log" +DUMP_LOG="${TEST_DIR}/dump.log" +RESTORE_LOG="${TEST_DIR}/restore.log" + +source "${MAIN_DIR}/../env.sh" || exit 1 echo "== Clean" make clean make libcriu -rm -rf wdir -echo "== Prepare" -mkdir -p wdir/i/ +rm -rf "${OUTPUT_DIR}" echo "== Run tests" export LD_LIBRARY_PATH=. -export PATH="`dirname ${BASH_SOURCE[0]}`/../../../criu:$PATH" +export PATH="${MAIN_DIR}/../../../criu:${PATH}" RESULT=0 -function run_test { +run_test() { echo "== Build $1" - if ! make $1; then + if ! make "$1"; then echo "FAIL build $1" - echo "** Output of $1/test.log" - cat wdir/i/$1/test.log - echo "---------------" - if [ -f wdir/i/$1/dump.log ]; then - echo "** Contents of dump.log" - cat wdir/i/$1/dump.log - echo "---------------" - fi - if [ -f wdir/i/$1/restore.log ]; then - echo "** Contents of restore.log" - cat wdir/i/$1/restore.log - echo "---------------" - fi RESULT=1; else echo "== Test $1" - mkdir wdir/i/$1/ - if ! setsid ./$1 ${CRIU} wdir/i/$1/ < /dev/null &>> wdir/i/$1/test.log; then + mkdir -p "${TEST_DIR}" + if ! setsid ./"$1" "${CRIU}" "${TEST_DIR}" < /dev/null &>> "${TEST_LOG}"; then echo "$1: FAIL" + echo "** Output of ${TEST_LOG}" + cat "${TEST_LOG}" + echo "---------------" + if [ -f "${DUMP_LOG}" ]; then + echo "** Contents of dump.log" + cat "${DUMP_LOG}" + echo "---------------" + fi + if [ -f "${RESTORE_LOG}" ]; then + echo "** Contents of restore.log" + cat "${RESTORE_LOG}" + echo "---------------" + fi RESULT=1 fi fi @@ -48,7 +54,7 @@ function run_test { run_test test_sub run_test test_self run_test test_notify -if [ "$(uname -m)" == "x86_64" ]; then +if [ "$(uname -m)" = "x86_64" ]; then # Skip this on aarch64 as aarch64 has no dirty page tracking run_test test_iters fi @@ -57,5 +63,5 @@ run_test test_join_ns echo "== Tests done" make libcriu_clean -[ $RESULT -eq 0 ] && echo "Success" || echo "FAIL" -exit $RESULT +[ "${RESULT}" -eq 0 ] && echo "Success" || echo "FAIL" +exit "${RESULT}"