<div dir="ltr"><div>From: Yicheng Qin <<a href="mailto:yichengq@google.com">yichengq@google.com</a>></div><div>Subject: [PATCH] test: adjust the output for tests</div><div><br></div><div>Adjust the format of information printed.</div>
<div>Print out more necessary debug information.</div><div>Display error message in STDERR and make it more readable.</div><div><br></div><div>Signed-off-by: Yicheng Qin <<a href="mailto:yichengq@google.com">yichengq@google.com</a>></div>
<div>---</div><div> test/tcp/run.sh | 10 ++++++++--</div><div> test/zdtm.sh | 34 +++++++++++++++++++++++++++-------</div><div> 2 files changed, 35 insertions(+), 9 deletions(-)</div><div><br></div><div>diff --git a/test/tcp/run.sh b/test/tcp/run.sh</div>
<div>index 0dd0e70..873c7d1 100644</div><div>--- a/test/tcp/run.sh</div><div>+++ b/test/tcp/run.sh</div><div>@@ -34,12 +34,16 @@ echo "Make it run"</div><div> echo "${TEXT}" >&3</div><div> </div>
<div> function fail {</div><div>-<span class="" style="white-space:pre">        </span>echo "$@"</div><div>+<span class="" style="white-space:pre">        </span>echo "$@" >&2</div><div> <span class="" style="white-space:pre">        </span>kill -9 ${CLN_PID}</div>
<div> <span class="" style="white-space:pre">        </span>kill -9 ${SRV_PID}</div><div>+<span class="" style="white-space:pre">        </span>echo ${CLN_LOG}: >&2</div><div>+<span class="" style="white-space:pre">        </span>cat ${CLN_LOG} >&2</div>
<div> <span class="" style="white-space:pre">        </span>exit 1</div><div> }</div><div> </div><div>+kill -s 0 ${CLN_PID} || fail "Client is dead"</div><div>+</div><div> echo "Suspend server"</div><div> ${CRIU} dump -D ${DDIR} -o dump.log -t ${SRV_PID} --tcp-established -vvvv || fail "Fail to dump server"</div>
<div> sleep 1</div><div>@@ -51,5 +55,7 @@ echo "${TEXT}" >&3</div><div> </div><div> echo "Collect results"</div><div> exec 3>&-</div><div>-wait ${CLN_PID}</div><div>+wait ${CLN_PID} || fail "Client exits abruptly"</div>
<div> kill -9 ${SRV_PID}</div><div>+</div><div>+echo PASS</div><div>diff --git a/test/zdtm.sh b/test/zdtm.sh</div><div>index 9e72fa3..5b064f7 100755</div><div>--- a/test/zdtm.sh</div><div>+++ b/test/zdtm.sh</div><div>@@ -179,6 +179,10 @@ check_mainstream()</div>
<div> <span class="" style="white-space:pre">        </span>local -a ver_arr</div><div> <span class="" style="white-space:pre">        </span>local ver_str=`uname -r`</div><div> </div><div>+<span class="" style="white-space:pre">        </span>cat >&2 <<EOF</div>
<div>+========================== CRIU CHECK =============================</div><div>+EOF</div><div>+</div><div> <span class="" style="white-space:pre">        </span>$CRIU check && return 0</div><div> <span class="" style="white-space:pre">        </span>MAINSTREAM_KERNEL=1</div>
<div> </div><div>@@ -262,6 +266,8 @@ export MAKEFLAGS=--no-print-directory</div><div> </div><div> start_test()</div><div> {</div><div>+<span class="" style="white-space:pre">        </span>echo Start test $2 at $(date)</div><div>
+</div><div> <span class="" style="white-space:pre">        </span>local tdir=$1</div><div> <span class="" style="white-space:pre">        </span>local tname=$2</div><div> <span class="" style="white-space:pre">        </span>export ZDTM_ROOT</div>
<div>@@ -500,6 +506,7 @@ EOF</div><div> <span class="" style="white-space:pre">        </span>cat $test.out</div><div> <span class="" style="white-space:pre">        </span>cat $test.out | grep -q PASS || return 2</div><div> <span class="" style="white-space:pre">        </span>[ "$CLEANUP" -ne 0 ] && rm -rf `dirname $ddump`</div>
<div>+<span class="" style="white-space:pre">        </span>echo "Test: $test, Result: PASS"</div><div> <span class="" style="white-space:pre">        </span>return 0</div><div> }</div><div> </div><div>@@ -510,23 +517,36 @@ case_error()</div>
<div> </div><div> <span class="" style="white-space:pre">        </span>ZDTM_FAILED=1</div><div> </div><div>-<span class="" style="white-space:pre">        </span>echo "Test: $test"</div><div>-<span class="" style="white-space:pre">        </span>echo "====================== ERROR ======================"</div>
<div>+<span class="" style="white-space:pre">        </span>echo "Test: $test, Result: FAIL"</div><div>+<span class="" style="white-space:pre">        </span>echo "====================== ERROR ======================" >&2</div>
<div>+<span class="" style="white-space:pre">        </span>echo "Test: $test, Namespace: ${PIDNS}" >&2</div><div> </div><div> <span class="" style="white-space:pre">        </span>if [ -n "$DUMP_PATH" ]; then</div>
<div> <span class="" style="white-space:pre">                </span>[ -e "$DUMP_PATH/dump.log" ] && {</div><div>-<span class="" style="white-space:pre">                        </span>echo "Dump log : $DUMP_PATH/dump.log"</div>
<div>-<span class="" style="white-space:pre">                        </span>cat $DUMP_PATH/dump.log* | grep Error</div><div>+<span class="" style="white-space:pre">                        </span>echo "Dump log : $DUMP_PATH/dump.log" >&2</div><div>
+<span class="" style="white-space:pre">                        </span>cat $DUMP_PATH/dump.log* | grep Error >&2</div><div>+<span class="" style="white-space:pre">                        </span>echo "* * * * * * * * * * * * * * *" >&2</div>
<div>+<span class="" style="white-space:pre">                        </span>tail -n 40 $DUMP_PATH/dump.log* >&2</div><div>+<span class="" style="white-space:pre">                        </span>echo "*****************************" >&2</div>
<div> <span class="" style="white-space:pre">                </span>}</div><div> <span class="" style="white-space:pre">                </span>[ -e "$DUMP_PATH/restore.log" ] && {</div><div>-<span class="" style="white-space:pre">                        </span>echo "Restore log: $DUMP_PATH/restore.log"</div>
<div>-<span class="" style="white-space:pre">                        </span>cat $DUMP_PATH/restore.log* | grep Error</div><div>+<span class="" style="white-space:pre">                        </span>echo "Restore log: $DUMP_PATH/restore.log" >&2</div>
<div>+<span class="" style="white-space:pre">                        </span>cat $DUMP_PATH/restore.log* | grep Error >&2</div><div>+<span class="" style="white-space:pre">                        </span>echo "* * * * * * * * * * * * * * *" >&2</div>
<div>+<span class="" style="white-space:pre">                        </span>tail -n 40 $DUMP_PATH/restore.log* >&2</div><div>+<span class="" style="white-space:pre">                        </span>echo "*****************************" >&2</div>
<div> <span class="" style="white-space:pre">                </span>}</div><div> <span class="" style="white-space:pre">        </span>fi</div><div> <span class="" style="white-space:pre">        </span>[ -e "$test_log" ] &&</div><div>
-<span class="" style="white-space:pre">                </span>echo "Output file: $test_log"</div><div>+<span class="" style="white-space:pre">                </span>echo "Output file: $test_log" >&2</div><div>+<span class="" style="white-space:pre">                </span>cat $test_log* >&2</div>
<div>+<span class="" style="white-space:pre">                </span>echo "*****************************" >&2</div><div>+</div><div> <span class="" style="white-space:pre">        </span>[ -n "$HEAD" ] &&</div>
<div> <span class="" style="white-space:pre">                </span>echo "The initial HEAD was $HEAD"</div><div>+</div><div>+<span class="" style="white-space:pre">        </span>echo "==================== ERROR OVER ====================" >&2</div>
<div>+</div><div> <span class="" style="white-space:pre">        </span>exit 1</div><div> }</div><div> </div><div>-- </div><div>1.8.3</div><div><br></div></div>