Projects STRLCPY criu Commits 59d0dfba
🤬
  • 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 <[email protected]>
  • Loading...
  • Radostin Stoyanov committed with Andrei Vagin 3 years ago
    59d0dfba
    1 parent 53bf82bc
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■
    test/others/libcriu/.gitignore
    skipped 3 lines
    4 4  test_self
    5 5  test_sub
    6 6  test_join_ns
    7  -wdir
     7 +output/
    8 8  libcriu.so.*
    9 9   
  • ■ ■ ■ ■ ■ ■
    test/others/libcriu/run.sh
    1 1  #!/bin/bash
    2 2   
    3 3  set -x
    4  -source ../env.sh || exit 1
     4 + 
     5 +MAIN_DIR=$(dirname "$0")
     6 +OUTPUT_DIR="${MAIN_DIR}/output"
     7 +TEST_DIR="${OUTPUT_DIR}/$1"
     8 +TEST_LOG="${TEST_DIR}/test.log"
     9 +DUMP_LOG="${TEST_DIR}/dump.log"
     10 +RESTORE_LOG="${TEST_DIR}/restore.log"
     11 + 
     12 +source "${MAIN_DIR}/../env.sh" || exit 1
    5 13   
    6 14  echo "== Clean"
    7 15  make clean
    8 16  make libcriu
    9  -rm -rf wdir
    10 17   
    11  -echo "== Prepare"
    12  -mkdir -p wdir/i/
     18 +rm -rf "${OUTPUT_DIR}"
    13 19   
    14 20  echo "== Run tests"
    15 21  export LD_LIBRARY_PATH=.
    16  -export PATH="`dirname ${BASH_SOURCE[0]}`/../../../criu:$PATH"
     22 +export PATH="${MAIN_DIR}/../../../criu:${PATH}"
    17 23   
    18 24  RESULT=0
    19 25   
    20  -function run_test {
     26 +run_test() {
    21 27   echo "== Build $1"
    22  - if ! make $1; then
     28 + if ! make "$1"; then
    23 29   echo "FAIL build $1"
    24  - echo "** Output of $1/test.log"
    25  - cat wdir/i/$1/test.log
    26  - echo "---------------"
    27  - if [ -f wdir/i/$1/dump.log ]; then
    28  - echo "** Contents of dump.log"
    29  - cat wdir/i/$1/dump.log
    30  - echo "---------------"
    31  - fi
    32  - if [ -f wdir/i/$1/restore.log ]; then
    33  - echo "** Contents of restore.log"
    34  - cat wdir/i/$1/restore.log
    35  - echo "---------------"
    36  - fi
    37 30   RESULT=1;
    38 31   else
    39 32   echo "== Test $1"
    40  - mkdir wdir/i/$1/
    41  - if ! setsid ./$1 ${CRIU} wdir/i/$1/ < /dev/null &>> wdir/i/$1/test.log; then
     33 + mkdir -p "${TEST_DIR}"
     34 + if ! setsid ./"$1" "${CRIU}" "${TEST_DIR}" < /dev/null &>> "${TEST_LOG}"; then
    42 35   echo "$1: FAIL"
     36 + echo "** Output of ${TEST_LOG}"
     37 + cat "${TEST_LOG}"
     38 + echo "---------------"
     39 + if [ -f "${DUMP_LOG}" ]; then
     40 + echo "** Contents of dump.log"
     41 + cat "${DUMP_LOG}"
     42 + echo "---------------"
     43 + fi
     44 + if [ -f "${RESTORE_LOG}" ]; then
     45 + echo "** Contents of restore.log"
     46 + cat "${RESTORE_LOG}"
     47 + echo "---------------"
     48 + fi
    43 49   RESULT=1
    44 50   fi
    45 51   fi
    skipped 2 lines
    48 54  run_test test_sub
    49 55  run_test test_self
    50 56  run_test test_notify
    51  -if [ "$(uname -m)" == "x86_64" ]; then
     57 +if [ "$(uname -m)" = "x86_64" ]; then
    52 58   # Skip this on aarch64 as aarch64 has no dirty page tracking
    53 59   run_test test_iters
    54 60  fi
    skipped 2 lines
    57 63   
    58 64  echo "== Tests done"
    59 65  make libcriu_clean
    60  -[ $RESULT -eq 0 ] && echo "Success" || echo "FAIL"
    61  -exit $RESULT
     66 +[ "${RESULT}" -eq 0 ] && echo "Success" || echo "FAIL"
     67 +exit "${RESULT}"
    62 68   
Please wait...
Page is in error, reload to recover