mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
zdtm: Add sockets_spair test case
Code to test socketpair (extracted from previous sockets00 test case). Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
7dad6fcfdf
commit
96c3c7bea4
@@ -28,6 +28,7 @@ transition/file_read
|
||||
transition/fork
|
||||
static/zombie00
|
||||
static/sockets00
|
||||
static/sockets_spair
|
||||
static/socket_queues
|
||||
static/pid00
|
||||
static/pstree
|
||||
|
@@ -35,6 +35,7 @@ TST_NOFILE = \
|
||||
utsname \
|
||||
pstree \
|
||||
sockets00 \
|
||||
sockets_spair \
|
||||
socket_queues \
|
||||
ipc_namespace \
|
||||
selfexe00 \
|
||||
|
58
test/zdtm/live/static/sockets_spair.c
Normal file
58
test/zdtm/live/static/sockets_spair.c
Normal file
@@ -0,0 +1,58 @@
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#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 unix stream socketpair\n";
|
||||
const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org";
|
||||
|
||||
#define SK_DATA "packet"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ssk_pair[2];
|
||||
char buf[64];
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, ssk_pair) == -1) {
|
||||
fail("socketpair\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
write(ssk_pair[0], SK_DATA, sizeof(SK_DATA));
|
||||
read(ssk_pair[1], &buf, sizeof(buf));
|
||||
if (strcmp(buf, SK_DATA)) {
|
||||
fail("data corrupted\n");
|
||||
exit(1);
|
||||
}
|
||||
test_msg("stream : '%s'\n", buf);
|
||||
|
||||
test_daemon();
|
||||
test_waitsig();
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
write(ssk_pair[0], SK_DATA, sizeof(SK_DATA));
|
||||
read(ssk_pair[1], &buf, sizeof(buf));
|
||||
if (strcmp(buf, SK_DATA)) {
|
||||
fail("data corrupted\n");
|
||||
exit(1);
|
||||
}
|
||||
test_msg("stream : '%s'\n", buf);
|
||||
|
||||
pass();
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user