diff options
-rwxr-xr-x | run_unittests.py | 14 | ||||
-rw-r--r-- | test cases/unit/25 ndebug if-release/main.c | 11 | ||||
-rw-r--r-- | test cases/unit/25 ndebug if-release/meson.build | 3 |
3 files changed, 28 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py index b6367c1..94e39c8 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1895,6 +1895,20 @@ int main(int argc, char **argv) { exception_raised = True self.assertTrue(exception_raised, 'Double locking did not raise exception.') + def test_ndebug_if_release_disabled(self): + testdir = os.path.join(self.unit_test_dir, '25 ndebug if-release') + self.init(testdir, extra_args=['--buildtype=release', '-Db_ndebug=if-release']) + self.build() + exe = os.path.join(self.builddir, 'main') + self.assertEqual(b'NDEBUG=1', subprocess.check_output(exe).strip()) + + def test_ndebug_if_release_enabled(self): + testdir = os.path.join(self.unit_test_dir, '25 ndebug if-release') + self.init(testdir, extra_args=['--buildtype=debugoptimized', '-Db_ndebug=if-release']) + self.build() + exe = os.path.join(self.builddir, 'main') + self.assertEqual(b'NDEBUG=0', subprocess.check_output(exe).strip()) + class FailureTests(BasePlatformTests): ''' diff --git a/test cases/unit/25 ndebug if-release/main.c b/test cases/unit/25 ndebug if-release/main.c new file mode 100644 index 0000000..70b3d04 --- /dev/null +++ b/test cases/unit/25 ndebug if-release/main.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <stdlib.h> + +int main(void) { +#ifdef NDEBUG + printf("NDEBUG=1\n"); +#else + printf("NDEBUG=0\n"); +#endif + return 0; +} diff --git a/test cases/unit/25 ndebug if-release/meson.build b/test cases/unit/25 ndebug if-release/meson.build new file mode 100644 index 0000000..4af2406 --- /dev/null +++ b/test cases/unit/25 ndebug if-release/meson.build @@ -0,0 +1,3 @@ +project('ndebug enabled', 'c') + +executable('main', 'main.c') |