mailarchive of the pengutronix oss-tools mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: oss-tools@pengutronix.de
Subject: [OSS-Tools] [PATCH 3/5] meson: add simple integration test
Date: Wed, 31 May 2023 17:31:23 +0200	[thread overview]
Message-ID: <20230531153125.1408092-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230531153125.1408092-1-a.fatoum@pengutronix.de>

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 <a.fatoum@pengutronix.de>
---
 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 <stdint.h>
+#include <assert.h>
+
+#include <dt/common.h>
+
+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




  parent reply	other threads:[~2023-05-31 15:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-31 15:31 [OSS-Tools] [PATCH 0/5] Add meson support and first test suite Ahmad Fatoum
2023-05-31 15:31 ` [OSS-Tools] [PATCH 1/5] Add meson as build system Ahmad Fatoum
2023-05-31 15:31 ` [OSS-Tools] [PATCH 2/5] state: add option to lock device node Ahmad Fatoum
2023-05-31 15:31 ` Ahmad Fatoum [this message]
2023-05-31 15:31 ` [OSS-Tools] [PATCH 4/5] libdt: add CONFIG_TEST_LOOPBACK Ahmad Fatoum
2023-06-12 11:56   ` Ahmad Fatoum
2023-05-31 15:31 ` [OSS-Tools] [PATCH 5/5] test: add barebox-state loop block device tests Ahmad Fatoum
2023-06-05 10:17 ` [OSS-Tools] [PATCH 0/5] Add meson support and first test suite Roland Hieber
2023-06-12 11:57   ` Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230531153125.1408092-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=oss-tools@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox