[CRIU] [PATCH 2/4] fi: Zdtm preparations for fault injection
Andrew Vagin
avagin at odin.com
Mon Sep 28 04:08:06 PDT 2015
On Thu, Sep 24, 2015 at 06:08:00PM +0300, Pavel Emelyanov wrote:
> Individual tests can be added to the test list with the
> 'finj/' prefix. When seeng such a line zdtm will
>
> 1. start the test and call criu dump and restore asking
> those to fail at the point specified in the 2nd line
> of the fault file (the 1st one is #!/bin/bash, see
> below)
>
> 2. Upon criu dump/restore failure the .fault file will
> be called as script. It is then to check whether the
> artificially aborted criu resulted in correct state
> or not. The test resul is then the result of the
> .fault file inspection.
>
> Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
> ---
> test/zdtm.sh | 46 +++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 45 insertions(+), 1 deletion(-)
>
> diff --git a/test/zdtm.sh b/test/zdtm.sh
> index f22f3ca..b0cf868 100755
> --- a/test/zdtm.sh
> +++ b/test/zdtm.sh
> @@ -678,6 +678,8 @@ run_test()
> fi
> fi
>
> + expr "$test" : 'finj/' > /dev/null && FINJ=1 || FINJ=""
> + test=${test#finj/}
> expr "$test" : 'ns/' > /dev/null && PIDNS=1 || PIDNS=""
> test=${test#ns/}
> expr "$test" : 'user/' > /dev/null && USERNS=1 || USERNS=""
> @@ -691,6 +693,17 @@ run_test()
> local rst_args=
> DUMP_PATH=""
>
> + if [ $FINJ -eq 1 ] ; then
> + if [ ! -f "$test".fault ]; then
> + echo "Test $test wants fault injection but cannot"
> + return 0
> + fi
> +
> + export CRIU_FAULT=$(cat "$test".fault | sed -n -e '2s/^#fault://p')
> + else
> + unset CRIU_FAULT
> + fi
> +
> if [ -f "$test".checkskip ] && ! "$test".checkskip; then
> echo "Skip $test"
> return 0
> @@ -802,6 +815,22 @@ EOF
> return 0
> fi
>
> + if [ $FINJ -eq 1 ]; then
> + echo "FAULT: $tname dump failed, checking ..."
> + "$test".fault "dump"
> + fetcode=$?
> +
> + stop_test $tdir $tname
> +
> + if [ "$fetcode" -ne 0 ]; then
> + echo "FAULT: $tname dump failed unexpectedly with $retcode/$fetcode"
> + return 1
> + else
> + echo "FAULT: $tname dump failed as expected with $retcode"
> + return 0
> + fi
> + fi
> +
> if [ $BATCH_TEST -eq 0 ]; then
> echo WARNING: $tname returned $retcode and left running for debug needs
> else
> @@ -867,7 +894,24 @@ EOF
> rm -f $TPID || true
>
> echo Restore
> - setsid $CRIU restore -D $ddump -o restore.log -v4 -d $gen_args $rst_args || return 2
> + setsid $CRIU restore -D $ddump -o restore.log -v4 -d $gen_args $rst_args
> + retcode=$?
> + if [ $retcode -ne 0 ]; then
> + [ $FINJ -eq 0 ] && return 2
> +
> + echo "FAULT: $tname restore failed, checking ..."
> + "$test".fault "restore"
> + fetcode=$?
> +
> + if [ "$fetcode" -ne 0 ]; then
> + echo "FAULT: $tname restore failed unexpectedly with $retcode/$fetcode"
> + return 2
> + else
> + echo "FAULT: $tname restore failed as expected with $retcode"
> + return 0
> + fi
> + fi
if
echo "restore passed unexpectedly"
> +
> cat $ddump/restore.log* | grep Error
your code should be after this line
>
> [ -n "$PIDNS" ] && PID=`cat $TPID`
> --
> 1.9.3
>
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list