{"id":14854,"url":"https://patchwork.libcamera.org/api/1.1/patches/14854/?format=json","web_url":"https://patchwork.libcamera.org/patch/14854/","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-3-laurent.pinchart@ideasonboard.com>","date":"2021-11-30T01:23:03","name":"[libcamera-devel,v1,2/2] test: Replace \"/proc/self/exe\" with path to test binary","commit_ref":"59002a9e9d84417197999391c7d8c6af620fc1fb","pull_url":null,"state":"accepted","archived":false,"hash":"57b82b81a3a9f3c09d7f02870650ed92c615e53a","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/14854/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/14854/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14854/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 9AC05BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 01:23:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1AC86605AA;\n\tTue, 30 Nov 2021 02:23:37 +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 0B79C604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 02:23:34 +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 946C98F0\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=\"GLMjePnA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638235413;\n\tbh=8NY/Nj+qgC+tCMt8hZ/p1gGEX+qWcFCbWVmwxKntxYo=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=GLMjePnAS3b7Gpo8k20Nuh1ZHv+qHTtg4aW6BJK4gqjateK/DrHL3BL4dLjhaEuoH\n\tL+iuVALNAWg52AGDp3riL7X3SI5FYy3FywXBWM8s8E+8tWiSbZyrVG1mfW8DnSnZeU\n\tq/7Ggmjau1cvBw1hZWxnfc52pDkWYndz+UNUJI6w=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 30 Nov 2021 03:23:03 +0200","Message-Id":"<20211130012303.10574-3-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 2/2] test: Replace \"/proc/self/exe\"\n\twith path to test binary","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":"When tests are run under valgrind, /proc/self/exe points to valgrind,\nnot to the test binary. This results in failures for tests that need to\nfork processes. Fix it by replacing \"/proc/self/exe\" with the path to\nthe test binary.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/file.cpp                 | 4 ++--\n test/ipc/unixsocket.cpp       | 5 ++---\n test/ipc/unixsocket_ipc.cpp   | 2 +-\n test/log/log_process.cpp      | 2 +-\n test/process/process_test.cpp | 2 +-\n 5 files changed, 7 insertions(+), 8 deletions(-)","diff":"diff --git a/test/file.cpp b/test/file.cpp\nindex 9ac151c944b5..5c978ebfcada 100644\n--- a/test/file.cpp\n+++ b/test/file.cpp\n@@ -180,7 +180,7 @@ protected:\n \t\t}\n \n \t\t/* Test size(). */\n-\t\tfile.setFileName(\"/proc/self/exe\");\n+\t\tfile.setFileName(self());\n \n \t\tif (file.size() >= 0) {\n \t\t\tcerr << \"File has valid size before open\" << endl;\n@@ -277,7 +277,7 @@ protected:\n \t\tfile.close();\n \n \t\t/* Test mapping and unmapping. */\n-\t\tfile.setFileName(\"/proc/self/exe\");\n+\t\tfile.setFileName(self());\n \t\tfile.open(File::OpenModeFlag::ReadOnly);\n \n \t\tSpan<uint8_t> data = file.map();\ndiff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp\nindex 4fc1c10a2125..b3568c0684b0 100644\n--- a/test/ipc/unixsocket.cpp\n+++ b/test/ipc/unixsocket.cpp\n@@ -209,8 +209,7 @@ protected:\n \n \t\tif (!pid_) {\n \t\t\tstd::string arg = std::to_string(fd);\n-\t\t\texecl(\"/proc/self/exe\", \"/proc/self/exe\",\n-\t\t\t      arg.c_str(), nullptr);\n+\t\t\texecl(self().c_str(), self().c_str(), arg.c_str(), nullptr);\n \n \t\t\t/* Only get here if exec fails. */\n \t\t\texit(TestFail);\n@@ -464,7 +463,7 @@ private:\n \n \tint prepareFDs(IPCUnixSocket::Payload *message, unsigned int num)\n \t{\n-\t\tint fd = open(\"/proc/self/exe\", O_RDONLY);\n+\t\tint fd = open(self().c_str(), O_RDONLY);\n \t\tif (fd < 0)\n \t\t\treturn fd;\n \ndiff --git a/test/ipc/unixsocket_ipc.cpp b/test/ipc/unixsocket_ipc.cpp\nindex 2e3b52ca4d4b..1a8d06a12d5c 100644\n--- a/test/ipc/unixsocket_ipc.cpp\n+++ b/test/ipc/unixsocket_ipc.cpp\n@@ -173,7 +173,7 @@ protected:\n \n \tint run()\n \t{\n-\t\tipc_ = std::make_unique<IPCPipeUnixSocket>(\"\", \"/proc/self/exe\");\n+\t\tipc_ = std::make_unique<IPCPipeUnixSocket>(\"\", self().c_str());\n \t\tif (!ipc_->isConnected()) {\n \t\t\tcerr << \"Failed to create IPCPipe\" << endl;\n \t\t\treturn TestFail;\ndiff --git a/test/log/log_process.cpp b/test/log/log_process.cpp\nindex ca8351335f3a..2484c58f2fa9 100644\n--- a/test/log/log_process.cpp\n+++ b/test/log/log_process.cpp\n@@ -74,7 +74,7 @@ protected:\n \t\tvector<std::string> args;\n \t\targs.push_back(to_string(exitCode));\n \t\targs.push_back(to_string(num_));\n-\t\tint ret = proc_.start(\"/proc/self/exe\", args);\n+\t\tint ret = proc_.start(self(), args);\n \t\tif (ret) {\n \t\t\tcerr << \"failed to start process\" << endl;\n \t\t\treturn TestFail;\ndiff --git a/test/process/process_test.cpp b/test/process/process_test.cpp\nindex 96bea17f8dce..b410756b3288 100644\n--- a/test/process/process_test.cpp\n+++ b/test/process/process_test.cpp\n@@ -55,7 +55,7 @@ protected:\n \t\tproc_.kill();\n \n \t\t/* Test starting the process and retrieving the exit code. */\n-\t\tint ret = proc_.start(\"/proc/self/exe\", args);\n+\t\tint ret = proc_.start(self(), args);\n \t\tif (ret) {\n \t\t\tcerr << \"failed to start process\" << endl;\n \t\t\treturn TestFail;\n","prefixes":["libcamera-devel","v1","2/2"]}