diff --git a/common/OpTestUtil.py b/common/OpTestUtil.py index 97453811..1da8eaf0 100644 --- a/common/OpTestUtil.py +++ b/common/OpTestUtil.py @@ -2469,6 +2469,21 @@ def format_email(self, linux_path , repo): with open("email.json","w") as email: json.dump({"subject":subject,"body":body},email) + def wait_for(self, func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=None): + args = args or [] + kwargs = kwargs or {} + start_time = time.monotonic() + end_time = start_time + timeout + time.sleep(first) + while time.monotonic() < end_time: + if text: + log.debug("%s (%.9f secs)", text, (time.monotonic() - start_time)) + output = func(*args, **kwargs) + if output: + return output + time.sleep(step) + return None + class Server(object): ''' diff --git a/testcases/OpTestKernelTest.py b/testcases/OpTestKernelTest.py index d35a5698..cab8de97 100644 --- a/testcases/OpTestKernelTest.py +++ b/testcases/OpTestKernelTest.py @@ -77,27 +77,6 @@ def setUp(self): self.fail( "Provide host ip user details refer, --host-{ip,user,password}") - def wait_for(self, func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=None): - args = args or [] - kwargs = kwargs or {} - - start_time = time.monotonic() - end_time = start_time + timeout - - time.sleep(first) - - while time.monotonic() < end_time: - if text: - log.debug("%s (%.9f secs)", text, (time.monotonic() - start_time)) - - output = func(*args, **kwargs) - if output: - return output - - time.sleep(step) - - return None - def build_kernel(self): """ Build and install the Linux kernel.