diff --git a/SConstruct b/SConstruct index 1b9ecb5..9bedcce 100644 --- a/SConstruct +++ b/SConstruct @@ -163,6 +163,7 @@ SConscript('sys/SConscript', variant_dir='build/sys') SConscript('lib/libc/SConscript', variant_dir='build/lib/libc') SConscript('bin/shell/SConscript', variant_dir='build/bin/shell') SConscript('sbin/init/SConscript', variant_dir='build/sbin/init') +SConscript('tests/SConscript', variant_dir='build/tests') # Build Tools env["TOOLCHAINBUILD"] = "TRUE" @@ -184,6 +185,7 @@ if env["BOOTDISK"] == "1": Depends(bootdisk, "#build/bin/shell/shell") Depends(bootdisk, "#build/sbin/init/init") Depends(bootdisk, "#build/sys/castor") + Depends(bootdisk, "#build/tests/threadtest") env.Alias('bootdisk', '#build/bootdisk.img') env.Install('$PREFIX/','#build/bootdisk.img') diff --git a/release/bootdisk.manifest b/release/bootdisk.manifest index cb37d8b..97ea663 100644 --- a/release/bootdisk.manifest +++ b/release/bootdisk.manifest @@ -10,5 +10,8 @@ DIR / DIR sbin FILE init build/sbin/init/init END + DIR tests + FILE threadtest build/tests/threadtest + END FILE LICENSE LICENSE END diff --git a/tests/SConscript b/tests/SConscript new file mode 100644 index 0000000..a73c457 --- /dev/null +++ b/tests/SConscript @@ -0,0 +1,13 @@ +import sys + +Import('env') + +test_env = env.Clone() + +test_env.Append(LINKFLAGS = ['-nostdlib']) +test_env.Append(CPPFLAGS = ['-fno-builtin', '-nostdinc']) +test_env.Append(CPPPATH = ['#build/include']) +test_env.Append(LIBPATH = ['#build/lib/libc'], LIBS = ['c']) + +test_env.Program("threadtest", ["threadtest.c"]) + diff --git a/tests/threadtest.c b/tests/threadtest.c new file mode 100644 index 0000000..a552aac --- /dev/null +++ b/tests/threadtest.c @@ -0,0 +1,36 @@ + +#include +#include +#include +#include + +// Castor Only +#include + +void +threadEntry(uint64_t arg) +{ + printf("Hello From Thread %d\n", arg); + OSThreadExit(arg); +} + +int +main(int argc, const char *argv[]) +{ + char buf[256]; + + printf("Thread Test\n"); + OSThreadCreate((uintptr_t)&threadEntry, 2); + OSThreadCreate((uintptr_t)&threadEntry, 3); + OSThreadCreate((uintptr_t)&threadEntry, 4); + + int result = OSThreadWait(0); + printf("Result %d\n", result); + result = OSThreadWait(0); + printf("Result %d\n", result); + result = OSThreadWait(0); + printf("Result %d\n", result); + + printf("Success!\n"); +} +