Commit c8f3e09f authored by Pavel Emelyanov's avatar Pavel Emelyanov

zdtm: Add test for semi-closed unix connection

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 1148edc1
......@@ -38,6 +38,7 @@ streaming/pipe_shared00
transition/file_read
static/sockets00
static/sockets01
static/sockets02
static/sock_opts00
static/sock_opts01
static/sockets_spair
......
......@@ -47,6 +47,7 @@ TST_NOFILE = \
utsname \
pstree \
sockets01 \
sockets02 \
sockets_spair \
socket_queues \
socket_queues02 \
......
#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 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;
test_init(argc, argv);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, ssk_pair) == -1) {
fail("socketpair\n");
exit(1);
}
close(ssk_pair[1]);
test_daemon();
test_waitsig();
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;
}
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