Commit 25d048c0 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

test: Add usnix-socket test

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 843747de
......@@ -5,6 +5,7 @@ SRCS += test-shmem-three-async.c
SRCS += test-pipe-async.c
SRCS += test-vdso.c
SRCS += test-sigaction.c
SRCS += test-unixsocket.c
SRCS-TH += test-pthreads.c
OBJS-TH += $(patsubst %.c,%.o,$(SRCS-TH))
......
#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>
int main(void)
{
int sv[2];
char buf;
int ret;
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1) {
perror("socketpair");
exit(1);
}
buf = 'a';
write(sv[0], &buf, 1);
printf("sent '%c'\n", buf);
while (1) {
/* stream */
read(sv[1], &buf, 1);
printf("read '%c'\n", buf);
/*
* checkpoint should be done here,
* we don't support queued data yet.
*/
printf("pause\n");
sleep(10);
buf = toupper(buf);
write(sv[0], &buf, 1);
printf("sent '%c'\n", buf);
}
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