Best Python code snippet using Airtest
xmlconfig.py
Source:xmlconfig.py
...99 except:100 pass101 def testBootParavirtDiskFile(self):102 g = utils.get_basic_paravirt_guest()103 g.add_device(utils.get_filedisk("/dev/default-pool/somerandomfilename.img"))104 self._compare(g, "boot-paravirt-disk-file", False)105 def testBootParavirtDiskFileBlktapCapable(self):106 oldblktap = virtinst.util.is_blktap_capable107 try:108 virtinst.util.is_blktap_capable = lambda ignore: True109 g = utils.get_basic_paravirt_guest()110 g.add_device(utils.get_filedisk())111 self._compare(g, "boot-paravirt-disk-drv-tap", False)112 finally:113 virtinst.util.is_blktap_capable = oldblktap114 def testBootParavirtDiskBlock(self):115 g = utils.get_basic_paravirt_guest()116 g.add_device(utils.get_blkdisk())117 self._compare(g, "boot-paravirt-disk-block", False)118 def testBootParavirtDiskDrvPhy(self):119 g = utils.get_basic_paravirt_guest()120 disk = utils.get_blkdisk()121 disk.driver_name = VirtualDisk.DRIVER_PHY122 g.add_device(disk)123 self._compare(g, "boot-paravirt-disk-drv-phy", False)124 def testBootParavirtDiskDrvFile(self):125 g = utils.get_basic_paravirt_guest()126 disk = utils.get_filedisk()127 disk.driver_name = VirtualDisk.DRIVER_FILE128 g.add_device(disk)129 self._compare(g, "boot-paravirt-disk-drv-file", False)130 def testBootParavirtDiskDrvTap(self):131 g = utils.get_basic_paravirt_guest()132 disk = utils.get_filedisk()133 disk.driver_name = VirtualDisk.DRIVER_TAP134 g.add_device(disk)135 self._compare(g, "boot-paravirt-disk-drv-tap", False)136 def testBootParavirtDiskDrvTapQCow(self):137 g = utils.get_basic_paravirt_guest()138 disk = utils.get_filedisk()139 disk.driver_name = VirtualDisk.DRIVER_TAP140 disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW141 g.add_device(disk)142 self._compare(g, "boot-paravirt-disk-drv-tap-qcow", False)143 def testBootParavirtManyDisks(self):144 g = utils.get_basic_paravirt_guest()145 disk = utils.get_filedisk("/dev/default-pool/test2.img")146 disk.driver_name = VirtualDisk.DRIVER_TAP147 disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW148 g.add_device(utils.get_filedisk("/dev/default-pool/test1.img"))149 g.add_device(disk)150 g.add_device(utils.get_blkdisk())151 self._compare(g, "boot-paravirt-many-disks", False)152 def testBootFullyvirtDiskFile(self):153 g = utils.get_basic_fullyvirt_guest()154 g.add_device(utils.get_filedisk())155 self._compare(g, "boot-fullyvirt-disk-file", False)156 def testBootFullyvirtDiskBlock(self):157 g = utils.get_basic_fullyvirt_guest()158 g.add_device(utils.get_blkdisk())159 self._compare(g, "boot-fullyvirt-disk-block", False)160 def testInstallParavirtDiskFile(self):161 g = utils.get_basic_paravirt_guest()162 g.add_device(utils.get_filedisk())163 self._compare(g, "install-paravirt-disk-file", True)164 def testInstallParavirtDiskBlock(self):165 g = utils.get_basic_paravirt_guest()166 g.add_device(utils.get_blkdisk())167 self._compare(g, "install-paravirt-disk-block", True)168 def testInstallParavirtDiskDrvPhy(self):169 g = utils.get_basic_paravirt_guest()170 disk = utils.get_blkdisk()171 disk.driver_name = VirtualDisk.DRIVER_PHY172 g.add_device(disk)173 self._compare(g, "install-paravirt-disk-drv-phy", True)174 def testInstallParavirtDiskDrvFile(self):175 g = utils.get_basic_paravirt_guest()176 disk = utils.get_filedisk()177 disk.driver_name = VirtualDisk.DRIVER_FILE178 g.add_device(disk)179 self._compare(g, "install-paravirt-disk-drv-file", True)180 def testInstallParavirtDiskDrvTap(self):181 g = utils.get_basic_paravirt_guest()182 disk = utils.get_filedisk()183 disk.driver_name = VirtualDisk.DRIVER_TAP184 g.add_device(disk)185 self._compare(g, "install-paravirt-disk-drv-tap", True)186 def testInstallParavirtDiskDrvTapQCow(self):187 g = utils.get_basic_paravirt_guest()188 disk = utils.get_filedisk()189 disk.driver_name = VirtualDisk.DRIVER_TAP190 disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW191 g.add_device(disk)192 self._compare(g, "install-paravirt-disk-drv-tap-qcow", True)193 def testInstallParavirtManyDisks(self):194 g = utils.get_basic_paravirt_guest()195 disk = utils.get_filedisk("/dev/default-pool/test2.img")196 disk.driver_name = VirtualDisk.DRIVER_TAP197 disk.driver_type = VirtualDisk.DRIVER_TAP_QCOW198 g.add_device(utils.get_filedisk("/dev/default-pool/test1.img"))199 g.add_device(disk)200 g.add_device(utils.get_blkdisk())201 self._compare(g, "install-paravirt-many-disks", True)202 def testInstallFullyvirtDiskFile(self):203 g = utils.get_basic_fullyvirt_guest()204 g.add_device(utils.get_filedisk())205 self._compare(g, "install-fullyvirt-disk-file", True)206 def testInstallFullyvirtDiskBlock(self):207 g = utils.get_basic_fullyvirt_guest()208 g.add_device(utils.get_blkdisk())209 self._compare(g, "install-fullyvirt-disk-block", True)210 def testInstallFVPXE(self):211 i = utils.make_pxe_installer()212 g = utils.get_basic_fullyvirt_guest(installer=i)213 g.add_device(utils.get_filedisk())214 self._compare(g, "install-fullyvirt-pxe", True)215 def testBootFVPXE(self):216 i = utils.make_pxe_installer()217 g = utils.get_basic_fullyvirt_guest(installer=i)218 g.add_device(utils.get_filedisk())219 self._compare(g, "boot-fullyvirt-pxe", False)220 def testBootFVPXEAlways(self):221 i = utils.make_pxe_installer()222 g = utils.get_basic_fullyvirt_guest(installer=i)223 g.add_device(utils.get_filedisk())224 g.os.bootorder = [225 g.os.BOOT_DEVICE_NETWORK]226 g.os.enable_bootmenu = True227 self._compare(g, "boot-fullyvirt-pxe-always", False)228 def testInstallFVPXENoDisks(self):229 i = utils.make_pxe_installer()230 g = utils.get_basic_fullyvirt_guest(installer=i)231 self._compare(g, "install-fullyvirt-pxe-nodisks", True)232 def testBootFVPXENoDisks(self):233 i = utils.make_pxe_installer()234 g = utils.get_basic_fullyvirt_guest(installer=i)235 self._compare(g, "boot-fullyvirt-pxe-nodisks", False)236 def testInstallFVLiveCD(self):237 i = utils.make_live_installer()238 g = utils.get_basic_fullyvirt_guest(installer=i)239 self._compare(g, "install-fullyvirt-livecd", False)240 def testDoubleInstall(self):241 # Make sure that installing twice generates the same XML, to ensure242 # we aren't polluting the device list during the install process243 i = utils.make_live_installer()244 g = utils.get_basic_fullyvirt_guest(installer=i)245 self._compare(g, "install-fullyvirt-livecd", False)246 self._compare(g, "install-fullyvirt-livecd", False)247 def testOSDeviceDefaultChange(self):248 """249 Make sure device defaults are properly changed if we change OS250 distro/variant mid process251 """252 conn = utils.open_plainkvm(connver=12005)253 utils.set_conn(conn)254 i = utils.make_distro_installer()255 g = utils.get_basic_fullyvirt_guest("kvm", installer=i)256 do_install = False257 g.installer.cdrom = True258 g.add_device(utils.get_floppy())259 g.add_device(utils.get_filedisk())260 g.add_device(utils.get_blkdisk())261 g.add_device(utils.get_virtual_network())262 g.add_device(VirtualAudio(g.conn))263 # Call get_xml_config sets first round of defaults w/o os_variant set264 g.get_install_xml(do_install)265 g.os_variant = "fedora11"266 self._compare(g, "install-f11-norheldefaults", do_install)267 try:268 virtinst.stable_defaults = True269 origemu = g.emulator270 g.emulator = "/usr/libexec/qemu-kvm"271 g.conn._support_cache = {}272 self._compare(g, "install-f11-rheldefaults", do_install)273 g.emulator = origemu274 g.conn._support_cache = {}275 finally:276 virtinst.stable_defaults = False277 # Verify main guest wasn't polluted278 self._compare(g, "install-f11-norheldefaults", do_install)279 def testInstallFVImport(self):280 i = utils.make_import_installer()281 g = utils.get_basic_fullyvirt_guest(installer=i)282 g.add_device(utils.get_filedisk())283 self._compare(g, "install-fullyvirt-import", False)284 def testInstallFVImportKernel(self):285 i = utils.make_import_installer()286 g = utils.get_basic_fullyvirt_guest(installer=i)287 g.add_device(utils.get_filedisk())288 g.os.kernel = "/kernel"289 g.os.initrd = "/initrd"290 g.os.kernel_args = "my kernel args"291 self._compare(g, "install-fullyvirt-import-kernel", False)292 def testInstallFVImportMulti(self):293 i = utils.make_import_installer()294 g = utils.get_basic_fullyvirt_guest(installer=i)295 g.os.enable_bootmenu = False296 g.os.bootorder = ["hd", "fd", "cdrom", "network"]297 g.add_device(utils.get_filedisk())298 self._compare(g, "install-fullyvirt-import-multiboot", False)299 def testInstallPVImport(self):300 i = utils.make_import_installer()301 g = utils.get_basic_paravirt_guest(installer=i)302 g.add_device(utils.get_filedisk())303 self._compare(g, "install-paravirt-import", False)304 def testQEMUDriverName(self):305 utils.set_conn(_plainkvm)306 g = utils.get_basic_fullyvirt_guest()307 g.add_device(utils.get_blkdisk())308 self._compare(g, "misc-qemu-driver-name", True)309 g = utils.get_basic_fullyvirt_guest()310 g.add_device(utils.get_filedisk())311 g.add_device(utils.get_blkdisk("/iscsi-pool/diskvol1"))312 self._compare(g, "misc-qemu-driver-type", True)313 g = utils.get_basic_fullyvirt_guest()314 g.add_device(utils.get_filedisk("/dev/default-pool/iso-vol"))315 self._compare(g, "misc-qemu-iso-disk", True)316 g = utils.get_basic_fullyvirt_guest()317 g.add_device(utils.get_filedisk("/dev/default-pool/iso-vol"))318 g.get_devices("disk")[0].driver_type = "qcow2"319 self._compare(g, "misc-qemu-driver-overwrite", True)320 def testXMLEscaping(self):321 g = utils.get_basic_fullyvirt_guest()322 g.description = "foooo barrrr \n baz && snarf. '' \"\" @@$\n"323 g.add_device(utils.get_filedisk("/dev/default-pool/ISO&'&s"))324 self._compare(g, "misc-xml-escaping", True)325 # OS Type/Version configurations326 def testF10(self):327 utils.set_conn(_plainkvm)328 i = utils.make_pxe_installer()329 g = utils.get_basic_fullyvirt_guest("kvm", installer=i)330 g.os_variant = "fedora10"331 g.add_device(utils.get_filedisk())332 g.add_device(utils.get_blkdisk())333 g.add_device(utils.get_virtual_network())334 self._compare(g, "install-f10", True)335 def testF11(self):336 utils.set_conn(_plainkvm)337 i = utils.make_distro_installer()338 g = utils.get_basic_fullyvirt_guest("kvm", installer=i)339 g.os.os_type = "hvm"340 g.os_variant = "fedora11"341 g.installer.cdrom = True342 g.add_device(utils.get_floppy())343 g.add_device(utils.get_filedisk())344 g.add_device(utils.get_blkdisk())345 g.add_device(utils.get_virtual_network())346 self._compare(g, "install-f11", False)347 def testF11AC97(self):348 def build_guest():349 i = utils.make_distro_installer()350 g = utils.get_basic_fullyvirt_guest("kvm", installer=i)351 g.os_variant = "fedora11"352 g.installer.cdrom = True353 g.add_device(utils.get_floppy())354 g.add_device(utils.get_filedisk())355 g.add_device(utils.get_blkdisk())356 g.add_device(utils.get_virtual_network())357 g.add_device(VirtualAudio(g.conn))358 return g359 utils.set_conn(utils.open_plainkvm(connver=11000))360 g = build_guest()361 self._compare(g, "install-f11-ac97", False)362 utils.set_conn(utils.open_plainkvm(libver=5000))363 g = build_guest()364 self._compare(g, "install-f11-noac97", False)365 utils.set_conn(utils.open_plainkvm(libver=7000, connver=7000))366 g = build_guest()367 self._compare(g, "install-f11-noac97", False)368 def testKVMKeymap(self):369 conn = utils.open_plainkvm(connver=10000)370 g = virtinst.VirtualGraphics(conn)371 g.type = "vnc"372 self.assertTrue(g.keymap is not None)373 conn = utils.open_plainkvm(connver=11000)374 g = virtinst.VirtualGraphics(conn)375 g.type = "vnc"376 self.assertTrue(g.keymap is None)377 def testF11Qemu(self):378 utils.set_conn(_plainkvm)379 i = utils.make_distro_installer()380 g = utils.get_basic_fullyvirt_guest("qemu", installer=i)381 g.os_variant = "fedora11"382 g.installer.cdrom = True383 g.add_device(utils.get_floppy())384 g.add_device(utils.get_filedisk())385 g.add_device(utils.get_blkdisk())386 g.add_device(utils.get_virtual_network())387 self._compare(g, "install-f11-qemu", False)388 def testF11Xen(self):389 utils.set_conn(_plainxen)390 i = utils.make_distro_installer()391 g = utils.get_basic_fullyvirt_guest("xen", installer=i)392 g.os_variant = "fedora11"393 g.installer.cdrom = True394 g.add_device(utils.get_floppy())395 g.add_device(utils.get_filedisk())396 g.add_device(utils.get_blkdisk())397 g.add_device(utils.get_virtual_network())398 self._compare(g, "install-f11-xen", False)399 def testInstallWindowsKVM(self):400 utils.set_conn(_plainkvm)401 g = utils.build_win_kvm("/dev/default-pool/winxp.img")402 self._compare(g, "winxp-kvm-stage1", True)403 def testContinueWindowsKVM(self):404 utils.set_conn(_plainkvm)405 g = utils.build_win_kvm("/dev/default-pool/winxp.img")406 self._compare(g, "winxp-kvm-stage2", True, True)407 def testBootWindowsKVM(self):408 utils.set_conn(_plainkvm)409 g = utils.build_win_kvm("/dev/default-pool/winxp.img")410 self._compare(g, "winxp-kvm-stage3", False)411 def testInstallWindowsXenNew(self):412 def make_guest():413 g = utils.get_basic_fullyvirt_guest("xen")414 g.os_variant = "winxp"415 g.add_device(utils.get_filedisk())416 g.add_device(utils.get_blkdisk())417 g.add_device(utils.get_virtual_network())418 g.add_device(VirtualAudio(g.conn))419 return g420 utils.set_conn(utils.open_plainxen(connver=3000001))421 g = make_guest()422 self._compare(g, "install-windowsxp-xenold", True)423 utils.set_conn(utils.open_plainxen(connver=3100000))424 g = make_guest()425 self._compare(g, "install-windowsxp-xennew", True)426 # Device heavy configurations427 def testManyDisks2(self):428 i = utils.make_pxe_installer()429 g = utils.get_basic_fullyvirt_guest(installer=i)430 g.add_device(utils.get_filedisk())431 g.add_device(utils.get_blkdisk())432 d = VirtualDisk(g.conn)433 d.type = "block"434 d.path = "/dev/null"435 d.device = d.DEVICE_CDROM436 d.driver_type = "raw"437 d.validate()438 g.add_device(d)439 d = VirtualDisk(g.conn)440 d.type = "block"441 d.path = "/dev/null"442 d.device = d.DEVICE_DISK443 d.driver_name = "qemu"444 d.validate()445 g.add_device(d)446 d = VirtualDisk(g.conn)447 d.path = None448 d.device = d.DEVICE_CDROM449 d.bus = "scsi"450 d.validate()451 g.add_device(d)452 d = VirtualDisk(g.conn)453 d.path = None454 d.device = d.DEVICE_FLOPPY455 d.iotune_tbs = 1456 d.iotune_tis = 2457 d.validate()458 g.add_device(d)459 d = VirtualDisk(g.conn)460 d.type = "block"461 d.path = "/dev/null"462 d.device = d.DEVICE_FLOPPY463 d.driver_name = "phy"464 d.driver_cache = "none"465 d.iotune_rbs = 5555466 d.iotune_ris = 1234467 d.iotune_wbs = 3468 d.iotune_wis = 4469 d.validate()470 g.add_device(d)471 d = VirtualDisk(g.conn)472 d.type = "block"473 d.path = "/dev/null"474 d.bus = "virtio"475 d.driver_name = "qemu"476 d.driver_type = "qcow2"477 d.driver_cache = "none"478 d.driver_io = "threads"479 d.validate()480 g.add_device(d)481 self._compare(g, "boot-many-disks2", False)482 def testManyNICs(self):483 i = utils.make_pxe_installer()484 g = utils.get_basic_fullyvirt_guest(installer=i)485 net1 = VirtualNetworkInterface(g.conn)486 net1.type = "user"487 net1.macaddr = "22:11:11:11:11:11"488 net2 = utils.get_virtual_network()489 net3 = utils.get_virtual_network()490 net3.model = "e1000"491 net4 = VirtualNetworkInterface(g.conn)492 net4.source = "foobr0"493 net4.macaddr = "22:22:22:22:22:22"494 net4.target_dev = "foo1"495 net5 = VirtualNetworkInterface(g.conn)496 net5.type = "ethernet"497 net5.macaddr = "00:11:00:22:00:33"498 net5.source = "testeth1"499 g.add_device(net1)500 g.add_device(net2)501 g.add_device(net3)502 g.add_device(net4)503 g.add_device(net5)504 self._compare(g, "boot-many-nics", False)505 def testManyHostdevs(self):506 i = utils.make_pxe_installer()507 g = utils.get_basic_fullyvirt_guest(installer=i)508 dev1 = VirtualHostDevice(g.conn)509 dev1.type = "usb"510 dev1.product = "0x1234"511 dev1.vendor = "0x4321"512 dev2 = VirtualHostDevice(g.conn)513 dev2.type = "pci"514 dev2.bus = "0x11"515 dev2.slot = "0x2"516 dev2.function = "0x3"517 g.add_device(dev1)518 g.add_device(dev2)519 self._compare(g, "boot-many-hostdevs", False)520 def testManySounds(self):521 i = utils.make_pxe_installer()522 g = utils.get_basic_fullyvirt_guest(installer=i)523 d = VirtualAudio(g.conn)524 d.model = "sb16"525 g.add_device(d)526 d = VirtualAudio(g.conn)527 d.model = "es1370"528 g.add_device(d)529 d = VirtualAudio(g.conn)530 d.model = "pcspk"531 g.add_device(d)532 d = VirtualAudio(g.conn)533 g.add_device(d)534 self._compare(g, "boot-many-sounds", False)535 def testManyChars(self):536 i = utils.make_pxe_installer()537 g = utils.get_basic_fullyvirt_guest(installer=i)538 dev = VirtualSerialDevice(g.conn)539 dev.type = "null"540 g.add_device(dev)541 dev = VirtualParallelDevice(g.conn)542 dev.type = "unix"543 dev.source_path = "/dev/default-pool/foobar"544 g.add_device(dev)545 dev = VirtualSerialDevice(g.conn)546 dev.type = "tcp"547 dev.protocol = "telnet"548 dev.source_host = "my.source.host"549 dev.source_port = "1234"550 g.add_device(dev)551 dev = VirtualParallelDevice(g.conn)552 dev.type = "udp"553 dev.bind_host = "my.bind.host"554 dev.bind_port = "1111"555 dev.source_host = "my.source.host"556 dev.source_port = "2222"557 g.add_device(dev)558 dev = VirtualChannelDevice(g.conn)559 dev.type = "pty"560 dev.target_type = dev.CHANNEL_TARGET_VIRTIO561 dev.target_name = "foo.bar.frob"562 g.add_device(dev)563 dev = VirtualConsoleDevice(g.conn)564 dev.type = "pty"565 dev.target_type = dev.CONSOLE_TARGET_VIRTIO566 g.add_device(dev)567 dev = VirtualChannelDevice(g.conn)568 dev.type = "pty"569 dev.target_type = dev.CHANNEL_TARGET_GUESTFWD570 dev.target_address = "1.2.3.4"571 dev.target_port = "4567"572 g.add_device(dev)573 self._compare(g, "boot-many-chars", False)574 def testManyDevices(self):575 i = utils.make_pxe_installer()576 g = utils.get_basic_fullyvirt_guest(installer=i)577 g.description = "foooo barrrr somedesc"578 g.memoryBacking.hugepages = True579 # Hostdevs580 dev1 = VirtualHostDevice(g.conn)581 dev1.type = "usb"582 dev1.vendor = "0x4321"583 dev1.product = "0x1234"584 g.add_device(dev1)585 # Sound devices586 d = VirtualAudio(g.conn)587 d.model = "sb16"588 g.add_device(d)589 d = VirtualAudio(g.conn)590 d.model = "es1370"591 g.add_device(d)592 # Disk devices593 d = VirtualDisk(g.conn)594 d.type = "block"595 d.path = "/dev/null"596 d.device = d.DEVICE_FLOPPY597 d.validate()598 g.add_device(d)599 d = VirtualDisk(g.conn)600 d.type = "block"601 d.path = "/dev/null"602 d.bus = "scsi"603 d.validate()604 g.add_device(d)605 d = VirtualDisk(g.conn)606 d.path = "/tmp"607 d.device = d.DEVICE_FLOPPY608 d.validate()609 g.add_device(d)610 d = VirtualDisk(g.conn)611 d.path = "/dev/default-pool/testvol1.img"612 d.bus = "scsi"613 d.driver_name = "qemu"614 d.address.type = "spapr-vio"615 d.validate()616 g.add_device(d)617 # Controller devices618 c1 = VirtualController(g.conn)619 c1.type = "ide"620 c1.index = "3"621 c2 = VirtualController(g.conn)622 c2.type = "virtio-serial"623 c2.ports = "32"624 c2.vectors = "17"625 g.add_device(c1)626 g.add_device(c2)627 # Network devices628 net1 = utils.get_virtual_network()629 net1.model = "e1000"630 net2 = VirtualNetworkInterface(g.conn)631 net2.type = "user"632 net2.macaddr = "22:11:11:11:11:11"633 net3 = VirtualNetworkInterface(g.conn)634 net3.type = virtinst.VirtualNetworkInterface.TYPE_VIRTUAL635 net3.macaddr = "22:22:22:22:22:22"636 net3.source = "default"637 net3.model = "spapr-vlan"638 net3.address.set_addrstr("spapr-vio")639 g.add_device(net1)640 g.add_device(net2)641 g.add_device(net3)642 # Character devices643 cdev1 = VirtualSerialDevice(g.conn)644 cdev1.type = "null"645 cdev2 = VirtualParallelDevice(g.conn)646 cdev2.type = "unix"647 cdev2.source_path = "/dev/default-pool/foobar"648 cdev3 = VirtualChannelDevice(g.conn)649 cdev3.type = "spicevmc"650 g.add_device(cdev1)651 g.add_device(cdev2)652 g.add_device(cdev3)653 # Video Devices654 vdev1 = VirtualVideoDevice(g.conn)655 vdev1.model = "vmvga"656 vdev2 = VirtualVideoDevice(g.conn)657 vdev2.model = "cirrus"658 vdev2.vram = 10 * 1024659 vdev2.heads = 3660 vdev3 = VirtualVideoDevice(g.conn)661 vdev4 = VirtualVideoDevice(g.conn)662 vdev4.model = "qxl"663 g.add_device(vdev1)664 g.add_device(vdev2)665 g.add_device(vdev3)666 g.add_device(vdev4)667 # Watchdog Devices668 wdev2 = VirtualWatchdog(g.conn)669 wdev2.model = "ib700"670 wdev2.action = "none"671 g.add_device(wdev2)672 # Memballoon Devices673 mdev1 = VirtualMemballoon(g.conn)674 mdev1.model = "virtio"675 g.add_device(mdev1)676 # Check keymap autoconfig677 gdev1 = virtinst.VirtualGraphics(g.conn)678 gdev1.type = "vnc"679 self.assertTrue(gdev1.keymap is not None)680 gdev1.keymap = "en-us"681 # Check keymap None682 gdev2 = virtinst.VirtualGraphics(g.conn)683 gdev2.type = "vnc"684 gdev2.keymap = None685 gdev3 = virtinst.VirtualGraphics(g.conn)686 gdev3.type = "sdl"687 gdev3.xauth = "/dev/default-pool/.Xauthority"688 gdev3.display = ":3.4"689 gdev4 = virtinst.VirtualGraphics(g.conn)690 gdev4.type = "spice"691 gdev4.passwdValidTo = "foobar"692 gdev5 = virtinst.VirtualGraphics(g.conn)693 gdev5.type = "sdl"694 gdev5.xauth = "fooxauth"695 gdev5.display = "foodisplay"696 g.add_device(gdev1)697 g.add_device(gdev2)698 g.add_device(gdev3)699 g.add_device(gdev4)700 g.add_device(gdev5)701 g.clock.offset = "localtime"702 g.seclabel.type = g.seclabel.TYPE_STATIC703 g.seclabel.model = "selinux"704 g.seclabel.label = "foolabel"705 g.seclabel.imagelabel = "imagelabel"706 redir1 = virtinst.VirtualRedirDevice(g.conn)707 redir1.type = "spicevmc"708 redir2 = virtinst.VirtualRedirDevice(g.conn)709 redir2.type = "tcp"710 redir2.parse_friendly_server("foobar.com:1234")711 g.add_device(redir1)712 g.add_device(redir2)713 # Panic Notifier device714 pdev = VirtualPanicDevice(g.conn)715 g.add_device(pdev)716 self._compare(g, "boot-many-devices", False)717 def testCpuset(self):718 normaltest = utils.open_testdefault()719 utils.set_conn(normaltest)720 g = utils.get_basic_fullyvirt_guest()721 # Cpuset722 cpustr = virtinst.DomainNumatune.generate_cpuset(g.conn, g.memory)723 g.cpuset = cpustr724 g.vcpus = 7725 g.cpu.model = "footest"726 g.cpu.vendor = "Intel"727 g.cpu.match = "minimum"728 g.cpu.threads = "2"729 g.cpu.sockets = "4"730 g.cpu.cores = "5"731 g.cpu.add_feature("x2apic", "force")732 g.cpu.add_feature("lahf_lm", "forbid")733 self._compare(g, "boot-cpuset", False)734 # Test CPU topology determining735 cpu = virtinst.CPU(g.conn)736 cpu.sockets = "2"737 cpu.set_topology_defaults(6)738 self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [2, 3, 1])739 cpu = virtinst.CPU(g.conn)740 cpu.cores = "4"741 cpu.set_topology_defaults(9)742 self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [2, 4, 1])743 cpu = virtinst.CPU(g.conn)744 cpu.threads = "3"745 cpu.set_topology_defaults(14)746 self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [4, 1, 3])747 cpu = virtinst.CPU(g.conn)748 cpu.sockets = 5749 cpu.cores = 2750 self.assertEquals(cpu.vcpus_from_topology(), 10)751 cpu = virtinst.CPU(g.conn)752 self.assertEquals(cpu.vcpus_from_topology(), 1)753 def testUsb2(self):754 i = utils.make_pxe_installer()755 g = utils.get_basic_fullyvirt_guest(installer=i)756 for dev in virtinst.VirtualController.get_usb2_controllers(g.conn):757 g.add_device(dev)758 self._compare(g, "boot-usb2", False)759 def testFullKVMRHEL6(self):760 utils.set_conn(_plainkvm)761 i = utils.make_distro_installer(762 location="tests/cli-test-xml/fakerhel6tree")763 g = utils.get_basic_fullyvirt_guest("kvm", installer=i)764 g.add_device(utils.get_floppy())765 g.add_device(utils.get_filedisk("/dev/default-pool/rhel6.img", fake=False))766 g.add_device(utils.get_blkdisk())767 g.add_device(utils.get_virtual_network())768 g.add_device(VirtualAudio(g.conn))769 g.add_device(VirtualVideoDevice(g.conn))770 self._testInstall(g, "rhel6-kvm-stage1", "rhel6-kvm-stage2",771 detect_distro=True)772 def testFullKVMWinxp(self):773 utils.set_conn(_plainkvm)774 g = utils.build_win_kvm("/dev/default-pool/winxp.img", fake=False)775 self._testInstall(g, "winxp-kvm-stage1",776 "winxp-kvm-stage3", "winxp-kvm-stage2")777 def testDefaultBridge(self):778 origfunc = None779 util = None780 try:781 util = getattr(virtinst, "util")782 origfunc = util.default_bridge783 def newbridge(ignore_conn):...
counter.py
Source:counter.py
...90 super(BaseGate, self).__init__(base_signal_name=base_signal_name, **kwargs)91 self.p_dwell = 2.092 self.p_duty_cycle = 0.593 self.p_num_points = 194 self.run = self.add_device('Run', _delim=':', is_dev_attr=True)95 self.dwell = self.add_device('Dwell',_delim=':', is_dev_attr=True)96 self.max_points = self.add_device('MaxPoints', _delim=':', is_dev_attr=True)97 self.duty_cycle = self.add_device('DutyCycle', _delim=':', is_dev_attr=True)98 self.trig_type = self.add_device('TriggerType', _delim=':', is_dev_attr=True)99 self.trig_delay = self.add_device('TriggerDelay', _delim=':', is_dev_attr=True)100 self.retrig = self.add_device('Retriggerable', _delim=':', is_dev_attr=True)101 self.device_select = self.add_device('DeviceSelect', _delim=':', is_dev_attr=True)102 self.counter_select = self.add_device('CounterSelect', _delim=':', is_dev_attr=True)103 self.sample_mode = self.add_device('SampleMode', _delim=':', is_dev_attr=True)104 self.output_idle_state = self.add_device('OutputIdleState', _delim=':', is_dev_attr=True)105 self.clock_src_select = self.add_device('ClockSrcSelect', _delim=':', is_dev_attr=True)106 self.retriggerable = self.add_device('Retriggerable', _delim=':', is_dev_attr=True)107 self.trigger_type = self.add_device('TriggerType', _delim=':', is_dev_attr=True)108 self.trig_src_select = self.add_device('TrigSrcSelect', _delim=':', is_dev_attr=True)109 self.edge_select = self.add_device('EdgeSelect', _delim=':', is_dev_attr=True)110 self.trigger_delay = self.add_device('TriggerDelay', _delim=':', is_dev_attr=True)111 self.soft_trigger = self.add_device('SoftTrigger', _delim=':', is_dev_attr=True)112 self.run_rbv = self.add_device('Run_RBV', _delim=':', is_dev_attr=True)113 self.runningcb_idx = self.add_callback('Run_RBV', self.on_running)114 self.trig = None115 # if(soft_trig):116 # self.trig = self.add_device('SoftTrigger')117 self.isRunning = 0118 time.sleep(0.4)119 self.stop()120 # self.configure()121 def get_name(self):122 return (self.p_prefix + ':Run')123 # def on_running(self, **kwargs):124 # rawData = kwargs['value']125 # # print 'BaseGate: on_running' , kwargs126 # self.isRunning = kwargs['value']127 def on_running(self, val):128 # print 'BaseGate: on_running' , kwargs129 self.isRunning = val130 def wait_till_stopped(self, proc_qt_msgs=True):131 while self.isRunning:132 time.sleep(0.1)133 if (proc_qt_msgs):134 QtWidgets.QApplication.processEvents()135 def wait_till_running(self, proc_qt_msgs=True):136 while not self.isRunning:137 time.sleep(0.1)138 if (proc_qt_msgs):139 QtWidgets.QApplication.processEvents()140 def wait_till_running_polling(self, proc_qt_msgs=True):141 idx = 0142 while (not self.run_rbv.get() and (idx < 10)):143 time.sleep(0.1)144 if (proc_qt_msgs):145 QtWidgets.QApplication.processEvents()146 idx += 1147 def stop(self):148 if(self.run.is_connected()):149 self.run.put(0)150 # self.isRunning = 0151 def configure(self, num_points=1, dwell=2.0, duty=0.5, soft_trig=False, trig_delay=0.0):152 self.p_dwell = dwell153 self.p_duty_cycle = duty154 self.p_num_points = num_points155 self.max_points.put(self.p_num_points)156 self.dwell.put(self.p_dwell)157 self.duty_cycle.put(self.p_duty_cycle)158 self.trig_delay.put(trig_delay)159 if (self.trig is not None):160 self.trig_type.put(trig_types.SOFT_TRIGGER)161 else:162 self.trig_type.put(trig_types.DAQMX_VAL_DIGEDGE)163 def get_report(self):164 """ return a dict that reresents all of the settings for this device """165 dct = {}166 dct_put(dct, 'dwell', self.dwell.get())167 dct_put(dct, 'max_points', self.max_points.get())168 dct_put(dct, 'duty_cycle', self.duty_cycle.get())169 dct_put(dct, 'trig_type', self.trig_type.get())170 dct_put(dct, 'trig_delay', self.trig_delay.get())171 dct_put(dct, 'retrig', self.retrig.get())172 dct_put(dct, 'device_select', self.device_select.get())173 dct_put(dct, 'counter_select', self.counter_select.get())174 dct_put(dct, 'sample_mode', self.sample_mode.get())175 dct_put(dct, 'output_idle_state', self.output_idle_state.get())176 dct_put(dct, 'clock_src_select', self.clock_src_select.get())177 dct_put(dct, 'retriggerable', self.retriggerable.get())178 dct_put(dct, 'trigger_type', self.trigger_type.get())179 dct_put(dct, 'trig_src_select', self.trig_src_select.get())180 dct_put(dct, 'edge_select', self.edge_select.get())181 dct_put(dct, 'trigger_delay', self.trigger_delay.get())182 return (dct)183 def load_defaults(self):184 self.duty_cycle.set(0.5)185 self.max_points(1)186 self.retrig.set(0)187 def open(self):188 self.start()189 def start(self):190 self.run.put(1)191 # self.isRunning = 1192 def do_trigger(self):193 if (self.trig is not None):194 self.trig.put(1)195class BaseCounter(BaseObject):196 changed = QtCore.pyqtSignal(int, object)197 proc_queue = QtCore.pyqtSignal()198 def __init__(self, base_signal_name=None, **kwargs):199 super(BaseCounter, self).__init__(base_signal_name=base_signal_name, **kwargs)200 self.name = self.base_signal_name = self.base_signal_name + ':Run'201 self.data_q = queue.Queue()202 self.proc_queue.connect(self.on_proc_queue)203 self.run = self.add_device('Run', _delim=':', is_dev_attr=True)204 self.row_mode = self.add_device('RowMode', _delim=':', is_dev_attr=True)205 self.points_per_row = self.add_device('PointsPerRow', _delim=':', is_dev_attr=True)206 self.device_select = self.add_device('DeviceSelect', _delim=':', is_dev_attr=True)207 self.counter_select = self.add_device('CounterSelect', _delim=':', is_dev_attr=True)208 self.signal_src_pin_select = self.add_device('SignalSrcPinSelect', _delim=':', is_dev_attr=True)209 self.initial_count = self.add_device('InitialCount', _delim=':', is_dev_attr=True)210 self.count_dir = self.add_device('CountDir', _delim=':', is_dev_attr=True)211 self.max_points = self.add_device('MaxPoints', _delim=':', is_dev_attr=True)212 self.sample_mode = self.add_device('SampleMode', _delim=':', is_dev_attr=True)213 self.signal_src_clock_select = self.add_device('SignalSrcClockSelect', _delim=':', is_dev_attr=True)214 self.sampling_rate = self.add_device('SamplingRate', _delim=':', is_dev_attr=True)215 self.edge_select = self.add_device('EdgeSelect', _delim=':', is_dev_attr=True)216 self.retriggerable = self.add_device('Retriggerable', _delim=':', is_dev_attr=True)217 self.trig_type = self.add_device('TriggerType', _delim=':', is_dev_attr=True)218 self.trig_src_select = self.add_device('TrigSrcSelect', _delim=':', is_dev_attr=True)219 self.row_num_rbv = self.add_device('RowNum_RBV', _delim=':', is_dev_attr=True)220 self.point_num_rbv = self.add_device('PointNum_RBV', _delim=':', is_dev_attr=True)221 self.read_counts = self.add_device('ReadCounts', _delim=':', is_dev_attr=True)222 self.point_dwell = self.add_device('PointDwell', _delim=':', is_dev_attr=True)223 self.single_value_rbv = self.add_device('SingleValue_RBV', _delim=':', is_dev_attr=True)224 self.run_rbv = self.add_device('Run_RBV', _delim=':', is_dev_attr=True)225 # self.data = self.add_device('Waveform_RBV')226######## self.data = self.add_device('Waveform_RBV', _delim=':', is_dev_attr=True)227######## self.runningcb_idx = self.add_callback('Run_RBV', self.on_running)228 # self.data.changed.connect(self.on_new_data)229 self.num_points = 1230 self.isRunning = 0231 self.connected = False232 time.sleep(0.2)233 self.cb_idx = None234 self.mode = 'Line'235 # self.configure()236 def get_report(self):237 """ return a dict that reresents all of the settings for this device """238 dct = {}239 dct_put(dct, 'row_mode', self.row_mode.get())240 dct_put(dct, 'points_per_row', self.points_per_row.get())...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!