From: Subrata <sub...@us...> - 2008-05-19 06:40:52
|
Update of /cvsroot/ltp/ltp/testcases/kernel/mem/shmt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15349/ltp/testcases/kernel/mem/shmt Modified Files: shmt06.c Log Message: Roy Lee <roy...@gm...> wrote: Your patch looks good to me. It does what I'm intended but failed to do; eliminating explicit arch-dependent code without breaking logics. How about merge the scenario of shm06 into shm04, and then eliminate shm06? Modify shm04 to attach the same segment _twice_ to the child's address space. In this case, the first returned address should be the same as where the parent attaches its segment to while the second returned address should be different. Helge Deller <de...@gm...> wrote: Yes, this is probably the best idea. Alternatively, just leave shm04 as-is, and do the twice-mapping you mentioned above in shm06. This way we'd keep two simple tests. Roy Lee <roy...@gm...> wrote back: Here's the patch for the shmt06 according to Helge's recommandation, please help review it. Index: shmt06.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/mem/shmt/shmt06.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** shmt06.c 15 May 2008 06:54:17 -0000 1.9 --- shmt06.c 19 May 2008 06:40:38 -0000 1.10 *************** *** 31,37 **** * Parent process forks a child. Child pauses until parent has created * a shared memory segment, attached to it and written to it too. At that ! * time child gets the shared memory segment id, attaches to it at a ! * different address than the parents and verifies that its contents are ! * the same as the contents of the parent attached segment. * */ --- 31,37 ---- * Parent process forks a child. Child pauses until parent has created * a shared memory segment, attached to it and written to it too. At that ! * time child gets the shared memory segment id, attaches to it at two ! * different addresses than the parents and verifies that their contents ! * are the same as the contents of the parent attached segment. * */ *************** *** 185,188 **** --- 185,213 ---- } + /* + * Attach the segment to a different addresse + * and verify it's contents again. + */ + cp = (char *)shmat(shmid, (void *)NULL, 0); + + if (cp == (char *)-1) { + perror("shmat:child process"); + tst_resm(TFAIL, + "Error: shmat: errno=%d, shmid=%d, child_pid=%d\n", + errno, shmid, chld_pid); + } else { + if (*cp != 'A') { + tst_resm(TFAIL, "child: not A\n"); + } + if (*(cp + 1) != 'B') { + tst_resm(TFAIL, "child: not B\n"); + } + if (*(cp + 2) != 'C') { + tst_resm(TFAIL, "child: not C\n"); + } + if (*(cp + 8192) != 0) { + tst_resm(TFAIL, "child: not 0\n"); + } + } } tst_exit(); |