Skip to content
Snippets Groups Projects
Commit 019e8555 authored by Felix Gerking's avatar Felix Gerking
Browse files

EMV Testsuite: Bug fixes on emv_network_pretest.py, refs #31490

* The script will now checks, if the folder /opt/ltp/results exists, otherwise it will be created
** The log file can not be initialized if the upper folder does not exist
* If a default ip route is set, the script will remove it
** The device can no longer use a default ip route if the wifi stick is removed

Change-Id: I1a4ce4145fd02a0602c6c4a76699a06843c65bb2
Reviewed-on: http://gfweb/gerrit/327
parent 75857246
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import subprocess import subprocess
import time import time
import curses import curses
import os
# Window dimensions # Window dimensions
x_max = 70 x_max = 70
...@@ -59,8 +60,8 @@ def msg_write(action,keys,stdscr): ...@@ -59,8 +60,8 @@ def msg_write(action,keys,stdscr):
stdscr.addstr(action, curses.color_pair(1)) stdscr.addstr(action, curses.color_pair(1))
stdscr.move(19,2) stdscr.move(19,2)
stdscr.addstr(keys, curses.color_pair(1)) stdscr.addstr(keys, curses.color_pair(1))
stdscr.refresh()
stdscr.move(y_max+2,0) stdscr.move(y_max+2,0)
stdscr.refresh()
def msg_clear(stdscr): def msg_clear(stdscr):
for x in range(1,70): for x in range(1,70):
stdscr.move(18,x) stdscr.move(18,x)
...@@ -68,8 +69,8 @@ def msg_clear(stdscr): ...@@ -68,8 +69,8 @@ def msg_clear(stdscr):
for x in range(1,70): for x in range(1,70):
stdscr.move(19,x) stdscr.move(19,x)
stdscr.addstr(" ") stdscr.addstr(" ")
stdscr.refresh()
stdscr.move(y_max+2,0) stdscr.move(y_max+2,0)
stdscr.refresh()
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
# Evaluate test output # Evaluate test output
...@@ -109,6 +110,14 @@ def bash_cmd(inputStr): ...@@ -109,6 +110,14 @@ def bash_cmd(inputStr):
value = subprocess.call(callStr, shell=True) value = subprocess.call(callStr, shell=True)
return value return value
#---------------------------------------------------------------------------#
# Check and delete default ip route
#---------------------------------------------------------------------------#
def del_default_route():
route_str = subprocess.check_output('route')
if route_str.find('default') != -1:
bash_cmd("route del default")
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
# Network Ethernet 0 # Network Ethernet 0
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
...@@ -120,7 +129,8 @@ def eth0(stdscr): ...@@ -120,7 +129,8 @@ def eth0(stdscr):
msg_write("Remove the cable from ethernet port 0","Press 'c' to continue, 'q' to quit",stdscr) msg_write("Remove the cable from ethernet port 0","Press 'c' to continue, 'q' to quit",stdscr)
user_input(stdscr) user_input(stdscr)
msg_clear(stdscr) msg_clear(stdscr)
bash_cmd("echo 'Ethernet 0 unplugged (Test should fail):'")
out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.1.100 -n 1 -w 50 &>>/opt/ltp/results/network_test.log", shell=True) out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.1.100 -n 1 -w 50 &>>/opt/ltp/results/network_test.log", shell=True)
ev_output(out,0,current_line,stdscr) ev_output(out,0,current_line,stdscr)
...@@ -132,6 +142,7 @@ def eth0(stdscr): ...@@ -132,6 +142,7 @@ def eth0(stdscr):
time.sleep(8) time.sleep(8)
msg_clear(stdscr) msg_clear(stdscr)
bash_cmd("echo 'Ethernet 0 plugged (Test should pass):'")
out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.1.100 -n 1 -w 50 &>>/opt/ltp/results/network_test.log", shell=True) out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.1.100 -n 1 -w 50 &>>/opt/ltp/results/network_test.log", shell=True)
ev_output(out,1,current_line,stdscr) ev_output(out,1,current_line,stdscr)
...@@ -147,6 +158,8 @@ def eth1(stdscr): ...@@ -147,6 +158,8 @@ def eth1(stdscr):
user_input(stdscr) user_input(stdscr)
msg_clear(stdscr) msg_clear(stdscr)
del_default_route()
bash_cmd("echo 'Ethernet 1 unplugged (Test should fail):'")
out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.2.100 -n 1 -w 50 &>>/opt/ltp/results/network_test.log", shell=True) out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.2.100 -n 1 -w 50 &>>/opt/ltp/results/network_test.log", shell=True)
ev_output(out,0,current_line,stdscr) ev_output(out,0,current_line,stdscr)
...@@ -158,6 +171,8 @@ def eth1(stdscr): ...@@ -158,6 +171,8 @@ def eth1(stdscr):
time.sleep(8) time.sleep(8)
msg_clear(stdscr) msg_clear(stdscr)
del_default_route()
bash_cmd("echo 'Ethernet 1 plugged (Test should pass):'")
out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.2.100 -n 1 -w 50 &>>/opt/ltp/results/network_test.log", shell=True) out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.2.100 -n 1 -w 50 &>>/opt/ltp/results/network_test.log", shell=True)
ev_output(out,1,current_line,stdscr) ev_output(out,1,current_line,stdscr)
...@@ -169,21 +184,25 @@ def wlan(stdscr): ...@@ -169,21 +184,25 @@ def wlan(stdscr):
stdscr.addstr(current_line,2,"WLAN:") stdscr.addstr(current_line,2,"WLAN:")
# Unplugged test # Unplugged test
msg_write("Remove ethernet cable from the router","Press 'c' to continue, 'q' to quit",stdscr) msg_write("Remove the WLAN stick","Press 'c' to continue, 'q' to quit",stdscr)
user_input(stdscr) user_input(stdscr)
msg_clear(stdscr) msg_clear(stdscr)
del_default_route()
bash_cmd("echo 'WLAN unplugged (Test should fail):'")
out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.3.100 -n 1 -w 1000 &>>/opt/ltp/results/network_test.log", shell=True) out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.3.100 -n 1 -w 1000 &>>/opt/ltp/results/network_test.log", shell=True)
ev_output(out,0,current_line,stdscr) ev_output(out,0,current_line,stdscr)
# Plugged test # Plugged test
msg_write ("Reconnect the cable","Press 'c' to continue, 'q' to quit",stdscr) msg_write ("Reconnect the WLAN stick","Press 'c' to continue, 'q' to quit",stdscr)
user_input(stdscr) user_input(stdscr)
msg_clear(stdscr) msg_clear(stdscr)
msg_write("Wait for the network to come up","",stdscr) msg_write("Wait for the network to come up","",stdscr)
time.sleep(10) time.sleep(10)
msg_clear(stdscr) msg_clear(stdscr)
del_default_route()
bash_cmd("echo 'WLAN plugged (Test should pass):'")
out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.3.100 -n 1 -w 1000 &>>/opt/ltp/results/network_test.log", shell=True) out = subprocess.call("/opt/ltp/testcases/bin/iptest -q -g 192.168.3.100 -n 1 -w 1000 &>>/opt/ltp/results/network_test.log", shell=True)
ev_output(out,1,current_line,stdscr) ev_output(out,1,current_line,stdscr)
...@@ -196,7 +215,9 @@ def main(stdscr): ...@@ -196,7 +215,9 @@ def main(stdscr):
msg_write("Ensure the network interfaces are configured correctly. For this","you can use the emv_network_config.sh file. Press 'c' to continue",stdscr) msg_write("Ensure the network interfaces are configured correctly. For this","you can use the emv_network_config.sh file. Press 'c' to continue",stdscr)
user_input(stdscr) user_input(stdscr)
msg_clear(stdscr) msg_clear(stdscr)
# Resest log # Create and reset log
if not os.path.exists("/opt/ltp/results"):
os.makedirs("/opt/ltp/results")
subprocess.call("date &>/opt/ltp/results/network_test.log", shell=True) subprocess.call("date &>/opt/ltp/results/network_test.log", shell=True)
# Ethernet 0 test # Ethernet 0 test
eth0(stdscr) eth0(stdscr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment