From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6FD19A04AC; Thu, 13 Aug 2020 17:07:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1EFE81C0B3; Thu, 13 Aug 2020 17:07:13 +0200 (CEST) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by dpdk.org (Postfix) with ESMTP id C15E31C023 for ; Thu, 13 Aug 2020 17:07:12 +0200 (CEST) Received: by mail-lj1-f179.google.com with SMTP id m22so6554490ljj.5 for ; Thu, 13 Aug 2020 08:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=P0Hxx9mrTXgg6QFohvsSuTQj9D9r3BYJWOZX9vL5o/4=; b=Nj9vCMRM0MLIpRxPPgfhkU4qwcSYzB5pwJvGpVCB5gKKbJFfoSeIkTjsVmH4eX72r/ h0P+RfuZH+uNMyF5rz/3bqjQoQNdAQkNBm8do10U2zm0ej9W2kHV87RFLTaYOCBUTHr3 YIhAbTndrsbD8RLVrLrnNBKrvKL084q972OWE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=P0Hxx9mrTXgg6QFohvsSuTQj9D9r3BYJWOZX9vL5o/4=; b=evDk0jtoTHU7dTFAi1cXdcNv3YWgVo9QjNGAc8n+nMIyjgxD5EARidnECaaPPenh7p l2dRJFrWGojqZl88v8TYlYKDwg3BjVtU5cvso9ofO+9RuORN41JQpHLke5s/7nX7asfc XqrLn6TtLb3IzjfWmGnoOYod2v/ue7/A4izKoIbokmFF0gXkR7fcgfn8Jk8tyXAZvUUE 6pDMHSUG/CMhJRVOlxx4VYkXeTKpwcLNCT2L99RxAUiZEDguIhs85OzjsTx7mCb0qCJ0 TfqKaFuuHlbQc2xilwfgbUvIppB6bq/tYkFABpg4o7IEKu/43KN2B9EnaWNvXAPqHcRj ExNQ== X-Gm-Message-State: AOAM5334GN0yWXo3Am+WFRSxMZ2RYI7VGl+/cq7dOG6cSeg1cT/7cfPo PyUQxcZkRpFc1gwjH4ahPKlerBNQa0mVfkViffcf1NHYVhIOCIjRFKtRq4Y2N/xFtUVKgx7lQy6 sngAcdKxUCOzX84KEmuCayLq2mKqoDPZ4AsULeOcdm1HTdou44Q== X-Google-Smtp-Source: ABdhPJyu1nVmmtmbYEnYraHO4yDorWlfHiSPeHzi6bOYqhWQLbSTz/6GG3CcEr91NoNYYwb24JhGug== X-Received: by 2002:a05:651c:2044:: with SMTP id t4mr2081309ljo.420.1597331231636; Thu, 13 Aug 2020 08:07:11 -0700 (PDT) Received: from traffictester.opnfv.iol.unh.edu (opnfv-vpn.iol.unh.edu. [132.177.125.250]) by smtp.gmail.com with ESMTPSA id y9sm1152611ljm.89.2020.08.13.08.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2020 08:07:10 -0700 (PDT) From: David Liu To: dts@dpdk.org Cc: lylavoie@iol.unh.edu, David Liu Date: Thu, 13 Aug 2020 11:06:33 -0400 Message-Id: <20200813150634.47640-1-dliu@iol.unh.edu> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dts] [PATCH V1] Add FW Version X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Add firmware version test case Add firmware version test plan Add firmware version cfg file Signed-off-by: David Liu --- conf/firmware_version.cfg | 25 ++++ framework/pmd_output.py | 8 +- test_plans/firmware_version_test_plan.rst | 79 ++++++++++++ tests/TestSuite_firmware_version.py | 148 ++++++++++++++++++++++ 4 files changed, 259 insertions(+), 1 deletion(-) create mode 100644 conf/firmware_version.cfg create mode 100644 test_plans/firmware_version_test_plan.rst create mode 100644 tests/TestSuite_firmware_version.py diff --git a/conf/firmware_version.cfg b/conf/firmware_version.cfg new file mode 100644 index 0000000..149dd47 --- /dev/null +++ b/conf/firmware_version.cfg @@ -0,0 +1,25 @@ +# Users could change these configuration on demand: +# +# - expected_firmware_version is a dictionary defining expected firmware version. +# Each diver will have different version format. +# The pattern for supported expected firmare version: +# +# - i40e: +# {'driver' : ['X.XX', '0x8000XXXX', 'X.X.X']} +# - mlx5: +# {'driver' : ['XX.XX.XXXX', 'MT_XXXXXX']} +# - bnxt: +# {'driver' : ['XXX.XXX.XXX.XXX/pkg', 'XXX.XXX.XXX.XXX']} +# +# Note: run ./dts and use show port info command will show you the +# firmware version. +# +# Example: +# [suite] +# expected_firmware_version = { +# 'i40e': ['0x80002919', '5.05', '1.1313.0'], +# 'mlx5' : ['12.25.6555', 'MT_555555555'], +# 'bnxt' : ['236.0.222.0/pkg', '216.3.254.0']} + +[suite] +expected_firmware_version = {} diff --git a/framework/pmd_output.py b/framework/pmd_output.py index 2d66743..8967b5e 100644 --- a/framework/pmd_output.py +++ b/framework/pmd_output.py @@ -1,6 +1,6 @@ # BSD LICENSE # -# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +# Copyright(c) 2020 Intel Corporation. All rights reserved # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -237,6 +237,12 @@ class PmdOutput(): """ return self.get_detail_from_port_info("MAC address: ", "([0-9A-F]{2}:){5}[0-9A-F]{2}", port_id) + def get_firmware_version(self, port_id): + """ + Get the firmware version. + """ + return self.get_detail_from_port_info("Firmware-version: ", "\S.*", port_id) + def get_port_connect_socket(self, port_id): """ Get the socket id which the specified port is connecting with. diff --git a/test_plans/firmware_version_test_plan.rst b/test_plans/firmware_version_test_plan.rst new file mode 100644 index 0000000..d9cf47f --- /dev/null +++ b/test_plans/firmware_version_test_plan.rst @@ -0,0 +1,79 @@ +.. # BSD LICENSE + # + # Copyright(c) 2020 Intel Corporation. All rights reserved + # Copyright © 2018[, 2019] The University of New Hampshire. All rights reserved. + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions + # are met: + # + # * Redistributions of source code must retain the above copyright + # notice, this list of conditions and the following disclaimer. + # * Redistributions in binary form must reproduce the above copyright + # notice, this list of conditions and the following disclaimer in + # the documentation and/or other materials provided with the + # distribution. + # * Neither the name of Intel Corporation nor the names of its + # contributors may be used to endorse or promote products derived + # from this software without specific prior written permission. + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +======================= +Firmware Version Test +======================= + +The Firmware Version Test checks the firmware version from the device info and +compares to the firmware version defined by user. This test case is driver +restricted since each driver will have different version format. + + +Prerequisites +============= + +If using vfio the kernel must be >= 3.6+ and VT-d must be enabled in bios.When +using vfio, use the following commands to load the vfio driver and bind it +to the device under test:: + + modprobe vfio + modprobe vfio-pci + usertools/dpdk-devbind.py --bind=vfio-pci device_bus_id + +Assuming that ports are up and working, then launch the ``testpmd`` application +with the following arguments:: + + ./build/app/testpmd -- -i --portmask=0x3 + +Ensure the ```firmware_version.cfg``` file have the correct name and firmware +version. + +Test Case : Firmware Version Test +=================================== + +1. Use testpmd to show the port info that contained the firmware version:: + + testpmd> show port info + +2. Compares the outputted firmware version with the firmware version listed in the + ```firmware_version.cfg``` file. Different driver will have different version + format. + Currently support: i40e, mlx5, bnxt + + Example below: + {'i40e' : ['5.01', '0x80002341', '1.1.1']} + {'mlx5' : ['12.14.3462', 'MT_2416545656']} + {'bnxt' : ['236.0.222.0', '216.3.254.0']} + + +3. Verifies they matches. diff --git a/tests/TestSuite_firmware_version.py b/tests/TestSuite_firmware_version.py new file mode 100644 index 0000000..85f0833 --- /dev/null +++ b/tests/TestSuite_firmware_version.py @@ -0,0 +1,148 @@ +# BSD LICENSE +# +# Copyright(c) 2020 Intel Corporation. All rights reserved +# Copyright © 2018[, 2019] The University of New Hampshire. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +DPDK Test suite. +""" +from pmd_output import PmdOutput +from test_case import TestCase +import re + + +class TestFirmwareVersion(TestCase): + + def set_up_all(self): + """ + Run at the start of each test suite. + """ + self.ports = self.dut.get_ports() + + self.pmdout = PmdOutput(self.dut) + + def set_up(self): + """ + Run before each test case. + """ + pass + + def check_firmware_version(self, exp_fwversion, fwversion): + vf = ['major', 'minor', 'path', 'build'] + fwversion = re.split("\\.", fwversion) + exp_fwversion = re.split("\\.", exp_fwversion) + + self.verify(len(exp_fwversion) == len(fwversion), "Invalid version format") + + for i in range(len(exp_fwversion)): + if fwversion[i] != exp_fwversion[i] and i == 0: + self.verify(False, + f"Fail: {vf[i]} version is different expected {exp_fwversion[i]} but was {fwversion[i]}") + elif fwversion[i] != exp_fwversion[i] and i > 0: + print(f"Warning: {vf[i]} version is different expected {exp_fwversion[i]} but was {fwversion[i]}") + + def check_format(self, exp, out, name, pattern, match): + if match is None: + self.verify(re.search(pattern, exp) is not None, f"Invalid expected {name} format") + self.verify(re.search(pattern, out) is not None, f"Invalid {name} format") + else: + exp = re.findall(pattern, exp) + out = re.findall(pattern, out) + + self.verify(exp[0] == match, f"Invalid expected {name} format") + self.verify(out[0] == match, f"Invalid {name} format") + + def test_firmware_version(self): + self.pmdout.start_testpmd("Default") + + # Read the version cfg + expected_version_list = self.get_suite_cfg()['expected_firmware_version'] + + self.verify(self.kdriver in expected_version_list, "driver is not in the cfg file") + expected_version_info = expected_version_list[self.kdriver] + + for port in self.ports: + out = self.dut.send_expect(f"show port info {port}", "testpmd> ") + self.verify("Firmware-version:" in out, "Firmware version not detected") + + version_info = self.pmdout.get_firmware_version(port) + + if self.kdriver == "i40e": + # Get the version information from output and cfg file + fwversion, etrackid, networkdriver = version_info.split() + exp_etrackid, exp_fwversion, exp_networkdriver = expected_version_info + self.check_format(exp_fwversion, fwversion, "version", r'^\d{1,4}\.\d{1,4}$', None) + + self.check_firmware_version(exp_fwversion, fwversion) + + self.check_format(exp_etrackid, etrackid, "etrackid", r'^.{0,6}', "0x8000") + + self.check_format(exp_networkdriver, networkdriver, + "network driver", r'^\d{1,4}\.\d{1,4}\.\d{1,4}$', None) + + elif self.kdriver == "mlx5": + # Get the version information from output and cfg file + exp_fwversion, exp_psid = expected_version_info + fwversion, psid = version_info.split() + + self.check_format(exp_fwversion, fwversion, "version", r'^\d{1,4}\.\d{1,4}\.\d{1,4}$', None) + + self.check_firmware_version(exp_fwversion, fwversion) + + # remove "(" and ")" from the string + psid = re.sub('[()]', '', psid) + + self.check_format(exp_psid, psid, "psid", r'^.{0,3}', "MT_") + + elif self.kdriver == "bnxt": + # Get the version information from output and cfg file + exp_pkg, exp_fwversion = expected_version_info + pkg, fwversion = version_info.split() + + self.check_format(exp_fwversion, fwversion, "version", r'^\d{1,4}\.\d{1,4}\.\d{1,4}\.\d{1,4}$', None) + + self.check_firmware_version(exp_fwversion, fwversion) + + self.check_format(exp_pkg, pkg, "pkg", r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\S{1,3}$', None) + + else: + self.verify(False, f"Test: case fails on {self.kdriver} driver") + + def tear_down(self): + """ + Run after each test case. + """ + self.dut.kill_all() + + def tear_down_all(self): + """ + Run after each test suite. + """ + self.dut.kill_all() -- 2.17.1