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@
|
AM_CFLAGS = @win32_cflags@
|
||||||
|
|
||||||
bin_PROGRAMS = evil_suite test_pipe test_evil
|
bin_PROGRAMS = evil_suite test_evil
|
||||||
|
|
||||||
evil_suite_SOURCES = \
|
evil_suite_SOURCES = \
|
||||||
evil_suite.c \
|
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_LDADD = $(top_builddir)/src/lib/libevil.la $(top_builddir)/src/lib/dlfcn/libdl.la -lm
|
||||||
evil_suite_LDFLAGS = -Wl,--enable-auto-import
|
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_SOURCES = test_evil.c
|
||||||
test_evil_LDADD = $(top_builddir)/src/lib/libevil.la
|
test_evil_LDADD = $(top_builddir)/src/lib/libevil.la
|
||||||
test_evil_LDFLAGS = -Wl,--enable-auto-import
|
test_evil_LDFLAGS = -Wl,--enable-auto-import
|
||||||
|
@ -51,4 +47,5 @@ evil_test_environment.h \
|
||||||
evil_test_link.h \
|
evil_test_link.h \
|
||||||
evil_test_memcpy.h \
|
evil_test_memcpy.h \
|
||||||
evil_test_mkstemp.h \
|
evil_test_mkstemp.h \
|
||||||
|
evil_test_pipe.h \
|
||||||
evil_test_realpath.h
|
evil_test_realpath.h
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -5,7 +9,10 @@
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
# undef WIN32_LEAN_AND_MEAN
|
# undef WIN32_LEAN_AND_MEAN
|
||||||
|
|
||||||
#include "Evil.h"
|
#include <Evil.h>
|
||||||
|
|
||||||
|
#include "evil_suite.h"
|
||||||
|
|
||||||
|
|
||||||
#define FDREAD 0
|
#define FDREAD 0
|
||||||
#define FDWRITE 1
|
#define FDWRITE 1
|
||||||
|
@ -17,7 +24,7 @@ typedef struct
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
|
|
||||||
DWORD WINAPI
|
static DWORD WINAPI
|
||||||
thread (void *param)
|
thread (void *param)
|
||||||
{
|
{
|
||||||
data *d;
|
data *d;
|
||||||
|
@ -31,19 +38,15 @@ thread (void *param)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int test_pipe_test(void)
|
||||||
main (int argc, char *argv[])
|
|
||||||
{
|
{
|
||||||
int sockets[2];
|
int sockets[2];
|
||||||
int ret;
|
|
||||||
fd_set rfds;
|
|
||||||
struct timeval t;
|
struct timeval t;
|
||||||
data *d;
|
fd_set rfds;
|
||||||
DWORD thread_id;
|
int ret;
|
||||||
HANDLE h;
|
data *d;
|
||||||
|
DWORD thread_id;
|
||||||
if (!evil_sockets_init())
|
HANDLE h;
|
||||||
return EXIT_FAILURE;
|
|
||||||
|
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
|
|
||||||
|
@ -51,50 +54,74 @@ main (int argc, char *argv[])
|
||||||
t.tv_usec = 0;
|
t.tv_usec = 0;
|
||||||
|
|
||||||
if (pipe(sockets) < 0)
|
if (pipe(sockets) < 0)
|
||||||
{
|
return 0;
|
||||||
printf ("can not create sockets\n");
|
|
||||||
evil_sockets_shutdown();
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
FD_SET(sockets[FDREAD], &rfds);
|
FD_SET(sockets[FDREAD], &rfds);
|
||||||
|
fcntl(sockets[FDREAD], F_SETFL, O_NONBLOCK);
|
||||||
|
|
||||||
d = (data *)malloc(sizeof (data));
|
d = (data *)malloc(sizeof (data));
|
||||||
|
if (!d)
|
||||||
|
return 0;
|
||||||
|
|
||||||
d->val = 14;
|
d->val = 14;
|
||||||
d->fd_write = sockets[FDWRITE];
|
d->fd_write = sockets[FDWRITE];
|
||||||
printf (" pointer sent........: %p\n", d);
|
|
||||||
|
|
||||||
h = CreateThread(NULL, 0, thread, d, 0, &thread_id);
|
h = CreateThread(NULL, 0, thread, d, 0, &thread_id);
|
||||||
|
if (!h)
|
||||||
|
|
||||||
ret = select(sockets[FDREAD] + 1, &rfds, NULL, NULL, &t);
|
ret = select(sockets[FDREAD] + 1, &rfds, NULL, NULL, &t);
|
||||||
|
|
||||||
if (ret < 0) return -1;
|
if (ret < 0)
|
||||||
|
goto free_d;
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0)
|
||||||
printf ("temps expire\n");
|
goto close_h;
|
||||||
}
|
|
||||||
|
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
data *d;
|
|
||||||
int len;
|
|
||||||
int j = 0;
|
|
||||||
void *buf[1];
|
void *buf[1];
|
||||||
|
data *d2 = NULL;
|
||||||
|
int len;
|
||||||
|
|
||||||
while ((len = recv(sockets[FDREAD], (char *)buf, sizeof(buf), 0)) > 0)
|
while ((len = recv(sockets[FDREAD], (char *)buf, sizeof(buf), 0)) > 0)
|
||||||
{
|
{
|
||||||
if (len == sizeof(buf))
|
if (len == sizeof(buf))
|
||||||
{
|
{
|
||||||
d = buf[0];
|
d2 = (data *)buf[0];
|
||||||
printf (" pointer received....: %p\n", d);
|
break;
|
||||||
j = d->val;
|
|
||||||
printf (" value (should be 14) : %d\n", j);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (d2 && (d2->val == d->val))
|
||||||
|
ret = 1;
|
||||||
|
else
|
||||||
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle (h);
|
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