diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-02-19 06:10:28 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-02-19 23:13:32 +0530 |
commit | f90f17b25089ac173929c955e35956d19f3a5e2a (patch) | |
tree | ddae628741ad8ab3a049e8b314c113e9ad38ad39 | |
parent | 06d615611bd21a33363a9a907c31f018bd3e057c (diff) | |
download | meson-f90f17b25089ac173929c955e35956d19f3a5e2a.zip meson-f90f17b25089ac173929c955e35956d19f3a5e2a.tar.gz meson-f90f17b25089ac173929c955e35956d19f3a5e2a.tar.bz2 |
unit tests: Test some corner-cases in test setups
https://github.com/mesonbuild/meson/pull/1402
-rwxr-xr-x | run_unittests.py | 10 | ||||
-rw-r--r-- | test cases/unit/2 testsetups/buggy.c | 4 | ||||
-rw-r--r-- | test cases/unit/2 testsetups/meson.build | 4 |
3 files changed, 16 insertions, 2 deletions
diff --git a/run_unittests.py b/run_unittests.py index 95e52e3..46be657 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -451,9 +451,11 @@ class AllPlatformTests(BasePlatformTests): testdir = os.path.join(self.unit_test_dir, '2 testsetups') self.init(testdir) self.build() + # Run tests without setup self.run_tests() with open(os.path.join(self.logdir, 'testlog.txt')) as f: basic_log = f.read() + # Run buggy test with setup that has env that will make it fail self.assertRaises(subprocess.CalledProcessError, self._run, self.mtest_command + ['--setup=valgrind']) with open(os.path.join(self.logdir, 'testlog-valgrind.txt')) as f: @@ -462,6 +464,14 @@ class AllPlatformTests(BasePlatformTests): self.assertFalse('Memcheck' in basic_log) self.assertTrue('TEST_ENV is set' in vg_log) self.assertTrue('Memcheck' in vg_log) + # Run buggy test with setup without env that will pass + self._run(self.mtest_command + ['--setup=wrapper']) + # Setup with no properties works + self._run(self.mtest_command + ['--setup=empty']) + # Setup with only env works + self._run(self.mtest_command + ['--setup=onlyenv']) + # Setup with only a timeout works + self._run(self.mtest_command + ['--setup=timeout']) def assertFailedTestCount(self, failure_count, command): try: diff --git a/test cases/unit/2 testsetups/buggy.c b/test cases/unit/2 testsetups/buggy.c index 5d20a24..d238830 100644 --- a/test cases/unit/2 testsetups/buggy.c +++ b/test cases/unit/2 testsetups/buggy.c @@ -5,10 +5,10 @@ int main(int argc, char **argv) { char *ten = malloc(10); - do_nasty(ten); - free(ten); 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/meson.build b/test cases/unit/2 testsetups/meson.build index a65548e..488cf21 100644 --- a/test cases/unit/2 testsetups/meson.build +++ b/test cases/unit/2 testsetups/meson.build @@ -14,3 +14,7 @@ add_test_setup('valgrind', buggy = executable('buggy', 'buggy.c', 'impl.c') test('Test buggy', buggy) +add_test_setup('empty') +add_test_setup('onlyenv', env : env) +add_test_setup('wrapper', exe_wrapper : [vg, '--error-exitcode=1']) +add_test_setup('timeout', timeout_multiplier : 20) |