break up spawntest into seperate tests

This commit is contained in:
Emil Tsalapatis 2023-10-02 18:16:15 -04:00
parent 21a30db5d3
commit 79016dc2b3
6 changed files with 77 additions and 16 deletions

View File

@ -215,7 +215,9 @@ if env["BOOTDISK"] == "1":
Depends(bootdisk, "#build/sys/castor") Depends(bootdisk, "#build/sys/castor")
#Depends(bootdisk, "#build/tests/lwiptest") #Depends(bootdisk, "#build/tests/lwiptest")
Depends(bootdisk, "#build/tests/pthreadtest") Depends(bootdisk, "#build/tests/pthreadtest")
Depends(bootdisk, "#build/tests/spawntest") Depends(bootdisk, "#build/tests/spawnanytest")
Depends(bootdisk, "#build/tests/spawnmultipletest")
Depends(bootdisk, "#build/tests/spawnsingletest")
Depends(bootdisk, "#build/tests/threadtest") Depends(bootdisk, "#build/tests/threadtest")
env.Alias('bootdisk', '#build/bootdisk.img') env.Alias('bootdisk', '#build/bootdisk.img')
env.Install('$PREFIX/','#build/bootdisk.img') env.Install('$PREFIX/','#build/bootdisk.img')

View File

@ -20,7 +20,9 @@ DIR /
END END
DIR tests DIR tests
FILE pthreadtest build/tests/pthreadtest FILE pthreadtest build/tests/pthreadtest
FILE spawntest build/tests/spawntest FILE spawnsingletest build/tests/spawnsingletest
FILE spawnmultipletest build/tests/spawnmultipletest
FILE spawnanytest build/tests/spawnanytest
FILE threadtest build/tests/threadtest FILE threadtest build/tests/threadtest
END END
FILE LICENSE LICENSE FILE LICENSE LICENSE

View File

@ -15,11 +15,23 @@ threadtest_src.append(["threadtest.c"])
threadtest_src.append(env["CRTEND"]) threadtest_src.append(env["CRTEND"])
test_env.Program("threadtest", threadtest_src) test_env.Program("threadtest", threadtest_src)
spawntest_src = [] spawnanytest_src = []
spawntest_src.append(env["CRTBEGIN"]) spawnanytest_src.append(env["CRTBEGIN"])
spawntest_src.append(["spawntest.c"]) spawnanytest_src.append(["spawnanytest.c"])
spawntest_src.append(env["CRTEND"]) spawnanytest_src.append(env["CRTEND"])
test_env.Program("spawntest", spawntest_src) test_env.Program("spawnanytest", spawnanytest_src)
spawnmultipletest_src = []
spawnmultipletest_src.append(env["CRTBEGIN"])
spawnmultipletest_src.append(["spawnmultipletest.c"])
spawnmultipletest_src.append(env["CRTEND"])
test_env.Program("spawnmultipletest", spawnmultipletest_src)
spawnsingletest_src = []
spawnsingletest_src.append(env["CRTBEGIN"])
spawnsingletest_src.append(["spawnsingletest.c"])
spawnsingletest_src.append(env["CRTEND"])
test_env.Program("spawnsingletest", spawnsingletest_src)
pthreadtest_src = [] pthreadtest_src = []
pthreadtest_src.append(env["CRTBEGIN"]) pthreadtest_src.append(env["CRTBEGIN"])

View File

@ -12,15 +12,6 @@ main(int argc, const char *argv[])
{ {
int status[10]; int status[10];
printf("Spawn test: ");
for (int i = 0; i < 100; i++) {
status[0] = OSSpawn("/bin/echo", &argv[0]);
printf("spawn: %lx\n", status[0]);
status[0] = OSWait(status[0]);
printf("wait: %lx\n", status[0]);
}
printf("Success!\n");
printf("Spawn parallel test wait any: "); printf("Spawn parallel test wait any: ");
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
status[i] = OSSpawn("/bin/echo", &argv[0]); status[i] = OSSpawn("/bin/echo", &argv[0]);

28
tests/spawnmultipletest.c Normal file
View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// Castor Only
#include <syscall.h>
int
main(int argc, const char *argv[])
{
int status[10];
printf("Spawn parallel test wait any: ");
for (int i = 0; i < 10; i++) {
status[i] = OSSpawn("/bin/echo", &argv[0]);
printf("spawn: %lx\n", status[i]);
}
for (int i = 0; i < 10; i++) {
status[i] = OSWait(status[i]);
printf("wait: %lx\n", status[i]);
}
printf("Success!\n");
return 0;
}

26
tests/spawnsingletest.c Normal file
View File

@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// Castor Only
#include <syscall.h>
int
main(int argc, const char *argv[])
{
int status[10];
printf("Spawn test: ");
for (int i = 0; i < 100; i++) {
status[0] = OSSpawn("/bin/echo", &argv[0]);
printf("spawn: %lx\n", status[0]);
status[0] = OSWait(status[0]);
printf("wait: %lx\n", status[0]);
}
printf("Success!\n");
return 0;
}