Commit 96c3c7be authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

zdtm: Add sockets_spair test case

Code to test socketpair (extracted from
previous sockets00 test case).
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7dad6fcf
......@@ -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 \
......
#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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment