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 B321AA04B7; Fri, 18 Sep 2020 05:24:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8A9681D6D6; Fri, 18 Sep 2020 05:24:02 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 18C0B1D6C8 for ; Fri, 18 Sep 2020 05:24:00 +0200 (CEST) IronPort-SDR: MmkyG8XSLGxOfrUWproPfwOTIGECJhe9ga/LqbG8bGJhKuvboM9mBdc/E4vLCfiXd8oWjoXQTW +Pd6vIc0+FPg== X-IronPort-AV: E=McAfee;i="6000,8403,9747"; a="147595754" X-IronPort-AV: E=Sophos;i="5.77,273,1596524400"; d="scan'208";a="147595754" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2020 20:23:57 -0700 IronPort-SDR: zI0LS/oZMbKWZSm8T/2xvT4VY7PjB0bKtV+oY6+JLOZq04No7RZyRhvbVszq/d2jPBo/yLWWkg 9VdxzLudew1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,273,1596524400"; d="scan'208";a="320465156" Received: from unknown (HELO localhost.localdomain) ([10.240.183.222]) by orsmga002.jf.intel.com with ESMTP; 17 Sep 2020 20:23:55 -0700 From: lingwei To: dts@dpdk.org Cc: lingwei Date: Fri, 18 Sep 2020 11:19:26 +0000 Message-Id: <20200918111926.96466-1-weix.ling@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dts] [PATCH V3] tests/TestSuite_ptpclient:support meson build and restore systime form RTC time 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" v1: 1.use app name to support meson build. 2.restore systime form RTC time in tear_down_all. v2: 1.use re to get the right RTC time when kill app. v3: 1.use killall self.app_name to kill app avoid when other suite exception can't get the pid by re. Signed-off-by: lingwei --- tests/TestSuite_ptpclient.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/TestSuite_ptpclient.py b/tests/TestSuite_ptpclient.py index 5a524b9..07bfde6 100644 --- a/tests/TestSuite_ptpclient.py +++ b/tests/TestSuite_ptpclient.py @@ -50,19 +50,18 @@ class TestPtpClient(TestCase): self.verify("command not found" not in out, "ptp4l not install") dutPorts = self.dut.get_ports() self.verify(len(dutPorts) > 0, "No ports found for " + self.nic) - global default - default = self.dut.send_expect("cat config/common_base |grep IEEE1588=", "# ") # Change the config file to support IEEE1588 and recompile the package. - self.dut.send_expect("sed -i -e 's/%s$/CONFIG_RTE_LIBRTE_IEEE1588=y/' config/common_base" % default, "# ", 30) + self.dut.set_build_options({'RTE_LIBRTE_IEEE1588': 'y'}) self.dut.skip_setup = False self.dut.build_install_dpdk(self.target) # build sample app out = self.dut.build_dpdk_apps("examples/ptpclient") + self.app_ptpclient_path = self.dut.apps_name['ptpclient'] self.verify("Error" not in out, "compilation error 1") self.verify("No such file" not in out, "compilation error 2") - + self.app_name = self.app_ptpclient_path[self.app_ptpclient_path.rfind('/')+1:] port = self.tester.get_local_port(dutPorts[0]) self.itf0 = self.tester.get_interface(port) @@ -87,11 +86,7 @@ class TestPtpClient(TestCase): self.result_table_print() def kill_ptpclient(self): - out_ps = self.dut.send_expect("ps -C ptpclient -L -opid,args", "# ") - utils.regexp(out_ps, r'(\d+) ./examples/ptpclient') - pid = re.compile(r'(\d+) ./examples/ptpclient') - pid_num = list(set(pid.findall(out_ps))) - out_ps = self.dut.send_expect("kill %s" % pid_num[0], "# ") + self.dut.send_expect("killall %s" % self.app_name, "# ") def test_ptpclient(self): """ @@ -104,7 +99,8 @@ class TestPtpClient(TestCase): self.tester.send_expect("ptp4l -i %s -2 -m -S &" % self.itf0, "ptp4l") # run ptpclient on the background - self.dut.send_expect("./examples/ptpclient/build/ptpclient -c f -n 3 -- -T 0 -p 0x1 " + "&", "Delta between master and slave", 60) + self.dut.send_expect("./%s -c f -n 3 -- -T 0 -p 0x1 " % self.app_ptpclient_path + "&", + "Delta between master and slave", 60) time.sleep(3) out = self.dut.get_session_output() self.kill_ptpclient() @@ -134,7 +130,8 @@ class TestPtpClient(TestCase): self.tester.send_expect("ptp4l -i %s -2 -m -S &" % self.itf0, "ptp4l") # run ptpclient on the background - self.dut.send_expect("./examples/ptpclient/build/ptpclient -c f -n 3 -- -T 1 -p 0x1" + "&", "Delta between master and slave", 60) + self.dut.send_expect("./%s -c f -n 3 -- -T 1 -p 0x1" % self.app_ptpclient_path + "&", + "Delta between master and slave", 60) time.sleep(3) out = self.dut.get_session_output() @@ -158,7 +155,7 @@ class TestPtpClient(TestCase): # the output will include kill process info, at that time need get system time again. if len(dut_out) != len(tester_out): dut_out = self.dut.send_expect("date -u '+%Y-%m-%d %H:%M'", "# ") - ## In rare cases minute may change while getting time. So get time again + # In rare cases minute may change while getting time. So get time again if dut_out != tester_out: tester_out = self.tester.send_expect("date -u '+%Y-%m-%d %H:%M'", "# ") dut_out = self.dut.send_expect("date -u '+%Y-%m-%d %H:%M'", "# ") @@ -175,6 +172,10 @@ class TestPtpClient(TestCase): """ Run after each test suite. """ + # Restore the systime from RTC time. + out = self.dut.send_expect("hwclock", "# ") + rtc_time = re.findall(r"(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2})", out)[0] + self.dut.send_command('date -s "%s"' % rtc_time, "# ") # Restore the config file and recompile the package. - self.dut.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_IEEE1588=y$/%s/' config/common_base" % default, "# ", 30) + self.dut.set_build_options({'RTE_LIBRTE_IEEE1588': 'n'}) self.dut.build_install_dpdk(self.target) -- 2.17.1