From eb22cd070c4d255b1069aae5b331845de2ed1b94 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 29 Aug 2022 17:44:19 +0200 Subject: user/libc: setjmp --- src/user/app/tests/libc/setjmp.c | 31 +++++++++++++++++++++++++++++++ src/user/app/tests/tests.c | 1 + src/user/app/tests/tests.h | 1 + 3 files changed, 33 insertions(+) create mode 100644 src/user/app/tests/libc/setjmp.c (limited to 'src/user/app') diff --git a/src/user/app/tests/libc/setjmp.c b/src/user/app/tests/libc/setjmp.c new file mode 100644 index 0000000..0dded9d --- /dev/null +++ b/src/user/app/tests/libc/setjmp.c @@ -0,0 +1,31 @@ +#include "../tests.h" +#include +#include + +static void test_setjmp(void) { + jmp_buf env; + volatile bool inner; + int val; + inner = false; + if (!(val = setjmp(env))) { + inner = true; + longjmp(env, 1234); + test(0); + } else { + test(val == 1234); + test(inner); + } + inner = false; + if (!(val = setjmp(env))) { + inner = true; + longjmp(env, 0); + test(0); + } else { + test(val == 1); + test(inner); + } +} + +void r_libc_setjmp(void) { + run_test(test_setjmp); +} diff --git a/src/user/app/tests/tests.c b/src/user/app/tests/tests.c index f9b085a..8cdf79f 100644 --- a/src/user/app/tests/tests.c +++ b/src/user/app/tests/tests.c @@ -19,6 +19,7 @@ int main(void) { r_k_path(); r_k_threads(); r_libc_esemaphore(); + r_libc_setjmp(); r_libc_string(); r_s_printf(); r_s_ringbuf(); diff --git a/src/user/app/tests/tests.h b/src/user/app/tests/tests.h index b47e9b9..63dd940 100644 --- a/src/user/app/tests/tests.h +++ b/src/user/app/tests/tests.h @@ -13,6 +13,7 @@ void r_k_miscsyscall(void); void r_k_path(void); void r_k_threads(void); void r_libc_esemaphore(void); +void r_libc_setjmp(void); void r_libc_string(void); void r_s_printf(void); void r_s_ringbuf(void); -- cgit v1.2.3