def test_server_terminate_session(debug_server): s = create_socket(connect=True) d = {"name": "setConfig", "args": {"path": CCXML_PATH}} result = send_msg(s, d) assert_msg_ok(result) d = {"name": "openSession", "args": {"name": SESSION}} result = send_msg(s, d) assert_msg_ok(result) sessionPort = result["data"]["port"] s2 = create_socket(connect=True, port=sessionPort) d = {"name": "connect"} result = send_msg(s2, d) assert_msg_ok(result) s2.close() d = {"name": "terminateSession", "args": {"name": SESSION}} result = send_msg(s, d) assert_msg_ok(result) time.sleep(2) # Give time to close down # Check that port was closed on server side with pytest.raises(Exception): s2 = create_socket(connect=True, port=sessionPort)
def test_server_create_existing_session_fail(debug_server): s = create_socket(connect=True) d = {"name": "setConfig", "args": {"path": CCXML_PATH}} result = send_msg(s, d) assert_msg_ok(result) d = {"name": "openSession", "args": {"name": SESSION}} result = send_msg(s, d) assert_msg_ok(result) assert result["data"]["name"] == SESSION sessionPort = result["data"]["port"] s2 = create_socket(connect=True, port=sessionPort) # Check we can send a command successfully d = {"name": "connect"} result = send_msg(s2, d) assert_msg_ok(result) # Try to open an existing session d = {"name": "openSession", "args": {"name": SESSION}} result = send_msg(s, d) assert_msg_fail(result)
def test_server_stop_session(debug_server): s = create_socket(connect=True) d = {"name": "setConfig", "args": {"path": CCXML_PATH}} result = send_msg(s, d) assert_msg_ok(result) d = {"name": "openSession", "args": {"name": SESSION}} result = send_msg(s, d) assert_msg_ok(result) assert result["data"]["name"] == SESSION sessionPort = result["data"]["port"] s2 = create_socket(connect=True, port=sessionPort) d = {"name": "connect"} result = send_msg(s2, d) assert_msg_ok(result) d = {"name": "stop"} result = send_msg(s2, d) assert_msg_ok(result) s2.close() s.close()
def test_server_kill_with_session_open(debug_server): s = create_socket(connect=True) d = {"name": "setConfig", "args": {"path": CCXML_PATH}} result = send_msg(s, d) assert_msg_ok(result) d = {"name": "openSession", "args": {"name": SESSION}} result = send_msg(s, d) assert_msg_ok(result) sessionPort = result["data"]["port"] s2 = create_socket(connect=True, port=sessionPort) # Check we can send a command successfully d = {"name": "connect"} result = send_msg(s2, d) s2.close() # Send kill command to server d = {"name": "killServer"} result = send_msg(s, d) assert_msg_ok(result) s.close()
def test_session_basic_verify(debug_server): s = start_server() s2 = start_session(s) connect_to_target(s2) d = { "name": "load", "args": { "file": RESOURCES_PATH + "/sensor_cc1350lp.hex" } } result = send_msg(s2, d) assert_msg_ok(result) d = { "name": "verify", "args": { "file": RESOURCES_PATH + "/sensor_cc1350lp.hex" } } result = send_msg(s2, d) assert_msg_ok(result) disconnect_from_target(s2) stop_session(s2) s2.close() kill_server(s) s.close()
def test_server_get_config(debug_server): s = create_socket(connect=True) d = {"name": "setConfig", "args": {"path": CCXML_PATH}} result = send_msg(s, d) assert_msg_ok(result) d2 = {"name": "getConfig"} result = send_msg(s, d2) assert_msg_ok(result) assert result['data'] == d['args']['path']
def test_server_getListOfCPUs(debug_server): s = create_socket(connect=True) d = {"name": "setConfig", "args": {"path": CCXML_PATH}} result = send_msg(s, d) assert_msg_ok(result) d = {"name": "getListOfCPUs"} result = send_msg(s, d) assert_msg_ok(result) assert SESSION in result['data']
def test_server_set_timeout(debug_server): s = create_socket(connect=True) d = {"name": "setTimeout", "args": {"timeout": 300}} result = send_msg(s, d) assert_msg_ok(result) d = {"name": "getTimeout"} result = send_msg(s, d) assert_msg_ok(result) assert result['data'] == 300 s.close()
def test_server_attach_ccs(debug_server): s = create_socket(connect=True) d = {"name": "setConfig", "args": {"path": CCXML_PATH}} result = send_msg(s, d) assert_msg_ok(result) d = {"name": "attachCCS"} result = send_msg(s, d) assert_msg_ok(result) time.sleep(10) s.close()
def test_session_evaluate_with_symbols(debug_server): s = start_server() s2 = start_session(s) connect_to_target(s2) d = { "name": "evaluate", "args": { "expression": "&Sensor_msgStats", "file": RESOURCES_PATH + "/sensor_cc1350lp.out" } } result = send_msg(s2, d) assert_msg_ok(result) assert type(result["data"]) == int disconnect_from_target(s2) stop_session(s2) s2.close() kill_server(s) s.close()
def test_session_load_binary(debug_server): s = start_server() s2 = start_session(s) connect_to_target(s2) d = { "name": "load", "args": { "file": RESOURCES_PATH + "/sensor_cc1350lp.bin", "binary": True, "address": 0x0 } } result = send_msg(s2, d) assert_msg_ok(result) disconnect_from_target(s2) stop_session(s2) s2.close() kill_server(s) s.close()
def test_server_getListOfCPUs_fail(debug_server): s = create_socket(connect=True) d = {"name": "getListOfCPUs"} result = send_msg(s, d) assert_msg_fail(result)
def test_session_basic_get_option_object(debug_server): s = start_server() s2 = start_session(s) connect_to_target(s2) d = { "name": "getOption", "args": { "id": "DeviceInfoRevision", } } result = send_msg(s2, d) assert_msg_ok(result) assert type(result['data']) == str assert result['data'] == "2.1" disconnect_from_target(s2) stop_session(s2) s2.close() kill_server(s) s.close()
def test_server_get_empty_config(debug_server): s = create_socket(connect=True) d = {"name": "getConfig"} result = send_msg(s, d) assert_msg_ok(result) with pytest.raises(KeyError): assert result['data'] == None
def test_server_get_timeout(debug_server): s = create_socket(connect=True) d = {"name": "getTimeout"} result = send_msg(s, d) assert_msg_ok(result) assert result['data'] == -1 s.close()
def test_server_get_list_of_sessions(debug_server): s = create_socket(connect=True) d = {"name": "setConfig", "args": {"path": CCXML_PATH}} result = send_msg(s, d) assert_msg_ok(result) d = {"name": "openSession", "args": {"name": SESSION}} result = send_msg(s, d) assert_msg_ok(result) sessionPort = result["data"]["port"] d = {"name": "getListOfSessions"} result = send_msg(s, d) assert_msg_ok(result) assert result['data'][0]['name'] == SESSION assert result['data'][0]['port'] == sessionPort
def test_server_set_console_log_command(debug_server): s = create_socket(connect=True) d = {"name": "setConsoleLevel", "args": {"level": "ALL"}} result = send_msg(s, d) assert_msg_ok(result) d = {"name": "setConsoleLevel", "args": {"level": "INFO"}} result = send_msg(s, d) assert_msg_ok(result) d = {"name": "setConsoleLevel", "args": {"level": "WARNING"}} result = send_msg(s, d) assert_msg_ok(result) d = {"name": "setConsoleLevel", "args": {"level": "OFF"}} result = send_msg(s, d) assert_msg_ok(result) s.close()
def test_server_list_configurations(debug_server): s = start_server() d = {"name": "getListOfConfigurations"} result = send_msg(s, d) assert type(result['data']) == list kill_server(s) s.close()
def test_server_set_config_fail(debug_server): s = create_socket(connect=True) d = { "name": "setConfig", "args": { "path": HOME + "/ti/CCSTargetConfigurations/MISSING.ccxml" } } result = send_msg(s, d) assert_msg_fail(result)
def test_server_list_cpus(debug_server): s = start_server() d = {"name": "getListOfCPUs"} result = send_msg(s, d) assert type(result['data']) == list assert len(result['data']) > 0 kill_server(s) s.close()
def test_session_reset_with_no_connection(debug_server): s = start_server() s2 = start_session(s) d = {"name": "reset"} result = send_msg(s2, d) assert_msg_fail(result) stop_session(s2) s2.close() kill_server(s) s.close()
def test_session_read_register_with_no_connection(debug_server): s = start_server() s2 = start_session(s) d = {"name": "readRegister", "args": {"name": "PC"}} result = send_msg(s2, d) assert_msg_fail(result) stop_session(s2) s2.close() kill_server(s) s.close()
def test_server_kill_command(debug_server): s = create_socket(connect=True) d = {"name": "killServer"} result = send_msg(s, d) assert_msg_ok(result) s.close() time.sleep(1) # Give time for server to shutdown # Check Server is dead with pytest.raises(Exception): server01.test_server_simple_connect(debug_server)
def test_session_evaluate_with_no_connection(debug_server): s = start_server() s2 = start_session(s) d = {"name": "evaluate", "args": {"expression": "MassErase();"}} result = send_msg(s2, d) assert_msg_fail(result) stop_session(s2) s2.close() kill_server(s) s.close()
def test_session_get_option_with_no_connection(debug_server): s = start_server() s2 = start_session(s) d = {"name": "getOption", "args": {"id": "DeviceInfoRevision"}} result = send_msg(s2, d) assert_msg_fail(result) stop_session(s2) s2.close() kill_server(s) s.close()
def test_server_create_config_missing_connection(debug_server): s = create_socket(connect=True) directory = HOME + "/Develop/debugserver-js/" name = "TEST.ccxml" d = { "name": "createConfig", "args": { "device": DEVICETYPE, "name": "TEST.ccxml", "directory": directory, } } result = send_msg(s, d) assert_msg_fail(result) assert result['message'] == "createConfig: Missing 'connection' argument"
def test_server_create_config_bad_directory(debug_server): s = create_socket(connect=True) directory = HOME + "/fake_directory/" name = "TEST.ccxml" d = { "name": "createConfig", "args": { "connection": CONNECTION, "device": DEVICETYPE, "name": "TEST.ccxml", "directory": directory, } } result = send_msg(s, d) assert_msg_fail(result)
def test_session_halt(debug_server): s = start_server() s2 = start_session(s) d = { "name": "halt" } result = send_msg(s2, d) assert_msg_fail(result) stop_session(s2) s2.close() kill_server(s) s.close()
def test_session_basic_reset(debug_server): s = start_server() s2 = start_session(s) connect_to_target(s2) d = {"name": "reset"} result = send_msg(s2, d) assert_msg_ok(result) disconnect_from_target(s2) stop_session(s2) s2.close() kill_server(s) s.close()
def test_session_basic_set_option_string(debug_server): s = start_server() s2 = start_session(s) connect_to_target(s2) d = {"name": "setOption", "args": {"id": "TestString", "value": "Testing"}} result = send_msg(s2, d) assert_msg_ok(result) disconnect_from_target(s2) stop_session(s2) s2.close() kill_server(s) s.close()