[{"id":59,"web_url":"https://patchwork.libcamera.org/comment/59/","msgid":"<20181220185320.GD19959@bigcity.dyn.berto.se>","date":"2018-12-20T18:53:20","subject":"Re: [libcamera-devel] [PATCH] tests: Add a base Test class","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2018-12-19 11:48:30 +0200, Laurent Pinchart wrote:\n> The base Test class is meant to provide infrastructure common to all\n> tests. It is very limited for now, and should be extended with at least\n> logging and assertion handling.\n\nI agree it's a bit limited now but can serve as a good base to build \nupon. I have used this to write tests for device enumerator work.\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  test/meson.build |  6 ++++++\n>  test/test.cpp    | 28 ++++++++++++++++++++++++++++\n>  test/test.h      | 28 ++++++++++++++++++++++++++++\n>  3 files changed, 62 insertions(+)\n>  create mode 100644 test/test.cpp\n>  create mode 100644 test/test.h\n> \n> diff --git a/test/meson.build b/test/meson.build\n> index 24d1927f977c..fc9c124927d2 100644\n> --- a/test/meson.build\n> +++ b/test/meson.build\n> @@ -1,3 +1,9 @@\n> +libtest_sources = files([\n> +    'test.cpp',\n> +])\n> +\n> +libtest = static_library('libtest', libtest_sources)\n> +\n>  test_init = executable('test_init', 'init.cpp',\n>                         link_with : libcamera,\n>                         include_directories : libcamera_includes)\n> diff --git a/test/test.cpp b/test/test.cpp\n> new file mode 100644\n> index 000000000000..4e7779e750d5\n> --- /dev/null\n> +++ b/test/test.cpp\n> @@ -0,0 +1,28 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2018, Google Inc.\n> + *\n> + * test.cpp - libcamera test base class\n> + */\n> +\n> +#include \"test.h\"\n> +\n> +Test::Test()\n> +{\n> +}\n> +\n> +Test::~Test()\n> +{\n> +\tcleanup();\n> +}\n> +\n> +int Test::execute()\n> +{\n> +\tint ret;\n> +\n> +\tret = init();\n> +\tif (ret < 0)\n> +\t\treturn ret;\n> +\n> +\treturn run();\n> +}\n> diff --git a/test/test.h b/test/test.h\n> new file mode 100644\n> index 000000000000..2464fc5cb607\n> --- /dev/null\n> +++ b/test/test.h\n> @@ -0,0 +1,28 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2018, Google Inc.\n> + *\n> + * test.h - libcamera test base class\n> + */\n> +\n> +#include <sstream>\n> +\n> +class Test\n> +{\n> +public:\n> +\tTest();\n> +\tvirtual ~Test();\n> +\n> +\tint execute();\n> +\n> +protected:\n> +\tvirtual int init() { return 0; }\n> +\tvirtual int run() = 0;\n> +\tvirtual void cleanup() { }\n> +};\n> +\n> +#define TEST_REGISTER(klass)\t\t\t\t\t\t\\\n> +int main(int argc, char *argv[])\t\t\t\t\t\\\n> +{\t\t\t\t\t\t\t\t\t\\\n> +\treturn klass().execute();\t\t\t\t\t\\\n> +}\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x244.google.com (mail-lj1-x244.google.com\n\t[IPv6:2a00:1450:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8DDF960B1F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 20 Dec 2018 19:53:34 +0100 (CET)","by mail-lj1-x244.google.com with SMTP id k19-v6so2492753lji.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 20 Dec 2018 10:53:34 -0800 (PST)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\ty24sm4354134lfj.17.2018.12.20.10.53.20\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tThu, 20 Dec 2018 10:53:21 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=EbBfrM/V4uZcujwETNBZU+iwFeAa+kgZJZjEy3wkGE4=;\n\tb=X3alUexEmnii8ca43xIEEYADDpMXQvz9nX6RGwqI+GdZlkDy/XYdZJoD9XpaCKVtQf\n\toY64G3Gz0byX1gEm1k0gJOpFg/21b5WyJQd63Iic3Z42Z7kMpf9e1POM2PrQ3EhA1qU5\n\tBaTCEkvXmvSz5l7BAj9KkgTNMnpHdvpMRm6GyPILYD+yWXgtI49pqaSXUs4kxe/8tHdK\n\tIoBRe26YSHaCx08Ffm/S2FsY8B0v5wLmB999bYdJEKYw4H3THtWirPU4YJ70h2o/7+gd\n\tdCkOgx8nTnOBePHSWcV2gjgtozzniZJKaj4GKiI3IfaDSpMaB/AxfNzT+Z+8SiuZ4T3N\n\tPTQQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=EbBfrM/V4uZcujwETNBZU+iwFeAa+kgZJZjEy3wkGE4=;\n\tb=lcDambEYMUPvg5jrzlhALIYx/byATmtlU8oRvuMU8yWIaw8Nfb2kltgcDqf8tGx5TB\n\tF52XncIliHXUbVcSzIA5aa/br+scp740min+mbdhmitx7y5ZfPWtV9TMz/3/RJXy5j3U\n\t0pdksVSrEsX/qYBF0oFtzADE68BymLG84kFjntLyp6GX6gNh8y4+zqoJL4pYGaNXlLq6\n\tQ6A+ad2z58w0eas0j4zV4PuEBwoCFAY0pMwEs2C2p2Lbo+nd/05wfGeKJ+apRoCFdaej\n\tD63sVIMjeuPpeZkz814yJyM94WKhngdm9C5UTxASSMv98eXVWcn2lMtFWRx4KZnaYRRB\n\tIQLg==","X-Gm-Message-State":"AA+aEWZS0IPmZcP/YARyer3LMU+GoEud4AdvaHDO/Ey8OD0/nhgGHQ6L\n\tyew50Y+DGDUMMqH/y5gfdAgbRw==","X-Google-Smtp-Source":"AFSGD/VEkVEWoM7IVPXv2Yk9MGThUNywKvfRyxKMid4b3RWwS2B8oqM4MEaC96AgPBWrqX42H92gnw==","X-Received":"by 2002:a2e:4746:: with SMTP id\n\tu67-v6mr15775725lja.142.1545332013446; \n\tThu, 20 Dec 2018 10:53:33 -0800 (PST)","Date":"Thu, 20 Dec 2018 19:53:20 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20181220185320.GD19959@bigcity.dyn.berto.se>","References":"<20181219094830.7226-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20181219094830.7226-1-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH] tests: Add a base Test class","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":"Thu, 20 Dec 2018 18:53:34 -0000"}},{"id":60,"web_url":"https://patchwork.libcamera.org/comment/60/","msgid":"<4d01d90c-9202-5b42-2f75-e3ca5be11a7c@ideasonboard.com>","date":"2018-12-20T19:40:52","subject":"Re: [libcamera-devel] [PATCH] tests: Add a base Test class","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 20/12/2018 18:53, Niklas Söderlund wrote:\n> Hi Laurent,\n> \n> Thanks for your work.\n> \n> On 2018-12-19 11:48:30 +0200, Laurent Pinchart wrote:\n>> The base Test class is meant to provide infrastructure common to all\n>> tests. It is very limited for now, and should be extended with at least\n>> logging and assertion handling.\n> \n> I agree it's a bit limited now but can serve as a good base to build \n> upon. I have used this to write tests for device enumerator work.\n> \n\nI've also used this as a base to rework my tests on top of, and I've now\nrefactored my v4l2device tests which does indeed reduce quite a bit of\ncode duplication.\n\n>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> \n>> ---\n>>  test/meson.build |  6 ++++++\n>>  test/test.cpp    | 28 ++++++++++++++++++++++++++++\n>>  test/test.h      | 28 ++++++++++++++++++++++++++++\n>>  3 files changed, 62 insertions(+)\n>>  create mode 100644 test/test.cpp\n>>  create mode 100644 test/test.h\n>>\n>> diff --git a/test/meson.build b/test/meson.build\n>> index 24d1927f977c..fc9c124927d2 100644\n>> --- a/test/meson.build\n>> +++ b/test/meson.build\n>> @@ -1,3 +1,9 @@\n>> +libtest_sources = files([\n>> +    'test.cpp',\n>> +])\n>> +\n>> +libtest = static_library('libtest', libtest_sources)\n\nI wonder if libtest should get it's own directory as test/libtest to\nseparate it out. Especially as it will likely expand with logging and\nother helpers.\n\n>> +\n>>  test_init = executable('test_init', 'init.cpp',\n>>                         link_with : libcamera,\n>>                         include_directories : libcamera_includes)\n>> diff --git a/test/test.cpp b/test/test.cpp\n>> new file mode 100644\n>> index 000000000000..4e7779e750d5\n>> --- /dev/null\n>> +++ b/test/test.cpp\n>> @@ -0,0 +1,28 @@\n>> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n>> +/*\n>> + * Copyright (C) 2018, Google Inc.\n>> + *\n>> + * test.cpp - libcamera test base class\n>> + */\n>> +\n>> +#include \"test.h\"\n>> +\n>> +Test::Test()\n>> +{\n>> +}\n>> +\n>> +Test::~Test()\n>> +{\n>> +\tcleanup();\n>> +}\n>> +\n>> +int Test::execute()\n>> +{\n>> +\tint ret;\n>> +\n>> +\tret = init();\n>> +\tif (ret < 0)\n>> +\t\treturn ret;\n>> +\n>> +\treturn run();\n>> +}\n>> diff --git a/test/test.h b/test/test.h\n>> new file mode 100644\n>> index 000000000000..2464fc5cb607\n>> --- /dev/null\n>> +++ b/test/test.h\n>> @@ -0,0 +1,28 @@\n>> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n>> +/*\n>> + * Copyright (C) 2018, Google Inc.\n>> + *\n>> + * test.h - libcamera test base class\n>> + */\n\nShouldn't we have an include guard here?\n\n>> +\n>> +#include <sstream>\n>> +\n>> +class Test\n>> +{\n>> +public:\n>> +\tTest();\n>> +\tvirtual ~Test();\n>> +\n>> +\tint execute();\n>> +\n>> +protected:\n>> +\tvirtual int init() { return 0; }\n>> +\tvirtual int run() = 0;\n>> +\tvirtual void cleanup() { }\n>> +};\n>> +\n>> +#define TEST_REGISTER(klass)\t\t\t\t\t\t\\\n>> +int main(int argc, char *argv[])\t\t\t\t\t\\\n>> +{\t\t\t\t\t\t\t\t\t\\\n>> +\treturn klass().execute();\t\t\t\t\t\\\n>> +}\n>> -- \n>> Regards,\n>>\n>> Laurent Pinchart\n>>\n>> _______________________________________________\n>> libcamera-devel mailing list\n>> libcamera-devel@lists.libcamera.org\n>> https://lists.libcamera.org/listinfo/libcamera-devel\n>","headers":{"Return-Path":"<kieran.bingham@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 244D760B1F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 20 Dec 2018 20:40:56 +0100 (CET)","from [192.168.0.21]\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 53E01565;\n\tThu, 20 Dec 2018 20:40:55 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1545334855;\n\tbh=KB1XxJtXE3FVyi/WU9ly8otfwq6rDDPhbv3QVaS/xhU=;\n\th=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=MUXLO2GauKmok4b8ZRc7Yh8gIxftkDXaLU2faiqcQmw12axVBimZNsMCOBWhq/aGu\n\tvTLRITOxIsB8Yl6qGpOQbwwV2hBuV0Kuox2OiyDTgBCRssv5H2h25otXID7UwYoCLc\n\tkTCq91PbsLmpyQWr+lrf8TWqpndNYH9pB5DlSDK0=","Reply-To":"kieran.bingham@ideasonboard.com","To":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20181219094830.7226-1-laurent.pinchart@ideasonboard.com>\n\t<20181220185320.GD19959@bigcity.dyn.berto.se>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfo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NOP1KgjCvyp1/KcFxDAo89IeqljaRsCdP\n\t7WCIECWYem6pLwaw6IAL7oX+tEqIMPph/G/jwZcdS6Hkyt/esHPuHNwX4guqTbVEuRqbDzDI\n\t2DJO5FbxABEBAAGJAiUEGAEKAA8CGwwFAlnDlGsFCQeA/gIACgkQoR5GchCkYf1yYRAAq+Yo\n\tnbf9DGdK1kTAm2RTFg+w9oOp2Xjqfhds2PAhFFvrHQg1XfQR/UF/SjeUmaOmLSczM0s6XMeO\n\tVcE77UFtJ/+hLo4PRFKm5X1Pcar6g5m4xGqa+Xfzi9tRkwC29KMCoQOag1BhHChgqYaUH3yo\n\tUzaPwT/fY75iVI+yD0ih/e6j8qYvP8pvGwMQfrmN9YB0zB39YzCSdaUaNrWGD3iCBxg6lwSO\n\tLKeRhxxfiXCIYEf3vwOsP3YMx2JkD5doseXmWBGW1U0T/oJF+DVfKB6mv5UfsTzpVhJRgee7\n\t4jkjqFq4qsUGxcvF2xtRkfHFpZDbRgRlVmiWkqDkT4qMA+4q1y/dWwshSKi/uwVZNycuLsz+\n\t+OD8xPNCsMTqeUkAKfbD8xW4LCay3r/dD2ckoxRxtMD9eOAyu5wYzo/ydIPTh1QEj9SYyvp8\n\tO0g6CpxEwyHUQtF5oh15O018z3ZLztFJKR3RD42VKVsrnNDKnoY0f4U0z7eJv2NeF8xHMuiU\n\tRCIzqxX1GVYaNkKTnb/Qja8hnYnkUzY1Lc+OtwiGmXTwYsPZjjAaDX35J/RSKAoy5wGo/YFA\n\tJxB1gWThL4kOTbsqqXj9GLcyOImkW0lJGGR3o/fV91Zh63S5TKnf2YGGGzxki+ADdxVQAm+Q\n\tsbsRB8KNNvVXBOVNwko86rQqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<4d01d90c-9202-5b42-2f75-e3ca5be11a7c@ideasonboard.com>","Date":"Thu, 20 Dec 2018 19:40:52 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.2.1","MIME-Version":"1.0","In-Reply-To":"<20181220185320.GD19959@bigcity.dyn.berto.se>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH] tests: Add a base Test class","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":"Thu, 20 Dec 2018 19:40:56 -0000"}},{"id":62,"web_url":"https://patchwork.libcamera.org/comment/62/","msgid":"<2026379.5NDlVFmdBh@avalon>","date":"2018-12-21T04:46:39","subject":"Re: [libcamera-devel] [PATCH] tests: Add a base Test class","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nOn Thursday, 20 December 2018 21:40:52 EET Kieran Bingham wrote:\n> On 20/12/2018 18:53, Niklas Söderlund wrote:\n> > On 2018-12-19 11:48:30 +0200, Laurent Pinchart wrote:\n> >> The base Test class is meant to provide infrastructure common to all\n> >> tests. It is very limited for now, and should be extended with at least\n> >> logging and assertion handling.\n> > \n> > I agree it's a bit limited now but can serve as a good base to build\n> > upon. I have used this to write tests for device enumerator work.\n> \n> I've also used this as a base to rework my tests on top of, and I've now\n> refactored my v4l2device tests which does indeed reduce quite a bit of\n> code duplication.\n> \n> >> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > \n> > Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > \n> >> ---\n> >> \n> >>  test/meson.build |  6 ++++++\n> >>  test/test.cpp    | 28 ++++++++++++++++++++++++++++\n> >>  test/test.h      | 28 ++++++++++++++++++++++++++++\n> >>  3 files changed, 62 insertions(+)\n> >>  create mode 100644 test/test.cpp\n> >>  create mode 100644 test/test.h\n> >> \n> >> diff --git a/test/meson.build b/test/meson.build\n> >> index 24d1927f977c..fc9c124927d2 100644\n> >> --- a/test/meson.build\n> >> +++ b/test/meson.build\n> >> @@ -1,3 +1,9 @@\n> >> +libtest_sources = files([\n> >> +    'test.cpp',\n> >> +])\n> >> +\n> >> +libtest = static_library('libtest', libtest_sources)\n> \n> I wonder if libtest should get it's own directory as test/libtest to\n> separate it out. Especially as it will likely expand with logging and\n> other helpers.\n\nThat would make sense. Or maybe moving tests in subdirectories. I think we can \ndecide when we'll get enough source files to call for a move.\n\n> >> +\n> >>  test_init = executable('test_init', 'init.cpp',\n> >>                         link_with : libcamera,\n> >>                         include_directories : libcamera_includes)\n> >> diff --git a/test/test.cpp b/test/test.cpp\n> >> new file mode 100644\n> >> index 000000000000..4e7779e750d5\n> >> --- /dev/null\n> >> +++ b/test/test.cpp\n> >> @@ -0,0 +1,28 @@\n> >> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> >> +/*\n> >> + * Copyright (C) 2018, Google Inc.\n> >> + *\n> >> + * test.cpp - libcamera test base class\n> >> + */\n> >> +\n> >> +#include \"test.h\"\n> >> +\n> >> +Test::Test()\n> >> +{\n> >> +}\n> >> +\n> >> +Test::~Test()\n> >> +{\n> >> +\tcleanup();\n> >> +}\n> >> +\n> >> +int Test::execute()\n> >> +{\n> >> +\tint ret;\n> >> +\n> >> +\tret = init();\n> >> +\tif (ret < 0)\n> >> +\t\treturn ret;\n> >> +\n> >> +\treturn run();\n> >> +}\n> >> diff --git a/test/test.h b/test/test.h\n> >> new file mode 100644\n> >> index 000000000000..2464fc5cb607\n> >> --- /dev/null\n> >> +++ b/test/test.h\n> >> @@ -0,0 +1,28 @@\n> >> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> >> +/*\n> >> + * Copyright (C) 2018, Google Inc.\n> >> + *\n> >> + * test.h - libcamera test base class\n> >> + */\n> \n> Shouldn't we have an include guard here?\n\nIt should :-) Fixed and pushed.\n\n> >> +\n> >> +#include <sstream>\n> >> +\n> >> +class Test\n> >> +{\n> >> +public:\n> >> +\tTest();\n> >> +\tvirtual ~Test();\n> >> +\n> >> +\tint execute();\n> >> +\n> >> +protected:\n> >> +\tvirtual int init() { return 0; }\n> >> +\tvirtual int run() = 0;\n> >> +\tvirtual void cleanup() { }\n> >> +};\n> >> +\n> >> +#define TEST_REGISTER(klass)\t\t\t\t\t\t\\\n> >> +int main(int argc, char *argv[])\t\t\t\t\t\\\n> >> +{\t\t\t\t\t\t\t\t\t\\\n> >> +\treturn klass().execute();\t\t\t\t\t\\\n> >> +}","headers":{"Return-Path":"<laurent.pinchart@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 4755A60B21\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Dec 2018 05:45:44 +0100 (CET)","from avalon.localnet (unknown [164.5.176.2])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BD0BC558;\n\tFri, 21 Dec 2018 05:45:43 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1545367543;\n\tbh=QaqXMwb2gfQiS7y4d1pVgbjK9Gw8p86E6HIde13kFY0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=BocoXJ/NIEmB2hXt/ABRCNlmpI+HLE8g0NuUb2sRok6kTdeKOhT/8mIx+7tEu9VPS\n\tjsbteJ7nUkPFTMQPu8XiwM3QGhFcTMVPysi38cOYf/00dhpOP4mijmV4oKu4m0DATT\n\tppV1xmf9YNLKFdcHZLWtNrmumUt/9WwfgITr8YXQ=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"kieran.bingham@ideasonboard.com","Cc":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 21 Dec 2018 06:46:39 +0200","Message-ID":"<2026379.5NDlVFmdBh@avalon>","Organization":"Ideas on Board Oy","In-Reply-To":"<4d01d90c-9202-5b42-2f75-e3ca5be11a7c@ideasonboard.com>","References":"<20181219094830.7226-1-laurent.pinchart@ideasonboard.com>\n\t<20181220185320.GD19959@bigcity.dyn.berto.se>\n\t<4d01d90c-9202-5b42-2f75-e3ca5be11a7c@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","Content-Type":"text/plain; charset=\"iso-8859-1\"","Subject":"Re: [libcamera-devel] [PATCH] tests: Add a base Test class","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":"Fri, 21 Dec 2018 04:45:44 -0000"}}]