new: 增加ktest_start函数以开启内核自测试

This commit is contained in:
fslongjin
2022-07-29 17:40:55 +08:00
parent c1f51bf4cb
commit 7c9366b297
6 changed files with 33 additions and 5 deletions

View File

@ -2,7 +2,10 @@
CFLAGS += -I .
all: bitree.o kfifo.o
all: ktest.o bitree.o kfifo.o
ktest.o: ktest.c
gcc $(CFLAGS) -c ktest.c -o ktest.o
bitree.o: test-bitree.c
gcc $(CFLAGS) -c test-bitree.c -o test-bitree.o

14
kernel/ktest/ktest.c Normal file
View File

@ -0,0 +1,14 @@
#include "ktest.h"
#include <process/process.h>
/**
* @brief 开启一个新的内核线程以进行测试
*
* @param func 测试函数
* @param arg 传递给测试函数的参数
* @return pid_t 测试内核线程的pid
*/
pid_t ktest_start(uint64_t (*func)(uint64_t arg), uint64_t arg)
{
return kernel_thread(func, arg, 0);
}

View File

@ -2,4 +2,13 @@
#include <common/sys/types.h>
uint64_t ktest_test_bitree(uint64_t arg);
uint64_t ktest_test_kfifo(uint64_t arg);
uint64_t ktest_test_kfifo(uint64_t arg);
/**
* @brief 开启一个新的内核线程以进行测试
*
* @param func 测试函数
* @param arg 传递给测试函数的参数
* @return pid_t 测试内核线程的pid
*/
pid_t ktest_start(uint64_t (*func)(uint64_t arg), uint64_t arg);