mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 13:58:34 +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:
committed by
Pavel Emelyanov
parent
aa40501d95
commit
615465498f
7
Makefile
7
Makefile
@@ -202,13 +202,8 @@ PHONY += cscope
|
|||||||
gcov:
|
gcov:
|
||||||
$(E) " GCOV"
|
$(E) " GCOV"
|
||||||
$(Q) test -d gcov || mkdir gcov && \
|
$(Q) test -d gcov || mkdir gcov && \
|
||||||
cp criu/*.{gcno,c,h} test/`pwd`/criu/ && \
|
geninfo --output-filename gcov/criu.info --no-recursion 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 && \
|
|
||||||
cd gcov && \
|
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
|
genhtml --rc lcov_branch_coverage=1 --output-directory html criu.info
|
||||||
@echo "Code coverage report is in `pwd`/gcov/html/ directory."
|
@echo "Code coverage report is in `pwd`/gcov/html/ directory."
|
||||||
PHONY += gcov
|
PHONY += gcov
|
||||||
|
15
test/zdtm.py
15
test/zdtm.py
@@ -348,6 +348,12 @@ class zdtm_test:
|
|||||||
if self.__flavor.uns:
|
if self.__flavor.uns:
|
||||||
env['ZDTM_USERNS'] = "1"
|
env['ZDTM_USERNS'] = "1"
|
||||||
self.__add_wperms()
|
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)
|
self.__make_action('pid', env, self.__flavor.root)
|
||||||
|
|
||||||
@@ -703,6 +709,11 @@ class criu_cli:
|
|||||||
|
|
||||||
a_opts += [ "--timeout", "10" ]
|
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)
|
self.__criu_act(action, opts = a_opts + opts)
|
||||||
|
|
||||||
if self.__page_server:
|
if self.__page_server:
|
||||||
@@ -716,6 +727,10 @@ class criu_cli:
|
|||||||
r_opts += self.__test.getropts()
|
r_opts += self.__test.getropts()
|
||||||
|
|
||||||
self.__prev_dump_iter = None
|
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"])
|
self.__criu_act("restore", opts = r_opts + ["--restore-detached"])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@@ -23,7 +23,7 @@ extern int pivot_root(const char *new_root, const char *put_old);
|
|||||||
static int prepare_mntns(void)
|
static int prepare_mntns(void)
|
||||||
{
|
{
|
||||||
int dfd, ret;
|
int dfd, ret;
|
||||||
char *root;
|
char *root, *criu_path;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
|
||||||
root = getenv("ZDTM_ROOT");
|
root = getenv("ZDTM_ROOT");
|
||||||
@@ -47,6 +47,16 @@ static int prepare_mntns(void)
|
|||||||
return -1;
|
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 */
|
/* Move current working directory to the new root */
|
||||||
ret = readlink("/proc/self/cwd", path, sizeof(path) - 1);
|
ret = readlink("/proc/self/cwd", path, sizeof(path) - 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
Reference in New Issue
Block a user