1########################################################################## 2# Copyright (c) 2016, ETH Zurich. 3# All rights reserved. 4# 5# This file is distributed under the terms in the attached LICENSE file. 6# If you do not find this file, copies can be found by writing to: 7# ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group. 8########################################################################## 9 10import tests 11import re 12from common import TestCommon 13from results import PassFailResult 14 15distops_tests = [ 16 { "testname": "retype", 17 "finish_string": "distops_retype: test done", 18 "error_regex": "^.*distops_retype: .* expected .*$" 19 }, 20 { "testname": "delete", 21 "finish_string": "distops_delete: test done", 22 "error_regex": "^.*distops_delete: .* failed: .*$", 23 }, 24 { "testname": "revoke", 25 "finish_string": "distops_revoke: test done", 26 "error_regex": "^.*distops_revoke: .* expected .*$", 27 }, 28] 29 30def dist_test_factory(testname, finish_string, error_regex): 31 class DistTest(TestCommon): 32 name = "distops_%s" % testname 33 34 def get_modules(self, build, machine): 35 modules = super(DistTest, self).get_modules(build, machine) 36 modules.add_module("test_remote_%s" % testname, [ "core=0", "server" ]) 37 modules.add_module("test_remote_%s" % testname, [ "core=1", "client" ]) 38 return modules 39 40 def get_finish_string(self): 41 return finish_string 42 43 def process_data(self, testdir, rawiter): 44 # the test passed iff we do not find a line matching the given 45 # error regex 46 error_re = re.compile(error_regex) 47 passed = True 48 found_test = False 49 for line in rawiter: 50 if error_re.match(line): 51 passed = False 52 if self.get_finish_string() in line: 53 found_test = True 54 return PassFailResult(found_test and passed) 55 return DistTest 56 57for t in distops_tests: 58 klass = dist_test_factory(**t) 59 tests.add_test(klass) 60