From a673abc9bc84aeb165ffeb36367d3a3df048f83a Mon Sep 17 00:00:00 2001 From: Lukas Ruzicka Date: Jul 09 2019 12:34:59 +0000 Subject: Add more improvements. --- diff --git a/modular_functions.py b/modular_functions.py index a636419..ba903ba 100755 --- a/modular_functions.py +++ b/modular_functions.py @@ -219,6 +219,7 @@ class TestSuite: else: problem = raw.stderr.decode('utf-8') logging.warning(f"The operation {key} has NOT finished successfully, because of {problem}.") + print('The script must be run with sudo or under root! Check the log for further errors.') result = 1 self.store_results(f'dnf module {operation}', result) return result @@ -412,7 +413,7 @@ class ModuleTest: logging.info(f"The result of installing {key} is SOFTFAIL.") print('') - def remove_module(self, module, stream=None): + def remove_module(self, module, stream=None, profile=None): print('-------- Remove module ---------') if self.newer != 'dummy': stream = self.newer @@ -420,11 +421,11 @@ class ModuleTest: key = f"{module}:{stream}" else: key = f"{module}" - res1 = self.suite.use_module(module, 'remove', stream) - print(f"DNF removes {key} =>", res1[key]) - res2 = self.suite.is_listed(module, stream, 'installed') - print(f"{key} is listed in --installed =>", res2[key]) - if res1[key] == 'pass' and res2[key] == 'no': + res1 = self.suite.use_module(module, 'remove', stream, profile) + print(f"DNF removes {key} =>", res1) + res2 = self.suite.is_listed(module, stream, profile, 'installed') + print(f"{key} is listed in --installed =>", res2) + if res1 == 0 and res2 == 111: self.overall['remove'] = 'pass' logging.info(f"The result of removing {key} is PASS.") else: @@ -436,6 +437,38 @@ class ModuleTest: logging.info(f"The result of removing {key} is SOFTFAIL.") print('') + def reset_module(self, module, stream=None, profile=None): + """Tests resetting the module.""" + # When the module status quo is changed once, it will always play some role in modularity. + # It will either be enabled, disabled, or installed. Removing an installed module, will not disable it, + # disabling an enabled module will not bring it to its neutral state (and vice versa). To bring the + # module into a neutral state, one has to reset it. Resetting a module is an important part of + # module stream switching, if one decides to do so. + # To reset a module, we will check that it is either enabled, or disabled (that means, not neutral, then + # we reset it and check that it is not enabled nor disabled -> neutral. + print('-------- Resetting module ---------') + res1 = self.suite.is_listed(module, stream, profile, 'enabled') + res2 = self.suite.is_listed(module, stream, profile, 'disabled') + if res1 == 0 or res2 == 0: + logging.info('The module name has been found in --enabled or --disabled.') + res3 = self.suite.use_module(module, 'reset', stream, profile) + print(f"DNF resets {module} => {res3}") + res1 = self.suite.is_listed(module, stream, profile, 'enabled') + print(f"{module} is listed in --enabled => {res1}") + res2 = self.suite.is_listed(module, stream, profile, 'disabled') + print(f"{module} is listed in --disabled => {res2}") + if res3 == 0 and res1 == 111 and res2 == 111: + self.overall['reset'] = 'pass' + logging.info(f"The result of resetting {module} is PASS.") + else: + self.overall['reset'] = 'fail' + logging.info(f"The result of resetting {module} is FAIL.") + + else: + print('It seems that the module does not exist or is already reset.') + logging.error('The prerequisites were not met. The module seems to be already reset.') + self.overall['reset'] = 'fail' + def switch_stream(self, module, oldstr, newstr): print('-------- Switching streams ---------') oldkey = f"{module}:{oldstr}" @@ -533,6 +566,8 @@ class ModuleTest: self.list_module(module, stream) elif s == 'checkinstall': self.check_install(module, stream) + elif s == 'reset': + self.reset_module(module) elif s == 'info': info = self.suite.module_info(module) print(f"Available streams and profiles of the {module} module:")