1 #!/usr/bin/python 2 3 import unittest 4 import common 5 from autotest_lib.client.virt import virt_utils 6 7 class virt_utils_test(unittest.TestCase): 8 9 10 def test_cpu_vendor_intel(self): 11 flags = ['fpu', 'vme', 'de', 'pse', 'tsc', 'msr', 'pae', 'mce', 12 'cx8', 'apic', 'sep', 'mtrr', 'pge', 'mca', 'cmov', 13 'pat', 'pse36', 'clflush', 'dts', 'acpi', 'mmx', 'fxsr', 14 'sse', 'sse2', 'ss', 'ht', 'tm', 'pbe', 'syscall', 'nx', 15 'lm', 'constant_tsc', 'arch_perfmon', 'pebs', 'bts', 16 'rep_good', 'aperfmperf', 'pni', 'dtes64', 'monitor', 17 'ds_cpl', 'vmx', 'smx', 'est', 'tm2', 'ssse3', 'cx16', 18 'xtpr', 'pdcm', 'sse4_1', 'xsave', 'lahf_lm', 'ida', 19 'tpr_shadow', 'vnmi', 'flexpriority'] 20 vendor = virt_utils.get_cpu_vendor(flags, False) 21 self.assertEqual(vendor, 'intel') 22 23 24 def test_cpu_vendor_amd(self): 25 flags = ['fpu', 'vme', 'de', 'pse', 'tsc', 'msr', 'pae', 'mce', 26 'cx8', 'apic', 'mtrr', 'pge', 'mca', 'cmov', 'pat', 27 'pse36', 'clflush', 'mmx', 'fxsr', 'sse', 'sse2', 28 'ht', 'syscall', 'nx', 'mmxext', 'fxsr_opt', 'pdpe1gb', 29 'rdtscp', 'lm', '3dnowext', '3dnow', 'constant_tsc', 30 'rep_good', 'nonstop_tsc', 'extd_apicid', 'aperfmperf', 31 'pni', 'monitor', 'cx16', 'popcnt', 'lahf_lm', 32 'cmp_legacy', 'svm', 'extapic', 'cr8_legacy', 'abm', 33 'sse4a', 'misalignsse', '3dnowprefetch', 'osvw', 'ibs', 34 'skinit', 'wdt', 'cpb', 'npt', 'lbrv', 'svm_lock', 35 'nrip_save'] 36 vendor = virt_utils.get_cpu_vendor(flags, False) 37 self.assertEqual(vendor, 'amd') 38 39 40 def test_vendor_unknown(self): 41 flags = ['non', 'sense', 'flags'] 42 vendor = virt_utils.get_cpu_vendor(flags, False) 43 self.assertEqual(vendor, 'unknown') 44 45 46 def test_get_archive_tarball_name(self): 47 tarball_name = virt_utils.get_archive_tarball_name('/tmp', 48 'tmp-archive', 49 'bz2') 50 self.assertEqual(tarball_name, 'tmp-archive.tar.bz2') 51 52 53 def test_get_archive_tarball_name_absolute(self): 54 tarball_name = virt_utils.get_archive_tarball_name('/tmp', 55 '/var/tmp/tmp', 56 'bz2') 57 self.assertEqual(tarball_name, '/var/tmp/tmp.tar.bz2') 58 59 60 def test_get_archive_tarball_name_from_dir(self): 61 tarball_name = virt_utils.get_archive_tarball_name('/tmp', 62 None, 63 'bz2') 64 self.assertEqual(tarball_name, 'tmp.tar.bz2') 65 66 67 if __name__ == '__main__': 68 unittest.main() 69