1456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis#!/usr/bin/python 2456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 3456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtisimport unittest 4456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtisimport common 5456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtisfrom autotest_lib.client.virt import virt_utils 6456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 7456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtisclass virt_utils_test(unittest.TestCase): 8456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 9456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 10456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis def test_cpu_vendor_intel(self): 11456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis flags = ['fpu', 'vme', 'de', 'pse', 'tsc', 'msr', 'pae', 'mce', 12456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'cx8', 'apic', 'sep', 'mtrr', 'pge', 'mca', 'cmov', 13456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'pat', 'pse36', 'clflush', 'dts', 'acpi', 'mmx', 'fxsr', 14456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'sse', 'sse2', 'ss', 'ht', 'tm', 'pbe', 'syscall', 'nx', 15456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'lm', 'constant_tsc', 'arch_perfmon', 'pebs', 'bts', 16456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'rep_good', 'aperfmperf', 'pni', 'dtes64', 'monitor', 17456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'ds_cpl', 'vmx', 'smx', 'est', 'tm2', 'ssse3', 'cx16', 18456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'xtpr', 'pdcm', 'sse4_1', 'xsave', 'lahf_lm', 'ida', 19456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'tpr_shadow', 'vnmi', 'flexpriority'] 20456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis vendor = virt_utils.get_cpu_vendor(flags, False) 21456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis self.assertEqual(vendor, 'intel') 22456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 23456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 24456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis def test_cpu_vendor_amd(self): 25456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis flags = ['fpu', 'vme', 'de', 'pse', 'tsc', 'msr', 'pae', 'mce', 26456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'cx8', 'apic', 'mtrr', 'pge', 'mca', 'cmov', 'pat', 27456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'pse36', 'clflush', 'mmx', 'fxsr', 'sse', 'sse2', 28456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'ht', 'syscall', 'nx', 'mmxext', 'fxsr_opt', 'pdpe1gb', 29456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'rdtscp', 'lm', '3dnowext', '3dnow', 'constant_tsc', 30456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'rep_good', 'nonstop_tsc', 'extd_apicid', 'aperfmperf', 31456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'pni', 'monitor', 'cx16', 'popcnt', 'lahf_lm', 32456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'cmp_legacy', 'svm', 'extapic', 'cr8_legacy', 'abm', 33456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'sse4a', 'misalignsse', '3dnowprefetch', 'osvw', 'ibs', 34456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'skinit', 'wdt', 'cpb', 'npt', 'lbrv', 'svm_lock', 35456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'nrip_save'] 36456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis vendor = virt_utils.get_cpu_vendor(flags, False) 37456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis self.assertEqual(vendor, 'amd') 38456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 39456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 40456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis def test_vendor_unknown(self): 41456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis flags = ['non', 'sense', 'flags'] 42456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis vendor = virt_utils.get_cpu_vendor(flags, False) 43456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis self.assertEqual(vendor, 'unknown') 44456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 45456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 46456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis def test_get_archive_tarball_name(self): 47456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis tarball_name = virt_utils.get_archive_tarball_name('/tmp', 48456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'tmp-archive', 49456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'bz2') 50456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis self.assertEqual(tarball_name, 'tmp-archive.tar.bz2') 51456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 52456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 53456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis def test_get_archive_tarball_name_absolute(self): 54456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis tarball_name = virt_utils.get_archive_tarball_name('/tmp', 55456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis '/var/tmp/tmp', 56456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'bz2') 57456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis self.assertEqual(tarball_name, '/var/tmp/tmp.tar.bz2') 58456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 59456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 60456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis def test_get_archive_tarball_name_from_dir(self): 61456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis tarball_name = virt_utils.get_archive_tarball_name('/tmp', 62456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis None, 63456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 'bz2') 64456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis self.assertEqual(tarball_name, 'tmp.tar.bz2') 65456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 66456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis 67456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtisif __name__ == '__main__': 68456d3c115952bf1ae984770e226c5a50676b31c0Dale Curtis unittest.main() 69