diff options
author | dzwdz | 2022-08-29 17:44:19 +0200 |
---|---|---|
committer | dzwdz | 2022-08-29 17:44:19 +0200 |
commit | eb22cd070c4d255b1069aae5b331845de2ed1b94 (patch) | |
tree | adb97869a9e6a0853527ddd5aceaedf4a1ae17eb /src/user/app/tests/libc/setjmp.c | |
parent | 4ae57a7fb13e68c5e6f1c1246a867555dbd986db (diff) |
user/libc: setjmp
Diffstat (limited to 'src/user/app/tests/libc/setjmp.c')
-rw-r--r-- | src/user/app/tests/libc/setjmp.c | 31 |
1 files changed, 31 insertions, 0 deletions
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 <stdbool.h> +#include <setjmp.h> + +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); +} |