mirror of
https://git.yoctoproject.org/poky
synced 2026-04-08 17:02:22 +02:00
oeqa: Add sync call to command execution
We previously put a sync call into devtool to try and combat the bitbake timeout issues on the autobuilder. It isn't enough as the timeouts occur mid test. They are also occurring on non-devtool tests. Add in sync calls around command execution instead. (From OE-Core rev: ed912771ea98c42f61bf927b1ca708650b0bed4c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit ceca5ed121e2b54415a7ab3a217882e4ea86923a) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -64,12 +64,12 @@ class RunCmdTests(OESelftestTestCase):
|
||||
runCmd, "echo foobar >&2; false", shell=True, assert_error=False)
|
||||
|
||||
def test_output(self):
|
||||
result = runCmd("echo stdout; echo stderr >&2", shell=True)
|
||||
result = runCmd("echo stdout; echo stderr >&2", shell=True, sync=False)
|
||||
self.assertEqual("stdout\nstderr", result.output)
|
||||
self.assertEqual("", result.error)
|
||||
|
||||
def test_output_split(self):
|
||||
result = runCmd("echo stdout; echo stderr >&2", shell=True, stderr=subprocess.PIPE)
|
||||
result = runCmd("echo stdout; echo stderr >&2", shell=True, stderr=subprocess.PIPE, sync=False)
|
||||
self.assertEqual("stdout", result.output)
|
||||
self.assertEqual("stderr", result.error)
|
||||
|
||||
@@ -77,7 +77,7 @@ class RunCmdTests(OESelftestTestCase):
|
||||
numthreads = threading.active_count()
|
||||
start = time.time()
|
||||
# Killing a hanging process only works when not using a shell?!
|
||||
result = runCmd(['sleep', '60'], timeout=self.TIMEOUT, ignore_status=True)
|
||||
result = runCmd(['sleep', '60'], timeout=self.TIMEOUT, ignore_status=True, sync=False)
|
||||
self.assertEqual(result.status, -signal.SIGTERM)
|
||||
end = time.time()
|
||||
self.assertLess(end - start, self.TIMEOUT + self.DELTA)
|
||||
@@ -87,7 +87,7 @@ class RunCmdTests(OESelftestTestCase):
|
||||
numthreads = threading.active_count()
|
||||
start = time.time()
|
||||
# Killing a hanging process only works when not using a shell?!
|
||||
result = runCmd(['sleep', '60'], timeout=self.TIMEOUT, ignore_status=True, stderr=subprocess.PIPE)
|
||||
result = runCmd(['sleep', '60'], timeout=self.TIMEOUT, ignore_status=True, stderr=subprocess.PIPE, sync=False)
|
||||
self.assertEqual(result.status, -signal.SIGTERM)
|
||||
end = time.time()
|
||||
self.assertLess(end - start, self.TIMEOUT + self.DELTA)
|
||||
@@ -95,7 +95,7 @@ class RunCmdTests(OESelftestTestCase):
|
||||
|
||||
def test_stdin(self):
|
||||
numthreads = threading.active_count()
|
||||
result = runCmd("cat", data=b"hello world", timeout=self.TIMEOUT)
|
||||
result = runCmd("cat", data=b"hello world", timeout=self.TIMEOUT, sync=False)
|
||||
self.assertEqual("hello world", result.output)
|
||||
self.assertEqual(numthreads, threading.active_count(), msg="Thread counts were not equal before (%s) and after (%s), active threads: %s" % (numthreads, threading.active_count(), threading.enumerate()))
|
||||
self.assertEqual(numthreads, 1)
|
||||
@@ -103,7 +103,7 @@ class RunCmdTests(OESelftestTestCase):
|
||||
def test_stdin_timeout(self):
|
||||
numthreads = threading.active_count()
|
||||
start = time.time()
|
||||
result = runCmd(['sleep', '60'], data=b"hello world", timeout=self.TIMEOUT, ignore_status=True)
|
||||
result = runCmd(['sleep', '60'], data=b"hello world", timeout=self.TIMEOUT, ignore_status=True, sync=False)
|
||||
self.assertEqual(result.status, -signal.SIGTERM)
|
||||
end = time.time()
|
||||
self.assertLess(end - start, self.TIMEOUT + self.DELTA)
|
||||
@@ -111,12 +111,12 @@ class RunCmdTests(OESelftestTestCase):
|
||||
|
||||
def test_log(self):
|
||||
log = MemLogger()
|
||||
result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log)
|
||||
result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log, sync=False)
|
||||
self.assertEqual(["Running: echo stdout; echo stderr >&2", "stdout", "stderr"], log.info_msgs)
|
||||
self.assertEqual([], log.error_msgs)
|
||||
|
||||
def test_log_split(self):
|
||||
log = MemLogger()
|
||||
result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log, stderr=subprocess.PIPE)
|
||||
result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log, stderr=subprocess.PIPE, sync=False)
|
||||
self.assertEqual(["Running: echo stdout; echo stderr >&2", "stdout"], log.info_msgs)
|
||||
self.assertEqual(["stderr"], log.error_msgs)
|
||||
|
||||
@@ -167,7 +167,7 @@ class Result(object):
|
||||
pass
|
||||
|
||||
|
||||
def runCmd(command, ignore_status=False, timeout=None, assert_error=True,
|
||||
def runCmd(command, ignore_status=False, timeout=None, assert_error=True, sync=True,
|
||||
native_sysroot=None, limit_exc_output=0, output_log=None, **options):
|
||||
result = Result()
|
||||
|
||||
@@ -184,6 +184,12 @@ def runCmd(command, ignore_status=False, timeout=None, assert_error=True,
|
||||
cmd = Command(command, timeout=timeout, output_log=output_log, **options)
|
||||
cmd.run()
|
||||
|
||||
# tests can be heavy on IO and if bitbake can't write out its caches, we see timeouts.
|
||||
# call sync around the tests to ensure the IO queue doesn't get too large, taking any IO
|
||||
# hit here rather than in bitbake shutdown.
|
||||
if sync:
|
||||
os.system("sync")
|
||||
|
||||
result.command = command
|
||||
result.status = cmd.status
|
||||
result.output = cmd.output
|
||||
|
||||
Reference in New Issue
Block a user