summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9ae8f7f)
raw | patch | inline | side by side (parent: 9ae8f7f)
author | Sebastian Harl <sh@tokkee.org> | |
Mon, 30 Jun 2014 06:19:58 +0000 (08:19 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Mon, 30 Jun 2014 06:19:58 +0000 (08:19 +0200) |
t/unit/frontend/connection_test.c | patch | blob | history |
index 9e9461453cff6204611bcd74192e94569d9ec3f0..a38c262c3febeba6715b884245d343e15acb92c3 100644 (file)
} /* mock_conn_truncate */
static int
-mock_unixsock_listener(char *sock_path)
+mock_unixsock_listener(char *socket_path)
{
struct sockaddr_un sa;
- char *filename;
int fd, status;
- filename = tmpnam(sock_path);
- fail_unless(filename != NULL,
- "INTERNAL ERROR: tmpnam() = NULL; expected: a string");
-
fd = socket(AF_UNIX, SOCK_STREAM, 0);
fail_unless(fd >= 0,
"INTERNAL ERROR: socket() = %d; expected: >=0", fd);
memset(&sa, 0, sizeof(sa));
sa.sun_family = AF_UNIX;
- strncpy(sa.sun_path, filename, sizeof(sa.sun_path));
+ strncpy(sa.sun_path, socket_path, sizeof(sa.sun_path));
status = bind(fd, (struct sockaddr *)&sa, sizeof(sa));
fail_unless(status == 0,
START_TEST(test_conn_accept)
{
- char socket_path[L_tmpnam];
+ char socket_path[] = "connection_test_socket.XXXXXX";
int fd, check;
sdb_conn_t *conn;
fail_unless(conn == NULL,
"sdb_connection_accept(-1) = %p; expected: NULL", conn);
- memset(&socket_path, 0, sizeof(socket_path));
+ mkstemp(socket_path);
+ unlink(socket_path);
+
fd = mock_unixsock_listener(socket_path);
check = pthread_create(&thr, /* attr = */ NULL, mock_client, socket_path);
fail_unless(check == 0,