Skip to content

Commit 4ca0d5b

Browse files
Merge pull request #852 from abdhaleegit/wait-move
Move wait_for function to utils
2 parents 392e59a + 8866d37 commit 4ca0d5b

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

common/OpTestUtil.py

+15
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,21 @@ def format_email(self, linux_path , repo):
24692469
with open("email.json","w") as email:
24702470
json.dump({"subject":subject,"body":body},email)
24712471

2472+
def wait_for(self, func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=None):
2473+
args = args or []
2474+
kwargs = kwargs or {}
2475+
start_time = time.monotonic()
2476+
end_time = start_time + timeout
2477+
time.sleep(first)
2478+
while time.monotonic() < end_time:
2479+
if text:
2480+
log.debug("%s (%.9f secs)", text, (time.monotonic() - start_time))
2481+
output = func(*args, **kwargs)
2482+
if output:
2483+
return output
2484+
time.sleep(step)
2485+
return None
2486+
24722487

24732488
class Server(object):
24742489
'''

testcases/OpTestKernelTest.py

-21
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,6 @@ def setUp(self):
7777
self.fail(
7878
"Provide host ip user details refer, --host-{ip,user,password}")
7979

80-
def wait_for(self, func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=None):
81-
args = args or []
82-
kwargs = kwargs or {}
83-
84-
start_time = time.monotonic()
85-
end_time = start_time + timeout
86-
87-
time.sleep(first)
88-
89-
while time.monotonic() < end_time:
90-
if text:
91-
log.debug("%s (%.9f secs)", text, (time.monotonic() - start_time))
92-
93-
output = func(*args, **kwargs)
94-
if output:
95-
return output
96-
97-
time.sleep(step)
98-
99-
return None
100-
10180
def build_kernel(self):
10281
"""
10382
Build and install the Linux kernel.

0 commit comments

Comments
 (0)