mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 01:51:51 +00:00
gcov: mount criu sources into a test mount tree
CRIU processes save *.gcda and *.gcno files near source files, so when we restore tests into another mount namespace, we need to have access to sources from this namespace. Cc: Sergey Bronnikov <sergeyb@openvz.org> Reported-by: Sergey Bronnikov <sergeyb@openvz.org> Signed-off-by: Andrew Vagin <avagin@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
parent
aa40501d95
commit
615465498f
7
Makefile
7
Makefile
@ -202,13 +202,8 @@ PHONY += cscope
|
||||
gcov:
|
||||
$(E) " GCOV"
|
||||
$(Q) test -d gcov || mkdir gcov && \
|
||||
cp criu/*.{gcno,c,h} test/`pwd`/criu/ && \
|
||||
geninfo --output-filename gcov/crtools.h.info --no-recursion criu/ && \
|
||||
geninfo --output-filename gcov/crtools.ns.info --no-recursion test/`pwd`/criu/ && \
|
||||
sed -i "s#/test`pwd`##" gcov/crtools.ns.info && \
|
||||
geninfo --output-filename gcov/criu.info --no-recursion criu/ && \
|
||||
cd gcov && \
|
||||
lcov --rc lcov_branch_coverage=1 --add-tracefile crtools.h.info \
|
||||
--add-tracefile crtools.ns.info --output-file criu.info && \
|
||||
genhtml --rc lcov_branch_coverage=1 --output-directory html criu.info
|
||||
@echo "Code coverage report is in `pwd`/gcov/html/ directory."
|
||||
PHONY += gcov
|
||||
|
15
test/zdtm.py
15
test/zdtm.py
@ -348,6 +348,12 @@ class zdtm_test:
|
||||
if self.__flavor.uns:
|
||||
env['ZDTM_USERNS'] = "1"
|
||||
self.__add_wperms()
|
||||
if os.getenv("GCOV"):
|
||||
criu_dir = os.path.dirname(os.getcwd())
|
||||
criu_dir_r = "%s%s" % (self.__flavor.root, criu_dir)
|
||||
|
||||
env['ZDTM_CRIU'] = os.path.dirname(os.getcwd());
|
||||
subprocess.check_call(["mkdir", "-p", criu_dir_r])
|
||||
|
||||
self.__make_action('pid', env, self.__flavor.root)
|
||||
|
||||
@ -703,6 +709,11 @@ class criu_cli:
|
||||
|
||||
a_opts += [ "--timeout", "10" ]
|
||||
|
||||
criu_dir = os.path.dirname(os.getcwd())
|
||||
if os.getenv("GCOV"):
|
||||
a_opts.append("--ext-mount-map")
|
||||
a_opts.append("%s:zdtm" % criu_dir)
|
||||
|
||||
self.__criu_act(action, opts = a_opts + opts)
|
||||
|
||||
if self.__page_server:
|
||||
@ -716,6 +727,10 @@ class criu_cli:
|
||||
r_opts += self.__test.getropts()
|
||||
|
||||
self.__prev_dump_iter = None
|
||||
criu_dir = os.path.dirname(os.getcwd())
|
||||
if os.getenv("GCOV"):
|
||||
r_opts.append("--ext-mount-map")
|
||||
r_opts.append("zdtm:%s" % criu_dir)
|
||||
self.__criu_act("restore", opts = r_opts + ["--restore-detached"])
|
||||
|
||||
@staticmethod
|
||||
|
@ -23,7 +23,7 @@ extern int pivot_root(const char *new_root, const char *put_old);
|
||||
static int prepare_mntns(void)
|
||||
{
|
||||
int dfd, ret;
|
||||
char *root;
|
||||
char *root, *criu_path;
|
||||
char path[PATH_MAX];
|
||||
|
||||
root = getenv("ZDTM_ROOT");
|
||||
@ -47,6 +47,16 @@ static int prepare_mntns(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
criu_path = getenv("ZDTM_CRIU");
|
||||
if (criu_path) {
|
||||
snprintf(path, sizeof(path), "%s%s", root, criu_path);
|
||||
if (mount(criu_path, path, NULL, MS_BIND, NULL) ||
|
||||
mount(NULL, path, NULL, MS_PRIVATE, NULL)) {
|
||||
pr_perror("Unable to mount %s", path);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Move current working directory to the new root */
|
||||
ret = readlink("/proc/self/cwd", path, sizeof(path) - 1);
|
||||
if (ret < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user