summaryrefslogtreecommitdiff
path: root/validation/test
diff options
context:
space:
mode:
authorJean-Philippe NOEL2012-09-13 11:33:16 +0200
committerJean-Philippe NOEL2012-10-05 09:46:02 +0200
commita8d2e1820fb2676677c99ec793f3130a00b84b1f (patch)
tree8d020efd61a8b05853a9373dbe1a725532700361 /validation/test
parent1b59959f8814dd8036fe6da2e323a3c02d4dcfd5 (diff)
validation: add unit tests on the config, refs #3363
Diffstat (limited to 'validation/test')
-rw-r--r--validation/test/P2P_throughput_report/P2P_throughput_report.py215
-rw-r--r--validation/test/P2P_throughput_report/P2P_throughput_report.rst4
2 files changed, 144 insertions, 75 deletions
diff --git a/validation/test/P2P_throughput_report/P2P_throughput_report.py b/validation/test/P2P_throughput_report/P2P_throughput_report.py
index 918bf812cf..67dbe66c50 100644
--- a/validation/test/P2P_throughput_report/P2P_throughput_report.py
+++ b/validation/test/P2P_throughput_report/P2P_throughput_report.py
@@ -9,6 +9,7 @@ import subprocess
import os
import numpy
import math
+import sys
import validlib.attenuator as attenuator
import validlib.waveform_generator as waveform_generator
@@ -144,7 +145,7 @@ config = {
#Signal attenuation on each side of the bench, to avoid any dazzling
#between the plugs. A typical value is 10.
"signal_attenuation_db": 10,
- #(unidir, bidir) throughput targets in Mbit/s for UDP tests
+ #(unidir, bidir) throughput targets for UDP tests
#Typical values are the following:
# - (100, 85) in AV with an SPR310 and
# - (142, 85) for EoC with an SPK300g
@@ -283,46 +284,68 @@ def build_test_bench_picture():
return fig_name
def check_config():
-
data = waveform_data()
-
- for (test_protocol, test_type, test_params) in config["fixtures"]:
- assert test_protocol in ["UDP", "TCP"]
- assert test_type in ["attenuation", "SNR", "frame_size", "SJR", \
- "dynamic_jammer"]
- for curve in config[test_type]["curves"]:
- assert curve in iperf.measurements_specs().keys()
- assert type(config[test_type]["duration_s"]) == int
- if test_type == "SNR":
- #We check here that the values of SNR are consistent with the
- #output power range of the waveform generator
- for test_value in config[test_type]["values"]:
- power_dbm = data["snr_offset"] - test_value
- (min_power_dbm, max_power_dbm) = \
- waveform_generator.power_range_dbm()
- assert power_dbm <= max_power_dbm, \
- ("SNR too low", test_value)
- assert power_dbm >= min_power_dbm, \
- ("SNR too high", test_value)
+ snr_offset_db = data["snr_offset_db"]
+ sjr_offset_db = data["sjr_offset_db"]
+ fixtures = config["fixtures"]
+ attenuation_offset = get_attenuation_offset()
+ attenuation_range_db = attenuator.attenuation_range_db()
+ power_range_dbm = waveform_generator.power_range_dbm()
+ for fixture in fixtures:
+ (test_protocol, test_type, test_params) = fixture
+ curves = config[test_type]["curves"]
+ test_values = config[test_type]["values"]
+ check_config_aux(attenuation_offset, attenuation_range_db,
+ snr_offset_db, sjr_offset_db, curves, test_values,
+ power_range_dbm,
+ test_protocol, test_type, test_params)
+
+def check_config_aux(attenuation_offset, attenuation_range_db,
+ snr_offset_db, sjr_offset_db, power_range_dbm,
+ curves,
+ test_values, test_protocol, test_type,
+ test_params):
+ assert test_protocol in ["UDP", "TCP"]
+ assert test_type in ["attenuation", "SNR", "frame_size", "SJR",
+ "dynamic_jammer"]
+ for curve in curves:
+ assert curve in iperf.measurements_specs().keys()
+ if test_type == "attenuation":
+ (min_attenuation_db, max_attenuation_db) = attenuation_range_db
+ for test_value in test_values:
+ attenuation_db = test_value - attenuation_offset
+ assert attenuation_db <= max_attenuation_db, \
+ ("Attenuation too high", test_value)
+ assert attenuation_db >= min_attenuation_db, \
+ ("Attenuation too low", test_value)
+ if test_type == "SNR":
+ #We check here that the values of SNR are consistent with the
+ #output power range of the waveform generator
+ (min_power_dbm, max_power_dbm) = power_range_dbm
+ for test_value in test_values:
+ power_dbm = snr_offset_db - test_value
+ assert power_dbm <= max_power_dbm, \
+ ("SNR too low", test_value)
+ assert power_dbm >= min_power_dbm, \
+ ("SNR too high", test_value)
assert test_params == None
- elif test_type == "SJR":
+ elif test_type == "SJR":
#Because of sjr_attenuator_attenuation_db, the bench is not
#symetrical on this test
- assert curve == "a_b_uni", curve
- #We check here that the values of SJR are consistent with the
- #output power range of the waveform generator
- for test_value in config[test_type]["values"]:
- power_dbm = data["sjr_offset"] - test_value
- (min_power_dbm, max_power_dbm) = \
- waveform_generator.power_range_dbm()
- assert power_dbm <= max_power_dbm, \
- ("SJR too low", test_value)
- assert power_dbm >= min_power_dbm, \
- ("SJR too high", test_value)
- elif test_type == "dynamic_jammer":
- assert config[test_type]["values"] == ["time"]
- else:
- assert test_params == None, test_params
+ assert curve == "a_b_uni", curve
+ #We check here that the values of SJR are consistent with the
+ #output power range of the waveform generator
+ for test_value in test_values:
+ power_dbm = sjr_offset_db - test_value
+ (min_power_dbm, max_power_dbm) = power_range_dbm
+ assert power_dbm <= max_power_dbm, \
+ ("SJR too low", test_value)
+ assert power_dbm >= min_power_dbm, \
+ ("SJR too high", test_value)
+ elif test_type == "dynamic_jammer":
+ assert test_values == ["time"]
+ else:
+ assert test_params == None, test_params
def build_rst_file(fig_name):
data = waveform_data()
@@ -502,6 +525,13 @@ def initialize_testing_devices():
attenuator.set_attenuation(0)
waveform_generator.switch("off")
+def get_attenuation_offset():
+ """Offset allowing to convert the overall attenuation in the attenuation
+ at the attenuator level (attenuation = overall attenuation - offset)"""
+ signal_attenuation_db = config["signal_attenuation_db"]
+ return (2 * (signal_attenuation_db + get_amn_attenuation_db()) + \
+ attenuation_t_db)
+
def change_channel(test_type, test_params, test_value):
print "\nSetting", test_value, units[test_type], "of", test_type
@@ -510,15 +540,12 @@ def change_channel(test_type, test_params, test_value):
if test_type == "attenuation":
#Offset allowing to convert the overall attenuation in the attenuation
#at the attenuator level (attenuation = overall attenuation - offset)
- signal_attenuation_db = config["signal_attenuation_db"]
- offset = 2 * (signal_attenuation_db + get_amn_attenuation_db()) + \
- attenuation_t_db
- assert test_value >= offset, (test_type, test_value)
+ offset = attenuation_offset()
attenuator.set_attenuation(test_value - offset)
return True
elif test_type == "SNR":
waveform_generator.switch("on")
- power_dbm = data["snr_offset"] - test_value
+ power_dbm = data["snr_offset_db"] - test_value
waveform_generator.configure_white_noise(power_dbm)
return True
elif test_type == "frame_size":
@@ -526,7 +553,7 @@ def change_channel(test_type, test_params, test_value):
elif test_type == "SJR":
attenuator.set_attenuation(data["sjr_attenuator_attenuation_db"])
waveform_generator.switch("on")
- power_dbm = data["sjr_offset"] - test_value
+ power_dbm = data["sjr_offset_db"] - test_value
(freq_mhz, am) = test_params
waveform_generator.configure_sinus(
freq_mhz * 1000 * 1000,
@@ -538,7 +565,7 @@ def change_channel(test_type, test_params, test_value):
elif test_type == "dynamic_jammer":
attenuator.set_attenuation(data["sjr_attenuator_attenuation_db"])
waveform_generator.switch("on")
- power_dbm = data["sjr_offset"] - test_params[0]
+ power_dbm = data["sjr_offset_db"] - test_params[0]
waveform_generator.configure_sinus(
1,
power_dbm,
@@ -695,17 +722,17 @@ def get_waveform_data(ppsd_dbm_per_hz, signal_band_mhz, noise_band_mhz,
bandwiths_ratio_db = int(round(10 * math.log10( \
float(signal_bandwith_mhz) / float(noise_bandwith_mhz)), 0))
- snr_offset = int(tx_signal_power_dbm - \
- amn_attenuation_db - \
- signal_attenuation_db + \
- waveform_attenuation_db - \
- bandwiths_ratio_db)
+ snr_offset_db = int(tx_signal_power_dbm - \
+ amn_attenuation_db - \
+ signal_attenuation_db + \
+ waveform_attenuation_db - \
+ bandwiths_ratio_db)
- sjr_offset = int(tx_signal_power_dbm - \
- amn_attenuation_db - \
- sjr_attenuator_attenuation_db - \
- signal_attenuation_db + \
- waveform_attenuation_db)
+ sjr_offset_db = int(tx_signal_power_dbm - \
+ amn_attenuation_db - \
+ sjr_attenuator_attenuation_db - \
+ signal_attenuation_db + \
+ waveform_attenuation_db)
return {"ppsd_dbm_per_hz":ppsd_dbm_per_hz,
"par_db":par_db,
@@ -721,8 +748,8 @@ def get_waveform_data(ppsd_dbm_per_hz, signal_band_mhz, noise_band_mhz,
"sjr_attenuator_attenuation_db":sjr_attenuator_attenuation_db,
"amn_attenuation_db":amn_attenuation_db,
"waveform_attenuation_db":waveform_attenuation_db,
- "snr_offset":snr_offset,
- "sjr_offset":sjr_offset}
+ "snr_offset_db":snr_offset_db,
+ "sjr_offset_db":sjr_offset_db}
def get_amn_attenuation_db():
if config["amn"] == True:
@@ -767,8 +794,8 @@ if __name__ == "__main__":
"sjr_attenuator_attenuation_db":17,
"amn_attenuation_db":6,
"waveform_attenuation_db":10,
- "snr_offset":11,
- "sjr_offset":-9} == \
+ "snr_offset_db":11,
+ "sjr_offset_db":-9} == \
get_waveform_data(-50, (2, 28), (0, 50), 17, 6, 10)
assert {"ppsd_dbm_per_hz":-63,
@@ -785,33 +812,33 @@ if __name__ == "__main__":
"sjr_attenuator_attenuation_db":17,
"amn_attenuation_db":0,
"waveform_attenuation_db":10,
- "snr_offset":4,
- "sjr_offset":-14} == \
+ "snr_offset_db":4,
+ "sjr_offset_db":-14} == \
get_waveform_data(-63, (1, 38), (0, 50), 17, 0, 10)
- assert "./test_throughput_UDP_frame_size_(5, 5)bytes" == \
+ assert "./P2P_throughput_report_UDP_frame_size_(5, 5)bytes" == \
get_file_prefix("UDP", "frame_size", None, (5, 5), "bytes", None, ".")
- assert "./test_throughput_UDP_SNR_-5dB" == \
+ assert "./P2P_throughput_report_UDP_SNR_-5dB" == \
get_file_prefix("UDP", "SNR", None, -5, "dB", None, ".")
- assert "/reports/test_throughput_UDP_SNR_-5dB" == \
+ assert "/reports/P2P_throughput_report_UDP_SNR_-5dB" == \
get_file_prefix("UDP", "SNR", None, -5, "dB", None, "/reports")
- assert "reports/test_throughput_UDP_SNR_-5dB" == \
+ assert "reports/P2P_throughput_report_UDP_SNR_-5dB" == \
get_file_prefix("UDP", "SNR", None, -5, "dB", None, "reports")
- assert "reports/test_throughput_UDP_SNR_-5dB" == \
+ assert "reports/P2P_throughput_report_UDP_SNR_-5dB" == \
get_file_prefix("UDP", "SNR", None, -5, "dB", None, "reports/")
- assert "reports/subreports/test_throughput_UDP_SNR_-5dB" == \
+ assert "reports/subreports/P2P_throughput_report_UDP_SNR_-5dB" == \
get_file_prefix("UDP", "SNR", None, -5, "dB", None, "reports/subreports")
- assert "reports/subreports/test_throughput_UDP_SJR_15_-5dB" == \
+ assert "reports/subreports/P2P_throughput_report_UDP_SJR_15_-5dB" == \
get_file_prefix("UDP", "SJR", (15,), -5, "dB", None, "reports/subreports")
- assert "reports/test_throughput_TCP_SNR" == \
+ assert "reports/P2P_throughput_report_TCP_SNR" == \
get_file_prefix("TCP", "SNR", None, None, None, None, "reports")
- assert "reports/test_throughput_TCP" == \
+ assert "reports/P2P_throughput_report_TCP" == \
get_file_prefix("TCP", None, None, None, None, None, "reports")
- assert "reports/test_throughput" == \
+ assert "reports/P2P_throughput_report" == \
get_file_prefix(None, None, None, None, None, None, "reports")
- assert "test_throughput" == \
+ assert "P2P_throughput_report" == \
get_file_prefix(None, None, None, None, None, None, "")
- assert "reports/test_throughput_UDP_SNR_-10dB_Throughput" == \
+ assert "reports/P2P_throughput_report_UDP_SNR_-10dB_Throughput" == \
get_file_prefix("UDP", "SNR", None, -10, "dB", "Throughput", "reports")
assert flatten([]) == []
@@ -823,4 +850,46 @@ if __name__ == "__main__":
assert flatten((1, [2, 3], 4)) == [1, 2, 3, 4]
assert flatten((1, (2, 3), 4)) == [1, 2, 3, 4]
- report()
+ def test_check_config_aux(attenuation_offset, attenuation_range_db,
+ snr_offset_db, sjr_offset_db, power_range_dbm,
+ curves,
+ test_values, test_protocol, test_type,
+ test_params):
+ try:
+ check_config_aux(attenuation_offset, attenuation_range_db,
+ snr_offset_db, sjr_offset_db, power_range_dbm,
+ curves,
+ test_values, test_protocol, test_type,
+ test_params)
+ return True
+ except Exception as exception:
+ # To be uncommented when the tests fail
+ #print "Exception:", exception
+ return False
+
+ assert False == test_check_config_aux(None, None, None, None, None, None, None, None, None, None)
+ assert False == test_check_config_aux(None, None, None, None, None, None, None, "TCP", None, None)
+
+ assert False == test_check_config_aux(None, None, None, None, None, None, None, "TCP", "attenuation", None)
+ assert False == test_check_config_aux(3, (5, 8), None, None, None, ["a_b_uni"], [7], "TCP", "attenuation", None)
+ assert True == test_check_config_aux(3, (5, 8), None, None, None, ["a_b_uni"], [8], "TCP", "attenuation", None)
+ assert True == test_check_config_aux(3, (5, 8), None, None, None, ["a_b_uni"], [11], "TCP", "attenuation", None)
+ assert False == test_check_config_aux(3, (5, 8), None, None, None, ["a_b_uni"], [12], "TCP", "attenuation", None)
+
+ assert False == test_check_config_aux(None, None, None, None, None, ["a_b_uni"], [1], "TCP", "SNR", None)
+ assert False == test_check_config_aux(None, None, 10, None, (15, 25), ["a_b_uni"], [-4], "TCP", "SNR", None)
+ assert True == test_check_config_aux(None, None, 10, None, (15, 25), ["a_b_uni"], [-5], "TCP", "SNR", None)
+ assert True == test_check_config_aux(None, None, 10, None, (15, 25), ["a_b_uni"], [-15], "TCP", "SNR", None)
+ assert False == test_check_config_aux(None, None, 10, None, (15, 25), ["a_b_uni"], [-16], "TCP", "SNR", None)
+
+ assert False == test_check_config_aux(None, None, None, None, None, ["a_b_uni"], [1], "TCP", "SJR", None)
+ assert False == test_check_config_aux(None, None, None, 10, (15, 25), ["a_b_uni"], [-4], "TCP", "SJR", None)
+ assert True == test_check_config_aux(None, None, None, 10, (15, 25), ["a_b_uni"], [-5], "TCP", "SJR", None)
+ assert True == test_check_config_aux(None, None, None, 10, (15, 25), ["a_b_uni"], [-15], "TCP", "SJR", None)
+ assert False == test_check_config_aux(None, None, None, 10, (15, 25), ["a_b_uni"], [-16], "TCP", "SJR", None)
+ assert False == test_check_config_aux(None, None, None, 10, (15, 25), ["b_a_uni"], [-15], "TCP", "SJR", None)
+
+ assert False == test_check_config_aux(None, None, None, None, None, ["a_b_uni"], [1], "TCP", "dynamic_jammer", None)
+ assert True == test_check_config_aux(None, None, None, None, None, ["a_b_uni"], ["time"], "TCP", "dynamic_jammer", None)
+
+# report()
diff --git a/validation/test/P2P_throughput_report/P2P_throughput_report.rst b/validation/test/P2P_throughput_report/P2P_throughput_report.rst
index a6737ca1f1..135a955a41 100644
--- a/validation/test/P2P_throughput_report/P2P_throughput_report.rst
+++ b/validation/test/P2P_throughput_report/P2P_throughput_report.rst
@@ -115,7 +115,7 @@ Therefore:
* Tx Signal Power (SP) = PSD - PAR + 10 log10(SB) = {tx_signal_power_dbm} dBm
* Bandwiths Ratio (BR) = 10 log10 (SB/NB) = {bandwiths_ratio_db} dB
* Signal to Noise Ratio (dB) = (SP - {amn_attenuation_db} dB - {signal_attenuation_db} dB) - (Noise Power (dBm) - {waveform_attenuation_db} dB) - BR
- * Signal to Noise Ratio (dB) = {snr_offset} - Noise Power (dBm)
+ * Signal to Noise Ratio (dB) = {snr_offset_db} - Noise Power (dBm)
SJR calculation
---------------
@@ -131,7 +131,7 @@ Therefore:
* Tx Signal Power (SP) = PSD - PAR + 10 log10(SB) = {tx_signal_power_dbm} dBm
* Signal to Jammer Ratio (dB) = (SP - {amn_attenuation_db} dB - {signal_attenuation_db} dB - {sjr_attenuator_attenuation_db} dB) - (Jammer Power (dBm) - {waveform_attenuation_db} dB)
- * Signal to Jammer Ratio (dB) = {sjr_offset} - Jammer Power (dBm)
+ * Signal to Jammer Ratio (dB) = {sjr_offset_db} - Jammer Power (dBm)
Channel Estimation (CE)
-----------------------