|
| 1 | +import reframe as rfm |
| 2 | +import reframe.core.builtins as builtins |
| 3 | +import reframe.utility.sanity as sn |
| 4 | + |
| 5 | + |
| 6 | +@rfm.simple_test |
| 7 | +@rfm.xfail('xfail sanity', lambda test: ( |
| 8 | + test.phase == 'sanity' and (test.status == 'xfail' or test.status == 'xpass') |
| 9 | +)) |
| 10 | +class XfailTest(rfm.RunOnlyRegressionTest): |
| 11 | + valid_systems = ['*'] |
| 12 | + valid_prog_environs = ['*'] |
| 13 | + executable = 'echo hello && echo perf=10 && echo time=0.1' |
| 14 | + reference = { |
| 15 | + '*': { |
| 16 | + 'perf': (10, 0, 0, 'GB/s'), |
| 17 | + 'time': (0.1, 0, 0, 's') |
| 18 | + } |
| 19 | + } |
| 20 | + status = parameter(['pass', 'fail', 'xfail', 'xpass']) |
| 21 | + phase = parameter(['sanity', 'performance']) |
| 22 | + |
| 23 | + @sanity_function |
| 24 | + def validate(self): |
| 25 | + if self.phase == 'sanity' and self.status in ('fail', 'xfail'): |
| 26 | + return sn.assert_found(r'helo', self.stdout) |
| 27 | + else: |
| 28 | + return sn.assert_found(r'hello', self.stdout) |
| 29 | + |
| 30 | + @run_after('init') |
| 31 | + def set_references(self): |
| 32 | + if self.phase == 'sanity': |
| 33 | + return |
| 34 | + |
| 35 | + if self.status == 'fail': |
| 36 | + self.reference['*:perf'] = (9, 0, 0, 'GB/s') |
| 37 | + elif self.status == 'xfail': |
| 38 | + self.reference['*:perf'] = builtins.xfail('xfail perf', (9, 0, 0, 'GB/s')) |
| 39 | + elif self.status == 'xpass': |
| 40 | + self.reference['*:perf'] = builtins.xfail('xfail perf', self.reference['*:perf']) |
| 41 | + |
| 42 | + @performance_function('GB/s') |
| 43 | + def perf(self): |
| 44 | + return sn.extractsingle(r'perf=(\S+)', self.stdout, 1, float) |
| 45 | + |
| 46 | + @performance_function('s') |
| 47 | + def time(self): |
| 48 | + return sn.extractsingle(r'time=(\S+)', self.stdout, 1, float) |
0 commit comments