Show a patch.

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

{
    "id": 12751,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/12751/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12751/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20210629151218.248650-6-nfraprado@collabora.com>",
    "date": "2021-06-29T15:12:18",
    "name": "[libcamera-devel,v10,5/5] lc-compliance: Add list and filter parameters",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "9dd192354cc6efe61b1d88578d3200d6ddb16d82",
    "submitter": {
        "id": 84,
        "url": "https://patchwork.libcamera.org/api/1.1/people/84/?format=api",
        "name": "Nícolas F. R. A. Prado",
        "email": "nfraprado@collabora.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/12751/mbox/",
    "series": [
        {
            "id": 2192,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2192/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2192",
            "date": "2021-06-29T15:12:13",
            "name": "lc-compliance: Refactor using Googletest",
            "version": 10,
            "mbox": "https://patchwork.libcamera.org/series/2192/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12751/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12751/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 82366C321F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Jun 2021 15:13:17 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 49B60684EE;\n\tTue, 29 Jun 2021 17:13:17 +0200 (CEST)",
            "from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 29836684F1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Jun 2021 17:13:16 +0200 (CEST)",
            "from localhost.localdomain (unknown\n\t[IPv6:2804:14c:1a9:2434:bd70:78a1:919c:f01a])\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 7DED01F43084;\n\tTue, 29 Jun 2021 16:13:14 +0100 (BST)"
        ],
        "From": "=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 29 Jun 2021 12:12:18 -0300",
        "Message-Id": "<20210629151218.248650-6-nfraprado@collabora.com>",
        "X-Mailer": "git-send-email 2.32.0",
        "In-Reply-To": "<20210629151218.248650-1-nfraprado@collabora.com>",
        "References": "<20210629151218.248650-1-nfraprado@collabora.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v10 5/5] lc-compliance: Add list and\n\tfilter parameters",
        "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>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nChanges in v10:\n- Thanks to Jacopo:\n  - Fixed some code style issues\n  - Stopped calling CameraManager::stop() in the path it didn't start()\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 | 78 ++++++++++++++++++++++++++++++++++++--\n 1 file changed, 74 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/src/lc-compliance/main.cpp b/src/lc-compliance/main.cpp\nindex ff14474c6425..7eb52ae4c094 100644\n--- a/src/lc-compliance/main.cpp\n+++ b/src/lc-compliance/main.cpp\n@@ -21,6 +21,8 @@ using namespace libcamera;\n \n enum {\n \tOptCamera = 'c',\n+\tOptList = 'l',\n+\tOptFilter = 'f',\n \tOptHelp = 'h',\n };\n \n@@ -77,12 +79,72 @@ 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+\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@@ -92,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@@ -109,15 +173,21 @@ 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+\tif (!options.isSet(OptList))\n+\t\tcm->stop();\n \n \treturn ret;\n }\n",
    "prefixes": [
        "libcamera-devel",
        "v10",
        "5/5"
    ]
}