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>
108 lines
2.8 KiB
C
108 lines
2.8 KiB
C
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <ctype.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/wait.h>
|
|
#include <sys/un.h>
|
|
#include <sys/stat.h>
|
|
#include <limits.h>
|
|
#include <fcntl.h>
|
|
|
|
#include "zdtmtst.h"
|
|
|
|
/* FIXME Need gram sockets tests */
|
|
|
|
const char *test_doc = "Test unix sockets queues (2 messages in queue)\n";
|
|
const char *test_author = "Stanislav Kinsbursky <skinsbursky@parallels.com>\n";
|
|
|
|
#define SK_DATA_S1 "packet stream left"
|
|
#define SK_DATA_S2 "packet stream right"
|
|
#define SK_DATA_D1 "packet dgram left"
|
|
#define SK_DATA_D2 "packet dgram right"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int ssk_pair_d[2];
|
|
int ssk_pair_s[2];
|
|
char buf_left[64], buf_right[64];
|
|
|
|
test_init(argc, argv);
|
|
|
|
if (socketpair(AF_UNIX, SOCK_STREAM, 0, ssk_pair_s) == -1) {
|
|
fail("socketpair\n");
|
|
exit(1);
|
|
}
|
|
|
|
write(ssk_pair_s[0], SK_DATA_S1, sizeof(SK_DATA_S1));
|
|
write(ssk_pair_s[0], SK_DATA_S2, sizeof(SK_DATA_S2));
|
|
write(ssk_pair_s[1], SK_DATA_S2, sizeof(SK_DATA_S2));
|
|
write(ssk_pair_s[1], SK_DATA_S1, sizeof(SK_DATA_S1));
|
|
|
|
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, ssk_pair_d) == -1) {
|
|
fail("socketpair\n");
|
|
exit(1);
|
|
}
|
|
|
|
write(ssk_pair_d[0], SK_DATA_D1, sizeof(SK_DATA_D1));
|
|
write(ssk_pair_d[0], SK_DATA_D2, sizeof(SK_DATA_D2));
|
|
write(ssk_pair_d[1], SK_DATA_D2, sizeof(SK_DATA_D2));
|
|
write(ssk_pair_d[1], SK_DATA_D1, sizeof(SK_DATA_D1));
|
|
|
|
test_daemon();
|
|
test_waitsig();
|
|
|
|
read(ssk_pair_s[1], buf_left, strlen(SK_DATA_S1) + 1);
|
|
if (strcmp(buf_left, SK_DATA_S1)) {
|
|
fail("SK_DATA_S2: '%s\n", SK_DATA_S1);
|
|
exit(1);
|
|
}
|
|
read(ssk_pair_s[1], buf_right, strlen(SK_DATA_S2) + 1);
|
|
if (strcmp(buf_right, SK_DATA_S2)) {
|
|
fail("data corrupted\n");
|
|
exit(1);
|
|
}
|
|
test_msg("stream1 : '%s' '%s'\n", buf_left, buf_right);
|
|
|
|
read(ssk_pair_s[0], buf_left, strlen(SK_DATA_S2) + 1);
|
|
if (strcmp(buf_left, SK_DATA_S2)) {
|
|
fail("data corrupted\n");
|
|
exit(1);
|
|
}
|
|
read(ssk_pair_s[0], buf_right, strlen(SK_DATA_S1) + 1);
|
|
if (strcmp(buf_right, SK_DATA_S1)) {
|
|
fail("data corrupted\n");
|
|
exit(1);
|
|
}
|
|
test_msg("stream2 : '%s' '%s'\n", buf_left, buf_right);
|
|
|
|
read(ssk_pair_d[1], buf_left, strlen(SK_DATA_D1) + 1);
|
|
if (strcmp(buf_left, SK_DATA_D1)) {
|
|
fail("data corrupted\n");
|
|
exit(1);
|
|
}
|
|
read(ssk_pair_d[1], buf_right, strlen(SK_DATA_D2) + 1);
|
|
if (strcmp(buf_right, SK_DATA_D2)) {
|
|
fail("data corrupted\n");
|
|
exit(1);
|
|
}
|
|
test_msg("dgram1 : '%s' '%s'\n", buf_left, buf_right);
|
|
|
|
read(ssk_pair_d[0], buf_left, strlen(SK_DATA_D2) + 1);
|
|
if (strcmp(buf_left, SK_DATA_D2)) {
|
|
fail("data corrupted\n");
|
|
exit(1);
|
|
}
|
|
read(ssk_pair_d[0], buf_right,strlen(SK_DATA_D1) + 1);
|
|
if (strcmp(buf_right, SK_DATA_D1)) {
|
|
fail("data corrupted\n");
|
|
exit(1);
|
|
}
|
|
test_msg("dgram2 : '%s' '%s'\n", buf_left, buf_right);
|
|
|
|
pass();
|
|
return 0;
|
|
}
|