def test_event_phys_core_param(self):
     found_flag = False
     for lne in process.get_command_output_matching('perf list', 'hv_24x7'):
         lne = lne.split(',')[0].split('/')[1]
         if 'HPM_0THRD_NON_IDLE_CCYC__PHYS_CORE' in lne:
             found_flag = True
             break
     if not found_flag:
         self.cancel("HPM_0THRD_NON_IDLE_CCYC__PHYS_CORE not found")
     result1 = self.event_stat('__PHYS_CORE,core=1/ sleep 1')
     if "Invalid event/parameter" not in result1.stdout.decode("utf-8"):
         self.fail('perf unable to recognize'
                   ' hv_24x7/HPM_0THRD_NON_IDLE_CCYC__PHYS_CORE'
                   ' has invalid event')
     else:
         self.log.info('perf recognized Invalid event')
示例#2
0
    def setUp(self):
        '''
        Install the basic packages to support perf
        '''

        # Check for basic utilities
        smm = SoftwareManager()
        detected_distro = distro.detect()
        distro_name = detected_distro.name

        if detected_distro.arch != 'ppc64le':
            self.cancel('This test is not supported on %s architecture' %
                        detected_distro.arch)

        if cpu.get_family() == 'power8':
            self.cancel('This test not applies to Power8')

        if 'PowerNV' not in genio.read_file('/proc/cpuinfo').rstrip(
                '\t\r\n\0'):
            self.cancel('This test applies only to PowerNV')

        deps = ['gcc', 'make']
        if 'Ubuntu' in distro_name:
            deps.extend(
                ['linux-tools-common',
                 'linux-tools-%s' % platform.uname()[2]])
        elif distro_name in ['rhel', 'SuSE', 'fedora', 'centos']:
            deps.extend(['perf'])
        else:
            self.cancel("Install the package for perf supported \
                         by %s" % detected_distro.name)
        for package in deps:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel('%s is needed for the test to be run' % package)

        # Collect nest events
        self.list_of_nest_events = []
        for line in process.get_command_output_matching('perf list', 'nest_'):
            line = line.split(' ')[2]
            if 'pm_nest' in line:
                continue
            self.list_of_nest_events.append(line)

        # Clear the dmesg, by that we can capture the delta at the end of the
        # test.
        process.run("dmesg -c", sudo=True)
示例#3
0
    def setUp(self):
        '''
        Install the basic packages to support perf
        '''

        # Check for basic utilities
        smm = SoftwareManager()
        detected_distro = distro.detect()
        self.distro_name = detected_distro.name

        if 'ppc64' not in detected_distro.arch:
            self.cancel('This test is not supported on %s architecture' %
                        detected_distro.arch)
        if 'PowerNV' in genio.read_file('/proc/cpuinfo'):
            self.cancel('This test is only supported on LPAR')

        deps = ['gcc', 'make']
        if 'Ubuntu' in self.distro_name:
            deps.extend(
                ['linux-tools-common',
                 'linux-tools-%s' % platform.uname()[2]])
        elif self.distro_name in ['rhel', 'SuSE', 'fedora', 'centos']:
            deps.extend(['perf'])
        else:
            self.cancel("Install the package for perf supported \
                         by %s" % detected_distro.name)
        for package in deps:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel('%s is needed for the test to be run' % package)

        # Collect all hv_gpci events
        self.list_of_hv_gpci_events = []
        for line in process.get_command_output_matching(
                'perf list', 'hv_gpci'):
            line = line.split(',')[0].split('/')[1]
            self.list_of_hv_gpci_events.append(line)

        # Clear the dmesg, by that we can capture the delta at the end of
        # the test.
        output = process.run("dmesg -c")
    def setUp(self):
        """
        Setup checks :
        0. Processor should be ppc64.
        1. Perf package
        2. 24x7 is not supported on guest
        3. 24x7 is present
        4. Performance measurement is enabled in LPAR through BMC
        """
        smm = SoftwareManager()
        detected_distro = distro.detect()
        if 'ppc64' not in detected_distro.arch:
            self.cancel("Processor is not PowerPC")
        deps = ['gcc', 'make']
        if 'Ubuntu' in detected_distro.name:
            deps.extend(
                ['linux-tools-common',
                 'linux-tools-%s' % platform.uname()[2]])
        elif detected_distro.name in ['rhel', 'SuSE', 'fedora', 'centos']:
            deps.extend(['perf', 'numactl'])
        else:
            self.cancel("Install the package for perf supported by %s" %
                        detected_distro.name)
        for package in deps:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel('%s is needed for the test to be run' % package)

        cpu_family = cpu.get_family()
        perf_args = "perf stat -v -e"
        if cpu_family == 'power8':
            perf_stat = "%s hv_24x7/HPM_0THRD_NON_IDLE_CCYC" % perf_args
        elif cpu_family == 'power9':
            perf_stat = "%s hv_24x7/CPM_TLBIE" % perf_args
        elif cpu_family == 'power10':
            perf_stat = "%s hv_24x7/CPM_TLBIE_FIN" % perf_args
        event_sysfs = "/sys/bus/event_source/devices/hv_24x7"

        # Check if this is a guest
        # 24x7 is not suported on guest
        if "emulated by" in cpu._get_info():
            self.cancel("This test is not supported on guest")

        # Check if 24x7 is present
        if os.path.exists(event_sysfs):
            self.log.info('hv_24x7 present')
        else:
            self.cancel("%s doesn't exist.This test is supported"
                        " only on PowerVM" % event_sysfs)

        # Performance measurement has to be enabled in lpar through BMC
        # Check if its enabled
        result_perf = process.run("%s,domain=2,core=1/ sleep 1" % perf_stat,
                                  ignore_status=True)
        if "operations is limited" in result_perf.stderr.decode("utf-8"):
            self.cancel("Please enable LPAR to allow collecting"
                        " the 24x7 counters info")

        # Getting the number of cores
        output = process.run("lscpu")
        for line in output.stdout.decode("utf-8").split('\n'):
            if 'Core(s) per socket:' in line:
                self.cores = int(line.split(':')[1].strip())

        # Getting the number of chips available in the machine
        self.chip = memory.numa_nodes()

        # Collect all hv_24x7 events
        self.list_of_hv_24x7_events = []
        for lne in process.get_command_output_matching('perf list', 'hv_24x7'):
            lne = lne.split(',')[0].split('/')[1]
            self.list_of_hv_24x7_events.append(lne)

        # Clear the dmesg to capture the delta at the end of the test.
        process.run("dmesg -C", sudo=True)
示例#5
0
 def test_does_not_match(self):
     res = process.get_command_output_matching("echo foo", "bar")
     self.assertEqual(res, [])
示例#6
0
 def test_matches_multiple(self):
     res = process.get_command_output_matching("echo -e 'foo\nfoo\n'",
                                               "foo")
     self.assertEqual(res, ["foo", "foo"])
示例#7
0
 def test_matches(self):
     res = process.get_command_output_matching("echo foo", "foo")
     self.assertEqual(res, ["foo"])