Add unittests for b_ndebug=if-release and buildtype interactions

pull/3274/head
Aleksey Filippov 7 years ago
parent 39a3bdb43f
commit af0b569ced
  1. 14
      run_unittests.py
  2. 11
      test cases/unit/25 ndebug if-release/main.c
  3. 3
      test cases/unit/25 ndebug if-release/meson.build

@ -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):
'''

@ -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;
}

@ -0,0 +1,3 @@
project('ndebug enabled', 'c')
executable('main', 'main.c')
Loading…
Cancel
Save