* Re: [dts] [PATCH V2] tests/TestSuite_ptpclient:support meson build and restore systime form RTC time
2020-09-17 11:34 [dts] [PATCH V2] tests/TestSuite_ptpclient:support meson build and restore systime form RTC time lingwei
@ 2020-09-17 5:01 ` Ling, WeiX
2020-09-17 9:00 ` Ma, LihongX
1 sibling, 0 replies; 3+ messages in thread
From: Ling, WeiX @ 2020-09-17 5:01 UTC (permalink / raw)
To: dts
[-- Attachment #1: Type: text/plain, Size: 5456 bytes --]
Tested-by: Ling, Wei <weix.ling@intel.com>
Regards,
Ling Wei
> -----Original Message-----
> From: Ling, WeiX <weix.ling@intel.com>
> Sent: Thursday, September 17, 2020 07:34 PM
> To: dts@dpdk.org
> Cc: Ling, WeiX <weix.ling@intel.com>
> Subject: [dts][PATCH V2] tests/TestSuite_ptpclient:support meson build and
> restore systime form RTC time
>
> 1.use app name to support meson build.
> 2.restore systime form RTC time in tear_down_all.
> 3.use re to get the right RTC time when kill app.
>
> Signed-off-by: lingwei <weix.ling@intel.com>
> ---
> tests/TestSuite_ptpclient.py | 27 ++++++++++++++++-----------
> 1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/tests/TestSuite_ptpclient.py b/tests/TestSuite_ptpclient.py index
> 5a524b9..04cacce 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,9 +86,9 @@ 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')
> + out_ps = self.dut.send_expect("ps -C %s -L -opid,args" % self.app_name,
> "# ")
> + utils.regexp(out_ps, r'(\d+) ./%s' % self.app_ptpclient_path)
> + pid = re.compile(r'(\d+) ./%s' % self.app_ptpclient_path)
> pid_num = list(set(pid.findall(out_ps)))
> out_ps = self.dut.send_expect("kill %s" % pid_num[0], "# ")
>
> @@ -104,7 +103,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 +134,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 +159,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 +176,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
[-- Attachment #2: TestPtpClient.log --]
[-- Type: application/octet-stream, Size: 520745 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dts] [PATCH V2] tests/TestSuite_ptpclient:support meson build and restore systime form RTC time
2020-09-17 11:34 [dts] [PATCH V2] tests/TestSuite_ptpclient:support meson build and restore systime form RTC time lingwei
2020-09-17 5:01 ` Ling, WeiX
@ 2020-09-17 9:00 ` Ma, LihongX
1 sibling, 0 replies; 3+ messages in thread
From: Ma, LihongX @ 2020-09-17 9:00 UTC (permalink / raw)
To: Ling, WeiX, dts; +Cc: Ling, WeiX
Acked-by: lihongx ma<lihongx.ma@intel.com>
Regards,
Ma,lihong
> -----Original Message-----
> From: dts <dts-bounces@dpdk.org> On Behalf Of lingwei
> Sent: Thursday, September 17, 2020 7:34 PM
> To: dts@dpdk.org
> Cc: Ling, WeiX <weix.ling@intel.com>
> Subject: [dts] [PATCH V2] tests/TestSuite_ptpclient:support meson build and
> restore systime form RTC time
>
> 1.use app name to support meson build.
> 2.restore systime form RTC time in tear_down_all.
> 3.use re to get the right RTC time when kill app.
>
> Signed-off-by: lingwei <weix.ling@intel.com>
> ---
^ permalink raw reply [flat|nested] 3+ messages in thread
* [dts] [PATCH V2] tests/TestSuite_ptpclient:support meson build and restore systime form RTC time
@ 2020-09-17 11:34 lingwei
2020-09-17 5:01 ` Ling, WeiX
2020-09-17 9:00 ` Ma, LihongX
0 siblings, 2 replies; 3+ messages in thread
From: lingwei @ 2020-09-17 11:34 UTC (permalink / raw)
To: dts; +Cc: lingwei
1.use app name to support meson build.
2.restore systime form RTC time in tear_down_all.
3.use re to get the right RTC time when kill app.
Signed-off-by: lingwei <weix.ling@intel.com>
---
tests/TestSuite_ptpclient.py | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/tests/TestSuite_ptpclient.py b/tests/TestSuite_ptpclient.py
index 5a524b9..04cacce 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,9 +86,9 @@ 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')
+ out_ps = self.dut.send_expect("ps -C %s -L -opid,args" % self.app_name, "# ")
+ utils.regexp(out_ps, r'(\d+) ./%s' % self.app_ptpclient_path)
+ pid = re.compile(r'(\d+) ./%s' % self.app_ptpclient_path)
pid_num = list(set(pid.findall(out_ps)))
out_ps = self.dut.send_expect("kill %s" % pid_num[0], "# ")
@@ -104,7 +103,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 +134,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 +159,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 +176,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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-17 9:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 11:34 [dts] [PATCH V2] tests/TestSuite_ptpclient:support meson build and restore systime form RTC time lingwei
2020-09-17 5:01 ` Ling, WeiX
2020-09-17 9:00 ` Ma, LihongX
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).