feat(userspace/apps/test/utest): add TestProcess function for executing test programs

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
EnderIce2 2025-02-21 02:58:30 +02:00
parent e003af38ff
commit 4d333f94bc
No known key found for this signature in database
GPG Key ID: 2EE20AF089811A5A
3 changed files with 43 additions and 5 deletions

View File

@ -15,7 +15,8 @@
"userspace/libc",
"userspace/libs/libdemo",
"vscode",
"userspace/apps/sys/init"
"userspace/apps/sys/init",
"userspace/apps/test/utest"
]
}
}

View File

@ -0,0 +1,4 @@
int fb_main()
{
return 0;
}

View File

@ -860,15 +860,48 @@ void fork_bomb_syscall()
#endif
}
void TestProcess(const char *program, char *const argv[])
{
printf("testing: %s\n", program);
pid_t pid = fork();
if (pid == 0)
{
execvp(program, argv);
perror("execvp");
}
else if (pid < 0)
perror("fork");
fflush(stderr);
}
extern int simd_main();
extern int web_main();
extern int fb_main();
int main(int argc, char *argv[], char *envp[])
{
if (argv[1] != NULL && strcmp(argv[1], "loop") == 0)
if (argv[1] != NULL)
{
if (strcmp(argv[1], "loop") == 0)
{
printf("[%d] Looping...\n", getpid());
while (1)
;
}
if (strcmp(argv[1], "--kernel") == 0)
{
printf("- Starting full tests...\n");
TestProcess("/bin/libc_test", NULL);
printf("- test: simd");
simd_main();
printf("- test: web");
web_main();
printf("- test: framebuffer");
fb_main();
}
}
printf("- Testing userspace...\n");
// printf("Press RETURN to start tests...\n");