From patchwork Fri Dec 15 23:24:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 10116737 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 3A6F760224 for ; Fri, 15 Dec 2017 23:24:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D3772A1B3 for ; Fri, 15 Dec 2017 23:24:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 222252A1C6; Fri, 15 Dec 2017 23:24:24 +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 C4B7F2A1B3 for ; Fri, 15 Dec 2017 23:24:23 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1163E22119BFB; Fri, 15 Dec 2017 15:19:41 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=dave.jiang@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B632722119BCA for ; Fri, 15 Dec 2017 15:19:39 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Dec 2017 15:24:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,407,1508828400"; d="scan'208";a="3188346" Received: from djiang5-desk3.ch.intel.com ([143.182.136.93]) by orsmga008.jf.intel.com with ESMTP; 15 Dec 2017 15:24:21 -0800 Subject: [PATCH v3 4/4] ndctl, test: firmware update unit test From: Dave Jiang To: dan.j.williams@intel.com Date: Fri, 15 Dec 2017 16:24:21 -0700 Message-ID: <151338026169.4485.17535956960021474462.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <151338007905.4485.4189717376304274611.stgit@djiang5-desk3.ch.intel.com> References: <151338007905.4485.4189717376304274611.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Adding a unit test that will use nfit_test kernel module to test the firmware update sequence. Signed-off-by: Dave Jiang --- ndctl/update.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ndctl/update.c b/ndctl/update.c index 8d33b6a..a9400d6 100644 --- a/ndctl/update.c +++ b/ndctl/update.c @@ -73,8 +73,6 @@ struct fw_info { uint32_t update_size; uint32_t query_interval; uint32_t max_query; - uint32_t update_cap; - uint32_t fis_version; uint64_t run_version; uint32_t context; }; @@ -158,14 +156,6 @@ static int submit_get_firmware_info(struct update_context *uctx) if (fw->max_query == UINT_MAX) return -ENXIO; - fw->update_cap = ndctl_cmd_fw_info_get_update_cap(cmd); - if (fw->update_cap == UINT_MAX) - return -ENXIO; - - fw->fis_version = ndctl_cmd_fw_info_get_fis_version(cmd); - if (fw->fis_version == UINT_MAX) - return -ENXIO; - fw->run_version = ndctl_cmd_fw_info_get_run_version(cmd); if (fw->run_version == ULLONG_MAX) return -ENXIO; diff --git a/test/Makefile.am b/test/Makefile.am index d4c2bd6..d5ef648 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -16,7 +16,8 @@ TESTS =\ blk-exhaust.sh \ sector-mode.sh \ inject-error.sh \ - btt-errors.sh + btt-errors.sh \ + firmware-update.sh check_PROGRAMS =\ libndctl \ diff --git a/test/firmware-update.sh b/test/firmware-update.sh new file mode 100755 index 0000000..ff777b9 --- /dev/null +++ b/test/firmware-update.sh @@ -0,0 +1,74 @@ +#!/bin/bash -Ex + +# Copyright(c) 2017 Intel Corporation. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. + +[ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ] && ndctl="../ndctl/ndctl" +[ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl" +[ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1 +bus="nfit_test.0" +json2var="s/[{}\",]//g; s/:/=/g" +rc=77 +dev="" +image="update-fw.img" + +trap 'err $LINENO' ERR + +# $1: Line number +# $2: exit code +err() +{ + [ -n "$2" ] && rc="$2" + echo "test/firmware-update.sh: failed at line $1" + exit "$rc" +} + +check_min_kver() +{ + local ver="$1" + : "${KVER:=$(uname -r)}" + + [ -n "$ver" ] || return 1 + [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]] +} + +reset() +{ + $ndctl disable-region -b "$bus" all + $ndctl zero-labels -b "$bus" all + $ndctl enable-region -b "$bus" all + if [ -f $image ]; then + rm -f $image + fi +} + +detect() +{ + dev=$($ndctl list -b "$bus" -D | jq .[0].dev | tr -d '"') + [ -n "$dev" ] || err "$LINENO" 2 +} + +do_tests() +{ + fallocate -l 196608 $image + $ndctl update-firmware -d $dev -f $image +} + +check_min_kver "4.16" || { echo "kernel $KVER may lack firmware update test handling"; exit +$rc; } +modprobe nfit_test +rc=1 +reset +detect +do_tests +reset +exit 0 +