Commit e374bfa35bfb833928e8edf686e962d16705abeb

Authored by bellard
1 parent b88e4a9a

shm tests - disabled clone test


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@637 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 29 additions and 2 deletions
tests/linux-test.c
... ... @@ -38,6 +38,7 @@
38 38 #include <sched.h>
39 39 #include <dirent.h>
40 40 #include <setjmp.h>
  41 +#include <sys/shm.h>
41 42  
42 43 #define TESTPATH "/tmp/linux-test.tmp"
43 44 #define TESTPORT 7654
... ... @@ -314,12 +315,19 @@ const char socket_msg[] = &quot;hello socket\n&quot;;
314 315  
315 316 void test_socket(void)
316 317 {
317   - int server_fd, client_fd, fd, pid, ret;
  318 + int server_fd, client_fd, fd, pid, ret, val;
318 319 struct sockaddr_in sockaddr;
319 320 socklen_t len;
320 321 char buf[512];
321 322  
322 323 server_fd = server_socket();
  324 +
  325 + /* test a few socket options */
  326 + len = sizeof(val);
  327 + chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len));
  328 + if (val != SOCK_STREAM)
  329 + error("getsockopt");
  330 +
323 331 pid = chk_error(fork());
324 332 if (pid == 0) {
325 333 client_fd = client_socket();
... ... @@ -497,13 +505,32 @@ void test_signal(void)
497 505 chk_error(sigaction(SIGSEGV, &act, NULL));
498 506 }
499 507  
  508 +#define SHM_SIZE 32768
  509 +
  510 +void test_shm(void)
  511 +{
  512 + void *ptr;
  513 + int shmid;
  514 +
  515 + shmid = chk_error(shmget(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | 0777));
  516 + ptr = shmat(shmid, NULL, 0);
  517 + if (!ptr)
  518 + error("shmat");
  519 +
  520 + memset(ptr, 0, SHM_SIZE);
  521 +
  522 + chk_error(shmctl(shmid, IPC_RMID, 0));
  523 + chk_error(shmdt(ptr));
  524 +}
  525 +
500 526 int main(int argc, char **argv)
501 527 {
502 528 test_file();
503 529 test_fork();
504 530 test_time();
505 531 test_socket();
506   - test_clone();
  532 + // test_clone();
507 533 test_signal();
  534 + test_shm();
508 535 return 0;
509 536 }
... ...