def test_modinfo_doc_examples(): env = {'modinfo_obj': ModInfoI40e(context_wrap(MODINFO_I40E)), 'modinfo_drv': ModInfoVmxnet3(context_wrap(MODINFO_VMXNET3)), 'modinfo_igb': ModInfoIgb(context_wrap(MODINFO_IGB)), 'modinfo_veth': ModInfoVeth(context_wrap(MODINFO_VETH)), 'modinfo_ixgbe': ModInfoIxgbe(context_wrap(MODINFO_IXGBE)), 'modinfo_each': ModInfoEach(context_wrap(MODINFO_VETH))} failed, total = doctest.testmod(modinfo, globs=env) assert failed == 0
def test_modinfo(): modinfo_obj = ModInfoI40e(context_wrap(MODINFO_I40E)) assert modinfo_obj.module_name == 'i40e' assert modinfo_obj.module_version == '2.3.2-k' assert modinfo_obj.module_deps == ['ptp'] assert modinfo_obj.module_signer == 'Red Hat Enterprise Linux kernel signing key' assert len(modinfo_obj.data['alias']) == 2 assert modinfo_obj.data[ 'sig_key'] == '81:7C:CB:07:72:4E:7F:B8:15:24:10:F9:27:2D:AA:CF:80:3E:CE:59' assert modinfo_obj.data[ 'vermagic'] == '3.10.0-993.el7.x86_64 SMP mod_unload modversions' assert sorted(modinfo_obj.data['parm']) == sorted([ 'debug:Debug level (0=none,...,16=all), Debug mask (0x8XXXXXXX) (uint)', 'int_mode: Force interrupt mode other than MSI-X (1 INT#x; 2 MSI) (int)' ]) assert modinfo_obj.data[ 'description'] == 'Intel(R) Ethernet Connection XL710 Network Driver' assert ('signer' in modinfo_obj) is True assert modinfo_obj.module_path == "/lib/modules/3.10.0-993.el7.x86_64/kernel/drivers/net/ethernet/intel/i40e/i40e.ko.xz" modinfo_obj = ModInfoI40e(context_wrap(MODINFO_INTEL)) assert len(modinfo_obj.data['alias']) == 5 assert sorted(modinfo_obj.data['alias']) == sorted([ 'aes', 'crypto-aes', 'crypto-fpu', 'fpu', 'x86cpu:vendor:*:family:*:model:*:feature:*0099*' ]) assert ('parm' in modinfo_obj) is False assert modinfo_obj.module_name == 'aesni-intel' assert modinfo_obj.data[ 'description'] == 'Rijndael (AES) Cipher Algorithm, Intel AES-NI instructions optimized' assert modinfo_obj.data['rhelversion'] == '7.7' assert modinfo_obj.module_signer == 'Red Hat Enterprise Linux kernel signing key' assert modinfo_obj.module_deps == [ 'glue_helper', 'lrw', 'cryptd', 'ablk_helper' ] assert modinfo_obj.data[ 'sig_key'] == '81:7C:CB:07:72:4E:7F:B8:15:24:10:F9:27:2D:AA:CF:80:3E:CE:59' modinfo_obj = ModInfoI40e(context_wrap(MODINFO_BNX2X)) assert len(modinfo_obj.data['alias']) == 24 assert len(modinfo_obj.data['parm']) == 6 assert len(modinfo_obj.data['firmware']) == 3 assert sorted(modinfo_obj.data['firmware']) == sorted([ 'bnx2x/bnx2x-e2-7.13.1.0.fw', 'bnx2x/bnx2x-e1h-7.13.1.0.fw', 'bnx2x/bnx2x-e1-7.13.1.0.fw' ]) assert modinfo_obj.module_name == 'bnx2x' assert modinfo_obj.module_path == '/lib/modules/3.10.0-514.el7.x86_64/kernel/drivers/net/ethernet/broadcom/bnx2x/bnx2x.ko' assert modinfo_obj.module_signer == 'Red Hat Enterprise Linux kernel signing key' assert sorted(modinfo_obj.module_deps) == sorted( ['mdio', 'libcrc32c', 'ptp']) modinfo_igb = ModInfoIgb(context_wrap(MODINFO_IGB)) assert modinfo_igb.data.get( 'alias') == 'pci:v00008086d000010D6sv*sd*bc*sc*i*' assert modinfo_igb.module_name == 'igb' assert modinfo_igb.module_path == '/lib/modules/3.10.0-327.10.1.el7.jump7.x86_64/kernel/drivers/net/ethernet/intel/igb/igb.ko' modinfo_ixgbe = ModInfoIxgbe(context_wrap(MODINFO_IXGBE)) assert modinfo_ixgbe.data.get( 'alias') == 'pci:v00008086d000015CEsv*sd*bc*sc*i*' assert modinfo_ixgbe.module_name == 'ixgbe' assert modinfo_ixgbe.module_path == '/lib/modules/3.10.0-514.6.1.el7.jump3.x86_64/kernel/drivers/net/ethernet/intel/ixgbe/ixgbe.ko' modinfo_drv = ModInfoVmxnet3(context_wrap(MODINFO_VMXNET3)) assert modinfo_drv.data.get( 'alias') == 'pci:v000015ADd000007B0sv*sd*bc*sc*i*' assert len(modinfo_drv.module_parm) == 0 assert len(modinfo_drv.module_firmware) == 0 assert modinfo_drv.module_name == 'vmxnet3' assert modinfo_drv.module_path == '/lib/modules/3.10.0-957.10.1.el7.x86_64/kernel/drivers/net/vmxnet3/vmxnet3.ko.xz' assert sorted(modinfo_obj.data['firmware']) == sorted([ 'bnx2x/bnx2x-e2-7.13.1.0.fw', 'bnx2x/bnx2x-e1h-7.13.1.0.fw', 'bnx2x/bnx2x-e1-7.13.1.0.fw' ]) modinfo_drv = ModInfoVeth(context_wrap(MODINFO_VETH)) assert modinfo_drv.module_name == 'veth' assert modinfo_drv.module_path == '/lib/modules/3.10.0-327.el7.x86_64/kernel/drivers/net/veth.ko' assert modinfo_drv.module_signer == 'Red Hat Enterprise Linux kernel signing key' with pytest.raises(SkipException) as exc: modinfo_obj = ModInfoI40e(context_wrap(MODINFO_NO)) assert 'No Contents' in str(exc) with pytest.raises(ParseException) as exc: modinfo_obj = ModInfoI40e(context_wrap(MODINFO_NO_1)) assert 'No Parsed Contents' in str(exc) with pytest.raises(SkipException) as exc: modinfo_drv = ModInfoVmxnet3(context_wrap(MODINFO_NO)) assert 'No Contents' in str(exc) with pytest.raises(ParseException) as exc: modinfo_drv = ModInfoVmxnet3(context_wrap(MODINFO_NO_1)) assert 'No Parsed Contents' in str(exc) with pytest.raises(SkipException) as exc: modinfo_drv = ModInfoVeth(context_wrap(MODINFO_NO)) assert 'No Contents' in str(exc) with pytest.raises(ParseException) as exc: modinfo_drv = ModInfoVeth(context_wrap(MODINFO_NO_1)) assert 'No Parsed Contents' in str(exc)