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 <radostin@redhat.com>
This commit is contained in:
Radostin Stoyanov 2021-09-25 12:24:29 +01:00 committed by Andrei Vagin
parent 53bf82bcfc
commit 59d0dfba96
2 changed files with 32 additions and 26 deletions

View file

@ -4,5 +4,5 @@ test_notify
test_self
test_sub
test_join_ns
wdir
output/
libcriu.so.*

View file

@ -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}"