def test_basic(self, call): """load_drivers: runs depmod and modprobes all named modules""" modnames = ['mod1', 'mod2'] load_drivers(modnames) call.assert_has_calls([ mock.call(["depmod", "-a"]), mock.call(["modprobe", "-a"] + modnames) ])
def test_basic(self, list_net_intfs, rm_net_intfs_for_unload, call): """load_drivers: runs depmod and modprobes all named modules""" modnames = ['mod1', 'mod2'] load_drivers({name: [name] for name in modnames}) call.assert_has_calls([ mock.call(["depmod", "-a"]), mock.call(["modprobe", "-a"] + modnames) ])
def test_basic(self, call): """load_drivers: runs depmod and modprobes all named modules""" modnames = ['mod1', 'mod2'] load_drivers(modnames) call.assert_has_calls([ mock.call(["depmod", "-a"]), mock.call(["modprobe", "-a"] + modnames) ])
def test_basic_replace(self, list_net_intfs, rm_net_intfs_for_unload, check_output, call): # "icecream" is the updated driver, replacing "sorbet" # the check_output patch intercepts 'modprobe -R <alias>' load_drivers({"icecream": ['pineapple', 'cherry', 'icecream']}) call.assert_has_calls([ mock.call(["modprobe", "-r", "sorbet"]), mock.call(["depmod", "-a"]), mock.call(["modprobe", "-a", "icecream"]) ])
def test_basic(self, list_net_intfs, rm_net_intfs_for_unload, call): """load_drivers: runs depmod and modprobes all named modules""" modnames = ['mod1', 'mod2'] moddict = collections.OrderedDict({name: [name] for name in modnames}) load_drivers(collections.OrderedDict(moddict)) call.assert_has_calls([ mock.call(["depmod", "-a"]), mock.call(["modprobe", "-a"] + list(moddict.keys())) ])
def test_reload_module_dependencies(self, get_all_loaded_modules, list_net_intfs, rm_net_intfs_for_unload, check_output, call): # "icecream" has module dependency "cornet" which will be unloaded because of # dependencies and must be reload back mod_dependencies=[["icecream", "cornet"], ["icecream"]] get_all_loaded_modules.side_effect = lambda: mod_dependencies.pop(0) load_drivers({"icecream": ['pineapple', 'cherry', 'icecream']}) call.assert_has_calls([ mock.call(["modprobe", "-r", "sorbet"]), mock.call(["depmod", "-a"]), mock.call(["modprobe", "-a", "icecream"]), mock.call(["modprobe", "-a", "cornet"]) ])
def test_interface_unload(self, list_net_intfs, check_output, check_call, call): # mode is net mode, remove dracut configuration for interface, # retrigger udev event intfs = ["ens3", "", "ens3"] list_net_intfs.side_effect = lambda: set(intfs.pop()) def patched_check_output(command, stderr=None): if command[0] == "modprobe": return "mod1" elif command[0] == "find-net-intfs-by-driver": return "ens3" check_output.side_effect = patched_check_output load_drivers({"mod1": ["mod1"]}) call.assert_has_calls([ mock.call(["modprobe", "-r", "mod1"]), mock.call(["depmod", "-a"]), mock.call(["modprobe", "-a", "mod1"]), ]) check_call.assert_has_calls([mock.call(["anaconda-ifdown", "ens3"])])
def test_interface_unload(self, list_net_intfs, check_output, check_call, call): # mode is net mode, remove dracut configuration for interface, # retrigger udev event intfs = ["ens3", "", "ens3"] list_net_intfs.side_effect = lambda: set(intfs.pop()) def patched_check_output(command, stderr=None, universal_newlines=True): if command[0] == "modprobe": return "mod1" elif command[0] == "find-net-intfs-by-driver": return "ens3" check_output.side_effect = patched_check_output load_drivers({"mod1": ["mod1"]}) call.assert_has_calls([ mock.call(["modprobe", "-r", "mod1"]), mock.call(["depmod", "-a"]), mock.call(["modprobe", "-a", "mod1"]), ]) check_call.assert_has_calls([ mock.call(["anaconda-ifdown", "ens3"]) ])