From patchwork Fri Mar 11 08:43:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 8563131 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 19EC19F46A for ; Fri, 11 Mar 2016 08:43:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50E1A201DD for ; Fri, 11 Mar 2016 08:43:43 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6BACE2017E for ; Fri, 11 Mar 2016 08:43:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AECF11A1F76; Fri, 11 Mar 2016 00:43:57 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D25721A1F76 for ; Fri, 11 Mar 2016 00:43:56 -0800 (PST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9F610AC16; Fri, 11 Mar 2016 08:43:39 +0000 (UTC) From: Johannes Thumshirn To: Dan Williams Subject: [ndctl PATCH v2] ndctl: Grab kernel version from utsname() Date: Fri, 11 Mar 2016 09:43:30 +0100 Message-Id: <1457685810-4103-1-git-send-email-jthumshirn@suse.de> X-Mailer: git-send-email 2.7.2 Cc: linux-nvdimm@lists.01.org X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- test/core.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) Changes to v1: Use utsname.release which is obviously correct. On my test system utsname.release = "4.4.4-default" I can only imagine the sscanf() failing and on stack garbage in a, b, c being greater than KERNEL_VERSION(4, 3, 0). --- a/test/core.c +++ b/test/core.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -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.release, "%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;