Added more userprog tests, mostly relating to boundary conditions
[pintos-anon] / src / tests / userprog / exec-bound-2.c
diff --git a/src/tests/userprog/exec-bound-2.c b/src/tests/userprog/exec-bound-2.c
new file mode 100644 (file)
index 0000000..7ebed61
--- /dev/null
@@ -0,0 +1,20 @@
+/* Invokes an exec system call with the exec string pointer argument
+   positioned such that only its first byte is valid  memory (bytes 1-3
+   of the pointer are invalid).  Must kill process. */
+
+#include <syscall-nr.h>
+#include "tests/userprog/boundary.h"
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void) 
+{
+  char *p = get_bad_boundary () - 5;
+  *((int *) p) = SYS_EXEC;
+  p[4] = '!';
+
+  /* Invoke the system call. */
+  asm volatile ("movl %0, %%esp; int $0x30" : : "g" (p));
+  fail ("should have killed process");
+}