diff options
Diffstat (limited to 'test cases/unit/2 testsetups')
-rw-r--r-- | test cases/unit/2 testsetups/buggy.c | 14 | ||||
-rwxr-xr-x | test cases/unit/2 testsetups/envcheck.py | 5 | ||||
-rw-r--r-- | test cases/unit/2 testsetups/impl.c | 5 | ||||
-rw-r--r-- | test cases/unit/2 testsetups/impl.h | 3 | ||||
-rw-r--r-- | test cases/unit/2 testsetups/meson.build | 33 |
5 files changed, 60 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..d238830 --- /dev/null +++ b/test cases/unit/2 testsetups/buggy.c @@ -0,0 +1,14 @@ +#include<stdio.h> +#include<stdlib.h> + +#include<impl.h> + +int main(int argc, char **argv) { + char *ten = malloc(10); + if(getenv("TEST_ENV")) { + do_nasty(ten); + printf("TEST_ENV is set.\n"); + } + free(ten); + return 0; +} diff --git a/test cases/unit/2 testsetups/envcheck.py b/test cases/unit/2 testsetups/envcheck.py new file mode 100755 index 0000000..e41a715 --- /dev/null +++ b/test cases/unit/2 testsetups/envcheck.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 + +import os + +assert 'PATH' in os.environ 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..91a5fbe --- /dev/null +++ b/test cases/unit/2 testsetups/meson.build @@ -0,0 +1,33 @@ +project('testsetups', 'c') + +vg = find_program('valgrind') + +cc = meson.get_compiler('c') +# clang 14 uses dwarf 5, and valgrind 3.19 GIT does not support this +if cc.get_id() == 'clang' and cc.version().version_compare('>=14') and \ + vg.version().version_compare('<3.20') + add_project_arguments('-gdwarf-4', language: 'c') +endif + +# This is only set when running under Valgrind test setup. +env = environment() +env.set('TEST_ENV', '1') + +add_test_setup('valgrind', + exe_wrapper : [vg, '--error-exitcode=1', '--leak-check=full'], + timeout_multiplier : 100, + env : env) + +buggy = executable('buggy', 'buggy.c', 'impl.c') +test('Test buggy', buggy, suite: ['buggy']) + +envcheck = find_program('envcheck.py') +test('test-env', envcheck) + +add_test_setup('empty') +add_test_setup('onlyenv', env : env) +add_test_setup('onlyenv2', env : 'TEST_ENV=1') +add_test_setup('onlyenv3', env : ['TEST_ENV=1']) +add_test_setup('wrapper', exe_wrapper : [vg, '--error-exitcode=1']) +add_test_setup('timeout', timeout_multiplier : 20) +add_test_setup('good', exclude_suites : 'buggy') |