Beispiel #1
0
    def test_mock(self):
        slot_name = '1111:11:11.1'
        pci_id = '1111:1111'

        try:
            pdev = PciDev(slot_name, pci_id, 'mock pci')
        except:
            pdev = None
        
        self.assertIsNotNone(pdev)
        self.assertEqual(pdev.vendor_name(), 'Other')
Beispiel #2
0
    def test_mock(self):

        slot_name = '1111:11:11.1'
        pci_id = '1111:1111'
        pdev = PciDev(slot_name, pci_id, 'mock pci')
        self.assertIsNotNone(pdev)
        self.assertEqual(pdev.vendor_name(), 'Other')

        self.assertIsNotNone(pdev)
        gpu_dev = GpuDev(pdev)
        self.assertIsNotNone(gpu_dev)
Beispiel #3
0
 def test_invalid_slot(self):
     slot_name = '01:00'
     pci_id = '1002:67df'
     try:
         pdev = PciDev(slot_name, pci_id, '')
         self.assertFalse(True)
     except:
         pdev = None
Beispiel #4
0
    def test_nak_gpu(self):
        slot_name = '1111:11:11.1'
        pci_id = '1111:1111'
        pdev = PciDev(slot_name, pci_id, 'mock pci')
        self.assertIsNotNone(pdev)
        self.assertEqual(pdev.vendor_name(), 'Other')

        gpu_dev = GpuNak(pdev)
        self.assertIsNotNone(gpu_dev)

        gpu_ctl = GpuCtl(gpu_devices=[gpu_dev], verbose=True)

        rv = gpu_ctl.set_interval(wait_period=10)
        self.assertTrue(rv)

        gpu_ctl.start()
        time.sleep(5)
        gpu_ctl.stop()
Beispiel #5
0
    def test_interval(self):
        slot_name = '1111:11:11.1'
        pci_id = '1111:1111'
        pdev = PciDev(slot_name, pci_id, 'mock pci')
        self.assertIsNotNone(pdev)
        self.assertEqual(pdev.vendor_name(), 'Other')

        gpu_dev = GpuOk(pdev)
        self.assertIsNotNone(gpu_dev)

        gpu_ctl = GpuCtl(gpu_devices=[gpu_dev])

        rv = gpu_ctl.set_interval(intvl=1, wait_period=3)
        self.assertTrue(rv)

        rv = gpu_ctl.set_interval(intvl=2, wait_period=20)
        self.assertTrue(rv)

        rv = gpu_ctl.set_interval(intvl=2, wait_period=1)
        self.assertFalse(rv)
Beispiel #6
0
    def test_over_temp(self):
        slot_name = '1111:11:11.1'
        pci_id = '1111:1111'
        pdev = PciDev(slot_name, pci_id, 'mock pci')
        self.assertIsNotNone(pdev)
        self.assertEqual(pdev.vendor_name(), 'Other')

        gpu_dev = GpuNak(pdev)
        self.assertIsNotNone(gpu_dev)

        gpu_ctl = GpuCtl(gpu_devices=[gpu_dev],
                         fan=10,
                         temp=20,
                         tas='./tests/ok.sh')
        self.assertNotEqual(gpu_ctl, None)

        rv = gpu_ctl.set_interval(wait_period=10)
        self.assertTrue(rv)

        gpu_ctl.start()
        time.sleep(5)
        gpu_ctl.stop()
Beispiel #7
0
 def test_valid_slot(self):
     slot_name = '0000:01:00.0'
     pci_id = '1002:67df'
     
     try:
         pdev = PciDev(slot_name, pci_id, '')
     except:
         pdev = None
         
     self.assertIsNotNone(pdev)
     self.assertEqual(pdev.domain, '0000')
     self.assertEqual(pdev.bus_id, '01')
     self.assertEqual(pdev.slot_id, '00')
     self.assertEqual(pdev.function, '0')
Beispiel #8
0
    def test_discover_all(self):

        pci_devices = PciDev.discovery()
        gpu_devices = []
        for pdev in pci_devices:
            gpu = None
            if pdev.is_amd():
                gpu = GpuAMD(pdev)
            if pdev.is_nvidia():
                gpu = GpuNV(pdev)
            if gpu and gpu.is_gpu():
                gpu_devices.append(gpu)

        gpu_ctl = GpuCtl(gpu_devices=gpu_devices)
Beispiel #9
0
    def test_get_temp(self):
        vendors = ['AMD', 'NVIDIA']
        pci_devices = PciDev.discovery(vendor_filter=vendors)
        gpu_devices = []
        for pdev in pci_devices:
            gpu = None
            if pdev.is_amd():
                gpu = GpuAMD(pdev)
            if pdev.is_nvidia():
                gpu = GpuNV(pdev)
            if gpu and gpu.is_gpu():
                gpu_devices.append(gpu)

        for gpu in gpu_devices:
            gpu.get_temperature()
Beispiel #10
0
    def test_create(self):

        slot_name = '0000:01:00.0'
        found = False

        # ensure the card is existed then proceed the test
        pci_devices = PciDev.discovery()
        for p in pci_devices:
            if p.slot_name == slot_name:
                found = True
                break

        if not found:
            return

        try:
            pdev = PciDev.create(slot_name=slot_name)
        except:
            pdev = None
        self.assertIsNotNone(pdev)
        self.assertEqual(pdev.domain, '0000')
        self.assertEqual(pdev.bus_id, '01')
        self.assertEqual(pdev.slot_id, '00')
        self.assertEqual(pdev.function, '0')
Beispiel #11
0
    def test_discover_vendor(self):

        vendors = ['AMD', 'NVIDIA']
        pci_devices = PciDev.discovery(vendor_filter=vendors)
        gpu_devices = []
        for pdev in pci_devices:
            gpu = None
            if pdev.is_amd():
                gpu = GpuAMD(pdev)
            if pdev.is_nvidia():
                gpu = GpuNV(pdev)
            if gpu and gpu.is_gpu():
                gpu_devices.append(gpu)

        gpu_ctl = GpuCtl(gpu_devices=gpu_devices)
Beispiel #12
0
    def test_add_devices(self):

        vendors = ['AMD', 'NVIDIA']
        pci_devices = PciDev.discovery(vendor_filter=vendors)
        gpu_devices = []
        for pdev in pci_devices:
            gpu = None
            if pdev.is_amd():
                gpu = GpuAMD(pdev)
            if pdev.is_nvidia():
                gpu = GpuNV(pdev)
            if gpu and gpu.is_gpu():
                gpu_devices.append(gpu)

        gpu_ctl = GpuCtl(gpu_devices=gpu_devices)
        cnt = gpu_ctl.add_gpu_devices(gpu_devices)
        self.assertEqual(cnt, 0)