test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1] tests/short_live: use a function to detect process
@ 2019-04-04  9:21 Wenjie Li
  2019-04-04  9:58 ` Zhu, WenhuiX
  2019-04-09  1:41 ` Tu, Lijuan
  0 siblings, 2 replies; 3+ messages in thread
From: Wenjie Li @ 2019-04-04  9:21 UTC (permalink / raw)
  To: dts; +Cc: Wenjie Li

On some platform, it will take more time to kill the process. Add a
function to detect the process status, if the process is killed within
DELAY_MAX seconds, break the loop and continue testing, else return
"failure".

Signed-off-by: Wenjie Li <wenjiex.a.li@intel.com>
---
 tests/TestSuite_short_live.py | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_short_live.py b/tests/TestSuite_short_live.py
index 7da7dd1..c18dac4 100644
--- a/tests/TestSuite_short_live.py
+++ b/tests/TestSuite_short_live.py
@@ -119,6 +119,18 @@ class TestShortLiveApp(TestCase):
         else:
             self.verify('PPP' not in out, "Receive test failed")
 
+    def check_process(self, delay_max=10):
+        process_file = "/var/run/dpdk/rte/config"
+        delay = 0
+        while delay < delay_max:
+            process = self.dut.send_expect("lsof %s | wc -l" % process_file, "#")
+            if process != '0':
+                time.sleep(1)
+                delay = delay + 1
+            else:
+                break
+        self.verify(delay < delay_max, "Failed to kill the process within %s seconds" % delay_max)
+
     def test_basic_forwarding(self):
         """
         Basic rx/tx forwarding test
@@ -161,7 +173,7 @@ class TestShortLiveApp(TestCase):
                 self.dut.send_expect("pkill -2 testpmd", "#", 60, True)
             else:
                 self.dut.send_expect("pkill -15 testpmd", "#", 60, True)
-            time.sleep(2)
+            self.check_process()
 
     def test_clean_up_with_signal_l2fwd(self):
         repeat_time = 5
@@ -175,10 +187,9 @@ class TestShortLiveApp(TestCase):
             # kill with different Signal
             if i%2 == 0:
                 self.dut.send_expect("pkill -2 l2fwd", "#", 60, True)
-                time.sleep(2)
             else:
                 self.dut.send_expect("pkill -15 l2fwd", "#", 60, True)
-                time.sleep(2)
+            self.check_process()
 
     def test_clean_up_with_signal_l3fwd(self):
         repeat_time = 5
@@ -192,10 +203,9 @@ class TestShortLiveApp(TestCase):
             # kill with different Signal
             if i%2 == 0:
                 self.dut.send_expect("pkill -2 l3fwd", "#", 60, True)
-                time.sleep(2)
             else:
                 self.dut.send_expect("pkill -15 l3fwd", "#", 60, True)
-                time.sleep(2)
+            self.check_process()
 
     def tear_down(self):
         """
-- 
2.17.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dts] [PATCH V1] tests/short_live: use a function to detect process
  2019-04-04  9:21 [dts] [PATCH V1] tests/short_live: use a function to detect process Wenjie Li
@ 2019-04-04  9:58 ` Zhu, WenhuiX
  2019-04-09  1:41 ` Tu, Lijuan
  1 sibling, 0 replies; 3+ messages in thread
From: Zhu, WenhuiX @ 2019-04-04  9:58 UTC (permalink / raw)
  To: Li, WenjieX A, dts; +Cc: Li, WenjieX A


Tested-by: Zhu, WenhuiX <wenhuix.zhu@intel.com>

-----Original Message-----
From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Wenjie Li
Sent: Thursday, April 4, 2019 5:21 PM
To: dts@dpdk.org
Cc: Li, WenjieX A <wenjiex.a.li@intel.com>
Subject: [dts] [PATCH V1] tests/short_live: use a function to detect process

On some platform, it will take more time to kill the process. Add a function to detect the process status, if the process is killed within DELAY_MAX seconds, break the loop and continue testing, else return "failure".

Signed-off-by: Wenjie Li <wenjiex.a.li@intel.com>
---
 tests/TestSuite_short_live.py | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/tests/TestSuite_short_live.py b/tests/TestSuite_short_live.py index 7da7dd1..c18dac4 100644
--- a/tests/TestSuite_short_live.py
+++ b/tests/TestSuite_short_live.py
@@ -119,6 +119,18 @@ class TestShortLiveApp(TestCase):
         else:
             self.verify('PPP' not in out, "Receive test failed")
 
+    def check_process(self, delay_max=10):
+        process_file = "/var/run/dpdk/rte/config"
+        delay = 0
+        while delay < delay_max:
+            process = self.dut.send_expect("lsof %s | wc -l" % process_file, "#")
+            if process != '0':
+                time.sleep(1)
+                delay = delay + 1
+            else:
+                break
+        self.verify(delay < delay_max, "Failed to kill the process 
+ within %s seconds" % delay_max)
+
     def test_basic_forwarding(self):
         """
         Basic rx/tx forwarding test
@@ -161,7 +173,7 @@ class TestShortLiveApp(TestCase):
                 self.dut.send_expect("pkill -2 testpmd", "#", 60, True)
             else:
                 self.dut.send_expect("pkill -15 testpmd", "#", 60, True)
-            time.sleep(2)
+            self.check_process()
 
     def test_clean_up_with_signal_l2fwd(self):
         repeat_time = 5
@@ -175,10 +187,9 @@ class TestShortLiveApp(TestCase):
             # kill with different Signal
             if i%2 == 0:
                 self.dut.send_expect("pkill -2 l2fwd", "#", 60, True)
-                time.sleep(2)
             else:
                 self.dut.send_expect("pkill -15 l2fwd", "#", 60, True)
-                time.sleep(2)
+            self.check_process()
 
     def test_clean_up_with_signal_l3fwd(self):
         repeat_time = 5
@@ -192,10 +203,9 @@ class TestShortLiveApp(TestCase):
             # kill with different Signal
             if i%2 == 0:
                 self.dut.send_expect("pkill -2 l3fwd", "#", 60, True)
-                time.sleep(2)
             else:
                 self.dut.send_expect("pkill -15 l3fwd", "#", 60, True)
-                time.sleep(2)
+            self.check_process()
 
     def tear_down(self):
         """
--
2.17.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dts] [PATCH V1] tests/short_live: use a function to detect process
  2019-04-04  9:21 [dts] [PATCH V1] tests/short_live: use a function to detect process Wenjie Li
  2019-04-04  9:58 ` Zhu, WenhuiX
@ 2019-04-09  1:41 ` Tu, Lijuan
  1 sibling, 0 replies; 3+ messages in thread
From: Tu, Lijuan @ 2019-04-09  1:41 UTC (permalink / raw)
  To: Li, WenjieX A, dts; +Cc: Li, WenjieX A

Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Wenjie Li
> Sent: Thursday, April 4, 2019 2:21 AM
> To: dts@dpdk.org
> Cc: Li, WenjieX A <wenjiex.a.li@intel.com>
> Subject: [dts] [PATCH V1] tests/short_live: use a function to detect process
> 
> On some platform, it will take more time to kill the process. Add a function
> to detect the process status, if the process is killed within DELAY_MAX
> seconds, break the loop and continue testing, else return "failure".
> 
> Signed-off-by: Wenjie Li <wenjiex.a.li@intel.com>
> ---
>  tests/TestSuite_short_live.py | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/TestSuite_short_live.py b/tests/TestSuite_short_live.py
> index 7da7dd1..c18dac4 100644
> --- a/tests/TestSuite_short_live.py
> +++ b/tests/TestSuite_short_live.py
> @@ -119,6 +119,18 @@ class TestShortLiveApp(TestCase):
>          else:
>              self.verify('PPP' not in out, "Receive test failed")
> 
> +    def check_process(self, delay_max=10):
> +        process_file = "/var/run/dpdk/rte/config"
> +        delay = 0
> +        while delay < delay_max:
> +            process = self.dut.send_expect("lsof %s | wc -l" % process_file, "#")
> +            if process != '0':
> +                time.sleep(1)
> +                delay = delay + 1
> +            else:
> +                break
> +        self.verify(delay < delay_max, "Failed to kill the process
> + within %s seconds" % delay_max)
> +
>      def test_basic_forwarding(self):
>          """
>          Basic rx/tx forwarding test
> @@ -161,7 +173,7 @@ class TestShortLiveApp(TestCase):
>                  self.dut.send_expect("pkill -2 testpmd", "#", 60, True)
>              else:
>                  self.dut.send_expect("pkill -15 testpmd", "#", 60, True)
> -            time.sleep(2)
> +            self.check_process()
> 
>      def test_clean_up_with_signal_l2fwd(self):
>          repeat_time = 5
> @@ -175,10 +187,9 @@ class TestShortLiveApp(TestCase):
>              # kill with different Signal
>              if i%2 == 0:
>                  self.dut.send_expect("pkill -2 l2fwd", "#", 60, True)
> -                time.sleep(2)
>              else:
>                  self.dut.send_expect("pkill -15 l2fwd", "#", 60, True)
> -                time.sleep(2)
> +            self.check_process()
> 
>      def test_clean_up_with_signal_l3fwd(self):
>          repeat_time = 5
> @@ -192,10 +203,9 @@ class TestShortLiveApp(TestCase):
>              # kill with different Signal
>              if i%2 == 0:
>                  self.dut.send_expect("pkill -2 l3fwd", "#", 60, True)
> -                time.sleep(2)
>              else:
>                  self.dut.send_expect("pkill -15 l3fwd", "#", 60, True)
> -                time.sleep(2)
> +            self.check_process()
> 
>      def tear_down(self):
>          """
> --
> 2.17.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-09  1:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-04  9:21 [dts] [PATCH V1] tests/short_live: use a function to detect process Wenjie Li
2019-04-04  9:58 ` Zhu, WenhuiX
2019-04-09  1:41 ` Tu, Lijuan

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).