Some more enhancements to test0

- Only the topmost parent prints pass messages. Any failed child can print fail message.
- Added testing of 16 forked threads doing file create/read/write/close and
  16 forked x 4 cloned = 64 threads spawning/exiting
This commit is contained in:
Bahadir Balban
2009-05-12 12:31:25 +03:00
parent 8528e2e1ba
commit 324481a334
9 changed files with 33 additions and 21 deletions

View File

@@ -11,6 +11,8 @@
int clone_global = 0;
extern pid_t parent_of_all;
int my_thread_func(void *arg)
{
for (int i = 0; i < 25; i++)
@@ -46,7 +48,9 @@ int clonetest(void)
/* TODO: Add wait() or something similar and check that global is 100 */
printf("CLONE TEST -- PASSED --\n");
if (getpid() == parent_of_all)
printf("CLONE TEST -- PASSED --\n");
return 0;
out_err:
printf("CLONE TEST -- FAILED --\n");

View File

@@ -61,7 +61,8 @@ int fileio(void)
goto out_err;
}
printf("FILE IO TEST -- PASSED --\n");
if (getpid() == parent_of_all)
printf("FILE IO TEST -- PASSED --\n");
return 0;
out_err:

View File

@@ -10,12 +10,13 @@
int global = 0;
static pid_t pid;
pid_t parent_of_all;
int forktest(void)
{
pid_t myid;
pid_t parent = getpid();
parent_of_all = getpid();
/* 16 forks */
for (int i = 0; i < 4; i++)
@@ -23,7 +24,7 @@ int forktest(void)
goto out_err;
myid = getpid();
pid = myid;
if (global != 0) {
test_printf("Global not zero.\n");
test_printf("-- FAILED --\n");
@@ -35,14 +36,15 @@ int forktest(void)
goto out_err;
if (getpid() != parent) {
/* Successful childs return here */
_exit(0);
BUG();
if (getpid() != parent_of_all) {
/* Exit here to exit successful children */
//_exit(0);
//BUG();
}
/* Parent of all comes here if successful */
printf("FORK TEST -- PASSED --\n");
if (getpid() == parent_of_all)
printf("FORK TEST -- PASSED --\n");
return 0;
/* Any erroneous child or parent comes here */

View File

@@ -23,7 +23,7 @@ int mmaptest(void)
void *base;
int x = 0x1000;
if ((fd = open("./newfile3.txt", O_CREAT | O_TRUNC | O_RDWR, S_IRWXU)) < 0)
if ((fd = open("./mmapfile.txt", O_CREAT | O_TRUNC | O_RDWR, S_IRWXU)) < 0)
goto out_err;
/* Extend the file */