Module: xenomai-head
Branch: master
Commit: dd64b743089c4ec842fac93b4d61edf9ef61d759
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=dd64b743089c4ec842fac93b4d61edf9ef61d759

Author: Wolfgang Mauerer <wolfgang.maue...@siemens.com>
Date:   Tue Dec 22 23:11:31 2009 +0100

    nucleus: Testcase for the xnvdso mechanism

    This testcase checks if the value in xnvdso->features matches the
    feature set specified on the command line. When no explicit
    feature test set is given, XNVDSO_FEATURES (i.e., the set
    of all features known to the current Xenomai revision) is used.

    Notice that the default approach will naturally fail once
    configurations are supported that know of multiple features and
    implement only some of them.

    Signed-off-by: Wolfgang Mauerer <wolfgang.maue...@siemens.com>
    Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 src/testsuite/unit/Makefile.am |   15 ++++++++++-
 src/testsuite/unit/runinfo.in  |    1 +
 src/testsuite/unit/xnvdso.c    |   52 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 1 deletions(-)

diff --git a/src/testsuite/unit/Makefile.am b/src/testsuite/unit/Makefile.am
index 24d077a..c77cc54 100644
--- a/src/testsuite/unit/Makefile.am
+++ b/src/testsuite/unit/Makefile.am
@@ -2,7 +2,8 @@ testdir = $(exec_prefix)/share/xenomai/testsuite/unit
 
 CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
 
-bin_PROGRAMS = arith wakeup-time mutex-torture-posix mutex-torture-native
+bin_PROGRAMS = arith wakeup-time mutex-torture-posix mutex-torture-native \
+               xnvdso
 
 arith_SOURCES = arith.c arith-noinline.c arith-noinline.h
 
@@ -53,6 +54,18 @@ mutex_torture_native_LDADD = \
        ../../skins/native/libnative.la \
        -lpthread -lm
 
+xnvdso_SOURCES = xnvdso.c
+
+xnvdso_CPPFLAGS = \
+       @XENO_USER_CFLAGS@ \
+       -I$(top_srcdir)/include
+
+xnvdso_LDFLAGS = @XENO_USER_LDFLAGS@
+
+xnvdso_LDADD = \
+       ../../skins/native/libnative.la \
+       -lpthread -lm
+
 install-data-local:
        $(mkinstalldirs) $(DESTDIR)$(testdir)
        @sed -e's,@exec_prefix\@,$(exec_prefix),g' $(srcdir)/runinfo.in > 
$(DESTDIR)$(testdir)/.runinfo
diff --git a/src/testsuite/unit/runinfo.in b/src/testsuite/unit/runinfo.in
index f4cd208..a22afc0 100644
--- a/src/testsuite/unit/runinfo.in
+++ b/src/testsuite/unit/runinfo.in
@@ -2,3 +2,4 @@ arith:native:!...@exec_prefix@/bin/arith;popall:control_c
 wakeup-time:native:!...@exec_prefix@/bin/wakeup-time;popall:control_c
 
mutex-torture-posix:posix:!...@exec_prefix@/bin/mutex-torture-posix;popall:control_c
 
mutex-torture-native:native:!...@exec_prefix@/bin/mutex-torture-native;popall:control_c
+xnvdso:native:!...@exec_prefix@/bin/xnvdso;popall:control_c
diff --git a/src/testsuite/unit/xnvdso.c b/src/testsuite/unit/xnvdso.c
new file mode 100644
index 0000000..69305c2
--- /dev/null
+++ b/src/testsuite/unit/xnvdso.c
@@ -0,0 +1,52 @@
+/*
+ * VDSO feature set testcase
+ * by Wolfgang Mauerer <wolfgang.maue...@siemens.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <asm/xenomai/syscall.h>
+#include <nucleus/xnvdso.h>
+
+extern unsigned long xeno_sem_heap[2];
+
+int main(int argc, char **argv)
+{
+       int err;
+       xnsysinfo_t sysinfo;
+       struct xnvdso *xnvdso;
+       unsigned long long test_features;
+
+       if (argc != 2) {
+               printf("No specific feature(s) given, using XNVDSO_FEATURE\n");
+               test_features = XNVDSO_FEATURES;
+       } else {
+               test_features = strtoull(argv[1], NULL, 0);
+       }
+
+       if (!xeno_sem_heap[1]) {
+               fprintf(stderr, "Could not determine position of the "
+                       "global semaphore heap\n");
+               return 1;
+       }
+
+       /* The muxid is irrelevant for this test as long as it's valid */
+       err = XENOMAI_SYSCALL2(__xn_sys_info, 1, &sysinfo);
+       if (err < 0) {
+               fprintf(stderr, "sys_sys_info failed: %d\n", err);
+               return 1;
+       }
+
+       printf("Address of the global semaphore heap: 0x%lx\n",
+              xeno_sem_heap[1]);
+       printf("Offset of xnvdso: %lu\n", sysinfo.xnvdso_off);
+
+       xnvdso = (struct xnvdso *)(xeno_sem_heap[1] + sysinfo.xnvdso_off);
+       printf("Contents of the features flag: %llu\n", xnvdso->features);
+
+       if (xnvdso->features == test_features)
+               return 0;
+
+       fprintf(stderr, "error: xnvdso->features != %llu\n", test_features);
+       return 1;
+}


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to