Commit c5c54345 authored by Andrei Vagin's avatar Andrei Vagin Committed by Pavel Emelyanov

fault: add ability to fault open_by_handel in check_open_handle

From code coverage report, we found that inotify_irmap doesn't test irmap
cache, because we is always able to resolve path from /proc/PID/fd/X.

Current view:	top level - criu - irmap.c (source / functions)			Hit	Total	Coverage
Test:	criu.info		Lines:	40	223	17.9 %
Date:	2016-03-16		Functions:	4	13	30.8 %

This series introduces a new fault to emulate a situation
when a file can't be opened by handle and we have to find
it in the irmap cache/

It's required to test irmap cache. I don't know how to force it
without this patch. Each time when a file can be opened by handle,
its path can be resolved via /proc/PID/fd/X.
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 84359f7a
......@@ -40,6 +40,7 @@
#include "cr_options.h"
#include "namespaces.h"
#include "pstree.h"
#include "fault-injection.h"
#include "protobuf.h"
#include "images/fsnotify.pb-c.h"
......@@ -224,7 +225,13 @@ int check_open_handle(unsigned int s_dev, unsigned long i_ino,
int fd = -1;
char *path;
if (fault_injected(FI_CHECK_OPEN_HANDLE)) {
fd = -1;
goto fault;
}
fd = open_handle(s_dev, i_ino, f_handle);
fault:
if (fd >= 0) {
struct mount_info *mi;
......
......@@ -6,6 +6,8 @@ enum faults {
FI_NONE = 0,
FI_DUMP_EARLY,
FI_RESTORE_ROOT_ONLY,
/* not fatal */
FI_CHECK_OPEN_HANDLE = 128,
FI_MAX,
};
......
......@@ -4,3 +4,4 @@ source `dirname $0`/criu-lib.sh
prep
./test/zdtm.py run -t zdtm/static/env00 --fault 1 --report report -f h || fail
./test/zdtm.py run -t zdtm/static/unlink_fstat00 --fault 2 --report report -f h || fail
./test/zdtm.py run -t zdtm/static/inotify_irmap --fault 128 --pre 2 -f uns || fail
......@@ -678,7 +678,7 @@ class criu_cli:
ret = self.__criu(action, s_args, self.__fault, strace, preexec)
grep_errors(os.path.join(__ddir, log))
if ret != 0:
if self.__fault:
if self.__fault and int(self.__fault) < 128:
try_run_hook(self.__test, ["--fault", action])
if action == "dump":
# create a clean directory for images
......
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