{"id":14853,"url":"https://patchwork.libcamera.org/api/1.1/patches/14853/?format=json","web_url":"https://patchwork.libcamera.org/patch/14853/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211130012303.10574-2-laurent.pinchart@ideasonboard.com>","date":"2021-11-30T01:23:02","name":"[libcamera-devel,v1,1/2] test: Store path to the test executable in Test class","commit_ref":"b24d9c4413b9d7f55f4105adeb7cf9a2450d3204","pull_url":null,"state":"accepted","archived":false,"hash":"f2ba6aaadd4e1c8b1068a92f63bd438600c2b3ae","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14853/mbox/","series":[{"id":2775,"url":"https://patchwork.libcamera.org/api/1.1/series/2775/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2775","date":"2021-11-30T01:23:01","name":"libcamera: Fix valgrind usage with tests that fork process","version":1,"mbox":"https://patchwork.libcamera.org/series/2775/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14853/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14853/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6D0EDBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 01:23:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 25927605B6;\n\tTue, 30 Nov 2021 02:23:36 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8B91A604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 02:23:33 +0100 (CET)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 333A593\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 02:23:33 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"nM/MPoJl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638235413;\n\tbh=K1tJ6XN5vrLXFt1ohWaTt5kneyz8VAJqM80uvTAIPO4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=nM/MPoJlCyME4KolAhbOiAgtAvI6mKHk6mlYPfV5f5CgXuX72jEs2ZNdmcIkEzcw/\n\t7/cZAJndvcwCXFMgEsjMGgWnS7uEGkS7pS0Md2at+UGbPnSlAX6dd1PTgNrUWKgm5o\n\tBPVo8VfQ8epupVPhTEiyNvuquVqJIiDx8cYa4k0w=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 30 Nov 2021 03:23:02 +0200","Message-Id":"<20211130012303.10574-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20211130012303.10574-1-laurent.pinchart@ideasonboard.com>","References":"<20211130012303.10574-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 1/2] test: Store path to the test\n\texecutable in Test class","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Store the path to the test executable, found in argv[0], in the Test\ninstance. This can be useful for tests that need to fork processes.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/ipc/unixsocket.cpp       |  4 +++-\n test/ipc/unixsocket_ipc.cpp   |  4 +++-\n test/libtest/test.cpp         |  5 +++++\n test/libtest/test.h           | 15 ++++++++++++---\n test/log/log_process.cpp      |  4 +++-\n test/process/process_test.cpp |  5 +++--\n 6 files changed, 29 insertions(+), 8 deletions(-)","diff":"diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp\nindex 7270bf4d2fe7..4fc1c10a2125 100644\n--- a/test/ipc/unixsocket.cpp\n+++ b/test/ipc/unixsocket.cpp\n@@ -501,5 +501,7 @@ int main(int argc, char **argv)\n \t\treturn slave.run(ipcfd);\n \t}\n \n-\treturn UnixSocketTest().execute();\n+\tUnixSocketTest test;\n+\ttest.setArgs(argc, argv);\n+\treturn test.execute();\n }\ndiff --git a/test/ipc/unixsocket_ipc.cpp b/test/ipc/unixsocket_ipc.cpp\nindex ab5d25572d83..2e3b52ca4d4b 100644\n--- a/test/ipc/unixsocket_ipc.cpp\n+++ b/test/ipc/unixsocket_ipc.cpp\n@@ -227,5 +227,7 @@ int main(int argc, char **argv)\n \t\treturn slave.run(ipcfd);\n \t}\n \n-\treturn UnixSocketTestIPC().execute();\n+\tUnixSocketTestIPC test;\n+\ttest.setArgs(argc, argv);\n+\treturn test.execute();\n }\ndiff --git a/test/libtest/test.cpp b/test/libtest/test.cpp\nindex fd9f3d74d6ce..af37b4dd28ff 100644\n--- a/test/libtest/test.cpp\n+++ b/test/libtest/test.cpp\n@@ -17,6 +17,11 @@ Test::~Test()\n {\n }\n \n+void Test::setArgs([[maybe_unused]] int argc, char *argv[])\n+{\n+\tself_ = argv[0];\n+}\n+\n int Test::execute()\n {\n \tint ret;\ndiff --git a/test/libtest/test.h b/test/libtest/test.h\nindex ee01a22591f8..23b07743fd2a 100644\n--- a/test/libtest/test.h\n+++ b/test/libtest/test.h\n@@ -8,6 +8,7 @@\n #pragma once\n \n #include <sstream>\n+#include <string>\n \n enum TestStatus {\n \tTestPass = 0,\n@@ -21,16 +22,24 @@ public:\n \tTest();\n \tvirtual ~Test();\n \n+\tvoid setArgs(int argc, char *argv[]);\n \tint execute();\n \n+\tconst std::string &self() const { return self_; }\n+\n protected:\n \tvirtual int init() { return 0; }\n \tvirtual int run() = 0;\n \tvirtual void cleanup() {}\n+\n+private:\n+\tstd::string self_;\n };\n \n-#define TEST_REGISTER(klass)\t\t\t\t\t\t\\\n-int main([[maybe_unused]] int argc, [[maybe_unused]] char *argv[])\t\\\n+#define TEST_REGISTER(Klass)\t\t\t\t\t\t\\\n+int main(int argc, char *argv[])\t\t\t\t\t\\\n {\t\t\t\t\t\t\t\t\t\\\n-\treturn klass().execute();\t\t\t\t\t\\\n+\tKlass klass;\t\t\t\t\t\t\t\\\n+\tklass.setArgs(argc, argv);\t\t\t\t\t\\\n+\treturn klass.execute();\t\t\t\t\t\t\\\n }\ndiff --git a/test/log/log_process.cpp b/test/log/log_process.cpp\nindex a56a399848a7..ca8351335f3a 100644\n--- a/test/log/log_process.cpp\n+++ b/test/log/log_process.cpp\n@@ -154,5 +154,7 @@ int main(int argc, char **argv)\n \t\treturn child.run(status, num);\n \t}\n \n-\treturn LogProcessTest().execute();\n+\tLogProcessTest test;\n+\ttest.setArgs(argc, argv);\n+\treturn test.execute();\n }\ndiff --git a/test/process/process_test.cpp b/test/process/process_test.cpp\nindex 378d680bf4ef..96bea17f8dce 100644\n--- a/test/process/process_test.cpp\n+++ b/test/process/process_test.cpp\n@@ -9,7 +9,6 @@\n #include <unistd.h>\n #include <vector>\n \n-\n #include <libcamera/base/event_dispatcher.h>\n #include <libcamera/base/thread.h>\n #include <libcamera/base/timer.h>\n@@ -106,5 +105,7 @@ int main(int argc, char **argv)\n \t\treturn child.run(status);\n \t}\n \n-\treturn ProcessTest().execute();\n+\tProcessTest test;\n+\ttest.setArgs(argc, argv);\n+\treturn test.execute();\n }\n","prefixes":["libcamera-devel","v1","1/2"]}