bootconfig: fix BCDStore SetBooleanElement order
SetBooleanElement seems to not respect the method contract defined in the document: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/bcd/setbooleanelement-bcdobject#syntax Instead the method contract has the two parameters in the inverse order: ``` boolean SetBooleanElement( [in] boolean Boolean, [in] uint32 Type ); ``` Change-Id: I8938cd0333b21a89971de88da47559fa929162dc Signed-off-by: Adrian Vladu <avladu@cloudbasesolutions.com>
This commit is contained in:
parent
4fd9b579f5
commit
c6e10ab462
@ -152,10 +152,15 @@ class BootConfigTest(unittest.TestCase):
|
||||
mock_success=True, mock_enable=True):
|
||||
mock_store = mock.Mock()
|
||||
mock_get_current_bcd_store.return_value = mock_store
|
||||
mock_store.SetBooleanElement.side_effect = ((mock_success,),)
|
||||
mock_store.SetBooleanElement.return_value = ()
|
||||
|
||||
mock_get_element = mock.MagicMock()
|
||||
mock_get_element.Boolean = mock_success
|
||||
mock_store.GetElement.return_value = [mock_get_element]
|
||||
|
||||
expected_call = (
|
||||
self.bootconfig.BCDLIBRARY_BOOLEAN_AUTO_RECOVERY_ENABLED,
|
||||
mock_enable)
|
||||
mock_enable,
|
||||
self.bootconfig.BCDLIBRARY_BOOLEAN_AUTO_RECOVERY_ENABLED)
|
||||
if not mock_success:
|
||||
self.assertRaises(exception.CloudbaseInitException,
|
||||
self.bootconfig.enable_auto_recovery,
|
||||
|
@ -96,9 +96,15 @@ def set_current_bcd_device_to_boot_partition():
|
||||
def enable_auto_recovery(enable):
|
||||
current_store = _get_current_bcd_store()
|
||||
|
||||
success, = current_store.SetBooleanElement(
|
||||
BCDLIBRARY_BOOLEAN_AUTO_RECOVERY_ENABLED, enable)
|
||||
if not success:
|
||||
current_store.SetBooleanElement(
|
||||
enable,
|
||||
BCDLIBRARY_BOOLEAN_AUTO_RECOVERY_ENABLED)
|
||||
|
||||
current_state = current_store.GetElement(
|
||||
BCDLIBRARY_BOOLEAN_AUTO_RECOVERY_ENABLED)[0].Boolean
|
||||
|
||||
if current_state != enable:
|
||||
raise exception.CloudbaseInitException(
|
||||
"Cannot set boolean element: %s" %
|
||||
BCDLIBRARY_BOOLEAN_AUTO_RECOVERY_ENABLED)
|
||||
"Cannot set boolean element: '%s'. "
|
||||
"Current state '%s' != desired state '%s'." %
|
||||
(BCDLIBRARY_BOOLEAN_AUTO_RECOVERY_ENABLED, current_state, enable))
|
||||
|
Loading…
x
Reference in New Issue
Block a user