devices: interface: Add support for testing different mac addresses
Some test scenarios need to make sure different mac addresses would _not_ be used in normal operations, but the test suite always generates the same value. Add some hacks to let the test suite override the default behavior and use incrementing addresses Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
68ca651d85
commit
c0f8da69b6
|
@ -5,14 +5,14 @@
|
|||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
+ <interface type="user">
|
||||
+ <mac address="00:11:22:33:44:55"/>
|
||||
+ <mac address="00:11:22:33:44:57"/>
|
||||
+ <model type="e1000"/>
|
||||
+ </interface>
|
||||
</devices>
|
||||
</domain>
|
||||
|
||||
<interface type="user">
|
||||
<mac address="00:11:22:33:44:55"/>
|
||||
<mac address="00:11:22:33:44:57"/>
|
||||
<model type="e1000"/>
|
||||
</interface>
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ Hotplug this device to the guest 'test'? (y/n): Device hotplug successful.
|
|||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
+ <interface type="user">
|
||||
+ <mac address="00:11:22:33:44:55"/>
|
||||
+ <mac address="00:11:22:33:44:56"/>
|
||||
+ <model type="e1000"/>
|
||||
+ </interface>
|
||||
</devices>
|
||||
|
|
|
@ -1267,7 +1267,7 @@ c.add_compare("--edit --print-diff --qemu-commandline clearxml=yes", "edit-clear
|
|||
c.add_compare("--print-diff --remove-device --serial 1", "remove-console-dup", input_file=(_VIRTXMLDIR + "virtxml-console-dup.xml"))
|
||||
c.add_compare("--connect %(URI-KVM)s test-hyperv-uefi --edit --boot uefi", "hyperv-uefi-collision")
|
||||
c.add_compare("--connect %(URI-KVM)s test-many-devices --edit --cpu host-copy", "edit-cpu-host-copy")
|
||||
c.add_compare("test --add-device --network default --update --confirm", "update-succeed", env={"VIRTXML_TESTSUITE_UPDATE_IGNORE_FAIL": "1"}, input_text="yes\nyes\n") # test hotplug success
|
||||
c.add_compare("test --add-device --network default --update --confirm", "update-succeed", env={"VIRTXML_TESTSUITE_UPDATE_IGNORE_FAIL": "1", "VIRTINST_TEST_SUITE_INCREMENT_MACADDR": "1"}, input_text="yes\nyes\n") # test hotplug success
|
||||
c.add_compare("test --add-device --network default --update --confirm --no-define", "update-nodefine-succeed", env={"VIRTXML_TESTSUITE_UPDATE_IGNORE_FAIL": "1"}, input_text="yes\n") # test hotplug success without define
|
||||
|
||||
|
||||
|
|
|
@ -110,6 +110,25 @@ def _default_bridge(conn):
|
|||
return ret
|
||||
|
||||
|
||||
_MAC_COUNTER = 0
|
||||
|
||||
|
||||
def _testsuite_mac():
|
||||
# Generate predictable mac addresses for the test suite
|
||||
# For some tests, we need to make sure that different mac addresses
|
||||
# would _not_ be generated in normal operations, so we add some magic
|
||||
# here to increment the generated address with a special env variable
|
||||
global _MAC_COUNTER
|
||||
|
||||
base = "00:11:22:33:44:55"
|
||||
ret = base[:-1] + str(int(base[-1]) + _MAC_COUNTER)
|
||||
_MAC_COUNTER += 1
|
||||
|
||||
if "VIRTINST_TEST_SUITE_INCREMENT_MACADDR" not in os.environ:
|
||||
_MAC_COUNTER = 0
|
||||
return ret
|
||||
|
||||
|
||||
class _VirtualPort(XMLBuilder):
|
||||
XML_NAME = "virtualport"
|
||||
|
||||
|
@ -139,8 +158,7 @@ class DeviceInterface(Device):
|
|||
the connection.
|
||||
"""
|
||||
if conn.fake_conn_predictable():
|
||||
# Testing hack
|
||||
return "00:11:22:33:44:55"
|
||||
return _testsuite_mac()
|
||||
|
||||
for ignore in range(256):
|
||||
mac = _random_mac(conn)
|
||||
|
|
Loading…
Reference in New Issue