summaryrefslogtreecommitdiff
path: root/validation/test
diff options
context:
space:
mode:
authorJean-Philippe NOEL2012-09-27 14:08:19 +0200
committerJean-Philippe NOEL2012-10-05 09:46:08 +0200
commit1812d1025e94c31090700efb706b8184fd334eae (patch)
treec5a0efe07ee870874e1ae8d53f07367d5e88dd25 /validation/test
parent9ae2acfb608504ef99f3b6d51a0f05e2bdfd95e2 (diff)
validation: store the dynamic values in a file, refs #3363
Diffstat (limited to 'validation/test')
-rw-r--r--validation/test/P2P_throughput/P2P_throughput.py107
-rw-r--r--validation/test/P2P_throughput/P2P_throughput.rst8
-rw-r--r--validation/test/P2P_throughput/P2P_throughput_caller.py11
3 files changed, 64 insertions, 62 deletions
diff --git a/validation/test/P2P_throughput/P2P_throughput.py b/validation/test/P2P_throughput/P2P_throughput.py
index 181cefc741..8c7c7381b6 100644
--- a/validation/test/P2P_throughput/P2P_throughput.py
+++ b/validation/test/P2P_throughput/P2P_throughput.py
@@ -63,6 +63,26 @@ def clear_tokens(new_config):
update_config(new_config)
iperf.clear_tokens()
+def evaluate(file_path):
+ file_handler = open(file_path, "r")
+ file_content = file_handler.read()
+ file_handler.close()
+ return eval(file_content)
+
+def get_bench_data_file_path():
+ reports_directory = get_reports_directory()
+ return os.path.join(reports_directory, "bench_data.py")
+
+def write_bench_data():
+ bench_data = iperf.bench_data()
+ bench_data_file = open(get_bench_data_file_path(), "w")
+ bench_data_file.write(str(bench_data))
+ bench_data_file.close()
+
+def read_bench_data():
+ bench_data_file_path = get_bench_data_file_path()
+ return evaluate(bench_data_file_path)
+
def report(new_config):
"""Generates the PDF report as specified in the configuration.
It requires to set up first the test bench as detailed in the test bench
@@ -74,6 +94,7 @@ def report(new_config):
# Make all the measurements
if config["make_measurements"] == True:
+ write_bench_data()
iperf.clean_traces()
t0 = time.time()
estimated_min = measurements_estimated_time_min()
@@ -113,10 +134,11 @@ def build_test_bench_picture():
return fig_name
def check_config():
- data = waveform_data()
- snr_offset_db = data["snr_offset_db"]
- sjr_offset_db = data["sjr_offset_db"]
- sjr_attenuator_attenuation_db = data["sjr_attenuator_attenuation_db"]
+ waveform_data = get_waveform_data()
+ snr_offset_db = waveform_data["snr_offset_db"]
+ sjr_offset_db = waveform_data["sjr_offset_db"]
+ sjr_attenuator_attenuation_db = \
+ waveform_data["sjr_attenuator_attenuation_db"]
fixtures = config["fixtures"]
attenuation_offset = get_attenuation_offset()
attenuation_range_db = attenuator.attenuation_range_db()
@@ -205,42 +227,21 @@ def check_config_aux(attenuation_offset, attenuation_range_db,
assert test_params == None, test_params
def build_rst_file(fig_name):
- data = waveform_data()
- (non_plc_ip_address_a, non_plc_ip_address_b) = iperf.non_plc_ip_addresses()
- (version_a, version_b) = iperf.versions()
+ bench_data = read_bench_data()
+ waveform_data = get_waveform_data()
+
+ rst_template_dict = {"fig_name":fig_name}
+ rst_template_dict.update(waveform_data)
+ rst_template_dict.update(bench_data)
+ rst_template_dict.update(config)
+
rst_file = open(os.path.splitext(__file__)[0] + ".rst", "r")
rst_template = rst_file.read()
rst_file.close()
- (plug_a, plug_b) = iperf.get_plugs()
- (plug_model_a, plug_version_a) = plug_a
- (plug_model_b, plug_version_b) = plug_b
-
- config_properties = [
- ("Start order", "The host A is started first"),
- ("Iperf version on the host A (%s)" % non_plc_ip_address_a,
- version_a),
- ("Iperf version on the host B (%s)" % non_plc_ip_address_b,
- version_b),
- ("AMN attenuation (M)",
- str(data["amn_attenuation_db"]) + " dB"),
- ("Signal attenuation (N)",
- str(data["signal_attenuation_db"]) + " dB"),
- ("T attenuation (T)",
- str(config["t_attenuation_db"]) + " dB"),
- ("Wave form attenuation (P)",
- str(data["waveform_attenuation_db"]) + " dB")
- ]
-
- config_properties = rst_params(config_properties)
- rst_template_dict = dict(plug_model_a = plug_model_a,
- plug_version_a = plug_version_a,
- plug_model_b = plug_model_b,
- plug_version_b = plug_version_b,
- fig_name = fig_name,
- config_properties = config_properties)
- rst_template_dict.update (data)
+
rst_filled_template = rst_template.format (**rst_template_dict)
rst_file = rst_filled_template + rst_results()
+
report = open(file_prefix() + ".rst", 'w')
report.write(rst_file)
report.close()
@@ -408,7 +409,7 @@ def get_attenuation_offset():
def change_channel(test_type, test_params, test_value):
print "\nSetting", test_value, units[test_type], "of", test_type
- data = waveform_data()
+ waveform_data = get_waveform_data()
if test_type == "attenuation":
attenuation_offset = get_attenuation_offset()
@@ -416,15 +417,16 @@ def change_channel(test_type, test_params, test_value):
return True
elif test_type == "SNR":
waveform_generator.switch("on")
- power_dbm = data["snr_offset_db"] - test_value
+ power_dbm = waveform_data["snr_offset_db"] - test_value
waveform_generator.configure_white_noise(power_dbm)
return True
elif test_type == "frame_size":
return False
elif test_type == "SJR":
- attenuator.set_attenuation(data["sjr_attenuator_attenuation_db"])
+ attenuator.set_attenuation( \
+ waveform_data["sjr_attenuator_attenuation_db"])
waveform_generator.switch("on")
- power_dbm = data["sjr_offset_db"] - test_value
+ power_dbm = waveform_data["sjr_offset_db"] - test_value
(freq_mhz, am) = test_params
waveform_generator.configure_sinus(
freq_mhz * 1000 * 1000,
@@ -434,9 +436,10 @@ def change_channel(test_type, test_params, test_value):
None)
return True
elif test_type == "dynamic_jammer":
- attenuator.set_attenuation(data["sjr_attenuator_attenuation_db"])
+ attenuator.set_attenuation( \
+ waveform_data["sjr_attenuator_attenuation_db"])
waveform_generator.switch("on")
- power_dbm = data["sjr_offset_db"] - test_params[0]
+ power_dbm = waveform_data["sjr_offset_db"] - test_params[0]
waveform_generator.configure_sinus(
1,
power_dbm,
@@ -565,7 +568,7 @@ def get_file_prefix(test_protocol, test_type, test_params, test_value,
base_name += "_" + measure_name.replace(' ','_')
return os.path.join(reports_directory, base_name)
-def waveform_data():
+def get_waveform_data():
ppsd_dbm_per_hz = config["ppsd_dbm_per_hz"]
signal_band_mhz = config["signal_band_mhz"]
sjr_attenuator_attenuation_db = config["sjr_attenuator_attenuation_db"]
@@ -573,14 +576,14 @@ def waveform_data():
amn_attenuation_db = config["amn_attenuation_db"]
waveform_attenuation_db = config["waveform_attenuation_db"]
noise_band_mhz = waveform_generator.noise_band_mhz()
- return get_waveform_data(ppsd_dbm_per_hz, signal_band_mhz,
- noise_band_mhz, sjr_attenuator_attenuation_db,
- amn_attenuation_db, signal_attenuation_db,
- waveform_attenuation_db)
-
-def get_waveform_data(ppsd_dbm_per_hz, signal_band_mhz, noise_band_mhz,
- sjr_attenuator_attenuation_db, amn_attenuation_db,
- signal_attenuation_db, waveform_attenuation_db):
+ return get_waveform_data_aux(ppsd_dbm_per_hz, signal_band_mhz,
+ noise_band_mhz, sjr_attenuator_attenuation_db,
+ amn_attenuation_db, signal_attenuation_db,
+ waveform_attenuation_db)
+
+def get_waveform_data_aux(ppsd_dbm_per_hz, signal_band_mhz, noise_band_mhz,
+ sjr_attenuator_attenuation_db, amn_attenuation_db,
+ signal_attenuation_db, waveform_attenuation_db):
(signal_freq_min_mhz, signal_freq_max_mhz) = signal_band_mhz
signal_bandwith_mhz = signal_freq_max_mhz - signal_freq_min_mhz
#the term 60 corresponds to the conversion from MHz to Hz
@@ -666,7 +669,7 @@ if __name__ == "__main__":
"waveform_attenuation_db":10,
"snr_offset_db":11,
"sjr_offset_db":-9} == \
- get_waveform_data(-50, (2, 28), (0, 50), 17, 6, 10, 10)
+ get_waveform_data_aux(-50, (2, 28), (0, 50), 17, 6, 10, 10)
assert {"ppsd_dbm_per_hz":-63,
"par_db":10,
@@ -684,7 +687,7 @@ if __name__ == "__main__":
"waveform_attenuation_db":10,
"snr_offset_db":4,
"sjr_offset_db":-14} == \
- get_waveform_data(-63, (1, 38), (0, 50), 17, 0, 10, 10)
+ get_waveform_data_aux(-63, (1, 38), (0, 50), 17, 0, 10, 10)
assert "./P2P_throughput_UDP_frame_size_(5, 5)bytes" == \
get_file_prefix("UDP", "frame_size", None, (5, 5), "bytes", None, ".")
diff --git a/validation/test/P2P_throughput/P2P_throughput.rst b/validation/test/P2P_throughput/P2P_throughput.rst
index e65af34570..48a0e4b974 100644
--- a/validation/test/P2P_throughput/P2P_throughput.rst
+++ b/validation/test/P2P_throughput/P2P_throughput.rst
@@ -50,7 +50,13 @@ The AMN's are necessary only if the plugs are not EoC, i.e have no native output
Configuration
-------------
-{config_properties}
+ * Start order: The host A is started first
+ * Iperf version on the host A ({non_plc_ip_address_a}): {version_a}
+ * Iperf version on the host B ({non_plc_ip_address_b}): {version_b}
+ * AMN attenuation (M): {amn_attenuation_db} dB
+ * Signal attenuation (N): {signal_attenuation_db} dB
+ * T attenuation (T): {t_attenuation_db} dB
+ * Wave form attenuation (P): {waveform_attenuation_db} dB
.. raw:: pdf
diff --git a/validation/test/P2P_throughput/P2P_throughput_caller.py b/validation/test/P2P_throughput/P2P_throughput_caller.py
index fc61423a5c..3efb92add7 100644
--- a/validation/test/P2P_throughput/P2P_throughput_caller.py
+++ b/validation/test/P2P_throughput/P2P_throughput_caller.py
@@ -44,11 +44,11 @@ class P2P_throughput_caller:
if cmd not in self._commands:
self._parser.error("Unknown command \"{0}\".".format(cmd))
- example_config = evaluate(self.example_file_name)
+ example_config = P2P_throughput.evaluate(self.example_file_name)
file_name = args[1]
try:
- config = evaluate(file_name)
+ config = P2P_throughput.evaluate(file_name)
expected = sorted(example_config.keys())
actual = sorted(config.keys())
assert actual == expected, (actual, expected)
@@ -87,13 +87,6 @@ class P2P_throughput_caller:
def run_clear_tokens(self, config):
P2P_throughput.clear_tokens(config)
-def evaluate(file_name):
- config_file = open(file_name, "r")
- config_string = config_file.read()
- config_file.close()
- config = eval(config_string)
- return config
-
if __name__ == "__main__":
try:
P2P_throughput_caller().run(sys.argv[1:])