add test case for setting options from reconfigure

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2025-05-09 11:44:36 +02:00 committed by Eli Schwartz
parent 2f6fc30df1
commit 5081536f57
2 changed files with 11 additions and 2 deletions

View File

@ -40,8 +40,7 @@ if get_option('integer_opt') != 3
endif
negint = get_option('neg_int_opt')
if negint != -3 and negint != -10
if negint not in [-2, -3, -10]
error('Incorrect value @0@ in negative integer option.'.format(negint))
endif

View File

@ -453,6 +453,16 @@ class PlatformAgnosticTests(BasePlatformTests):
self.setconf('-Dneg_int_opt=0')
self.assertIn('Unknown options: ":neg_int_opt"', e.exception.stdout)
def test_reconfigure_option(self) -> None:
testdir = self.copy_srcdir(os.path.join(self.common_test_dir, '40 options'))
self.init(testdir)
self.assertEqual(self.getconf('neg_int_opt'), -3)
with self.assertRaises(subprocess.CalledProcessError) as e:
self.init(testdir, extra_args=['--reconfigure', '-Dneg_int_opt=0'])
self.assertEqual(self.getconf('neg_int_opt'), -3)
self.init(testdir, extra_args=['--reconfigure', '-Dneg_int_opt=-2'])
self.assertEqual(self.getconf('neg_int_opt'), -2)
def test_configure_option_changed_constraints(self) -> None:
"""Changing the constraints of an option without reconfiguring should work."""
testdir = self.copy_srcdir(os.path.join(self.common_test_dir, '40 options'))