examples: Use flushed print to see logs on the CI server

This commit is contained in:
Roland Dobai
2018-09-21 10:34:55 +02:00
parent 17b7959de9
commit 975688b97f
7 changed files with 139 additions and 134 deletions

View File

@@ -38,6 +38,7 @@ if test_fw_path and test_fw_path not in sys.path:
import TinyFW
import IDF
import Utility
# Import client module
expath = os.path.dirname(os.path.realpath(__file__))
@@ -55,23 +56,23 @@ def test_examples_protocol_http_server_simple(env, extra_data):
IDF.check_performance("http_server_bin_size", bin_size//1024)
# Upload binary and start testing
print("Starting http_server simple test app")
Utility.console_log("Starting http_server simple test app")
dut1.start_app()
# Parse IP address of STA
print("Waiting to connect with AP")
Utility.console_log("Waiting to connect with AP")
got_ip = dut1.expect(re.compile(r"(?:[\s\S]*)Got IP: '(\d+.\d+.\d+.\d+)'"), timeout=120)[0]
got_port = dut1.expect(re.compile(r"(?:[\s\S]*)Starting server on port: '(\d+)'"), timeout=30)[0]
print("Got IP : " + got_ip)
print("Got Port : " + got_port)
Utility.console_log("Got IP : " + got_ip)
Utility.console_log("Got Port : " + got_port)
# Expected Logs
dut1.expect("Registering URI handlers", timeout=30)
# Run test script
# If failed raise appropriate exception
print("Test /hello GET handler")
Utility.console_log("Test /hello GET handler")
if not client.test_get_handler(got_ip, got_port):
raise RuntimeError
@@ -86,7 +87,7 @@ def test_examples_protocol_http_server_simple(env, extra_data):
dut1.expect("Found URL query parameter => query2=value2", timeout=30)
dut1.expect("Request headers lost", timeout=30)
print("Test /ctrl PUT handler and realtime handler de/registration")
Utility.console_log("Test /ctrl PUT handler and realtime handler de/registration")
if not client.test_put_handler(got_ip, got_port):
raise RuntimeError
dut1.expect("Unregistering /hello and /echo URIs", timeout=30)
@@ -94,24 +95,24 @@ def test_examples_protocol_http_server_simple(env, extra_data):
# Generate random data of 10KB
random_data = ''.join(string.printable[random.randint(0,len(string.printable))-1] for _ in range(10*1024))
print("Test /echo POST handler with random data")
Utility.console_log("Test /echo POST handler with random data")
if not client.test_post_handler(got_ip, got_port, random_data):
raise RuntimeError
query = "http://foobar"
print("Test /hello with custom query : " + query)
Utility.console_log("Test /hello with custom query : " + query)
if not client.test_custom_uri_query(got_ip, got_port, query):
raise RuntimeError
dut1.expect("Found URL query => " + query, timeout=30)
query = "abcd+1234%20xyz"
print("Test /hello with custom query : " + query)
Utility.console_log("Test /hello with custom query : " + query)
if not client.test_custom_uri_query(got_ip, got_port, query):
raise RuntimeError
dut1.expect("Found URL query => " + query, timeout=30)
query = "abcd\nyz"
print("Test /hello with invalid query")
Utility.console_log("Test /hello with invalid query")
if client.test_custom_uri_query(got_ip, got_port, query):
raise RuntimeError
dut1.expect("400 Bad Request - Server unable to understand request due to invalid syntax", timeout=30)