diff --git a/test/portability/Makefile b/test/portability/Makefile new file mode 100644 index 00000000..e3c3733a --- /dev/null +++ b/test/portability/Makefile @@ -0,0 +1,16 @@ +CC=gcc +MCEXEC=/home/satoken/ppos/bin/mcexec +TARGET=futex_wake_op unhandled_page_fault +all:: $(TARGET) + +futex_wake_op: futex_wake_op.c + $(CC) -o futex_wake_op -pthread $< + +unhandled_page_fualt: unhandled_page_fault.c + $(CC) -o unhandled_page_fault $< + +test:: $(TARGET) + -$(MCEXEC) ./futex_wake_op + -$(MCEXEC) ./unhandled_page_fault +clean:: + rm -f $(TARGET) diff --git a/test/portability/README b/test/portability/README new file mode 100644 index 00000000..f5637ac3 --- /dev/null +++ b/test/portability/README @@ -0,0 +1,6 @@ +# 本テストは、McKernel 基本機構の開発 V の +# 作業項目(4) カーネルのアーキテクチャに渡る可搬性向上 に関するテストである + +# 実行方法 + $ make test + diff --git a/test/portability/futex_wake_op.c b/test/portability/futex_wake_op.c new file mode 100644 index 00000000..7bf0171d --- /dev/null +++ b/test/portability/futex_wake_op.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int uaddr1 = 0; +int uaddr2 = 0; + +pid_t gettid() +{ + return syscall(SYS_gettid); +} + +static void * waker (void *ptr) +{ + int rc; + sleep(1); + + rc = syscall(SYS_futex, &uaddr1, FUTEX_WAKE_OP, 1, NULL, &uaddr2, FUTEX_OP(0, 0, 1, 0)); + + printf("futex_wake_op return:%d\n", rc); + pthread_exit(NULL); +} + +int main (void) +{ + int rc; + pthread_t thr; + + pthread_create(&thr, NULL, waker, NULL); + + rc = syscall(SYS_futex, &uaddr1, FUTEX_WAIT, uaddr1, NULL, NULL, 0); + + printf("futex_wait return:%d\n", rc); + + pthread_join(thr, NULL); + + printf("[OK] futex_wake_op_01 : succeed\n"); + + return 0; +} diff --git a/test/portability/unhandled_page_fault.c b/test/portability/unhandled_page_fault.c new file mode 100644 index 00000000..56ff5a07 --- /dev/null +++ b/test/portability/unhandled_page_fault.c @@ -0,0 +1,21 @@ +#include +#include +#include + +#define ARRAY_SIZE 10 + +void handler(int sig) { + printf("[OK] unhandled_page_fault_01: received SIGSEGV\n"); + exit(0); +} + + +int main(int argc, char** argv){ + int* test = NULL; + + signal(SIGSEGV, handler); + printf("try to access out of range!\n"); + *test = 99; + + return 0; +}