From: "Joshua Watt" <JPEWhacker@gmail.com>
To: bitbake-devel@lists.openembedded.org
Cc: Joshua Watt <JPEWhacker@gmail.com>
Subject: [bitbake-devel][PATCH] bitbake: Add parsing torture test
Date: Wed, 9 Sep 2020 17:09:01 -0500 [thread overview]
Message-ID: <20200909220901.29740-1-JPEWhacker@gmail.com> (raw)
Adds a contrib/ script that repeatedly runs bitbake and interrupts
parsing to try and reproduce parsing deadlocks.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
bitbake/contrib/bbparse-torture.py | 89 ++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
create mode 100755 bitbake/contrib/bbparse-torture.py
diff --git a/bitbake/contrib/bbparse-torture.py b/bitbake/contrib/bbparse-torture.py
new file mode 100755
index 0000000000..c25d547bb8
--- /dev/null
+++ b/bitbake/contrib/bbparse-torture.py
@@ -0,0 +1,89 @@
+#! /usr/bin/env python3
+#
+# Copyright (C) 2020 Joshua Watt <JPEWhacker@gmail.com>
+#
+# SPDX-License-Identifier: MIT
+
+import argparse
+import os
+import random
+import shutil
+import signal
+import subprocess
+import sys
+import time
+
+
+def try_unlink(path):
+ try:
+ os.unlink(path)
+ except:
+ pass
+
+
+def main():
+ def cleanup():
+ shutil.rmtree("tmp/cache", ignore_errors=True)
+ try_unlink("bitbake-cookerdaemon.log")
+ try_unlink("bitbake.sock")
+ try_unlink("bitbake.lock")
+
+ parser = argparse.ArgumentParser(
+ description="Bitbake parser torture test",
+ epilog="""
+ A torture test for bitbake's parser. Repeatedly interrupts parsing until
+ bitbake decides to deadlock.
+ """,
+ )
+
+ args = parser.parse_args()
+
+ if not "BUILDDIR" in os.environ:
+ print(
+ "'BUILDDIR' not found in the environment. Did you initialize the build environment?"
+ )
+ return 1
+
+ os.chdir(os.environ["BUILDDIR"])
+
+ run_num = 0
+ while True:
+ if run_num % 100 == 0:
+ print("Calibrating wait time...")
+ cleanup()
+
+ start_time = time.monotonic()
+ r = subprocess.run(["bitbake", "-p"])
+ max_wait_time = time.monotonic() - start_time
+
+ if r.returncode != 0:
+ print("Calibration run exited with %d" % r.returncode)
+ return 1
+
+ print("Maximum wait time is %f seconds" % max_wait_time)
+
+ run_num += 1
+ wait_time = random.random() * max_wait_time
+
+ print("Run #%d" % run_num)
+ print("Will sleep for %f seconds" % wait_time)
+
+ cleanup()
+ with subprocess.Popen(["bitbake", "-p"]) as proc:
+ time.sleep(wait_time)
+ proc.send_signal(signal.SIGINT)
+ try:
+ proc.wait(45)
+ except subprocess.TimeoutExpired:
+ print("Run #%d: Waited too long. Possible deadlock!" % run_num)
+ proc.wait()
+ return 1
+
+ if proc.returncode == 0:
+ print("Exited successfully. Timeout too long?")
+ else:
+ print("Exited with %d" % proc.returncode)
+
+
+if __name__ == "__main__":
+ sys.exit(main())
--
2.28.0
reply other threads:[~2020-09-09 22:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200909220901.29740-1-JPEWhacker@gmail.com \
--to=jpewhacker@gmail.com \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.