Skip to content

Add a count_uniq sanity function #556

@vkarak

Description

@vkarak

I think it is useful for flexible tests since it avoids caveats like the following:

import reframe as rfm
import reframe.utility.sanity as sn


@rfm.simple_test
class HostnameCheck(rfm.RunOnlyRegressionTest):
    def __init__(self):
        super().__init__()
        self.valid_systems = ['daint', 'dom']
        self.valid_prog_environs = ['PrgEnv-cray']
        self.executable = 'hostname'
        self.sourcesdir = None
        self.num_tasks = 0
        self.sanity_patterns = sn.assert_eq(
            self.num_tasks_assigned,
            sn.count(sn.findall(r'nid\d+', self.stdout))
        )

    @property
    @sn.sanity_function
    def num_tasks_assigned(self):
        return self.job.num_tasks

The test passes fine, but it's missing the num_tasks_per_node = 1, which would have been caught easily if I could replace count with count_uniq:

nid00000
nid00000
nid00000
nid00000
nid00000
nid00000
nid00000
nid00000
nid00001
nid00001
nid00001
nid00001
nid00001
nid00001
nid00001

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions