mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-24 02:29:23 +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>
65 lines
1.3 KiB
C
65 lines
1.3 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"
|
|
|
|
const char *test_doc = "Test semi-closed unix stream connection\n";
|
|
const char *test_author = "Pavel Emelyanov <xemul@parallels.com>\n";
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int ssk_pair[2], ret;
|
|
char aux, data;
|
|
|
|
test_init(argc, argv);
|
|
|
|
data = (char)lrand48();
|
|
|
|
if (socketpair(AF_UNIX, SOCK_STREAM, 0, ssk_pair) == -1) {
|
|
fail("socketpair\n");
|
|
exit(1);
|
|
}
|
|
|
|
if (write(ssk_pair[1], &data, sizeof(data)) != sizeof(data)) {
|
|
fail("write\n");
|
|
exit(1);
|
|
}
|
|
|
|
close(ssk_pair[1]);
|
|
|
|
test_daemon();
|
|
test_waitsig();
|
|
|
|
ret = read(ssk_pair[0], &aux, sizeof(aux));
|
|
if (ret != sizeof(data) && aux != data) {
|
|
fail("Data loss (write %d, read %d)", data, aux);
|
|
return 1;
|
|
}
|
|
|
|
errno = 0;
|
|
ret = read(ssk_pair[0], &aux, sizeof(aux));
|
|
if (ret != 0 || errno != 0) {
|
|
fail("Opened end in wrong state (%d/%d)", ret, errno);
|
|
return 0;
|
|
}
|
|
|
|
errno = 0;
|
|
ret = read(ssk_pair[1], &aux, sizeof(aux));
|
|
if (ret != -1 || errno != EBADF) {
|
|
fail("Closed end in wrong state (%d/%d)", ret, errno);
|
|
return 0;
|
|
}
|
|
|
|
pass();
|
|
return 0;
|
|
}
|