Esempio n. 1
0
    def setup(self, partition, environ, **job_opts):

        def parse_cpus(x):
            return sorted([int(xi) for xi in x.split()])

        re_aff_cores = r'CPU affinity: \[\s+(?P<cpus>[\d+\s+]+)\]'
        self.aff_cores = sn.extractall(
            re_aff_cores, self.stdout, 'cpus', parse_cpus)
        ref_key = 'ref_' + partition.fullname
        self.ref_cores = sn.extractall(
            re_aff_cores, self.cases[self.variant][ref_key],
            'cpus', parse_cpus)
        re_aff_thrds = r'^Tag:[^\n\r]*Thread:\s+(?P<thread>\d+)'
        self.aff_thrds = sn.extractall(re_aff_thrds, self.stdout, 'thread',
                                       int)
        self.ref_thrds = sn.extractall(
            re_aff_thrds, self.cases[self.variant][ref_key],
            'thread', int)
        re_aff_ranks = r'^Tag:[^\n\r]*Rank:\s+(?P<rank>\d+)[\s+\S+]'
        self.aff_ranks = sn.extractall(re_aff_ranks, self.stdout, 'rank', int)
        self.ref_ranks = sn.extractall(
            re_aff_ranks, self.cases[self.variant][ref_key],
            'rank', int)

        self.use_multithreading = self.cases[self.variant]['multithreading']

        # Ranks and threads can be extracted into lists in order to compare
        # them since the affinity programm prints them in ascending order.
        self.sanity_patterns = sn.all([
            sn.assert_eq(self.aff_thrds, self.ref_thrds),
            sn.assert_eq(self.aff_ranks, self.ref_ranks),
            sn.assert_eq(sn.sorted(self.aff_cores), sn.sorted(self.ref_cores))
        ])

        super().setup(partition, environ, **job_opts)
Esempio n. 2
0
    def set_sanity(self):
        def parse_cpus(x):
            return sorted(x)

        re_aff_cores = r'affinity = \s+(?P<cpus>\d+:\d+:(?:[\d+,]*|[\d+-]*)\d+)'
        self.aff_cores = sn.extractall(re_aff_cores, self.stdout, 'cpus',
                                       parse_cpus)
        ref_key = 'ref_' + self.current_partition.fullname
        self.ref_cores = sn.extractall(re_aff_cores,
                                       self.cases[self.variant][ref_key],
                                       'cpus', parse_cpus)

        # Ranks and threads can be extracted into lists in order to compare
        # them since the affinity programm prints them in ascending order.
        self.sanity_patterns = sn.all([
            sn.assert_eq(sn.sorted(self.aff_cores), sn.sorted(self.ref_cores))
        ])
Esempio n. 3
0
 def test_sorted(self):
     l = [2, 3, 1]
     ds = sn.sorted(l)
     self.assertEqual([1, 2, 3], list(evaluate(ds)))
Esempio n. 4
0
def test_sorted():
    l = [2, 3, 1]
    ds = sn.sorted(l)
    assert [1, 2, 3] == list(sn.evaluate(ds))