From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Wed, 31 May 2023 17:31:31 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q4NnQ-004QrI-F1 for lore@lore.pengutronix.de; Wed, 31 May 2023 17:31:31 +0200 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1q4NnN-0007Be-9a; Wed, 31 May 2023 17:31:29 +0200 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q4NnL-00079t-On; Wed, 31 May 2023 17:31:27 +0200 Received: from [2a0a:edc0:0:1101:1d::54] (helo=dude05.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1q4NnL-0049CK-43; Wed, 31 May 2023 17:31:27 +0200 Received: from afa by dude05.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1q4NnK-005uL8-3W; Wed, 31 May 2023 17:31:26 +0200 From: Ahmad Fatoum To: oss-tools@pengutronix.de Date: Wed, 31 May 2023 17:31:23 +0200 Message-Id: <20230531153125.1408092-4-a.fatoum@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531153125.1408092-1-a.fatoum@pengutronix.de> References: <20230531153125.1408092-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [OSS-Tools] [PATCH 3/5] meson: add simple integration test X-BeenThere: oss-tools@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: Pengutronix Public Open-Source-Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "OSS-Tools" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: oss-tools-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false It's straight forward to use meson as test runner, so let's compile a very simple test application that links against libdt-utils and verifies crc32 behaves as one would expect. Signed-off-by: Ahmad Fatoum --- README | 1 + meson.build | 2 ++ test/crc32.c | 18 ++++++++++++++++++ test/meson.build | 26 ++++++++++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 test/crc32.c create mode 100644 test/meson.build diff --git a/README b/README index 0b4e96d6002e..528751d2cb65 100644 --- a/README +++ b/README @@ -32,6 +32,7 @@ The intention is to deprecate autotools eventually in its favor. To build: meson setup build meson compile -C build + meson test -C build # optional Contributing ------------ diff --git a/meson.build b/meson.build index 2fc13f55ed62..1bc32274af07 100644 --- a/meson.build +++ b/meson.build @@ -158,3 +158,5 @@ executable('dtblint', dependencies : [versiondep], link_with : libdt, install : true) + +subdir('test') diff --git a/test/crc32.c b/test/crc32.c new file mode 100644 index 000000000000..9a99254c8f22 --- /dev/null +++ b/test/crc32.c @@ -0,0 +1,18 @@ +#include +#include + +#include
+ +int main(void) +{ + const char *str = "Hello, World!"; + uint32_t checksum; + + checksum = crc32(0, str, strlen(str)); + assert(checksum == 0xec4ac3d0); + + checksum = crc32_no_comp(0, str, strlen(str)); + assert(checksum == 0xe33e8552); + + return 0; +} diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 000000000000..5e073547d79b --- /dev/null +++ b/test/meson.build @@ -0,0 +1,26 @@ +if not get_option('tests') + subdir_done() +endif + +tests = [ + 'crc32', +] + +extra_test_sources = files([ +]) + +foreach test_name : tests + exe = executable( + test_name + '-test', + test_name + '.c', + extra_test_sources, + link_with : [libdt], + include_directories : incdir) + + test( + test_name, + exe, + is_parallel : false, + timeout : 240, + workdir : meson.source_root()) +endforeach -- 2.39.2