diff options
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/testcore/kernel/slbtest.H | 19 | ||||
-rw-r--r-- | src/usr/testcore/kernel/vmmbasetest.H | 97 |
2 files changed, 97 insertions, 19 deletions
diff --git a/src/usr/testcore/kernel/slbtest.H b/src/usr/testcore/kernel/slbtest.H index 8784458d0..f773efe2d 100644 --- a/src/usr/testcore/kernel/slbtest.H +++ b/src/usr/testcore/kernel/slbtest.H @@ -26,15 +26,6 @@ class slbtest: public CxxTest::TestSuite { TS_FAIL("Data Segment exception expected in 1TB segment\n"); } - - rc = 0; - task_create(writeEA2TB, this); - while (rc == 0) task_yield(); - task_yield(); - if (rc == -1) - { - TS_FAIL("Data Storage exception expected in 2TB segment\n"); - } } private: @@ -48,16 +39,6 @@ class slbtest: public CxxTest::TestSuite rc = -1; task_end(); } - - static void writeEA2TB(void *i_p) - { - rc = 1; - sync(); - *(int *)0x20000000000 = 1; - sync(); - rc = -1; - task_end(); - } }; volatile int slbtest::rc = 0; 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 |