[libcamera-devel] [PATCH] test: process: Test Process::kill()
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon Jul 27 14:53:17 CEST 2020
Add a test to ensure that Process::kill() on an unstarted process is
safe. This aims at ensuring we don't kill other processes unexpectedly.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
test/process/process_test.cpp | 4 ++++
1 file changed, 4 insertions(+)
If you want to try this at home *without* the corresponding fix to the
Process class ("libcamera: process: Fix killing innocent processes
unexpectedly"), make sure to save all your work first. It's a very
effective implementation of an ejection seat.
diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp
index ce0cc7c972cd..721a7c9d46ff 100644
--- a/test/process/process_test.cpp
+++ b/test/process/process_test.cpp
@@ -51,6 +51,10 @@ protected:
args.push_back(to_string(exitCode));
proc_.finished.connect(this, &ProcessTest::procFinished);
+ /* Test that kill() on an unstarted process is safe. */
+ proc_.kill();
+
+ /* Test starting the process and retrieving the exit code. */
int ret = proc_.start("/proc/self/exe", args);
if (ret) {
cerr << "failed to start process" << endl;
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list