write-boundary write-zero write-stdin write-bad-fd exec-once exec-arg \
exec-multiple exec-missing exec-bad-ptr wait-simple wait-twice \
wait-killed wait-bad-pid multi-recurse multi-child-fd rox-simple \
-rox-child rox-multichild)
+rox-child rox-multichild bad-read bad-write bad-read2 bad-write2 \
+bad-jump bad-jump2)
tests/userprog_PROGS = $(tests/userprog_TESTS) $(addprefix \
tests/userprog/,child-simple child-args child-bad child-close child-rox)
tests/userprog/args-dbl-space_SRC = tests/userprog/args.c
tests/userprog/sc-bad-sp_SRC = tests/userprog/sc-bad-sp.c tests/main.c
tests/userprog/sc-bad-arg_SRC = tests/userprog/sc-bad-arg.c tests/main.c
+tests/userprog/bad-read_SRC = tests/userprog/bad-read.c tests/main.c
+tests/userprog/bad-write_SRC = tests/userprog/bad-write.c tests/main.c
+tests/userprog/bad-jump_SRC = tests/userprog/bad-jump.c tests/main.c
+tests/userprog/bad-read2_SRC = tests/userprog/bad-read2.c tests/main.c
+tests/userprog/bad-write2_SRC = tests/userprog/bad-write2.c tests/main.c
+tests/userprog/bad-jump2_SRC = tests/userprog/bad-jump2.c tests/main.c
tests/userprog/sc-boundary_SRC = tests/userprog/sc-boundary.c \
tests/userprog/boundary.c tests/main.c
tests/userprog/sc-boundary-2_SRC = tests/userprog/sc-boundary-2.c \
5 wait-bad-pid
5 wait-killed
+- Test robustness of exception handling.
+1 bad-read
+1 bad-write
+1 bad-jump
+1 bad-read2
+1 bad-write2
+1 bad-jump2
--- /dev/null
+/* This program attempts to execute code at address 0, which is not mapped.
+ This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void)
+{
+ msg ("Congratulations - you have successfully called NULL: %d",
+ ((int (*)(void))NULL)());
+ fail ("should have exited with -1");
+}
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-jump) begin
+bad-jump: exit(-1)
+EOF
--- /dev/null
+/* This program attempts to execute code at a kernel virtual address.
+ This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void)
+{
+ msg ("Congratulations - you have successfully called kernel code: %d",
+ ((int (*)(void))0xC0000000)());
+ fail ("should have exited with -1");
+}
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-jump2) begin
+bad-jump2: exit(-1)
+EOF
--- /dev/null
+/* This program attempts to read memory at an address that is not mapped.
+ This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void)
+{
+ msg ("Congratulations - you have successfully dereferenced NULL: %d",
+ *(int *)NULL);
+ fail ("should have exited with -1");
+}
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-read) begin
+bad-read: exit(-1)
+EOF
--- /dev/null
+/* This program attempts to read kernel memory.
+ This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void)
+{
+ msg ("Congratulations - you have successfully read kernel memory: %d",
+ *(int *)0xC0000000);
+ fail ("should have exited with -1");
+}
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-read2) begin
+bad-read2: exit(-1)
+EOF
--- /dev/null
+/* This program attempts to write to memory at an address that is not mapped.
+ This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void)
+{
+ *(int *)NULL = 42;
+ fail ("should have exited with -1");
+}
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-write) begin
+bad-write: exit(-1)
+EOF
--- /dev/null
+/* This program attempts to write to kernel memory.
+ This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void)
+{
+ *(int *)0xC0000000 = 42;
+ fail ("should have exited with -1");
+}
--- /dev/null
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-write2) begin
+bad-write2: exit(-1)
+EOF