All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Mauerer <wolfgang.mauerer@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: "Kiszka, Jan" <jan.kiszka@domain.hid>,
	"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] [PATCH 2/2] Testcase for the xnvdso mechanism
Date: Wed, 23 Dec 2009 11:03:07 +0100	[thread overview]
Message-ID: <4B31EADB.8040305@domain.hid> (raw)
In-Reply-To: <4B31E503.8030208@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

Gilles Chanteperdrix wrote:
> Wolfgang Mauerer wrote:
>> This testcase checks if the value in xnvdso->features matches the
>> value of XNVDSO_FEATURES, that is, if the information is correctly
>> transferred from kernel to userland.
>>
>> Notice that the approach will fail once configurations are supported
>> that know of multiple features and implement only some of them.
>> In this case, the testcase needs to be extended accordingly
>> to check that only the expected features are present.
> 
> Please allow to pass the value we want to check on the test command line.

here you go. I suppose keeping XNVDSO_FEATURES as default value
unless something different is specified is okay?

Cheers,

Wolfgang

[-- Attachment #2: testcase.diff --]
[-- Type: text/x-patch, Size: 3701 bytes --]

commit 0f31dc5c50f7034dddbac67c22e53823f1be72d3
Author: Wolfgang Mauerer <wolfgang.mauerer@domain.hid>
Date:   Tue Dec 22 23:11:31 2009 +0100

    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.mauerer@domain.hid>
    Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>

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@domain.hid
 wakeup-time:native:!@exec_prefix@domain.hid
 mutex-torture-posix:posix:!@exec_prefix@domain.hid
 mutex-torture-native:native:!@exec_prefix@domain.hid
+xnvdso:native:!@exec_prefix@domain.hid
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.mauerer@domain.hid>
+ */
+
+#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;
+}

  reply	other threads:[~2009-12-23 10:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-23  9:25 [Xenomai-core] [PATCH 0/2] xnvdso mechanism and unit test Wolfgang Mauerer
2009-12-23  9:25 ` [Xenomai-core] [PATCH 1/2] Add support for sharing kernel/userland data between Xenomai and Linux Wolfgang Mauerer
2009-12-23  9:25 ` [Xenomai-core] [PATCH 2/2] Testcase for the xnvdso mechanism Wolfgang Mauerer
2009-12-23  9:38   ` Gilles Chanteperdrix
2009-12-23 10:03     ` Wolfgang Mauerer [this message]
2009-12-23 10:05       ` Gilles Chanteperdrix
2009-12-28 14:40         ` Gilles Chanteperdrix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B31EADB.8040305@domain.hid \
    --to=wolfgang.mauerer@domain.hid \
    --cc=gilles.chanteperdrix@xenomai.org \
    --cc=jan.kiszka@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.