From patchwork Fri Jul 1 22:08:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9210543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CD95D60752 for ; Fri, 1 Jul 2016 22:09:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBABD28531 for ; Fri, 1 Jul 2016 22:09:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFF32286A4; Fri, 1 Jul 2016 22:09:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 5083028531 for ; Fri, 1 Jul 2016 22:09:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C50551A1DFB; Fri, 1 Jul 2016 15:10:13 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ml01.01.org (Postfix) with ESMTP id 770B91A1DFB for ; Fri, 1 Jul 2016 15:10:12 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 01 Jul 2016 15:09:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,559,1459839600"; d="scan'208";a="987341087" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.14]) by orsmga001.jf.intel.com with ESMTP; 01 Jul 2016 15:09:34 -0700 Subject: [ndctl PATCH] test: override current kernel version with environment variable From: Dan Williams To: linux-nvdimm@lists.01.org Date: Fri, 01 Jul 2016 15:08:53 -0700 Message-ID: <146741093296.25756.14218284344995187267.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP For backport kernels where the functionality is more advanced than the base kernel version implies, allow 'KVER' environment to override the results of 'uname -r'. Signed-off-by: Dan Williams Reviewed-by: Johannes Thumshirn --- test/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/core.c b/test/core.c index b5703273fa76..c2d225d4921e 100644 --- a/test/core.c +++ b/test/core.c @@ -14,12 +14,16 @@ struct ndctl_test { static unsigned int get_system_kver(void) { + const char *kver = getenv("KVER"); struct utsname utsname; int a, b, c; - uname(&utsname); + if (!kver) { + uname(&utsname); + kver = utsname.release; + } - if (sscanf(utsname.release, "%d.%d.%d", &a, &b, &c) != 3) + if (sscanf(kver, "%d.%d.%d", &a, &b, &c) != 3) return LINUX_VERSION_CODE; return KERNEL_VERSION(a,b,c);