From: Anders Heimer <anders.heimer@est.tech>
To: openembedded-core@lists.openembedded.org
Cc: Anders Heimer <anders.heimer@est.tech>,
Daniel Turull <daniel.turull@ericsson.com>
Subject: [PATCH 2/9] oeqa/oelib: add runcmd tests
Date: Tue, 23 Jun 2026 15:35:14 +0200 [thread overview]
Message-ID: <20260623133521.17053-3-anders.heimer@est.tech> (raw)
In-Reply-To: <20260623133521.17053-1-anders.heimer@est.tech>
Cover literal argv handling, explicit shell use, subprocess exit
status, and exec failure wrapping.
AI-Generated: Claude Opus 4.6
Reviewed-by: Daniel Turull <daniel.turull@ericsson.com>
Signed-off-by: Anders Heimer <anders.heimer@est.tech>
---
meta/lib/oeqa/selftest/cases/oelib/patch.py | 45 +++++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 meta/lib/oeqa/selftest/cases/oelib/patch.py
diff --git a/meta/lib/oeqa/selftest/cases/oelib/patch.py b/meta/lib/oeqa/selftest/cases/oelib/patch.py
new file mode 100644
index 0000000000..4cbfef4ce6
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/oelib/patch.py
@@ -0,0 +1,45 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+import sys
+from unittest.case import TestCase
+
+import oe.patch
+
+
+class TestRunCmd(TestCase):
+ def test_runcmd_preserves_argv_elements(self):
+ output = oe.patch.runcmd([
+ sys.executable,
+ "-c",
+ "import sys; print(sys.argv[1])",
+ "value with spaces;$(false)*",
+ ])
+ self.assertEqual(output, "value with spaces;$(false)*\n")
+
+ def test_runcmd_allows_explicit_shell(self):
+ output = oe.patch.runcmd([
+ "sh", "-c", 'printf "%s" "$1"', "sh", "shell value",
+ ])
+ self.assertEqual(output, "shell value")
+
+ def test_runcmd_reports_exit_status(self):
+ with self.assertRaises(oe.patch.CmdError) as ctx:
+ oe.patch.runcmd([
+ sys.executable,
+ "-c",
+ "raise SystemExit(7)",
+ ])
+
+ self.assertEqual(ctx.exception.status, 7)
+
+ def test_runcmd_wraps_exec_failure(self):
+ with self.assertRaises(oe.patch.CmdError) as ctx:
+ oe.patch.runcmd([
+ "/definitely-not-an-existing-executable",
+ ])
+
+ self.assertEqual(ctx.exception.status, 127)
next prev parent reply other threads:[~2026-06-23 13:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 13:35 [PATCH 0/9] oe/patch: execute patch commands without an implicit shell Anders Heimer
2026-06-23 13:35 ` [PATCH 1/9] oe/patch: drop shell=True from runcmd Anders Heimer
2026-06-23 13:35 ` Anders Heimer [this message]
2026-06-23 13:35 ` [PATCH 3/9] oe/patch: convert simple runcmd shell callers Anders Heimer
2026-06-23 13:35 ` [PATCH 4/9] oe/patch: avoid shell pipeline in _applypatch Anders Heimer
2026-06-23 13:35 ` [PATCH 5/9] oe/patch: remove obsolete PATCHFILE assignment Anders Heimer
2026-06-23 13:35 ` [PATCH 6/9] oeqa/oelib: test GitApplyTree patch names Anders Heimer
2026-06-23 13:35 ` [PATCH 7/9] oe/patch: pass GitApplyTree commands as argv lists Anders Heimer
2026-06-23 13:35 ` [PATCH 8/9] oe/patch: return manual-resolution " Anders Heimer
2026-06-23 13:35 ` [PATCH 9/9] oeqa/oelib: test patch command argv handling Anders Heimer
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=20260623133521.17053-3-anders.heimer@est.tech \
--to=anders.heimer@est.tech \
--cc=daniel.turull@ericsson.com \
--cc=openembedded-core@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox