mirror of
https://github.com/drasko/codezero.git
synced 2026-09-28 00:00:21 +02: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:
+1
-1
@@ -135,7 +135,7 @@ void handle_fs_requests(void)
|
|||||||
|
|
||||||
void main(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();
|
initialise();
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ static inline int l4_open(const char *pathname, int flags, mode_t mode)
|
|||||||
}
|
}
|
||||||
/* Check if syscall itself was successful */
|
/* Check if syscall itself was successful */
|
||||||
if ((fd = l4_get_retval()) < 0) {
|
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;
|
||||||
}
|
}
|
||||||
return fd;
|
return fd;
|
||||||
|
|||||||
+1
-1
@@ -239,7 +239,7 @@ int self_spawn(void)
|
|||||||
|
|
||||||
void main(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 the memory, server tasks, mmap and start them. */
|
||||||
initialise();
|
initialise();
|
||||||
|
|||||||
@@ -3,13 +3,15 @@
|
|||||||
|
|
||||||
#define __TASKNAME__ "test0"
|
#define __TASKNAME__ "test0"
|
||||||
|
|
||||||
// #define TEST_VERBOSE_PRINT
|
//#define TEST_VERBOSE_PRINT
|
||||||
#if defined (TEST_VERBOSE_PRINT)
|
#if defined (TEST_VERBOSE_PRINT)
|
||||||
#define test_printf(...) printf(__VA_ARGS__)
|
#define test_printf(...) printf(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define test_printf(...)
|
#define test_printf(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
extern pid_t parent_of_all;
|
||||||
|
|
||||||
int shmtest(void);
|
int shmtest(void);
|
||||||
int forktest(void);
|
int forktest(void);
|
||||||
|
|||||||
+7
-5
@@ -24,22 +24,24 @@ void wait_pager(l4id_t partner)
|
|||||||
|
|
||||||
void main(void)
|
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);
|
wait_pager(0);
|
||||||
|
|
||||||
dirtest();
|
printf("%s: Running POSIX API tests.\n", __TASKNAME__);
|
||||||
|
|
||||||
// exectest();
|
dirtest();
|
||||||
|
|
||||||
mmaptest();
|
mmaptest();
|
||||||
|
|
||||||
fileio();
|
|
||||||
|
|
||||||
forktest();
|
forktest();
|
||||||
|
|
||||||
|
fileio();
|
||||||
|
|
||||||
clonetest();
|
clonetest();
|
||||||
|
|
||||||
|
// exectest();
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
wait_pager(0);
|
wait_pager(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
int clone_global = 0;
|
int clone_global = 0;
|
||||||
|
|
||||||
|
extern pid_t parent_of_all;
|
||||||
|
|
||||||
int my_thread_func(void *arg)
|
int my_thread_func(void *arg)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 25; i++)
|
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 */
|
/* 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;
|
return 0;
|
||||||
out_err:
|
out_err:
|
||||||
printf("CLONE TEST -- FAILED --\n");
|
printf("CLONE TEST -- FAILED --\n");
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ int fileio(void)
|
|||||||
goto out_err;
|
goto out_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("FILE IO TEST -- PASSED --\n");
|
if (getpid() == parent_of_all)
|
||||||
|
printf("FILE IO TEST -- PASSED --\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_err:
|
out_err:
|
||||||
|
|||||||
@@ -10,12 +10,13 @@
|
|||||||
|
|
||||||
int global = 0;
|
int global = 0;
|
||||||
|
|
||||||
static pid_t pid;
|
pid_t parent_of_all;
|
||||||
|
|
||||||
int forktest(void)
|
int forktest(void)
|
||||||
{
|
{
|
||||||
pid_t myid;
|
pid_t myid;
|
||||||
pid_t parent = getpid();
|
|
||||||
|
parent_of_all = getpid();
|
||||||
|
|
||||||
/* 16 forks */
|
/* 16 forks */
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
@@ -23,7 +24,7 @@ int forktest(void)
|
|||||||
goto out_err;
|
goto out_err;
|
||||||
|
|
||||||
myid = getpid();
|
myid = getpid();
|
||||||
pid = myid;
|
|
||||||
if (global != 0) {
|
if (global != 0) {
|
||||||
test_printf("Global not zero.\n");
|
test_printf("Global not zero.\n");
|
||||||
test_printf("-- FAILED --\n");
|
test_printf("-- FAILED --\n");
|
||||||
@@ -35,14 +36,15 @@ int forktest(void)
|
|||||||
goto out_err;
|
goto out_err;
|
||||||
|
|
||||||
|
|
||||||
if (getpid() != parent) {
|
if (getpid() != parent_of_all) {
|
||||||
/* Successful childs return here */
|
/* Exit here to exit successful children */
|
||||||
_exit(0);
|
//_exit(0);
|
||||||
BUG();
|
//BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parent of all comes here if successful */
|
if (getpid() == parent_of_all)
|
||||||
printf("FORK TEST -- PASSED --\n");
|
printf("FORK TEST -- PASSED --\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Any erroneous child or parent comes here */
|
/* Any erroneous child or parent comes here */
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ int mmaptest(void)
|
|||||||
void *base;
|
void *base;
|
||||||
int x = 0x1000;
|
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;
|
goto out_err;
|
||||||
|
|
||||||
/* Extend the file */
|
/* Extend the file */
|
||||||
|
|||||||
Reference in New Issue
Block a user