Patch Detail
Show a patch.
GET /api/patches/8998/?format=api
{ "id": 8998, "url": "https://patchwork.libcamera.org/api/patches/8998/?format=api", "web_url": "https://patchwork.libcamera.org/patch/8998/", "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": "<20200725122442.1679820-3-vicamo.yang@canonical.com>", "date": "2020-07-25T12:24:41", "name": "[libcamera-devel,2/3] test: log/process: check CAP_SYS_ADMIN in test init", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "a0eae6774c6853adf0db337a0ee261377bd40efd", "submitter": { "id": 61, "url": "https://patchwork.libcamera.org/api/people/61/?format=api", "name": "You-Sheng Yang", "email": "vicamo.yang@canonical.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/8998/mbox/", "series": [ { "id": 1145, "url": "https://patchwork.libcamera.org/api/series/1145/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1145", "date": "2020-07-25T12:24:39", "name": "fix test failures in package build systems", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1145/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/8998/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/8998/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 20BCEBD878\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 25 Jul 2020 13:03:30 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B586D61392;\n\tSat, 25 Jul 2020 15:03:28 +0200 (CEST)", "from mail-pl1-f195.google.com (mail-pl1-f195.google.com\n\t[209.85.214.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5DAC561247\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 25 Jul 2020 14:24:52 +0200 (CEST)", "by mail-pl1-f195.google.com with SMTP id k4so5897073pld.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 25 Jul 2020 05:24:52 -0700 (PDT)", "from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37])\n\tby smtp.gmail.com with ESMTPSA id\n\tq24sm9479757pfg.95.2020.07.25.05.24.49\n\tfor <libcamera-devel@lists.libcamera.org>\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 25 Jul 2020 05:24:49 -0700 (PDT)" ], "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=ozfoK3uawtbjSmM8oTXxM7sgf8Ans2dye0VC8eogObo=;\n\tb=DtsR2lBZdbHjeJ5eQEM8SBfXhkAbxlgGLjUqD2hus5gx/gsvCjcF5FTKFJ6fFBoUFG\n\twvBpHi4g5KLWb+MukaZFUzqBphdSInBkrRaWZfQiioPP/IZPCkamC4FoD77/CDyP8l3/\n\tfwJaPgkABd2tnTX3mm3GiM3pQgeSciqCWJaBtikzVgTR/uXXB0jPlTcvv9+bA1p6GNWv\n\tlnOd/L5VQeKTe37bZEf2FUhxyHEWMZg+RzKhFKVLT1ej+qyJZtnLshEOPxROVcNahSGj\n\tLQuSdHvpHyUit1ZSU/E7rx1czZgb0r8sgCLSFvdZJUVQ3cFHTRuZWKrxYYEFXq/nfJxl\n\t0Keg==", "X-Gm-Message-State": "AOAM531YaDHdqm+h9pJ60N9RtFhjun78Y2f/cEmEqbp41kBM2TyCkxFW\n\tVdHFopIqFNre62Zc0z6pP/2d9fEd5nI=", "X-Google-Smtp-Source": "ABdhPJxUYEFlWO0YXnDFtTrZ9KtyFguDArp/wrQPEVSBw3i6uds1hmad/TDYfSf9qrR7yJ7vF8eW7A==", "X-Received": "by 2002:a17:902:7e01:: with SMTP id\n\tb1mr12317419plm.310.1595679890537; \n\tSat, 25 Jul 2020 05:24:50 -0700 (PDT)", "From": "You-Sheng Yang <vicamo.yang@canonical.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 25 Jul 2020 20:24:41 +0800", "Message-Id": "<20200725122442.1679820-3-vicamo.yang@canonical.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200725122442.1679820-1-vicamo.yang@canonical.com>", "References": "<20200725122442.1679820-1-vicamo.yang@canonical.com>", "MIME-Version": "1.0", "X-Mailman-Approved-At": "Sat, 25 Jul 2020 15:03:26 +0200", "Subject": "[libcamera-devel] [PATCH 2/3] test: log/process: check\n\tCAP_SYS_ADMIN in test init", "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>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "While these tests may be executed as normal user at build time,\nunshare() call will fail and so are tests log_process and process_test.\nThis change checks if one is granted with necessary capabilities so that\nwe don't fail the build unexpectedly.\n\nSigned-off-by: You-Sheng Yang <vicamo.yang@canonical.com>\n---\n test/log/log_process.cpp | 20 ++++++++++++++++++++\n test/log/meson.build | 2 +-\n test/meson.build | 2 ++\n test/process/meson.build | 2 +-\n test/process/process_test.cpp | 23 +++++++++++++++++++++++\n 5 files changed, 47 insertions(+), 2 deletions(-)", "diff": "diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp\nindex d46d5e3..876da22 100644\n--- a/test/log/log_process.cpp\n+++ b/test/log/log_process.cpp\n@@ -9,6 +9,7 @@\n #include <iostream>\n #include <random>\n #include <string.h>\n+#include <sys/capability.h>\n #include <sys/stat.h>\n #include <sys/types.h>\n #include <unistd.h>\n@@ -55,6 +56,25 @@ class LogProcessTest : public Test\n protected:\n \tint init()\n \t{\n+\t\tint ret = TestPass;\n+\n+\t\tcap_t caps = cap_get_proc();\n+\t\tif (caps == NULL) {\n+\t\t\tcerr << \"failed to check process capabilities\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Check required permissions: CAP_SYS_ADMIN: unshare */\n+\t\tcap_flag_value_t fv;\n+\t\tif ((cap_get_flag(caps, CAP_SYS_ADMIN, CAP_EFFECTIVE, &fv) < 0) || (fv != CAP_SET)) {\n+\t\t\tcerr << \"skip due to insufficient capability\" << endl;\n+\t\t\tret = TestSkip;\n+\t\t}\n+\n+\t\tcap_free(caps);\n+\t\tif (ret != TestPass)\n+\t\t\treturn ret;\n+\n \t\trandom_device random;\n \t\tnum_ = random();\n \t\tlogPath_ = \"/tmp/libcamera.worker.test.\" +\ndiff --git a/test/log/meson.build b/test/log/meson.build\nindex 8cd664e..000f980 100644\n--- a/test/log/meson.build\n+++ b/test/log/meson.build\n@@ -7,7 +7,7 @@ log_test = [\n \n foreach t : log_test\n exe = executable(t[0], t[1],\n- dependencies : libcamera_dep,\n+ dependencies : [libcamera_dep, libcap],\n link_with : test_libraries,\n include_directories : test_includes_internal)\n \ndiff --git a/test/meson.build b/test/meson.build\nindex f41d6e7..b4db328 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -1,5 +1,7 @@\n # SPDX-License-Identifier: CC0-1.0\n \n+libcap = dependency('libcap', required : true)\n+\n subdir('libtest')\n \n subdir('camera')\ndiff --git a/test/process/meson.build b/test/process/meson.build\nindex c215fa7..828c17b 100644\n--- a/test/process/meson.build\n+++ b/test/process/meson.build\n@@ -6,7 +6,7 @@ process_tests = [\n \n foreach t : process_tests\n exe = executable(t[0], t[1],\n- dependencies : libcamera_dep,\n+ dependencies : [libcamera_dep, libcap],\n link_with : test_libraries,\n include_directories : test_includes_internal)\n \ndiff --git a/test/process/process_test.cpp b/test/process/process_test.cpp\nindex ce0cc7c..ffa2143 100644\n--- a/test/process/process_test.cpp\n+++ b/test/process/process_test.cpp\n@@ -5,6 +5,8 @@\n * process_test.cpp - Process test\n */\n \n+#include <sys/capability.h>\n+\n #include <iostream>\n #include <unistd.h>\n #include <vector>\n@@ -41,6 +43,27 @@ public:\n \t}\n \n protected:\n+\tint init()\n+\t{\n+\t\tint ret = TestPass;\n+\n+\t\tcap_t caps = cap_get_proc();\n+\t\tif (caps == NULL) {\n+\t\t\tcerr << \"failed to check process capabilities\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Check required permissions: CAP_SYS_ADMIN: unshare */\n+\t\tcap_flag_value_t fv;\n+\t\tif ((cap_get_flag(caps, CAP_SYS_ADMIN, CAP_EFFECTIVE, &fv) < 0) || (fv != CAP_SET)) {\n+\t\t\tcerr << \"skip due to insufficient capability\" << endl;\n+\t\t\tret = TestSkip;\n+\t\t}\n+\n+\t\tcap_free(caps);\n+\t\treturn ret;\n+\t}\n+\n \tint run()\n \t{\n \t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n", "prefixes": [ "libcamera-devel", "2/3" ] }