From patchwork Thu Sep 24 16:44:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: dliu X-Patchwork-Id: 78763 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CB8A9A04B7; Thu, 24 Sep 2020 18:45:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 565021DEE8; Thu, 24 Sep 2020 18:45:12 +0200 (CEST) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by dpdk.org (Postfix) with ESMTP id 2B0B71DED3 for ; Thu, 24 Sep 2020 18:45:09 +0200 (CEST) Received: by mail-qt1-f193.google.com with SMTP id n10so3502363qtv.3 for ; Thu, 24 Sep 2020 09:45:09 -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=sECWyzmZjJPTesY4b5rWaq7wS4CaY6yMQGj5D9MMfTY=; b=NfkD/Cdz/aMl8EYEMoE7ZTMhbrlObvz96LUEyIcTwRo2yvARVCA2HrQXYRETJEkGMg kLyMNaDrfiXFQQPeJW9O5CVBfL4ywepzlfhX+y2ob1mRYiTfyTx6zTdWPzBCeNZecM6g cFZKIrdyZkJoO+r3xqj3Qt4o1Gz5PdOCKREXQ= 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=sECWyzmZjJPTesY4b5rWaq7wS4CaY6yMQGj5D9MMfTY=; b=nvGAK6r13R08l7VkEllIogmDq2W5qoAa6wthHFQuZrI1uCLOKcd3d7BOnQXzSEJnDt n1L6VAkYtweAa1iImUJD1QVGmKOGY71d/TQKG/TFSSyLVvnfdLvxuyzpTpEWa2As99N8 58bRVMTV3NPyIjcWJ8bkfL2abAvGCnc+JxmXHnzqoJTlaw7uqL+/VZVYyAGDc97kPPr0 XIxF0CCLqv7Yq+FDVQwjZ0WeM+h5mPYU/N4ICZ9O8V6gShMg/Gup/EUbqZQLuKvSDUiQ wEuZCcm7cLXYZIQmfTh0q8cgZ+DHW3YdQHeNHsUuRdZfKhs+PsfCovsWjn5XYqFai157 t2xA== X-Gm-Message-State: AOAM530Og2dhf03W7dfCn6OxdbCt0KsEyFCkAivmCX91o2DEosElMO9k UmyXJhoK4uWYI+VkyiKBd7w7NqVHO816yzAlmuxyaFAxJNNa7CZ4qedeueDLJ20Qz/LhlTG6g11 lI4CNgwNl+SYJOvfASc7I2HkGw5LY+FOHz9B1rBKbj7LRi7p3glAk X-Google-Smtp-Source: ABdhPJxxzZmPWvk0JDKtADb0dvAwgnqG+9+MhkToa9AssgnMrHhSfHokAHIqNvL1gV9aWOOlwCioYA== X-Received: by 2002:aed:310e:: with SMTP id 14mr497898qtg.122.1600965907821; Thu, 24 Sep 2020 09:45:07 -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 v90sm17309qtd.66.2020.09.24.09.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 09:45:06 -0700 (PDT) From: David Liu To: dts@dpdk.org Cc: lylavoie@iol.unh.edu, dev@dpdk.org, David Liu Date: Thu, 24 Sep 2020 12:44:52 -0400 Message-Id: <20200924164453.50360-1-dliu@iol.unh.edu> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Subject: [dts] [PATCH] EEPROM Dump Feature 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 test case and test plan for eeprom dump compare output result from ethtool and testpmd Signed-off-by: David Liu --- test_plans/eeprom_dump_test_plan.rst | 92 ++++++++++++++++++ tests/TestSuite_eeprom_dump.py | 139 +++++++++++++++++++++++++++ 2 files changed, 231 insertions(+) create mode 100644 test_plans/eeprom_dump_test_plan.rst create mode 100644 tests/TestSuite_eeprom_dump.py diff --git a/test_plans/eeprom_dump_test_plan.rst b/test_plans/eeprom_dump_test_plan.rst new file mode 100644 index 0000000..3b169c3 --- /dev/null +++ b/test_plans/eeprom_dump_test_plan.rst @@ -0,0 +1,92 @@ +.. # BSD LICENSE + # + # Copyright(c) 2020 Intel Corporation. All rights reserved + # Copyright © 2020 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. + +================= +EEPROM Dump Test +================= + +The EEPROM Dump Test checks the ability to output EEPROM information on +testpmd when requested. Then compares with output from ethtool to verify +that both output information is the same. When finished, all the files +created during testing will be deleted. The difference of the two files +can be found in the log file. + +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 + +Test Case : EEPROM Dump +======================= + +1. Use testpmd to show the EEPROM information on selected port:: + + testpmd> show port eeprom + +2. Quit the testpmd to have access of ethtool, then use ethtool + to get EEPROM information on selected port:: + + ethtool -e raw on length >> .txt + +3. Store the output from testpmd and ethtool into two files, then compare both files. + Verify they are the same. + +4. Delete all the files created during testing. + + +Test Case : Module EEPROM Dump +=============================== + +1. Use testpmd to show the EEPROM information on selected port:: + + testpmd> show port module_eeprom + +2. Quit the testpmd to have access of ethtool, then use ethtool + to get EEPROM information on selected port:: + + ethtool -m raw on length >> .txt + +3. Store the output from testpmd and ethtool into two files, then compare both files. + Verify they are the same. + +4. Delete all the files created during testing. diff --git a/tests/TestSuite_eeprom_dump.py b/tests/TestSuite_eeprom_dump.py new file mode 100644 index 0000000..8c2bf4c --- /dev/null +++ b/tests/TestSuite_eeprom_dump.py @@ -0,0 +1,139 @@ +#BSD LICENSE +# +# Copyright(c) 2020 Intel Corporation. All rights reserved +# Copyright © 2020 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. +""" +import utils +import re +from pmd_output import PmdOutput +from test_case import TestCase + + +class TestEEPROMDump(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 clean_up_and_compare(self, testname, port): + # comapre the two files + result = self.dut.send_expect(f"diff testpmd_{testname}_{port}.txt ethtool_{testname}_{port}.txt", "#") + + # Clean up files + self.dut.send_expect(f"rm ethtool_{testname}_raw_{port}.txt", "#") + self.dut.send_expect(f"rm ethtool_{testname}_hex_{port}.txt", "#") + self.dut.send_expect(f"rm ethtool_{testname}_{port}.txt", "#") + self.dut.send_expect(f"rm testpmd_{testname}_{port}.txt", "#") + + self.verify(not result, "Testpmd dumped is not same as linux dumped") + + def dump_to_file(self, regex, get, to): + # Get testpmd output to have only hex value + for line in re.findall(regex, get): + line = line.replace(" ", "").lower() + self.dut.send_expect(f"echo {line} >> {to}", "#") + + def check_output(self, testname, ethcommand): + self.pmdout.start_testpmd("Default") + portsinfo = [] + + for port in self.ports: + pmdout = self.dut.send_expect(f"show port {port} {testname}", "testpmd>") + self.verify("Finish --" in pmdout, f"{testname} dump failed") + + # get length from testpmd outout + length = re.findall(r'(?<=length: )\d+', pmdout)[0] + + # Store the output and length + portinfo = {'port': port, 'length' : length, 'pmdout' :pmdout} + portsinfo.append(portinfo) + + self.dut.send_expect("quit", "# ") + + # Bind to the default driver to use ethtool after quit testpmd + for port in self.ports: + netdev = self.dut.ports_info[port]['port'] + portinfo = portsinfo[port] + + # strip original driver + portinfo['ori_driver'] = netdev.get_nic_driver() + portinfo['net_dev'] = netdev + + # bind to default driver + netdev.bind_driver() + + # get interface + iface = netdev.get_interface_name() + + # Get testpmd output to have only hex value + self.dump_to_file(r'(?<=: )(.*)(?= \| )', portinfo['pmdout'], f"testpmd_{testname}_{port}.txt") + + self.dut.send_expect(f"ethtool {ethcommand} {iface} raw on length {portinfo['length']} >> ethtool_{testname}_raw_{port}.txt", "#") + self.dut.send_expect(f"xxd ethtool_{testname}_raw_{port}.txt >> ethtool_{testname}_hex_{port}.txt", "#") + portinfo['ethout'] = self.dut.send_expect(f"cat ethtool_{testname}_hex_{port}.txt", "#") + + self.dump_to_file(r'(?<=: )(.*)(?= )', portinfo['ethout'], f"ethtool_{testname}_{port}.txt") + + # Compare the files and delete the files after + self.clean_up_and_compare(testname, port) + + # bind to original driver + portinfo['net_dev'].bind_driver(portinfo['ori_driver']) + + def test_eeprom_dump(self): + self.check_output("eeprom", "-e") + + def test_module_eeprom_dump(self): + self.check_output("module_eeprom", "-m") + + 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()