summaryrefslogtreecommitdiffstats
path: root/src/usr/testcore/kernel/vmmbasetest.H
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/testcore/kernel/vmmbasetest.H')
-rw-r--r--src/usr/testcore/kernel/vmmbasetest.H97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/usr/testcore/kernel/vmmbasetest.H b/src/usr/testcore/kernel/vmmbasetest.H
new file mode 100644
index 000000000..df9d320a4
--- /dev/null
+++ b/src/usr/testcore/kernel/vmmbasetest.H
@@ -0,0 +1,97 @@
+/** @file vmmbasetest.H
+ * @brief Test cases for permission settings on the base block of the VMM.
+ */
+#ifndef __KERNEL_VMMBASETEST_H
+#define __KERNEL_VMMBASETEST_H
+
+#include <cxxtest/TestSuite.H>
+#include <sys/task.h>
+#include <kernel/console.H>
+#include <arch/ppc.H>
+
+class VmmBaseTest : public CxxTest::TestSuite
+{
+ public:
+ static volatile int rc;
+
+ void testNullAccess()
+ {
+ rc = 0; sync();
+ printk("Test case: Expect to see uncaught exception! ");
+ task_create(readFromNULL, NULL);
+ while (rc == 0) task_yield();
+ task_yield();
+ if (rc == -1)
+ {
+ TS_FAIL("Write to NULL not caught.");
+ }
+
+ rc = 0; sync();
+ printk("Test case: Expect to see uncaught exception! ");
+ task_create(writeToNULL, NULL);
+ while (rc == 0) task_yield();
+ task_yield();
+ if (rc == -1)
+ {
+ TS_FAIL("Write to NULL not caught.");
+ }
+ }
+
+ void testWriteToKernelCode()
+ {
+ rc = 0; sync();
+ printk("Test case: Expect to see uncaught exception! ");
+ task_create(writeToKernelCode, NULL);
+ while (rc == 0) task_yield();
+ task_yield();
+ if (rc == -1)
+ {
+ TS_FAIL("Write to kernel code not caught.");
+ }
+ }
+
+ void testExecuteKernelDataSpace()
+ {
+ // @TODO. VMM not ready.
+ }
+
+ void testWriteModuleText()
+ {
+ // @TODO. VMM not ready.
+ }
+
+ void testExecuteModuleDataSpace()
+ {
+ // @TODO. VMM not ready.
+ }
+
+ private:
+
+ static void readFromNULL(void* unused)
+ {
+ rc = 1; sync();
+ printk("%lx", (*(uint64_t*)NULL)); sync();
+ rc = -1; sync();
+ task_end();
+ }
+
+ static void writeToNULL(void* unused)
+ {
+ rc = 1; sync();
+ (*(uint64_t*)NULL) = 0x12345678; sync();
+ rc = -1; sync();
+ task_end();
+ }
+
+ static void writeToKernelCode(void* unused)
+ {
+ rc = 1; sync();
+ (*(*(uint64_t**)&printk)) = 0x12345678; sync();
+ rc = -1; sync();
+ task_end();
+ }
+
+};
+volatile int VmmBaseTest::rc = 0;
+
+#endif
OpenPOWER on IntegriCloud