aboutsummaryrefslogtreecommitdiff
path: root/test cases/unit
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-12-26 20:56:04 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2017-01-02 23:52:50 +0200
commitee8a6e6fc5b58b5756f4e01271e77399f2d973bb (patch)
treeb10b93b2b28e1135a3e87b4f127198786e596896 /test cases/unit
parent776b0d9a5f425d0363b8b71933f990183ca4a281 (diff)
downloadmeson-ee8a6e6fc5b58b5756f4e01271e77399f2d973bb.zip
meson-ee8a6e6fc5b58b5756f4e01271e77399f2d973bb.tar.gz
meson-ee8a6e6fc5b58b5756f4e01271e77399f2d973bb.tar.bz2
Can specify test setups and run them with mesontest.
Diffstat (limited to 'test cases/unit')
-rw-r--r--test cases/unit/2 testsetups/buggy.c11
-rw-r--r--test cases/unit/2 testsetups/impl.c5
-rw-r--r--test cases/unit/2 testsetups/impl.h3
-rw-r--r--test cases/unit/2 testsetups/meson.build15
4 files changed, 34 insertions, 0 deletions
diff --git a/test cases/unit/2 testsetups/buggy.c b/test cases/unit/2 testsetups/buggy.c
new file mode 100644
index 0000000..1aa56f9
--- /dev/null
+++ b/test cases/unit/2 testsetups/buggy.c
@@ -0,0 +1,11 @@
+#include<stdio.h>
+#include<stdlib.h>
+
+#include<impl.h>
+
+int main(int argc, char **argv) {
+ char *ten = malloc(10);
+ do_nasty(ten);
+ free(ten);
+ return 0;
+}
diff --git a/test cases/unit/2 testsetups/impl.c b/test cases/unit/2 testsetups/impl.c
new file mode 100644
index 0000000..d87f3de
--- /dev/null
+++ b/test cases/unit/2 testsetups/impl.c
@@ -0,0 +1,5 @@
+/* Write past the end. */
+
+void do_nasty(char *ptr) {
+ ptr[10] = 'n';
+}
diff --git a/test cases/unit/2 testsetups/impl.h b/test cases/unit/2 testsetups/impl.h
new file mode 100644
index 0000000..7a08cb3
--- /dev/null
+++ b/test cases/unit/2 testsetups/impl.h
@@ -0,0 +1,3 @@
+#pragma once
+
+void do_nasty(char *ptr);
diff --git a/test cases/unit/2 testsetups/meson.build b/test cases/unit/2 testsetups/meson.build
new file mode 100644
index 0000000..f2295f5
--- /dev/null
+++ b/test cases/unit/2 testsetups/meson.build
@@ -0,0 +1,15 @@
+project('testsetups', 'c')
+
+vg = find_program('valgrind', required : false)
+
+env = environment()
+env.set('TEST_ENV', '1')
+
+add_test_setup('valgrind',
+ exe_wrapper : ['valgrind', '--error-exitcode=1', '--leak-check=full'],
+ timeout_multiplier : 100,
+ env : env)
+
+buggy = executable('buggy', 'buggy.c', 'impl.c')
+test('Test buggy', buggy)
+