forked from enlightenment/efl
* remove useless pipe() test
* add missing files SVN revision: 45737
This commit is contained in:
parent
65d13f2085
commit
367a8d9154
|
@ -10,7 +10,7 @@ AM_CPPFLAGS = \
|
|||
|
||||
AM_CFLAGS = @win32_cflags@
|
||||
|
||||
bin_PROGRAMS = evil_suite test_pipe test_evil
|
||||
bin_PROGRAMS = evil_suite test_evil
|
||||
|
||||
evil_suite_SOURCES = \
|
||||
evil_suite.c \
|
||||
|
@ -36,10 +36,6 @@ endif
|
|||
evil_suite_LDADD = $(top_builddir)/src/lib/libevil.la $(top_builddir)/src/lib/dlfcn/libdl.la -lm
|
||||
evil_suite_LDFLAGS = -Wl,--enable-auto-import
|
||||
|
||||
test_pipe_SOURCES = test_pipe.c
|
||||
test_pipe_LDADD = $(top_builddir)/src/lib/libevil.la
|
||||
test_pipe_LDFLAGS = -Wl,--enable-auto-import
|
||||
|
||||
test_evil_SOURCES = test_evil.c
|
||||
test_evil_LDADD = $(top_builddir)/src/lib/libevil.la
|
||||
test_evil_LDFLAGS = -Wl,--enable-auto-import
|
||||
|
@ -51,4 +47,5 @@ evil_test_environment.h \
|
|||
evil_test_link.h \
|
||||
evil_test_memcpy.h \
|
||||
evil_test_mkstemp.h \
|
||||
evil_test_pipe.h \
|
||||
evil_test_realpath.h
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -5,7 +9,10 @@
|
|||
# include <winsock2.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include "Evil.h"
|
||||
#include <Evil.h>
|
||||
|
||||
#include "evil_suite.h"
|
||||
|
||||
|
||||
#define FDREAD 0
|
||||
#define FDWRITE 1
|
||||
|
@ -17,7 +24,7 @@ typedef struct
|
|||
} data;
|
||||
|
||||
|
||||
DWORD WINAPI
|
||||
static DWORD WINAPI
|
||||
thread (void *param)
|
||||
{
|
||||
data *d;
|
||||
|
@ -31,70 +38,90 @@ thread (void *param)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
int test_pipe_test(void)
|
||||
{
|
||||
int sockets[2];
|
||||
int ret;
|
||||
fd_set rfds;
|
||||
struct timeval t;
|
||||
fd_set rfds;
|
||||
int ret;
|
||||
data *d;
|
||||
DWORD thread_id;
|
||||
HANDLE h;
|
||||
|
||||
if (!evil_sockets_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
FD_ZERO(&rfds);
|
||||
|
||||
t.tv_sec = 5;
|
||||
t.tv_usec = 0;
|
||||
|
||||
if (pipe(sockets) < 0)
|
||||
{
|
||||
printf ("can not create sockets\n");
|
||||
evil_sockets_shutdown();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return 0;
|
||||
|
||||
FD_SET(sockets[FDREAD], &rfds);
|
||||
fcntl(sockets[FDREAD], F_SETFL, O_NONBLOCK);
|
||||
|
||||
d = (data *)malloc(sizeof (data));
|
||||
if (!d)
|
||||
return 0;
|
||||
|
||||
d->val = 14;
|
||||
d->fd_write = sockets[FDWRITE];
|
||||
printf (" pointer sent........: %p\n", d);
|
||||
|
||||
h = CreateThread(NULL, 0, thread, d, 0, &thread_id);
|
||||
if (!h)
|
||||
|
||||
ret = select(sockets[FDREAD] + 1, &rfds, NULL, NULL, &t);
|
||||
|
||||
if (ret < 0) return -1;
|
||||
if (ret < 0)
|
||||
goto free_d;
|
||||
|
||||
if (ret == 0) {
|
||||
printf ("temps expire\n");
|
||||
}
|
||||
if (ret == 0)
|
||||
goto close_h;
|
||||
|
||||
if (ret > 0)
|
||||
{
|
||||
data *d;
|
||||
int len;
|
||||
int j = 0;
|
||||
void *buf[1];
|
||||
data *d2 = NULL;
|
||||
int len;
|
||||
|
||||
while ((len = recv(sockets[FDREAD], (char *)buf, sizeof(buf), 0)) > 0)
|
||||
{
|
||||
if (len == sizeof(buf))
|
||||
{
|
||||
d = buf[0];
|
||||
printf (" pointer received....: %p\n", d);
|
||||
j = d->val;
|
||||
printf (" value (should be 14) : %d\n", j);
|
||||
d2 = (data *)buf[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (d2 && (d2->val == d->val))
|
||||
ret = 1;
|
||||
else
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
CloseHandle(h);
|
||||
free(d);
|
||||
|
||||
evil_sockets_shutdown();
|
||||
return 1;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
close_h:
|
||||
CloseHandle(h);
|
||||
free_d:
|
||||
free(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_pipe_run(suite *s)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = test_pipe_test();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int
|
||||
test_pipe(suite *s)
|
||||
{
|
||||
|
||||
return test_pipe_run(s);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef __EVIL_TEST_PIPE_H__
|
||||
#define __EVIL_TEST_PIPE_H__
|
||||
|
||||
|
||||
int test_pipe(suite *s);
|
||||
|
||||
|
||||
#endif /* __EVIL_TEST_PIPE_H__ */
|
Loading…
Reference in New Issue