Module: xenomai-forge
Branch: next
Commit: e885fec06cd66e317955283da79da1cb746abde9
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=e885fec06cd66e317955283da79da1cb746abde9

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Apr 23 13:01:34 2014 +0200

alchemy/testsuite: check for rt_task_unblock()

---

 lib/alchemy/testsuite/Makefile |    1 +
 lib/alchemy/testsuite/task-9.c |   70 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/lib/alchemy/testsuite/Makefile b/lib/alchemy/testsuite/Makefile
index 950a2aa..04a299d 100644
--- a/lib/alchemy/testsuite/Makefile
+++ b/lib/alchemy/testsuite/Makefile
@@ -20,6 +20,7 @@ TESTS :=      \
        task-6  \
        task-7  \
        task-8  \
+       task-9  \
        mq-1    \
        mq-2    \
        mq-3    \
diff --git a/lib/alchemy/testsuite/task-9.c b/lib/alchemy/testsuite/task-9.c
new file mode 100644
index 0000000..168afbb
--- /dev/null
+++ b/lib/alchemy/testsuite/task-9.c
@@ -0,0 +1,70 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <copperplate/traceobj.h>
+#include <alchemy/task.h>
+
+static struct traceobj trobj;
+
+static RT_TASK t_test;
+
+#define ONE_SECOND  1000000000ULL
+
+void sighandler(int sig)
+{
+       /* nop */
+}
+
+static void test_task(void *arg)
+{
+       int ret;
+
+       traceobj_enter(&trobj);
+
+       ret = rt_task_sleep_until(TM_INFINITE);
+       traceobj_assert(&trobj, ret == -EINTR);
+
+       traceobj_exit(&trobj);
+}
+
+int main(int argc, char *const argv[])
+{
+       struct sigaction sa;
+       RT_TASK_INFO info;
+       sigset_t set;
+       int ret;
+
+       memset(&sa, 0, sizeof(sa));
+       sa.sa_handler = sighandler;
+       sigaction(SIGUSR1, &sa, NULL);
+
+       traceobj_init(&trobj, argv[0], 0);
+
+       ret = rt_task_create(&t_test, "test_task", 0, 10, 0);
+       traceobj_assert(&trobj, ret == 0);
+
+       ret = rt_task_inquire(&t_test, &info);
+       traceobj_assert(&trobj, ret == 0);
+
+       sigemptyset(&set);
+       sigaddset(&set, SIGUSR1);
+       pthread_sigmask(SIG_BLOCK, &set, NULL);
+
+       ret = rt_task_start(&t_test, test_task, NULL);
+       traceobj_assert(&trobj, ret == 0);
+
+       ret = rt_task_sleep(ONE_SECOND);
+       traceobj_assert(&trobj, ret == 0);
+
+       ret = __STD(kill(info.pid, SIGUSR1));
+       traceobj_assert(&trobj, ret == 0);
+
+       ret = rt_task_sleep(ONE_SECOND);
+       traceobj_assert(&trobj, ret == 0);
+       ret = rt_task_unblock(&t_test);
+       traceobj_assert(&trobj, ret == 0);
+
+       traceobj_join(&trobj);
+
+       exit(0);
+}


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to