~kdsch/c-modules

a75bc229b5cc3efab4d8a5fc3c39e26716068d42 — Karl Schultheisz 5 months ago 46d0bf0
add test harness
4 files changed, 79 insertions(+), 0 deletions(-)

A envsetup.sh
A main.c
A meson.build
A scripts/local-ci.sh
A envsetup.sh => envsetup.sh +13 -0
@@ 0,0 1,13 @@
BUILD=build

modules_setup() {
	meson setup $BUILD
}

modules_test() {
	meson test -C $BUILD
}

modules_clean() {
	rm -rf $BUILD
}

A main.c => main.c +21 -0
@@ 0,0 1,21 @@
#include "dynamic-array.c"

static void
harness_array(void)
{
	struct array a;
	array_init(&a);
	array_append(&a, 42);
	assert(a.length == 1);
	array_append(&a, 42);
	assert(a.length == 2);
	array_free(&a);
	assert(a.length == 0);
}

int
main(void)
{
	harness_array();
	return 0;
}

A meson.build => meson.build +42 -0
@@ 0,0 1,42 @@
project(
	'c-modules',
	'c',
	version: '0.1',
	default_options: [
		'c_std=c11',
		'warning_level=3',
		'werror=true',
	],
)

add_project_arguments(
	'-fmax-errors=1',
	'-Wconversion',
	language: 'c',
)

test(
	'bounded-model-check',
	find_program('cbmc', required: true),
	args: [
		'-I', meson.source_root(),
		'--bounds-check',
		'--c11',
		'--compact-trace',
		'--conversion-check',
		'--div-by-zero-check',
		'--float-overflow-check',
		'--memory-leak-check',
		'--nan-check',
		'--pointer-check',
		'--pointer-overflow-check',
		'--signed-overflow-check',
		'--undefined-shift-check',
		'--unsigned-overflow-check',
		files(
			'dynamic-array.c',
			'main.c',
		),
	],
	verbose: true,
)

A scripts/local-ci.sh => scripts/local-ci.sh +3 -0
@@ 0,0 1,3 @@
#!/bin/sh -e
. ./envsetup.sh
modules_test