Show a patch.

GET /api/patches/12714/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 12714,
    "url": "https://patchwork.libcamera.org/api/patches/12714/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12714/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20210625193925.517406-6-nfraprado@collabora.com>",
    "date": "2021-06-25T19:39:25",
    "name": "[libcamera-devel,v9,5/5] lc-compliance: Add list and filter parameters",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "8be8a16bf3a7e1496dc1962ff2c049566900f25a",
    "submitter": {
        "id": 84,
        "url": "https://patchwork.libcamera.org/api/people/84/?format=api",
        "name": "Nícolas F. R. A. Prado",
        "email": "nfraprado@collabora.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/12714/mbox/",
    "series": [
        {
            "id": 2177,
            "url": "https://patchwork.libcamera.org/api/series/2177/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2177",
            "date": "2021-06-25T19:39:20",
            "name": "lc-compliance: Refactor using Googletest",
            "version": 9,
            "mbox": "https://patchwork.libcamera.org/series/2177/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12714/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12714/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 18FAFC321A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Jun 2021 19:40:04 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D58F6684D9;\n\tFri, 25 Jun 2021 21:40:03 +0200 (CEST)",
            "from bhuna.collabora.co.uk (bhuna.collabora.co.uk\n\t[IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E789F684CA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jun 2021 21:40:02 +0200 (CEST)",
            "from localhost.localdomain (unknown\n\t[IPv6:2804:14c:1a9:2434:51f6:da24:ae79:702d])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits))\n\t(No client certificate requested) (Authenticated sender: nfraprado)\n\tby bhuna.collabora.co.uk (Postfix) with ESMTPSA id A928F1F4486D;\n\tFri, 25 Jun 2021 20:40:00 +0100 (BST)"
        ],
        "From": "=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 25 Jun 2021 16:39:25 -0300",
        "Message-Id": "<20210625193925.517406-6-nfraprado@collabora.com>",
        "X-Mailer": "git-send-email 2.32.0",
        "In-Reply-To": "<20210625193925.517406-1-nfraprado@collabora.com>",
        "References": "<20210625193925.517406-1-nfraprado@collabora.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v9 5/5] lc-compliance: Add list and filter\n\tparameters",
        "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>",
        "Cc": "kernel@collabora.com, =?utf-8?q?Andr=C3=A9_Almeida?=\n\t<andrealmeid@collabora.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add a --list parameter that lists all current tests (by mapping to\ngoogletest's --gtest_list_tests).\n\nAdd a --filter 'filterString' parameter that filters the tests to run\n(by mapping to googletest's --gtest_filter).\n\nWhile at it, add to the help message that further googletest options can\nbe passed through the environment.\n\nSigned-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\nChanges in v9:\n- Thanks to Jacopo:\n  - Fixed some style issues\n  - Added to --help that further Googletest options can be passed as environment\n    variables\n- Thanks to Paul:\n  - Fixed compiling error on clang\n\nChanges in v8:\n- Thanks to Kieran:\n  - Switched from malloc/free to new/delete in gtest parameter allocation\n\nChanges in v7:\n- Thanks to Niklas:\n  - Removed intermediary filter string variable in Harness::initGtestParameters()\n\nChanges in v6:\n- Thanks to Niklas:\n  - Changed buildGtestParameters() into initGtestParameters() and removed the\n    need for Harness::gtestArgc_ and Harness::gtestArgv_\n\nChanges in v5:\n- Thanks to Niklas:\n  - Moved buildGtestParameters() inside run()\n\nNo changes in v4\n\n src/lc-compliance/main.cpp | 76 ++++++++++++++++++++++++++++++++++++--\n 1 file changed, 73 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/src/lc-compliance/main.cpp b/src/lc-compliance/main.cpp\nindex b01768b5fc0b..45ec70351f2c 100644\n--- a/src/lc-compliance/main.cpp\n+++ b/src/lc-compliance/main.cpp\n@@ -20,6 +20,8 @@ using namespace libcamera;\n \n enum {\n \tOptCamera = 'c',\n+\tOptList = 'l',\n+\tOptFilter = 'f',\n \tOptHelp = 'h',\n };\n \n@@ -76,12 +78,73 @@ static int initCamera(CameraManager *cm, OptionsParser::Options options)\n \treturn 0;\n }\n \n+static int initGtestParameters(char *arg0, OptionsParser::Options options)\n+{\n+\tconst std::map<std::string, std::string> gtestFlags = { { \"list\", \"--gtest_list_tests\" },\n+\t\t\t\t\t\t\t\t{ \"filter\", \"--gtest_filter\" } };\n+\n+\tint argc = 0;\n+\tstd::string filterParam;\n+\n+\t/*\n+\t * +2 to have space for both the 0th argument that is needed but not\n+\t * used and the null at the end.\n+\t */\n+\tchar **argv = new char *[(gtestFlags.size() + 2)];\n+\n+\tif (!argv)\n+\t\treturn -ENOMEM;\n+\n+\targv[0] = arg0;\n+\targc++;\n+\n+\tif (options.isSet(OptList)) {\n+\t\targv[argc] = const_cast<char *>(gtestFlags.at(\"list\").c_str());\n+\t\targc++;\n+\t}\n+\n+\tif (options.isSet(OptFilter)) {\n+\t\t/*\n+\t\t * The filter flag needs to be passed as a single parameter, in\n+\t\t * the format --gtest_filter=filterStr\n+\t\t */\n+\t\tfilterParam = gtestFlags.at(\"filter\") + \"=\" +\n+\t\t\t      static_cast<const std::string &>(options[OptFilter]);\n+\n+\t\targv[argc] = const_cast<char *>(filterParam.c_str());\n+\t\targc++;\n+\t}\n+\n+\targv[argc] = nullptr;\n+\n+\t::testing::InitGoogleTest(&argc, argv);\n+\n+\tdelete[] argv;\n+\n+\treturn 0;\n+}\n+\n+static int initGtest(char *arg0, OptionsParser::Options options)\n+{\n+\tint ret = initGtestParameters(arg0, options);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\ttesting::UnitTest::GetInstance()->listeners().Append(new ThrowListener);\n+\n+\treturn 0;\n+}\n+\n static int parseOptions(int argc, char **argv, OptionsParser::Options *options)\n {\n \tOptionsParser parser;\n \tparser.addOption(OptCamera, OptionString,\n \t\t\t \"Specify which camera to operate on, by id\", \"camera\",\n \t\t\t ArgumentRequired, \"camera\");\n+\tparser.addOption(OptList, OptionNone, \"List all tests and exit\", \"list\");\n+\tparser.addOption(OptFilter, OptionString,\n+\t\t\t \"Specify which tests to run\", \"filter\",\n+\t\t\t ArgumentRequired, \"filter\");\n \tparser.addOption(OptHelp, OptionNone, \"Display this help message\",\n \t\t\t \"help\");\n \n@@ -91,6 +154,8 @@ static int parseOptions(int argc, char **argv, OptionsParser::Options *options)\n \n \tif (options->isSet(OptHelp)) {\n \t\tparser.usage();\n+\t\tstd::cerr << \"Further options from Googletest can be passed as environment variables\"\n+\t\t\t  << std::endl;\n \t\treturn -EINTR;\n \t}\n \n@@ -108,12 +173,17 @@ int main(int argc, char **argv)\n \n \tstd::unique_ptr<CameraManager> cm = std::make_unique<CameraManager>();\n \n-\tret = initCamera(cm.get(), options);\n+\t/* No need to initialize the camera if we'll just list tests */\n+\tif (!options.isSet(OptList)) {\n+\t\tret = initCamera(cm.get(), options);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n+\tret = initGtest(argv[0], options);\n \tif (ret)\n \t\treturn ret;\n \n-\ttesting::UnitTest::GetInstance()->listeners().Append(new ThrowListener);\n-\n \tret = RUN_ALL_TESTS();\n \n \tcm->stop();\n",
    "prefixes": [
        "libcamera-devel",
        "v9",
        "5/5"
    ]
}