All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Thumshirn <jthumshirn@suse.de>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: [ndctl PATCH] ndctl: Grab kernel version from utsname()
Date: Thu, 10 Mar 2016 15:28:09 +0100	[thread overview]
Message-ID: <1457620089-28984-1-git-send-email-jthumshirn@suse.de> (raw)

Grab the kernel version used for tests dynamically via utsname() instead of
hardcoding the version of the build host.

Otherwise tests will be skipped if the build host had a too old kernel
version.

flodin:~ # ./ndctl test
__ndctl_test_attempt: skip test_libndctl:1950 requires: 4.2.0 current: 4.1.0
test-libndctl: SKIP
__ndctl_test_attempt: skip test_dpa_alloc:300 requires: 4.2.0 current: 4.1.0
test-dpa-alloc: SKIP
__ndctl_test_attempt: skip test_parent_uuid:230 requires: 4.3.0 current: 4.1.0
test-parent-uuid: SKIP
attempted: 3 skipped: 3

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 test/core.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

--- a/test/core.c
+++ b/test/core.c
@@ -1,4 +1,5 @@
 #include <linux/version.h>
+#include <sys/utsname.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <test.h>
@@ -11,6 +12,18 @@ struct ndctl_test {
 	int skip;
 };
 
+static unsigned int get_system_kver(void)
+{
+	struct utsname utsname;
+	int a, b, c;
+
+	uname(&utsname);
+
+	sscanf(utsname.version, "%d.%d.%d", &a, &b, &c);
+
+	return KERNEL_VERSION(a,b,c);
+}
+
 struct ndctl_test *ndctl_test_new(unsigned int kver)
 {
 	struct ndctl_test *test = calloc(1, sizeof(*test));
@@ -19,7 +32,7 @@ struct ndctl_test *ndctl_test_new(unsign
 		return NULL;
 
 	if (!kver)
-		test->kver = LINUX_VERSION_CODE;
+		test->kver = get_system_kver();
 	else
 		test->kver = kver;
 
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

             reply	other threads:[~2016-03-10 14:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-10 14:28 Johannes Thumshirn [this message]
2016-03-10 18:57 ` [ndctl PATCH] ndctl: Grab kernel version from utsname() Dan Williams
2016-03-11  8:05   ` Johannes Thumshirn

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=1457620089-28984-1-git-send-email-jthumshirn@suse.de \
    --to=jthumshirn@suse.de \
    --cc=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.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.