From patchwork Thu Mar 10 14:28:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 8557481 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 13EECC0553 for ; Thu, 10 Mar 2016 14:28:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0BA7C20123 for ; Thu, 10 Mar 2016 14:28:20 +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 ED8692011D for ; Thu, 10 Mar 2016 14:28:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A4C851A1ED6; Thu, 10 Mar 2016 06:28:33 -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 4BFFB1A1ED6 for ; Thu, 10 Mar 2016 06:28:32 -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 F20CAAD8A; Thu, 10 Mar 2016 14:28:14 +0000 (UTC) From: Johannes Thumshirn To: Dan Williams Subject: [ndctl PATCH] ndctl: Grab kernel version from utsname() Date: Thu, 10 Mar 2016 15:28:09 +0100 Message-Id: <1457620089-28984-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(-) --- 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.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;