From e374bfa35bfb833928e8edf686e962d16705abeb Mon Sep 17 00:00:00 2001 From: bellard Date: Sun, 22 Feb 2004 14:54:18 +0000 Subject: shm tests - disabled clone test git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@637 c046a42c-6fe2-441c-8c8c-71466251a162 --- tests/linux-test.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/linux-test.c b/tests/linux-test.c index 14cbe1385e..6ca9029650 100644 --- a/tests/linux-test.c +++ b/tests/linux-test.c @@ -38,6 +38,7 @@ #include #include #include +#include #define TESTPATH "/tmp/linux-test.tmp" #define TESTPORT 7654 @@ -314,12 +315,19 @@ const char socket_msg[] = "hello socket\n"; void test_socket(void) { - int server_fd, client_fd, fd, pid, ret; + int server_fd, client_fd, fd, pid, ret, val; struct sockaddr_in sockaddr; socklen_t len; char buf[512]; server_fd = server_socket(); + + /* test a few socket options */ + len = sizeof(val); + chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len)); + if (val != SOCK_STREAM) + error("getsockopt"); + pid = chk_error(fork()); if (pid == 0) { client_fd = client_socket(); @@ -497,13 +505,32 @@ void test_signal(void) chk_error(sigaction(SIGSEGV, &act, NULL)); } +#define SHM_SIZE 32768 + +void test_shm(void) +{ + void *ptr; + int shmid; + + shmid = chk_error(shmget(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | 0777)); + ptr = shmat(shmid, NULL, 0); + if (!ptr) + error("shmat"); + + memset(ptr, 0, SHM_SIZE); + + chk_error(shmctl(shmid, IPC_RMID, 0)); + chk_error(shmdt(ptr)); +} + int main(int argc, char **argv) { test_file(); test_fork(); test_time(); test_socket(); - test_clone(); + // test_clone(); test_signal(); + test_shm(); return 0; } -- cgit v1.2.3