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.fat...@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