Show a patch.

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

{
    "id": 1647,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/1647/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1647/",
    "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": "<20190710191708.13049-4-laurent.pinchart@ideasonboard.com>",
    "date": "2019-07-10T19:17:06",
    "name": "[libcamera-devel,4/6] test: Add Thread test cases",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "d50f2254174519fa2de84b39a2502d8c26195725",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/1647/mbox/",
    "series": [
        {
            "id": 414,
            "url": "https://patchwork.libcamera.org/api/1.1/series/414/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=414",
            "date": "2019-07-10T19:17:03",
            "name": "[libcamera-devel,1/6] libcamera: Add thread support",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/414/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1647/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1647/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "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 882BF6157B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Jul 2019 21:17:46 +0200 (CEST)",
            "from pendragon.ideasonboard.com (softbank126163157105.bbtec.net\n\t[126.163.157.105])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5E75354B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Jul 2019 21:17:45 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562786266;\n\tbh=nClxrVfSMwnbHVqa+iOoMRsPGU5WwfEC/3Y5sbTELjA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=G8ui7RpwGFkdAVs2gkFyuPceDu9wDI91B8VQdZg5jnSXxtVZbRp5k1h872jdYtzwX\n\tAg+NCYFmJ8ZjzvGwTk6SfcZPbbc61KQRLT1HzYqqDfl+V2Hg2tPNbHCAMk+zX274fc\n\tjudFnB4tn0XuUrmeH+T4LRBrQKsmzPid3cDnW3os=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 10 Jul 2019 22:17:06 +0300",
        "Message-Id": "<20190710191708.13049-4-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190710191708.13049-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20190710191708.13049-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 4/6] test: Add Thread test cases",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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>",
        "X-List-Received-Date": "Wed, 10 Jul 2019 19:17:46 -0000"
    },
    "content": "The Thread test case verifies that\n\n- a Thread instance is created for the main thread\n- a new Thread can be created, started, and stopped\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/meson.build |  1 +\n test/threads.cpp | 93 ++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 94 insertions(+)\n create mode 100644 test/threads.cpp",
    "diff": "diff --git a/test/meson.build b/test/meson.build\nindex 41b54ffd358c..bd0e0d98f0e7 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -21,6 +21,7 @@ public_tests = [\n \n internal_tests = [\n     ['camera-sensor',                   'camera-sensor.cpp'],\n+    ['threads',                         'threads.cpp'],\n ]\n \n foreach t : public_tests\ndiff --git a/test/threads.cpp b/test/threads.cpp\nnew file mode 100644\nindex 000000000000..9a2d39dfd106\n--- /dev/null\n+++ b/test/threads.cpp\n@@ -0,0 +1,93 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * threads.cpp - Threads test\n+ */\n+\n+#include <chrono>\n+#include <iostream>\n+#include <thread>\n+\n+#include \"thread.h\"\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class InstrumentedThread : public Thread\n+{\n+public:\n+\tInstrumentedThread(unsigned int iterations)\n+\t\t: iterations_(iterations)\n+\t{\n+\t}\n+\n+protected:\n+\tvoid run()\n+\t{\n+\t\tfor (unsigned int i = 0; i < iterations_; ++i) {\n+\t\t\tthis_thread::sleep_for(chrono::milliseconds(50));\n+\t\t}\n+\t}\n+\n+private:\n+\tunsigned int iterations_;\n+};\n+\n+class ThreadTest : public Test\n+{\n+protected:\n+\tint init()\n+\t{\n+\t\treturn 0;\n+\t}\n+\n+\tint run()\n+\t{\n+\t\t/* Test Thread() retrieval for the main thread. */\n+\t\tThread *thread = Thread::current();\n+\t\tif (!thread) {\n+\t\t\tcout << \"Thread::current() failed to main thread\"\n+\t\t\t     << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (!thread->isRunning()) {\n+\t\t\tcout << \"Main thread is not running\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test starting the main thread, the test shall not crash. */\n+\t\tthread->start();\n+\n+\t\t/* Test the running state of a custom thread. */\n+\t\tthread = new Thread();\n+\t\tthread->start();\n+\n+\t\tif (!thread->isRunning()) {\n+\t\t\tcout << \"Thread is not running after being started\"\n+\t\t\t     << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tthread->exit(0);\n+\t\tthread->wait();\n+\n+\t\tif (thread->isRunning()) {\n+\t\t\tcout << \"Thread is still running after finishing\"\n+\t\t\t     << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tdelete thread;\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tvoid cleanup()\n+\t{\n+\t}\n+};\n+\n+TEST_REGISTER(ThreadTest)\n",
    "prefixes": [
        "libcamera-devel",
        "4/6"
    ]
}