From 4afc3b968bc3505f7dcaa2736d13030ab3f4909f Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 13 Apr 2019 00:00:59 +0300 Subject: [PATCH] Add tests for std usage. Closes #5097. --- run_unittests.py | 16 ++++++++++++++++ test cases/unit/50 std remains/meson.build | 2 ++ test cases/unit/50 std remains/prog.c | 1 + 3 files changed, 19 insertions(+) create mode 100644 test cases/unit/50 std remains/meson.build create mode 100644 test cases/unit/50 std remains/prog.c diff --git a/run_unittests.py b/run_unittests.py index 9c5cfc533..59940d76e 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -5043,6 +5043,14 @@ c = ['{0}'] # TODO should someday be explicit about build platform only here self.init(testdir) + def test_std_remains(self): + # C_std defined in project options must be in effect also when native compiling. + testdir = os.path.join(self.unit_test_dir, '50 std remains') + self.init(testdir) + compdb = self.get_compdb() + self.assertRegex(compdb[0]['command'], '-std=c99') + self.build() + def should_run_cross_arm_tests(): return shutil.which('arm-linux-gnueabihf-gcc') and not platform.machine().lower().startswith('arm') @@ -5094,6 +5102,14 @@ class LinuxCrossArmTests(BasePlatformTests): return self.assertTrue(False, 'Option libdir not in introspect data.') + def test_std_remains(self): + # C_std defined in project options must be in effect also when cross compiling. + testdir = os.path.join(self.unit_test_dir, '50 std remains') + self.init(testdir) + compdb = self.get_compdb() + self.assertRegex(compdb[0]['command'], '-std=c99') + self.build() + def should_run_cross_mingw_tests(): return shutil.which('x86_64-w64-mingw32-gcc') and not (is_windows() or is_cygwin()) diff --git a/test cases/unit/50 std remains/meson.build b/test cases/unit/50 std remains/meson.build new file mode 100644 index 000000000..ac6f9e247 --- /dev/null +++ b/test cases/unit/50 std remains/meson.build @@ -0,0 +1,2 @@ +project('std_remains', 'c', default_options: ['c_std=c99']) +executable('prog', 'prog.c') diff --git a/test cases/unit/50 std remains/prog.c b/test cases/unit/50 std remains/prog.c new file mode 100644 index 000000000..0314ff17b --- /dev/null +++ b/test cases/unit/50 std remains/prog.c @@ -0,0 +1 @@ +int main(int argc, char **argv) { return 0; }