diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-04-17 17:57:58 +0200 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2025-04-18 15:38:56 -0400 |
| commit | b9db06b2b12a50b95185082910cfef01341fd7db (patch) | |
| tree | f2a4b9629406099db07f5b73a0274ab824d25237 /unittests | |
| parent | 855cf199fc950de3e764a74e7b545c2213aa601c (diff) | |
| download | meson-b9db06b2b12a50b95185082910cfef01341fd7db.tar.gz | |
fix prefix computation in validate_original_args
validate_original_args only checks whether an option is prefixed with the name of a
built-in option that was also set. It does not check whether the prefix is the full
name of the option specified with -D. Adding an "=" at the end fixes the test.
Fixes: #14487
Reported-by: Alyssa Ross <hi@alyssa.is>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'unittests')
| -rw-r--r-- | unittests/allplatformstests.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 412723cc5..2fee06c69 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -1361,6 +1361,36 @@ class AllPlatformTests(BasePlatformTests): self.utime(os.path.join(testdir, 'srcgen.py')) self.assertRebuiltTarget('basic') + def test_long_opt_vs_D(self): + ''' + Test that conflicts between -D for builtin options and the corresponding + long option are detected without false positives or negatives. + ''' + testdir = os.path.join(self.unit_test_dir, '128 long opt vs D') + + for opt in ['-Dsysconfdir=/etc', '-Dsysconfdir2=/etc']: + exception_raised = False + try: + self.init(testdir, extra_args=[opt, '--sysconfdir=/etc']) + except subprocess.CalledProcessError: + exception_raised = True + if 'sysconfdir2' in opt: + self.assertFalse(exception_raised, f'{opt} --sysconfdir raised an exception') + else: + self.assertTrue(exception_raised, f'{opt} --sysconfdir did not raise an exception') + + exception_raised = False + try: + self.init(testdir, extra_args=['--sysconfdir=/etc', opt]) + except subprocess.CalledProcessError: + exception_raised = True + if 'sysconfdir2' in opt: + self.assertFalse(exception_raised, f'--sysconfdir {opt} raised an exception') + else: + self.assertTrue(exception_raised, f'--sysconfdir {opt} did not raise an exception') + + self.wipe() + def test_static_library_lto(self): ''' Test that static libraries can be built with LTO and linked to |
