aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/filst/sc-bad-nr-2.c
diff options
context:
space:
mode:
authorFilip Strömbäck <filip.stromback@liu.se>2020-03-18 12:28:10 +0100
committerFilip Strömbäck <filip.stromback@liu.se>2020-03-18 17:23:10 +0100
commit68c4eda1c24d56f3108648c5b1855664d7f0e8cc (patch)
tree773c77b9253ad7e6816aa0100236fd5e483da38b /src/tests/filst/sc-bad-nr-2.c
parent4be5b82aa9c40e428d5dc2149dae001627ab0146 (diff)
downloadpintos-rs-68c4eda1c24d56f3108648c5b1855664d7f0e8cc.tar.gz
Added new tests for the validating the syscall number.
Signed-off-by: Filip Strömbäck <filip.stromback@liu.se>
Diffstat (limited to 'src/tests/filst/sc-bad-nr-2.c')
-rw-r--r--src/tests/filst/sc-bad-nr-2.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/tests/filst/sc-bad-nr-2.c b/src/tests/filst/sc-bad-nr-2.c
new file mode 100644
index 0000000..35fc49e
--- /dev/null
+++ b/src/tests/filst/sc-bad-nr-2.c
@@ -0,0 +1,24 @@
+#include <syscall-nr.h>
+#include "tests/lib.h"
+#include "tests/main.h"
+
+// From "lib/user/syscall.c", but modified to push some zeros on the stack
+// first, to get a better output for the tests if the stack error message
+// remains.
+#define syscall0(NUMBER) \
+ ({ \
+ int retval; \
+ asm volatile \
+ ("pushl $0; pushl $0; pushl %[number]; int $0x30; addl $4, %%esp" \
+ : "=a" (retval) \
+ : [number] "i" (NUMBER) \
+ : "memory"); \
+ retval; \
+ })
+
+void test_main(void)
+{
+ // Call a syscall that is quite a bit larger than the maximum syscall number.
+ syscall0(1024 * 1024);
+ fail("Should have failed.");
+}