<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import pyOCD <EOL> import logging , os , sys <EOL> class Logger ( object ) : <EOL> def __init__ ( self , filename = "<STR_LIT>" ) : <EOL> self . terminal = sys . stdout <EOL> self . log = open ( filename , "<STR_LIT:a>" ) <EOL> def write ( self , message ) : <EOL> self . terminal . write ( message ) <EOL> self . log . write ( message ) <EOL> def flush ( self ) : <EOL> self . terminal . flush ( ) <EOL> self . log . flush ( ) <EOL> class TestResult ( object ) : <EOL> def __init__ ( self , test_board , test , result ) : <EOL> self . passed = result <EOL> self . board = test_board <EOL> self . test = test <EOL> class Test ( object ) : <EOL> def __init__ ( self , name , function ) : <EOL> self . name = name <EOL> self . test_function = function <EOL> def run ( self , board ) : <EOL> """<STR_LIT>""" <EOL> passed = False <EOL> try : <EOL> self . test_function ( board . getUniqueID ( ) ) <EOL> passed = True <EOL> except Exception as e : <EOL> print ( "<STR_LIT>" % ( e , board . getUniqueID ( ) ) ) <EOL> return TestResult ( board , self , passed ) <EOL> def print_perf_info ( self , result_list , output_file = None ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> @ staticmethod <EOL> def print_results ( result_list , output_file = None ) : <EOL> msg_format_str = "<STR_LIT>" <EOL> print ( "<STR_LIT>" ) <EOL> print ( msg_format_str . format ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> file = output_file ) <EOL> print ( "<STR_LIT>" , file = output_file ) <EOL> for result in result_list : <EOL> status_str = "<STR_LIT>" if result . passed else "<STR_LIT>" <EOL> print ( msg_format_str . format ( result . board . target_type , <EOL> result . test . name , <EOL> status_str , result . time ) , <EOL> file = output_file ) <EOL> @ staticmethod <EOL> def all_tests_pass ( result_list ) : <EOL> passed = True <EOL> for result in result_list : <EOL> if not result . passed : <EOL> passed = False <EOL> break <EOL> if len ( result_list ) <= <NUM_LIT:0> : <EOL> passed = False <EOL> return passed </s>
