mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-08-04 15:53:44 +00:00
After the commit
02c763939c10 ("test/zdtm: unify common code")
CFLAGS with -D_GNU_SOURCE defined in the top Makefile
are being passed to tests Makefiles.
As _GNU_SOURCE is also defined by tests, that resulted in
zdtm tests build failures:
make[2]: Entering directory `/home/criu/test/zdtm/lib'
CC test.o
test.c:1:0: error: "_GNU_SOURCE" redefined [-Werror]
#define _GNU_SOURCE
^
<command-line>:0:0: note: this is the location of the previous definition
cc1: all warnings being treated as errors
make[2]: *** [test.o] Error 1
However, we didn't catch this in time by Travis-CI, as zdtm.py doesn't
do `make zdtm`, rather it does `make -C test/zdtm/{lib,static,transition}`.
By calling middle makefile this way, it doesn't have _GNU_SOURCE in
CFLAGS from top-Makefile.
I think the right thing to do here - is following CRIU's way:
rely on definition of _GNU_SOURCE by Makefiles.
This patch is almost fully generated with
find test/zdtm/ -name '*.c' -type f \
-exec sed -i '/define _GNU_SOURCE/{n;/^$/d;}' '{}' \; \
-exec sed -i '/define _GNU_SOURCE/d' '{}' \;
With an exception for adding -D_GNU_SOURCE in tests Makefile.inc for
keeping the same behaviour for zdtm.py.
Also changed utsname.c to use utsname::domainname, rather private
utsname::__domainname, as now it's uncovered (from sys/utsname.h):
> struct utsname
> {
...
> # ifdef __USE_GNU
> char domainname[_UTSNAME_DOMAIN_LENGTH];
> # else
> char __domainname[_UTSNAME_DOMAIN_LENGTH];
> # endif
Reported-by: Adrian Reber <areber@redhat.com>
Cc: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
68 lines
1.2 KiB
C
68 lines
1.2 KiB
C
#include <sched.h>
|
|
|
|
#include <sys/mount.h>
|
|
#include <unistd.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#include <sys/wait.h>
|
|
#include <linux/limits.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "zdtmtst.h"
|
|
|
|
const char *test_doc = "Check that mounts with external master peers are c/r'd";
|
|
const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>";
|
|
|
|
char *dirname = "mnt_ext_auto.test";
|
|
TEST_OPTION(dirname, string, "directory name", 1);
|
|
|
|
int main(int argc, char ** argv)
|
|
{
|
|
char src[PATH_MAX], dst[PATH_MAX], *root;
|
|
char *dname = "/tmp/zdtm_ext_auto.XXXXXX";
|
|
|
|
root = getenv("ZDTM_ROOT");
|
|
if (root == NULL) {
|
|
pr_perror("root");
|
|
return 1;
|
|
}
|
|
|
|
sprintf(dst, "%s/ext_mounts", getenv("ZDTM_ROOT"));
|
|
|
|
if (strcmp(getenv("ZDTM_NEWNS"), "1"))
|
|
goto test;
|
|
|
|
mkdir(dname, 755);
|
|
sprintf(src, "%s/test", dname);
|
|
if (mount("zdtm_auto_ext_mnt", dname, "tmpfs", 0, NULL)) {
|
|
pr_perror("mount");
|
|
return 1;
|
|
}
|
|
|
|
mkdir(src, 755);
|
|
mkdir(dst, 755);
|
|
|
|
unshare(CLONE_NEWNS);
|
|
|
|
if (mount(src, dst, NULL, MS_BIND, NULL)) {
|
|
pr_perror("bind");
|
|
return 1;
|
|
}
|
|
|
|
if (mount(src, dst, NULL, MS_SLAVE, NULL)) {
|
|
pr_perror("slave");
|
|
return 1;
|
|
}
|
|
|
|
test:
|
|
test_init(argc, argv);
|
|
|
|
test_daemon();
|
|
test_waitsig();
|
|
|
|
|
|
pass();
|
|
|
|
return 0;
|
|
}
|