1 2import tests 3import re 4from common import TestCommon 5from results import PassFailResult 6 7@tests.add_test 8class RetypeTest(TestCommon): 9 '''test new retype code''' 10 name = "capops_retype" 11 12 def get_modules(self, build, machine): 13 modules = super(RetypeTest, self).get_modules(build, machine) 14 modules.add_module("test_retype") 15 return modules 16 17 def get_finish_string(self): 18 return "retype: result:" 19 20 def process_data(self, testdir, rawiter): 21 # the test passed iff the last line is the finish string 22 passed = False 23 for line in rawiter: 24 if line.startswith(self.get_finish_string()): 25 _,_,results=line.split(':') 26 results = results.strip() 27 passed = results == "0" 28 return PassFailResult(passed) 29 30@tests.add_test 31class RetypeMultiTest(TestCommon): 32 '''test new retype code''' 33 name = "capops_retype_multi" 34 35 def setup(self,build,machine,testdir): 36 super(RetypeMultiTest, self).setup(build,machine,testdir) 37 self._ncores = machine.get_ncores() 38 self._nseen = 0 39 40 def get_modules(self, build, machine): 41 modules = super(RetypeMultiTest, self).get_modules(build, machine) 42 modules.add_module("test_retype", ["core=0-%d" % (machine.get_ncores()-1), "quiet"]) 43 return modules 44 45 def is_finished(self, line): 46 if line.startswith("retype: result:"): 47 self._nseen += 1 48 return self._nseen == self._ncores or super(RetypeMultiTest, self).is_finished(line) 49 50 def process_data(self, testdir, rawiter): 51 # the test passed iff the last line is the finish string 52 nspawned = 0 53 npassed = 0 54 for line in rawiter: 55 if re.match(r'.*pawning .*test_retype on core', line): 56 nspawned += 1 57 if line.startswith("retype: result:"): 58 _,_,r=line.split(':') 59 r = r.strip() 60 if r == "0": 61 npassed += 1 62 return PassFailResult(npassed == nspawned) 63 64@tests.add_test 65class RootCNResize(TestCommon): 66 '''test root cnode resizing''' 67 name = "capops_rootcn_resize" 68 69 def get_modules(self, build, machine): 70 modules = super(RootCNResize, self).get_modules(build, machine) 71 modules.add_module("test_rootcn_resize") 72 return modules 73 74 def get_finish_string(self): 75 return "test_rootcn_resize: " 76 77 def process_data(self, testdir, rawiter): 78 # the test passed iff the last line is the finish string 79 passed = False 80 for line in rawiter: 81 if line.startswith(self.get_finish_string()): 82 results =line.split(':') 83 results = map(str.strip, results) 84 passed = "passed" in results 85 return PassFailResult(passed) 86 87@tests.add_test 88class CreateL1L2(TestCommon): 89 '''test L1/L2 cnode creation''' 90 name = "capops_create_l1l2" 91 92 def get_modules(self, build, machine): 93 modules = super(CreateL1L2, self).get_modules(build, machine) 94 modules.add_module("test_create_l1l2_cnodes") 95 return modules 96 97 def get_finish_string(self): 98 return "L1/L2 CNode creation: " 99 100 def process_data(self, testdir, rawiter): 101 # the test passed iff the last line is the finish string 102 passed = False 103 for line in rawiter: 104 if line.startswith(self.get_finish_string()): 105 results =line.split(':') 106 results = map(str.strip, results) 107 passed = "passed" in results 108 return PassFailResult(passed) 109