summaryrefslogtreecommitdiff
path: root/validation/test/av_home/av_home.py
diff options
context:
space:
mode:
authorOlivier Dufour2013-02-26 16:59:48 +0100
committerOlivier Dufour2013-04-02 09:05:01 +0200
commit48fe91475a30acda366861aef5de5c52548ac34a (patch)
treebaf6be825e770e4c30a9610872bcef5a7ac55a5f /validation/test/av_home/av_home.py
parent28e656b8079f4567cddb553ec0ae3eb4ce75b5a3 (diff)
validation/test/av_home: create skeleton for P2P AV test, refs #3844
The test is intended for field/home test. It will gather information on the environment, check that the plug can see each other, perform an UDP iperf test and format the results. The skeleton provides: * An option parser * A configuration file * A script wrapper for the test class
Diffstat (limited to 'validation/test/av_home/av_home.py')
-rwxr-xr-xvalidation/test/av_home/av_home.py87
1 files changed, 87 insertions, 0 deletions
diff --git a/validation/test/av_home/av_home.py b/validation/test/av_home/av_home.py
new file mode 100755
index 0000000000..2ec9f0330f
--- /dev/null
+++ b/validation/test/av_home/av_home.py
@@ -0,0 +1,87 @@
+# -*- coding: utf-8 -*-
+
+"""Module allowing to generate P2P report in field test."""
+
+import re, os, sys
+import ConfigParser
+import av_home_attr
+
+def master_script():
+ print ("Executing master script")
+ test_init ()
+ print ("Sending MME for environment discovery to " + av_home_attr.plug_mac +
+ " through " + av_home_attr.iface + " ...")
+ raw_input ("Press enter when slave script has been launched")
+ print ("Executing ping on slave PC ("+ av_home_attr.addr +")...")
+ print ("Executing upload iperf test on " + av_home_attr.addr + " ...")
+ raw_input ("Press enter when slave script has finished upload iperf")
+
+def slave_script():
+ print ("Executing slave script")
+ test_init ()
+ print ("Sending MME for environment discovery...")
+ print ("Starting iperf server...")
+ raw_input ("Press enter when master script has finished upload iperf test")
+ print ("Executing upload iperf test...")
+
+def config_get_item (config, section, key):
+ """Get the value of the key in the section from the config parser"""
+ try:
+ return config.get (section, key)
+ except:
+ return None
+
+def parse_config(file):
+ config = ConfigParser.RawConfigParser ()
+ config.read (file)
+ av_home_attr.plug_mac = config_get_item (config, 'Test', 'plug_mac')
+ av_home_attr.peer_mac = config_get_item (config, 'Test', 'peer_mac')
+ av_home_attr.source_mac = config_get_item (config, 'Test', 'source_mac')
+ av_home_attr.iface = config_get_item (config, 'Test', 'iface')
+ av_home_attr.addr = config_get_item (config, 'Test', 'addr')
+ av_home_attr.output_dir = config_get_item (config, 'Test', 'output_dir')
+ av_home_attr.scammer_path = config_get_item (config, 'Test', 'scammer_path')
+
+def set_opts(options):
+ if options.plug_mac:
+ av_home_attr.plug_mac = options.plug_mac
+ if options.peer_mac:
+ av_home_attr.peer_mac = options.peer_mac
+ if options.source_mac:
+ av_home_attr.source_mac = options.source_mac
+ if options.addr:
+ av_home_attr.addr = options.addr
+ if options.output_dir:
+ av_home_attr.output_dir = options.output_dir
+ if options.iface:
+ av_home_attr.iface = options.iface
+ if options.scammer_path:
+ av_home_attr.scammer_path = options.scammer_path
+
+def check_params():
+ errorstr = ""
+ error = 0
+ mac_re = re.compile (r"([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$")
+ if not re.match (mac_re, av_home_attr.plug_mac) \
+ or not re.match (mac_re, av_home_attr.peer_mac) \
+ or not re.match (mac_re, av_home_attr.source_mac):
+ print "MAC address invalid"
+ sys.exit (1)
+ if not re.match (r"((((25[0-5])|(2[0-4][0-9])|(1?[0-9]{1,2})).){3})((25[0-5])|(2[0-4][0-9])|(1?[0-9]{1,2}))$",
+ av_home_attr.addr):
+ print "IP address invalid"
+ sys.exit (1)
+ if not av_home_attr.scammer_path:
+ print "You must set the path to scammer"
+ sys.exit (1)
+
+def test_init():
+ if not av_home_attr.output_dir:
+ av_home_attr.output_dir = "test_home-default"
+ else:
+ av_home_attr.output_dir = "test_home-%s" % av_home_attr.output_dir
+ if not os.path.exists(av_home_attr.output_dir):
+ os.mkdir (av_home_attr.output_dir)
+ else:
+ print "Test directory already exists, choose another name"
+ sys.exit (1)