1########################################################################## 2# Copyright (c) 2009, 2010, 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, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 8########################################################################## 9 10import re 11import debug, tests 12from common import TestCommon, TimeoutError 13from results import RawResults, PassFailResult 14 15class MultihopTestCommon(TestCommon): 16 17 def get_module_name(self): 18 raise NotImplementedError 19 20 def get_modules(self, build, machine): 21 modules = super(MultihopTestCommon, self).get_modules(build, machine) 22 modules.add_module(self.get_module_name()) 23 return modules 24 25@tests.add_test 26class MultihopTest(MultihopTestCommon): 27 ''' Test whether multi-hop messaging is working ''' 28 name = "multihop_test" 29 30 def get_module_name(self): 31 return "multihoptest" 32 33 def get_finish_string(self): 34 return "server all done" 35 36 def get_modules(self, build, machine): 37 modules = super(MultihopTestCommon, self).get_modules(build, machine) 38 modules.add_module(self.get_module_name(),["core=0", "server"]) 39 modules.add_module(self.get_module_name(),["core=1", "client"]) 40 return modules 41 42 def process_data(self, testdir, rawiter): 43 # the test passed iff we see the finish string 44 passed = False 45 for line in rawiter: 46 if self.get_finish_string() in line: 47 passed = True 48 return PassFailResult(True) 49 return PassFailResult(False) 50 51 52@tests.add_test 53class MultihopLatencyTest(MultihopTestCommon): 54 ''' Multihop Transport Throughput microbenchmark ''' 55 name = "multihop_throughput_latency" 56 57 def get_module_name(self): 58 return "multihop_latency_bench" 59 60 def process_data(self, testdir, rawiter): 61 results = RawResults('message type') 62 times = [] 63 iteration = None 64 for line in rawiter: 65 m = re.match("Running latency test for message (.*)....", line) 66 if m: 67 if times: 68 results.add_group(iteration, times) 69 iteration = m.group(1) 70 times = [] 71 continue 72 73 m = re.match("page \d+ took (\d+)", line) 74 if m: 75 assert(iteration is not None) 76 times.append(int(m.group(1))) 77 78 if len(times) != 0: 79 results.add_group(iteration, times) 80 return results 81 82