master
Raw Download raw file
 1import os.path
 2
 3# From this package
 4import lib.error as error
 5import lib.test_framework as test_framework
 6import lib.util as util
 7
 8class Runner(test_framework.AbstractRunner):
 9    LEVEL = 0
10
11    def __init__(self, options):
12        self.dictionary_path = options["dictionary_path"]
13        super(Runner, self).__init__(options)
14
15    def subprocess_command(self):
16        return [self.executable_path(), self.dictionary_path]
17
18    def executable_path(self):
19        return os.path.join(os.path.dirname(__file__), "..", "level0")
20
21    def report_result(self, test_case, result):
22        benchmark_output = test_case['output']
23        benchmark_time = test_case['wall_clock_time']
24
25        your_output = result['output']
26        your_time = result['wall_clock_time']
27
28        returncode = result['exitstatus']
29
30        if returncode != 0:
31            util.logger.info('Your process exited uncleanly. Exit code: %i',
32                        result['returncode'])
33        elif benchmark_output == your_output:
34            time_ratio = (your_time + 0.0) / benchmark_time
35            msg = ("Test case passed. Your time: %(your_time)f seconds. Benchmark time: "
36                   "%(benchmark_time)f seconds. You/Benchmark: %(time_ratio)f")
37            util.logger.info(msg,
38                        {"your_time": your_time,
39                         "benchmark_time": benchmark_time,
40                         "time_ratio": time_ratio}
41                        )
42        else:
43            msg = ("Test case failed. Your time: %(your_time)f. "
44                   "Benchmark time: %(benchmark_time)f")
45            util.logger.error(msg, {"your_time": your_time, "benchmark_time": benchmark_time})
46            self.log_diff(benchmark_output, your_output)