mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-23 18:19:39 +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>
81 lines
1.6 KiB
C
81 lines
1.6 KiB
C
#include <errno.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/un.h>
|
|
|
|
#include "zdtmtst.h"
|
|
|
|
const char *test_doc = "Check that data in dgram socket are restored correctly";
|
|
const char *test_author = "Andrew Vagin <avagin@openvz.org";
|
|
|
|
#define SK_SRV "\0socket_dgram_srv"
|
|
|
|
#define MSG "hello"
|
|
int main(int argc, char **argv)
|
|
{
|
|
struct sockaddr_un addr;
|
|
unsigned int addrlen;
|
|
int srv, clnt1, clnt2, ret;
|
|
char buf[1024];
|
|
|
|
test_init(argc, argv);
|
|
|
|
srv = socket(PF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);
|
|
if (srv < 0) {
|
|
pr_perror("socket");
|
|
return 1;
|
|
}
|
|
clnt1 = socket(PF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);
|
|
if (clnt1 < 0) {
|
|
pr_perror("socket");
|
|
return 1;
|
|
}
|
|
clnt2 = socket(PF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);
|
|
if (clnt2 < 0) {
|
|
pr_perror("socket");
|
|
return 1;
|
|
}
|
|
|
|
addr.sun_family = AF_UNIX;
|
|
memcpy(addr.sun_path, SK_SRV, sizeof(SK_SRV));
|
|
addrlen = sizeof(addr.sun_family) + sizeof(SK_SRV);
|
|
|
|
if (bind(srv, &addr, addrlen)) {
|
|
fail("bind\n");
|
|
exit(1);
|
|
}
|
|
if (connect(clnt1, &addr, addrlen)) {
|
|
fail("connect\n");
|
|
exit(1);
|
|
}
|
|
if (connect(clnt2, &addr, addrlen)) {
|
|
fail("connect\n");
|
|
exit(1);
|
|
}
|
|
|
|
if (write(clnt1, MSG, sizeof(MSG)) != sizeof(MSG)) {
|
|
pr_perror("write");
|
|
return 1;
|
|
}
|
|
|
|
test_daemon();
|
|
test_waitsig();
|
|
|
|
ret = read(srv, buf, sizeof(buf));
|
|
buf[ret > 0 ? ret : 0] = 0;
|
|
if (ret != sizeof(MSG)) {
|
|
fail("%d: %s", ret, buf);
|
|
return 1;
|
|
}
|
|
|
|
ret = read(srv, buf, sizeof(buf));
|
|
if (ret != -1 || errno != EAGAIN) {
|
|
fail("unexpected data: %d", ret);
|
|
return 1;
|
|
}
|
|
|
|
pass();
|
|
return 0;
|
|
}
|