def callback(): myGame = int(client.getGame()) msg_to_send = e.get() ready = client.send_cmd(-3, False) #if ready: #print full[myGame] + " is ready to play!" if(msg_to_send != ''): e.delete(0,END) listbox.yview(END) if(msg_to_send[0] != '/'): client.send_msg(name + ": " + msg_to_send) else: #print msg_to_send[1:] result = switch(msg_to_send[1:]) #print "My game is " + str(myGame) if(result != myGame): if(result == -3): Waldo.stop(); #does this even work? i don't think so! else: client.send_cmd(myGame, False) if(myGame >= 0): client.send_msg(name + " no longer wishes to play " + full[myGame] + ". Sissy.") if(result >= 0): client.send_cmd(result, True) client.send_msg(name + " would like to play " + full[result] + "!") #client.setGame(result) client.setGame(result) myGame = result;
def run_test(): math_endpoint = Waldo.math_endpoint_lib() single_side = Waldo.no_partner_create(SingleSide, math_endpoint) # to mod between mod_tuples_list = [(6, 2), (5, 3), (100, 3), (38, 7)] for mod_tuple in mod_tuples_list: lhs = mod_tuple[0] rhs = mod_tuple[1] if single_side.test_mod(lhs, rhs) != (lhs % rhs): print '\nErr with mod call' return False # to max max_min_list_list = [ list(range(205, 150, -1)), [-1, 52, 1, 0], [73, 13.25, 100, 239] ] for max_min_list in max_min_list_list: if single_side.test_max(max_min_list) != max(max_min_list): print '\nErr with max call' return False # to min for max_min_list in max_min_list_list: if single_side.test_min(max_min_list) != min(max_min_list): print '\nErr with min call' return False return True
def run_test(): accept_stoppable = Waldo.tcp_accept( SideA, SIDEA_HOST, SIDEA_PORT, connected_callback=sidea_connected) sideb = Waldo.tcp_connect( SideB,SIDEA_HOST,SIDEA_PORT) sidea = sidea_wait_queue.get() sidea.add_stop_listener(sidea_stop_listener) sideb.add_stop_listener(sideb_stop_listener_1) sideb.add_stop_listener(sideb_stop_listener_2) listener_id = sideb.add_stop_listener(sideb_stop_listener_2) sideb.remove_stop_listener(listener_id) sideb.remove_stop_listener(listener_id) sidea.do_nothing() sideb.do_nothing() sidea.stop() time.sleep(1) if sidea_stop_counter != 1: return False if sideb_stop_counter != 3: return False return True
def run_test(): accept_stoppable = Waldo.tcp_accept( SideA, SIDEA_HOST, SIDEA_PORT, connected_callback=sidea_connected) sideb = Waldo.tcp_connect( SideB,SIDEA_HOST,SIDEA_PORT) sidea = sidea_wait_queue.get() sidea.do_nothing() sideb.do_nothing() sidea.stop() time.sleep(1) # ensure that stop fires on single host. try: sidea.do_nothing() return False except Waldo.StoppedException as inst: pass # ensure that the other side also sees the stop. try: sideb.do_nothing() return False except Waldo.StoppedException as inst: pass return True
def spawn_acceptor(): ''' Starts the TCP accept thread and spins as connections are brought up. ''' Waldo.tcp_accept(Pong, HOST, PORT) while True: pass
def spawn_acceptor(): ''' Starts the TCP accept thread and spins as connections are brought up. ''' Waldo.tcp_accept(InnerPong, HOST, PORT_INNER, throw_func) while True: pass
def run_chatter_a(): # runs in accept mode global quit Waldo.tcp_accept(ChatterA, HOSTNAME, PORT, display_msg, connected_callback=listen_for_user_input) while True: if quit: break time.sleep(SLEEP_TIME)
def run_test(): ''' Tests whether Waldo can propagate an application exception back through an endpoint call. Returns true if the test passes and false otherwise. ''' thrower = Waldo.no_partner_create(SingleSide, None) catcher = Waldo.no_partner_create(SingleSide, thrower) return catcher.test_catch()
def run_test(): """ Tests whether Waldo can propagate an application exception back through an endpoint call. Returns true if the test passes and false otherwise. """ thrower = Waldo.no_partner_create(SingleSide, None) catcher = Waldo.no_partner_create(SingleSide, thrower) return catcher.test_catch()
def run_server(): ''' Runs the multi-connection chat server. ''' global server server = Waldo.no_partner_create(Server, display_msg) print server Waldo.tcp_accept(ClientHandler, HOSTNAME, PORT, server, display_msg) while True: time.sleep(SLEEP_TIME)
def run_test(): ''' Tests Waldo's ability to detect an application exception on the partner endpoint mid-sequence and propagate that exception back to the root endpoint for handling. Returns true if the exception is caught and handled, and false otherwise. ''' Waldo.tcp_accept(Pong, HOST, PORT) connector = Waldo.tcp_connect(Ping, HOST, PORT) return connector.testPropagateException()
def run_test(): ''' Tests Waldo's ability to detect an application exception on the partner endpoint mid-sequence and propagate that exception back to the root endpoint for handling. Returns true if the exception is caught and handled, and false otherwise. ''' Waldo.tcp_accept(Pong,HOST,PORT) connector = Waldo.tcp_connect(Ping,HOST,PORT) return connector.testPropagateException()
def run_test(): ''' Tests Waldo's ability to propagate an exception back through a sequence within an endpoint call. Returns true if the exception is caught and handled, and false otherwise. ''' Waldo.tcp_accept(Pong,HOST,PORT) connector = Waldo.tcp_connect(Ping,HOST,PORT) catcher = Waldo.no_partner_create(Catcher) catcher.addEndpoint(connector) return catcher.testCatchApplicationExceptionFromSequence()
def start_coordinator(): math_endpoint = Waldo.math_endpoint_lib() coordinator_master = Waldo.no_partner_create( CoordinatorMaster, util_funcs.between, util_funcs.rand_uuid, math_endpoint, conf.MAX_NUMBER_FINGER_TABLE_ENTRIES) # begin listening for connections to coordinator master Waldo.tcp_accept(Coordinator, conf.COORDINATOR_HOST_PORT_PAIR.host, conf.COORDINATOR_HOST_PORT_PAIR.port, coordinator_master) return coordinator_master
def run_test(): Waldo.tcp_accept(Pt2, HOST, PORT, connected_callback=pt2_connected) pt1 = Waldo.tcp_connect(Pt1, HOST, PORT,createList); pt2 = pt2_wait_queue.get() returned_list = pt1.start_seq() time.sleep(1) list_to_return.append('wo') if returned_list != list_to_return: return False return True
def run_test(): ''' Tests Waldo's ability to propagate an ApplicationException back through an endpoint call on the remote partner in a sequence. The exception should be passed back to the root endpoint which initiates the sequence. Returns true if the exception is caught and handled, and false otherwise. ''' thrower = Waldo.no_partner_create(Pong,None) catcher_partner = Waldo.tcp_accept(Pong,HOST,PORT,thrower) catcher = Waldo.tcp_connect(Ping,HOST,PORT) return catcher.testExceptionPropagation()
def run_test(): ''' Tests the try...finally statement (without the use of catch). Returns true if an error may be propagated through a try...finally and handled later while having the code in the finally block execute. ''' catcher = Waldo.no_partner_create(Catcher) thrower = Waldo.no_partner_create(Thrower) catcher.addEndpoint(thrower) thrower.addEndpoint(catcher) return catcher.testTryFinally()
def run_test(): ''' Tests Waldo's ability to detect a network failure between two endpoints mid-sequence, thrown a NetworkException, and catch that exception using a try-catch. Returns true if the exception is caught and handled, and false otherwise. ''' Waldo.set_default_heartbeat_period(1) Waldo.set_default_partner_timeout(3) acceptor_process.start() time.sleep(SLEEP_TIME) connector = Waldo.tcp_connect(Ping,HOST,PORT,signal_func) return connector.testNetworkException()
def start_coordinator(): math_endpoint = Waldo.math_endpoint_lib() coordinator_master = Waldo.no_partner_create( CoordinatorMaster, util_funcs.between, util_funcs.rand_uuid,math_endpoint, conf.MAX_NUMBER_FINGER_TABLE_ENTRIES) # begin listening for connections to coordinator master Waldo.tcp_accept( Coordinator, conf.COORDINATOR_HOST_PORT_PAIR.host, conf.COORDINATOR_HOST_PORT_PAIR.port, coordinator_master) return coordinator_master
def run_test(): ''' Tests Waldo's ability to detect a network failure between two endpoints mid-sequence, thrown a NetworkException, and catch that exception using a try-catch. Returns true if the exception is caught and handled, and false otherwise. ''' Waldo.set_default_heartbeat_period(1) Waldo.set_default_partner_timeout(3) acceptor_process.start() time.sleep(SLEEP_TIME) connector = Waldo.tcp_connect(Ping, HOST, PORT, signal_func) return connector.testNetworkException()
def on_change_password(event): password_info = menu.get_password_info() #contains tuple (current password, new password, new password) cur_password = password_info[0] if user_login.get_encrypted_key(name, cur_password) != "": if password_info[1] == password_info[2]: new_password = password_info[1] salt = user_login.get_salt(name) new_pw_hash = Waldo.hash(new_password, salt) user_login.change_password(name, Waldo.encrypt_keytext(key, new_pw_hash), new_pw_hash) menu.set_message("Password has been changed.") else: menu.set_message("New passwords do not match.") else: menu.set_message("Username/password combination was not found.")
def run_test(): id_tester = Waldo.no_partner_create(IdTester) id = id_tester.id() manager = Waldo.no_partner_create(Manager) manager_id = manager.id() manager.add_endpoint(id_tester) if id != id_tester._uuid or manager_id != manager._uuid: return False elif id_tester.get_id() != id_tester.id() or manager.get_id() != manager.id(): return False elif id != manager.get_managed_endpoint_id(): return False else: return True
def on_login (event): login_info = login.get_login_info() encrypted_key = user_login.get_encrypted_key(login_info[0], login_info[1]) if encrypted_key != "": global name name = login_info[0] password_hashed = Waldo.hash(login_info[1], user_login.get_salt(name)) global key key = Waldo.decrypt_keytext(encrypted_key, password_hashed) global certificate certificate = Waldo.get_cert_from_text(user_login.get_certificate(name)) login.close() else: login.set_message("Username/password combination was not found.")
def run_test(): id_tester = Waldo.no_partner_create(IdTester) id = id_tester.id() manager = Waldo.no_partner_create(Manager) manager_id = manager.id() manager.add_endpoint(id_tester) if id != id_tester._uuid or manager_id != manager._uuid: return False elif id_tester.get_id() != id_tester.id() or manager.get_id( ) != manager.id(): return False elif id != manager.get_managed_endpoint_id(): return False else: return True
def add_single_dht_node(node_host_port_pair): # first: connect to discovery service requester = Waldo.tcp_connect( Requester, conf.COORDINATOR_HOST_PORT_PAIR.host, conf.COORDINATOR_HOST_PORT_PAIR.port, # the host and port that our new dht node will listen on for # connections to other dht nodes. node_host_port_pair.host, node_host_port_pair.port) # request request addresses of other nodes to contact from # discovery service, plus register self with discovery service. uuid, finger_table, next, prev = requester.register() dht_node = Waldo.no_partner_create(Node, uuid, util_funcs.distance, util_funcs.hashed_uuid, util_funcs.between, util_funcs.debug_print) # listen for connections to my node def on_connected(sidea_endpoint): sidea_endpoint.add_connection_to_node() Waldo.tcp_accept(NodeSideA, node_host_port_pair.host, node_host_port_pair.port, dht_node, node_host_port_pair.host, node_host_port_pair.port, connected_callback=on_connected) # connect to other nodes in my finger table for uuid in finger_table.keys(): # table_entry has form: # host: <text> # port: <number> # valid: <bool> # uuid: <text> table_entry = finger_table[uuid] host_to_connect_to = table_entry['host'] port_to_connect_to = table_entry['port'] connection_to_finger_table_node = Waldo.tcp_connect( NodeSideB, host_to_connect_to, port_to_connect_to, dht_node, node_host_port_pair.host, node_host_port_pair.port) return dht_node
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if not test_ext_num(single_side): return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) num_to_assign = 30 single_side.assign_num_to_number_struct(num_to_assign) if single_side.read_num_from_number_struct() != num_to_assign: print '\nErr: could not write user struct number' return False # tests nesting user structs outer_nested_num = 52 inner_nested_num = 31 single_side.assign_num_to_nested_struct( outer_nested_num,inner_nested_num) if single_side.get_outer_and_inner_nested_nums() != (outer_nested_num,inner_nested_num): print '\nErr with nested user structs' return False # tests passing struct through argument to method new_num = 1 if single_side.get_endpoint_nested_struct_num(new_num) != new_num: print '\nError passing structs through as method args' return False return True
def run_test(): single_side = Waldo.no_partner_create( SingleSide, min_func,max_func,mod_func) # to mod between mod_tuples_list = [ (6,2), (5,3), (100,3), (38, 7)] for mod_tuple in mod_tuples_list: if single_side.test_mod(*mod_tuple) != mod_func(None,*mod_tuple): print '\nErr with mod call' return False # to max max_min_list_list = [ list(range(205,150, -1)), [-1, 52,1,0], [73, 13.25,100,239]] for max_min_list in max_min_list_list: if single_side.test_max(max_min_list) != max_func(None,max_min_list): print '\nErr with max call' return False # to min for max_min_list in max_min_list_list: if single_side.test_min(max_min_list) != min_func(None,max_min_list): print '\nErr with min call' return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if (1, 2, 3) != single_side.return_static_nums(): print "\nErr getting static numbers" return False if (1, 2, 3) != single_side.return_func_call_nums(): print "\nErr getting func call numbers" return False if ("a", "b") != single_side.return_variable_texts(): print "\nErr getting variable texts" return False if ("a", "b") != single_side.return_func_call_variable_texts(): print "\nErr getting func call variable texts" return False if ("a", "b", "c") != single_side.return_extended_texts(): print "\nErr getting extended texts" return False for i in range(1, 15): if (i, i) != single_side.return_tuple_endpoint_global(): print "\nErr: incorrect tuple value of mutated state" return False for j in range(i + 1, i + 15): if (j, j, 0) != single_side.wrapped_tuple(): print "\nErr: incorrect tuple value of wrapped mutated state" return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if single_side.get_num() != 0: print '\nGot incorrect initial value for number' return False if single_side.get_txt() != '': print '\nGot incorrect initial value for text' return False for counter in range(0, 100): if single_side.increment_num() != counter + 1: print '\nGot incorrect number when incrementing' return False # just want to append a single a each time. Note: probably # more efficient to just keep track of a shadow text val # myself and append an 'a' to it each time. But I wanted to # play with reduce a bit. expected_str = reduce(lambda x, y: x + y, (['a'] * (counter + 1)), '') if single_side.increment_txt('a') != expected_str: print '\nGot incorrect string back' return False internal_list = single_side.increment_list(counter) expected_internal_list = list(range(0, counter + 1)) if internal_list != expected_internal_list: print '\nNot appending to internal list correctly' return False return True
def main(): # Connecting + Starting client = Waldo.tcp_connect(Client, HOSTNAME, PORT) print "Started" startTime = time.time() # Sending all messages try: for n in range(0, 100): client.send_msg(str(100)) time.sleep(DELAY) for n in range(100, numMessages): client.send_msg(str(n)) time.sleep(DELAY) except: print "Sending message failed." # Packaging time and sending it totalTime = time.time() - startTime print "Finished: " + str(totalTime) numClients = 1 if len(sys.argv) >= 2: # assume numClients is only one unless the number of clients is given numClients = int(sys.argv[1]) # Writing and closing client.stop() f = open("clientLog", "a") f.write(str(numClients) + " " + str(numClients * numMessages) + " " + str(totalTime) + "\n") f.close()
def main(): #Connecting + Starting client = Waldo.tcp_connect(Client, HOSTNAME, PORT) print 'Started' startTime = time.time() #Sending all messages try: for n in range(0, numMessages): client.send_msg() except: print 'Sending message failed.' #Packaging time and sending it totalTime = time.time() - startTime print "Finished: " + str(totalTime) numClients = 1 if(len(sys.argv) >= 2): #assume numClients is only one unless the number of clients is given numClients = int(sys.argv[1]) #Writing and closing client.stop() f = open('clientLog', 'a') f.write(str(numClients) + ' ' + str(numClients * numMessages) + ' ' + str(totalTime) + '\n') f.close()
def run_test(): sideA, sideB = Waldo.same_host_create(SideA).same_host_create(SideB) initial_val = 22 # check peered value is initialized properly if sideA.read_peered_num() != initial_val: print '\nErr: incorrect initial val of peered num on SideA' return False if sideB.read_peered_num() != initial_val: print '\nErr: incorrect initial val of peered num on SideB' return False #### Testing that when send a 2-long sequence message, both sides update peered #### value NUM_BASIC_EXCHANGES = 20 for i in range(0, NUM_BASIC_EXCHANGES): # when we initiate a basic sequence, peered number should end up # +2 of what it was before it started. expected_new_val = initial_val + (i + 1) * 2 if sideA.basic_exchange_test() != expected_new_val: err_msg = '\nErr: incorrect value after basic message ' err_msg += 'seq on peered data' print err_msg return False if sideB.read_peered_num() != expected_new_val: err_msg = '\nErr: B did not receive updated peered ' err_msg += 'data from basic message seq' print err_msg return False #### Now testing a longer sequence message. Also ends on where we started val_after_basics = expected_new_val NUM_EXTENDED_EXCHANGES = 20 for i in range(0, NUM_EXTENDED_EXCHANGES): # when we initiate a basic sequence, peered number should end up # +2 of what it was before it started. expected_new_val = val_after_basics + (i + 1) * 28 # gotten_val = sideA.extended_exchange_test() # import pdb # pdb.set_trace() if sideA.extended_exchange_test() != expected_new_val: err_msg = '\nErr: incorrect value after ext message ' err_msg += 'seq on peered data' print err_msg return False if sideB.read_peered_num() != expected_new_val: err_msg = '\nErr: B did not receive updated peered ' err_msg += 'data from ext message seq' print err_msg return False return True
def add_single_dht_node(node_host_port_pair): # first: connect to discovery service requester = Waldo.tcp_connect( Requester, conf.COORDINATOR_HOST_PORT_PAIR.host, conf.COORDINATOR_HOST_PORT_PAIR.port, # the host and port that our new dht node will listen on for # connections to other dht nodes. node_host_port_pair.host, node_host_port_pair.port) # request request addresses of other nodes to contact from # discovery service, plus register self with discovery service. uuid, finger_table, next, prev = requester.register() dht_node = Waldo.no_partner_create( Node,uuid,util_funcs.distance,util_funcs.hashed_uuid, util_funcs.between, util_funcs.debug_print) # listen for connections to my node def on_connected(sidea_endpoint): sidea_endpoint.add_connection_to_node() Waldo.tcp_accept( NodeSideA, node_host_port_pair.host, node_host_port_pair.port, dht_node, node_host_port_pair.host, node_host_port_pair.port, connected_callback = on_connected) # connect to other nodes in my finger table for uuid in finger_table.keys(): # table_entry has form: # host: <text> # port: <number> # valid: <bool> # uuid: <text> table_entry = finger_table[uuid] host_to_connect_to = table_entry['host'] port_to_connect_to = table_entry['port'] connection_to_finger_table_node = Waldo.tcp_connect( NodeSideB, host_to_connect_to, port_to_connect_to, dht_node,node_host_port_pair.host, node_host_port_pair.port) return dht_node
def run_test(): ''' Tests Waldo's ability to detect a network failure between two endpoints mid-sequence, thrown a NetworkException, and catch that exception using a try-catch. Returns true if the exception is caught and handled, and false otherwise. ''' acceptor_process = Process(target=spawn_acceptor,args=()) Waldo.set_default_heartbeat_period(1) Waldo.set_default_partner_timeout(3) acceptor_process.start() time.sleep(KILL_WAIT_TIME) connector = Waldo.tcp_connect(Ping,HOST,PORT) time.sleep(KILL_WAIT_TIME) acceptor_process.terminate() time.sleep(TIMEOUT_DETECT_TIME) return connector.testNetworkException()
def connect_user(): app = create_chat_window() gui_string = GUI_String_Ext(text_display) global user user = Waldo.stcp_connect(User, HOSTNAME, PORT, gui_string, key = key, cert = certificate) user.set_name(name) text_display.AppendText("You have been added to the chat server.\n") user.add_to_server() app.MainLoop()
def login_user(): global user_login user_login = Waldo.stcp_connect(UserLogin, HOSTNAME, PORT + 1) global login login = LoginWindow() login.bind_functions(on_register, on_login) login.mainloop() if name == "": exit(0)
def run_test(): sideA, sideB = ( Waldo.same_host_create(SideA).same_host_create(SideB)) sideX, sideY=( Waldo.same_host_create(SideA).same_host_create(SideB)) in_val = 320 if sideA.get_struct_from_other_side(sideX,in_val) != in_val: print '\nErr: getting struct from endpoint call' return False gotten_val = sideA.get_partner_struct(in_val) if gotten_val != in_val: # if sideA.get_partner_struct(in_val) != in_val: print '\nErr: getting struct from partner' print gotten_val print in_val print '\n\n' return False # test changes to input struct across sequences inc1 = 39 inc2 = 5 if sideA.input_struct_sequence(inc1,inc2) != (inc1 + inc2): print '\nErr: input struct sequence did not increment correctly' return False # test that can insert a struct into a map and access its fields # from within map expected_num = 390 if sideA.test_struct_map('hello',expected_num) != expected_num: print '\nErr: structs in maps is broken' return False # test that can serialize maps of structs sideA.test_sequence_struct_map() return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if not test_maps(single_side): return False if not test_lists(single_side): return False return True
def __init__(self): self._connections = [] self._users = Waldo.ExternalList([]) self._matching_users = Waldo.ExternalList([]) self._open_games = Waldo.ExternalList([]) self._active_games = Waldo.ExternalList([]) Waldo.accept( self._users, self._matching_users, self._open_games, self._active_games, self.on_open_game_added, self.on_matched_game, constructor = Lobby, host_name = config.host, port = config.port, connected_callback=self.on_connection )
def run_test(): single_side = Waldo.no_partner_create(SingleSide) single_side.do_nothing() single_side.stop() try: single_side.do_nothing() except Waldo.StoppedException as inst: return True return False
def run_test(): ''' Returns true on success. ''' firstEndpoint = Waldo.no_partner_create(SelfTester) secondEndpoint = firstEndpoint.get_self() if firstEndpoint != secondEndpoint: return False elif secondEndpoint.test_input_output(NUM) != NUM: return False else: return True
def run_test(): sideA, sideB = (Waldo.same_host_create(A).same_host_create(B)) index = 'hi' val = 30 if sideA.map_test(index, val) != val: return False # val = 30 # if sideA.struct_test(val) != val: # return False return True
def run_test(): accept_stoppable = Waldo.tcp_accept( Modifier, MODIFIER_HOST, MODIFIER_PORT, connected_callback=modifier_connected) data_reader = Waldo.tcp_connect( DataReader,MODIFIER_HOST,MODIFIER_PORT) modifier = modifier_wait_queue.get() # check peered value is initialized properly if modifier.read_peered_num() != 22: print '\nErr: incorrect modifier initial val of peered num' return False if data_reader.read_peered_num() != 22: print '\nErr: incorrect data reader initial val of peered num' return False # check modifier can increment if modifier.increment_peered_num() != 23: print '\nErr: incorrect modifier return from peered num increment' return False # check modifier sees increment if modifier.read_peered_num() != 23: print '\nErr: incorrect modifier return from peered num read' return False # check data reader sees increment if data_reader.read_peered_num() != 23: print '\nErr: incorrect data reader return from peered num read' return False accept_stoppable.stop() return True
def run_test(): sideA, sideB = ( Waldo.same_host_create( SideA,print_debug).same_host_create(SideB,print_debug)) texta, textb = ('a','b') received_texta, received_textb = sideA.test_two_sequences(texta,textb) if (received_texta != texta) or (received_textb != textb): err_msg = '\nError: did not get correct values back when ' err_msg += 'initiating a 2-sequence test' print err_msg return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if not test_to_text(single_side): return False if not test_misc_list(single_side): return False if not test_nested_map(single_side): return False if not test_user_struct_returns(single_side): return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if not test_range(single_side): return False if not test_while(single_side): return False if not test_for(single_side): return False if not test_break_continue(single_side): return False return True
def run_test(): sideA, sideB = (Waldo.same_host_create(SideA).same_host_create(SideB)) original_num = 30 ext_num = Waldo._waldo_classes['WaldoExtNumVariable'](sideA._host_uuid, False, original_num) sideA.load_ext_num(ext_num) # sequences + externals amt_to_increment = 6 a, b = sideA.test_seq_arg(amt_to_increment) if a != (b + amt_to_increment): print '\nErr: incorrect numbers from sequence' return False return True
def run_test(): # for single side tests, these values do not really matter. single_side = Waldo.no_partner_create(SingleSide) if not test_comparisons(single_side): return False if not test_math(single_side): return False if not test_other_plusses(single_side): return False if not test_in(single_side): return False return True
def run_test(): a_num = 3902 a_index = 133 b_num = 302 b_index = 33 side_a, side_b = ( Waldo.same_host_create(SideA,a_num,a_index).same_host_create(SideB,b_num)) list_of_endpoints, map_of_endpoints = side_a.get_self_holders() # load sideb into external list and map side_b.append_self_to_list(list_of_endpoints) side_b.append_self_to_map(b_index,map_of_endpoints) # make endpoint calls on all endpoints in the list (ie, sideA and # sideB) and test that their values are what should be expected # for sidea's and sideb's internal numbers endpoint_num_list = side_a.get_numbers_from_list() if len(endpoint_num_list) != 2: print '\nErr: incorrect number of numbers returned in endpoint list' return False if (endpoint_num_list[0] != a_num) or (endpoint_num_list[1] != b_num): print '\nErr: incorrect numbers returned in endpoint list' return False # make endpoint calls on all endpoints in the list (ie, sideA and # sideB) and test that their values are what should be expected # for sidea's and sideb's internal numbers endpoint_num_map = side_a.get_numbers_from_map() if len(endpoint_num_map) != 2: print '\nErr: incorrect number of numbers returned in endpoint map' return False if (a_index not in endpoint_num_map) or (b_index not in endpoint_num_map): print '\nErr: missing indices in endpoint number map' return False if (endpoint_num_map[a_index] != a_num) or (endpoint_num_map[b_index] != b_num): print '\nErr: incorrect values returned in endpoint map' return False return True
def run_test(): # for single side tests, these values do not really matter. init_num = 50 init_text = 'hello' init_list = [[True, False], [False]] init_map = {2: 'wow', 6: 'this'} host_uuid = 10 single_side = Waldo.no_partner_create(SingleSide, init_num, init_text, init_list, init_map) if (single_side.get_endpoint_values() != (init_num, init_text, init_list, init_map)): print '\nErr when initializing' return False return True
def run_test(): # for single side tests, these values do not really matter. host_uuid = 10 wlist = Waldo._waldo_classes['WaldoListVariable']('some list', host_uuid) single_side = Waldo.no_partner_create(SingleSide, wlist) internal_list = wlist.get_val(None) raw_internal_list = internal_list.val.val if len(raw_internal_list) != 1: print '\nErr: did not append self to list' return False if raw_internal_list[0].val.val != single_side: print '\nErr: incorrect endpoint value appended to list' return False return True
def run_test(): endpt = Waldo.no_partner_create(SingleHost, delay) long_write_long_thread = EndpointThread(endpt, True) write_long_long_thread = EndpointThread(endpt, False) long_write_long_thread.start() time.sleep(.05) write_long_long_thread.start() long_write_long_thread.join() write_long_long_thread.join() if long_write_long_thread.result != 1: return False if write_long_long_thread.result != 2: return False return True
def run_test(): endpt = Waldo.no_partner_create(SingleHost, delay) long_write_long_thread = EndpointThread(endpt, True) write_long_long_thread = EndpointThread(endpt, False) long_write_long_thread.start() time.sleep(.05) write_long_long_thread.start() long_write_long_thread.join() write_long_long_thread.join() global got_retry, got_aborted_retry if not got_retry: return False if not got_aborted_retry: return False return True
def run_test(): # for single side tests, these values do not really matter. internal_num = 35 index_num = 31 single_side = Waldo.no_partner_create(SingleSide, internal_num, index_num) if single_side.get_external_vals(index_num) != (internal_num, internal_num): print '\nErr: got an incorrect external val' return False internal_num = 22 single_side.change_external_num(internal_num) if single_side.get_external_vals(index_num) != (internal_num, internal_num): print '\nErr: got an incorrect external val after changing' return False return True