Commit cf8b7c8f authored by Pavel Emelyanov's avatar Pavel Emelyanov

zdtm: Introduce per-test hooks

This is inspired by two problems we have with cgroup* tests.

1. Tests cannot easily clean after themselves -- one cannot
   remove a cg dir with tasks in it and the root task of
   a test is in a cgroup it tries to remove.

2. After dump old cgroup dirs are remained after the test,
   while criu should restore them (this is what we write
   tests for).

The proposal is to introduce per-test hooks, for now two of
them: --pre-restore and --clean. For cgroup tests both hooks
will remove the created directories.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 513091aa
......@@ -618,6 +618,11 @@ EOF
done
done
if [ -x "${test}.hook" ]; then
echo "Executing pre-restore hook"
"${test}.hook" --pre-restore || return 2
fi
echo Restore
setsid $CRIU restore -D $ddump -o restore.log -v4 -d $gen_args || return 2
......@@ -651,6 +656,11 @@ EOF
[ $sltime -lt 9 ] && sltime=$((sltime+1))
done
if [ -x "${test}.hook" ]; then
echo "Executing cleanup hook"
"${test}.hook" --clean
fi
if [ -n "$AUTO_DEDUP" ]; then
for img in $ddump/pages-*.img; do
img_name="${img##*/}"
......
#!/bin/bash
set -e
tname=$(mktemp -d cgclean.XXXXXX)
mount -t cgroup none $tname -o "none,name=zdtmtst"
echo "Cleaning $tname"
set +e
rmdir "$tname/subcg/subsubcg/"
rmdir "$tname/subcg/empty/"
rmdir "$tname/subcg/"
set -e
echo "Left there is:"
ls "$tname"
umount "$tname"
rmdir "$tname"
......@@ -70,14 +70,6 @@ static int cg_check(char *name)
return found ? 0 : -1;
}
static void cg_cleanup(void)
{
char paux[256];
sprintf(paux, "%s/%s", dirname, SUBNAME);
rmdir(paux);
}
int main(int argc, char **argv)
{
char aux[64];
......@@ -200,7 +192,6 @@ int main(int argc, char **argv)
pass();
out_rs:
cg_cleanup();
umount(dirname);
out_rd:
rmdir(dirname);
......
cgroup.hook
\ No newline at end of file
......@@ -97,12 +97,7 @@ int main(int argc, char **argv)
out_close:
fclose(cgf);
sprintf(paux, "%s/%s/%s", dirname, subname, empty);
rmdir(paux);
out_rs:
sprintf(paux, "%s/%s", dirname, subname);
rmdir(paux);
umount(dirname);
out_rd:
rmdir(dirname);
......
cgroup.hook
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment