{"id":288,"url":"https://patchwork.libcamera.org/api/patches/288/?format=json","web_url":"https://patchwork.libcamera.org/patch/288/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20190121102826.16873-1-kieran.bingham@ideasonboard.com>","date":"2019-01-21T10:28:26","name":"[libcamera-devel] test: v4l2_device: Provide compile time assertions","commit_ref":null,"pull_url":null,"state":"rejected","archived":false,"hash":"b67087978a2a8c99269360b44574ae246f4d1f87","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/288/mbox/","series":[{"id":98,"url":"https://patchwork.libcamera.org/api/series/98/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=98","date":"2019-01-21T10:28:26","name":"[libcamera-devel] test: v4l2_device: Provide compile time assertions","version":1,"mbox":"https://patchwork.libcamera.org/series/98/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/288/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/288/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61F0760C65\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jan 2019 11:28:30 +0100 (CET)","from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E452A53E;\n\tMon, 21 Jan 2019 11:28:29 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548066510;\n\tbh=JHBL8agOBjf75kkRwMWqQemOdK3eSnvIUISAV1XL95I=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=Tie3NFIVosxkzI0S0IYnY0igFr6T8rpjh8OLIlx8OTVqdcXh8xF5mShDopi56+QRB\n\tIc2IEuRdqFmsbA0qGLw9JDepc9iRyfH56+6lTmEPRTBTf9gSoy8W9VAitAWANYMd3Z\n\tqIJGhFw0cwFC9G6XAnvGpdJ/yJIdVN1eoY2KC160=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Date":"Mon, 21 Jan 2019 10:28:26 +0000","Message-Id":"<20190121102826.16873-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.17.1","Subject":"[libcamera-devel] [PATCH] test: v4l2_device: Provide compile time\n\tassertions","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":"Mon, 21 Jan 2019 10:28:30 -0000"},"content":"The V4L2Capability structure is inherited from struct v4l2_capability only\nto provide an interface. It must not extend the type or data.\n\nEnforce this with a static assertion with sizeof() comparisons.\n\nThere is no need here for a specific test binary which will always return\nTEST_PASS when compiled, as this test failure will be caught at compile time.\nIn light of this - the static compile time assertion is added to the\nV4L2DeviceTest base class.\n\nShould there be a large number of static assertions required, they could be\nmoved to their own unit for clarity.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n test/v4l2_device/v4l2_device_test.cpp | 6 ++++++\n 1 file changed, 6 insertions(+)","diff":"diff --git a/test/v4l2_device/v4l2_device_test.cpp b/test/v4l2_device/v4l2_device_test.cpp\nindex 362553712caa..97876f8d65db 100644\n--- a/test/v4l2_device/v4l2_device_test.cpp\n+++ b/test/v4l2_device/v4l2_device_test.cpp\n@@ -5,6 +5,7 @@\n  * libcamera V4L2 API tests\n  */\n \n+#include <assert.h>\n #include <iostream>\n #include <sys/stat.h>\n \n@@ -41,3 +42,8 @@ void V4L2DeviceTest::cleanup()\n {\n \tdelete dev_;\n };\n+\n+/* Static compile time assertion tests */\n+\n+static_assert(sizeof(struct v4l2_capability) == sizeof(struct V4L2Capability),\n+\t      \"V4L2Capability must match v4l2_capability size\");\n","prefixes":["libcamera-devel"]}