summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2011-06-17 13:15:52 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2011-06-17 13:24:39 -0500
commitb301c77be3ab2b9c097f2e3df47e96a907221ed9 (patch)
treeec39f064c115847aa0d93b1e14d7e4746294eefe /src/usr
parent609d6810b8bc92dc979f8bbb8e7e7d7b7b5d9490 (diff)
downloadtalos-hostboot-b301c77be3ab2b9c097f2e3df47e96a907221ed9.tar.gz
talos-hostboot-b301c77be3ab2b9c097f2e3df47e96a907221ed9.zip
Create testcore directory for kernel-level tests.
Change-Id: I4b6235edec59c0a97f53af431752d2f4dfabcfa9 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/151 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/makefile2
-rw-r--r--src/usr/testcore/lib/makefile6
-rw-r--r--src/usr/testcore/lib/synctest.H93
-rw-r--r--src/usr/testcore/makefile6
4 files changed, 106 insertions, 1 deletions
diff --git a/src/usr/makefile b/src/usr/makefile
index cd0daeba7..64c9dea42 100644
--- a/src/usr/makefile
+++ b/src/usr/makefile
@@ -1,6 +1,6 @@
ROOTPATH = ../..
OBJS = module_init.o
-SUBDIRS = example.d trace.d cxxtest.d errl.d devicefw.d
+SUBDIRS = example.d trace.d cxxtest.d testcore.d errl.d devicefw.d
include ${ROOTPATH}/config.mk
diff --git a/src/usr/testcore/lib/makefile b/src/usr/testcore/lib/makefile
new file mode 100644
index 000000000..b3d28a89c
--- /dev/null
+++ b/src/usr/testcore/lib/makefile
@@ -0,0 +1,6 @@
+ROOTPATH = ../../../..
+
+MODULE = testsyslib
+TESTS = *.H
+
+include ${ROOTPATH}/config.mk
diff --git a/src/usr/testcore/lib/synctest.H b/src/usr/testcore/lib/synctest.H
new file mode 100644
index 000000000..5a53d2e0a
--- /dev/null
+++ b/src/usr/testcore/lib/synctest.H
@@ -0,0 +1,93 @@
+#ifndef __SYNCTEST_H
+#define __SYNCTEST_H
+/**
+ * @file synctest.H
+ *
+ * @brief Test cases for the sycronization
+*/
+
+#include <cxxtest/TestSuite.H>
+#include <sys/sync.h>
+#include <sys/task.h>
+
+class SyncTest: public CxxTest::TestSuite
+{
+ public:
+
+
+ void testMutex()
+ {
+ mutex_init(&mutex);
+ barrier_init(&barrier, 7);
+
+ task_create(func1, this);
+ task_create(func2, this);
+ task_create(func2, this);
+ task_create(func2, this);
+ task_create(func2, this);
+ task_create(func2, this);
+ barrier_wait(&barrier);
+ TS_TRACE("ALL THREADS ENDED");
+ }
+
+ void testBarrier()
+ {
+ barrier_t barrier;
+ barrier_init(&barrier,3);
+ task_create(func3,&barrier);
+ task_create(func4,&barrier);
+ barrier_wait(&barrier);
+ TS_TRACE("B0");
+ barrier_destroy(&barrier);
+ }
+
+ private:
+
+ mutex_t mutex;
+ barrier_t barrier;
+
+ static void func1(void * i_p)
+ {
+ SyncTest * my = (SyncTest *) i_p;
+ mutex_t * mutex = &(my->mutex);
+ barrier_t * barrier = &(my->barrier);
+
+ mutex_lock(mutex);
+ for(int i = 0; i < 100000; ++i);
+ TS_TRACE("ME FIRST");
+ mutex_unlock(mutex);
+ barrier_wait(barrier);
+ task_end();
+ }
+
+ static void func2(void * i_p)
+ {
+ SyncTest * my = (SyncTest *) i_p;
+ mutex_t * mutex = &(my->mutex);
+ barrier_t * barrier = &(my->barrier);
+
+ mutex_lock(mutex);
+ TS_TRACE("ME NEXT");
+ mutex_unlock(mutex);
+ barrier_wait(barrier);
+ task_end();
+ }
+
+ static void func3(void * i_p)
+ {
+ barrier_t * barrier = (barrier_t *) i_p;
+ barrier_wait(barrier);
+ TS_TRACE("B1");
+ task_end();
+ }
+ static void func4(void * i_p)
+ {
+ barrier_t * barrier = (barrier_t *) i_p;
+ barrier_wait(barrier);
+ TS_TRACE("B2");
+ task_end();
+ }
+
+};
+#endif
+
diff --git a/src/usr/testcore/makefile b/src/usr/testcore/makefile
new file mode 100644
index 000000000..1f4881373
--- /dev/null
+++ b/src/usr/testcore/makefile
@@ -0,0 +1,6 @@
+ROOTPATH = ../../..
+
+SUBDIRS = lib.d
+
+include ${ROOTPATH}/config.mk
+
OpenPOWER on IntegriCloud