mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 02:43:15 +01:00
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:
@@ -135,7 +135,7 @@ void handle_fs_requests(void)
|
||||
|
||||
void main(void)
|
||||
{
|
||||
printf("\n%s: Started with thread id: %d\n", __TASKNAME__, self_tid());
|
||||
printf("\n%s: Started with thread id %d\n", __TASKNAME__, self_tid());
|
||||
|
||||
initialise();
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ static inline int l4_open(const char *pathname, int flags, mode_t mode)
|
||||
}
|
||||
/* Check if syscall itself was successful */
|
||||
if ((fd = l4_get_retval()) < 0) {
|
||||
printf("%s: OPEN Error: %d.\n", __FUNCTION__, fd);
|
||||
printf("%s: OPEN Error: %d, for path %s\n",
|
||||
__FUNCTION__, fd, pathname);
|
||||
return fd;
|
||||
}
|
||||
return fd;
|
||||
|
||||
@@ -239,7 +239,7 @@ int self_spawn(void)
|
||||
|
||||
void main(void)
|
||||
{
|
||||
printf("\n%s: Started with thread id: %d\n", __TASKNAME__, self_tid());
|
||||
printf("\n%s: Started with thread id %d\n", __TASKNAME__, self_tid());
|
||||
|
||||
/* Initialise the memory, server tasks, mmap and start them. */
|
||||
initialise();
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
|
||||
#define __TASKNAME__ "test0"
|
||||
|
||||
// #define TEST_VERBOSE_PRINT
|
||||
//#define TEST_VERBOSE_PRINT
|
||||
#if defined (TEST_VERBOSE_PRINT)
|
||||
#define test_printf(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define test_printf(...)
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
extern pid_t parent_of_all;
|
||||
|
||||
int shmtest(void);
|
||||
int forktest(void);
|
||||
|
||||
@@ -24,22 +24,24 @@ void wait_pager(l4id_t partner)
|
||||
|
||||
void main(void)
|
||||
{
|
||||
printf("\n%s: Started with tid %d.\n", __TASKNAME__, self_tid());
|
||||
printf("\n%s: Started with thread id %d\n", __TASKNAME__, self_tid());
|
||||
|
||||
wait_pager(0);
|
||||
|
||||
dirtest();
|
||||
printf("%s: Running POSIX API tests.\n", __TASKNAME__);
|
||||
|
||||
// exectest();
|
||||
dirtest();
|
||||
|
||||
mmaptest();
|
||||
|
||||
fileio();
|
||||
|
||||
forktest();
|
||||
|
||||
fileio();
|
||||
|
||||
clonetest();
|
||||
|
||||
// exectest();
|
||||
|
||||
while (1)
|
||||
wait_pager(0);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user