def test_persist(self, time): with tempfile.TemporaryDirectory() as d: Config.update({'metrics': {'outputdir': d}}) persist([ get_metric('a.b.c', '1'), get_metric('e', '2'), ]) with open(os.path.join(d, 'vatu-123456123456.metrics')) as metricsfile: metrics = metricsfile.readlines() self.assertEqual(metrics[0], '123456123456// a.b.c{} 1\n') self.assertEqual(metrics[1], '123456123456// e{} 2\n')
def test_set_power_limit(self): with tempfile.NamedTemporaryFile('w') as f: Config.update({'files': {'power': f.name}}) Config.update({'readonly': False}) set_power_limit(100) self.assertEqual(get_power_limit(), 100) # make sure we honor read-only mode Config.update({'readonly': True}) set_power_limit(99) self.assertEqual(get_power_limit(), 100) # make sure we honor the power limit Config.update({'readonly': False}) Config.update({'card': {'power': {'limit': 150}}}) with self.assertRaises(ValueError): set_power_limit(200) self.assertEqual(get_power_limit(), 100)
def test_get_core_plevel(self): Config.update({'files': {'core': get_filepath('pp_dpm_sclk')}}) level = get_core_plevel() self.assertEqual(level, 0)
def test_get_memory_plevel(self): Config.update({'files': {'memory': get_filepath('pp_dpm_mclk')}}) level = get_memory_plevel() self.assertEqual(level, 3)
def test_get_power_limit(self): Config.update({'files': {'power': get_filepath('power1_cap')}}) self.assertEqual(get_power_limit(), 123)
def test_set_powerplay_table(self): with tempfile.NamedTemporaryFile('w+') as f: Config.update({'files': {'powerplay': f.name}}) Config.update({'readonly': False}) set_powerplay_table('core', [(1200, 800), (1400, 900)]) self.assertEqual(f.readlines(), ['s 0 1200 800\n', 's 1 1400 900\n', 'c\n']) # make sure we honor the clock limit with tempfile.NamedTemporaryFile('w+') as f: Config.update({'files': {'powerplay': f.name}}) Config.update({'core': {'clock': {'limit': 1650}}}) Config.update({'core': {'voltage': {'limit': 1300}}}) with self.assertRaises(ValueError): set_powerplay_table('core', [(1500, 1050), (1650, 1050), (1700, 1200)]) self.assertEqual(f.readlines(), ['s 0 1500 1050\n', 's 1 1650 1050\n', 'r\n']) # make sure we honor the voltage limit with tempfile.NamedTemporaryFile('w+') as f: Config.update({'files': {'powerplay': f.name}}) Config.update({'core': {'clock': {'limit': 1800}}}) Config.update({'core': {'voltage': {'limit': 1100}}}) with self.assertRaises(ValueError): set_powerplay_table('core', [(1600, 1050), (1650, 1100), (1700, 1200)]) self.assertEqual(f.readlines(), ['s 0 1600 1050\n', 's 1 1650 1100\n', 'r\n']) # make sure we honor read-only mode with tempfile.NamedTemporaryFile('w+') as f: Config.update({'files': {'powerplay': f.name}}) Config.update({'readonly': True}) set_powerplay_table('core', [(1200, 800), (1400, 900)]) self.assertEqual(f.readlines(), [])
def test_get_powerplay_table(self): Config.update({'files': {'powerplay': get_filepath('pp_od_clk_voltage')}}) table = get_powerplay_table('memory') self.assertEqual(table, [(167, 800), (500, 800), (800, 950), (1234, 1050)])
def setUpClass(cls): Config.update({'files': {'gpuinfo': get_filepath('amdgpu_pm_info')}})