Commit e239d77b authored by Projects's avatar Projects

tests/pulse_rejection: more robust testing

- introduced a flag to indicate a continuous test
- increased the cooldown time
- more verbose output
parent 45565e3c
...@@ -24,7 +24,7 @@ address = cfg.HNAME if cfg.ENABLED and cfg.HNAME else raw_input("Hostname: ") ...@@ -24,7 +24,7 @@ address = cfg.HNAME if cfg.ENABLED and cfg.HNAME else raw_input("Hostname: ")
user = cfg.USER if cfg.ENABLED and cfg.USER else raw_input("User: ") user = cfg.USER if cfg.ENABLED and cfg.USER else raw_input("User: ")
password = cfg.PWD if cfg.ENABLED and cfg.PWD else raw_input("Password: ") password = cfg.PWD if cfg.ENABLED and cfg.PWD else raw_input("Password: ")
slot = int(input("Slot number: ")) slot = int(input("Slot number: "))
cooldown_time = 6 # 6 seconds of cool down time between tests cooldown_time = 20 # number seconds of cool down time between tests
elma = Elma(address, user, password) elma = Elma(address, user, password)
convttl = PyConvTTL(slot, elma) convttl = PyConvTTL(slot, elma)
...@@ -50,9 +50,9 @@ if(convttl.status.switch[1]): ...@@ -50,9 +50,9 @@ if(convttl.status.switch[1]):
{'freq': 1333333, 'seconds': 6.5}, {'freq': 1333333, 'seconds': 6.5},
{'freq': 1000000, 'seconds': 10}, {'freq': 1000000, 'seconds': 10},
{'freq': 800000, 'seconds': 26}, {'freq': 800000, 'seconds': 26},
{'freq': 666667, 'seconds': 36.66}, {'freq': 666667, 'seconds': 36.6},
{'freq': 571428.6, 'seconds': 120} # continuous, but waiting for infinite {'freq': 571428.6, 'seconds': 120, 'continuous': True}
) # number of seconds takes too long )
else: else:
# long pulse # long pulse
print("Running long pulse tests") print("Running long pulse tests")
...@@ -63,14 +63,16 @@ else: ...@@ -63,14 +63,16 @@ else:
{'freq': 75757.8, 'seconds': 10}, {'freq': 75757.8, 'seconds': 10},
{'freq': 69444.4, 'seconds': 20}, {'freq': 69444.4, 'seconds': 20},
{'freq': 55555.6, 'seconds': 60}, {'freq': 55555.6, 'seconds': 60},
{'freq': 52083.3, 'seconds': 120}, # continuous, but waiting for infinite {'freq': 52083.3, 'seconds': 120, 'continuous': True},
) # number of seconds takes too long )
# run tests # run tests
for test in tests: for test in tests:
old_counters = None old_counters = None
freq = test['freq'] freq = test['freq']
pulses = test['freq'] * test['seconds'] seconds = test['seconds']
pulses = freq * seconds
continuous = True if 'continuous' in test and test['continous'] else False
############################################################################################# #############################################################################################
# test if the guaranteed number of pulses is repeated # test if the guaranteed number of pulses is repeated
...@@ -83,7 +85,7 @@ for test in tests: ...@@ -83,7 +85,7 @@ for test in tests:
convttl.error.clear() convttl.error.clear()
print("------") print("------")
print("TEST: accept %d pulses at %d Hz" % (pulses, freq)) print("TEST: accept %d pulses at %d Hz (%f s)" % (pulses, freq, seconds))
print("Start the pulse burst generator (%d pulses)" % int(pulses)) print("Start the pulse burst generator (%d pulses)" % int(pulses))
print(" ./pulsegen.py -c %d -f %F" % (pulses, freq)) print(" ./pulsegen.py -c %d -f %F" % (pulses, freq))
print("") print("")
...@@ -121,11 +123,14 @@ for test in tests: ...@@ -121,11 +123,14 @@ for test in tests:
test_run = False test_run = False
break break
print("waiting %d seconds of cool-down period" % cooldown_time)
time.sleep(cooldown_time)
############################################################################################# #############################################################################################
# test if pulses are rejected after the counter threshold has been reached # test if pulses are rejected after the counter threshold has been reached
print("waiting %d seconds of cool-down period" % cooldown_time) if continuous: # we cannot perform this test for frequencies that
time.sleep(cooldown_time) continue # are meant to repeat pulses without rejecting any
# clear counters # clear counters
for ch in range(1, 7): for ch in range(1, 7):
...@@ -144,7 +149,7 @@ for test in tests: ...@@ -144,7 +149,7 @@ for test in tests:
print("Pulse counters:") print("Pulse counters:")
test_run = True test_run = True
passed = [False for _ in range(6)] passed = [False for _ in range(6)] # passed test flags for each channel
# test if pulses are rejected after a certain threshold # test if pulses are rejected after a certain threshold
while(test_run): while(test_run):
...@@ -178,5 +183,8 @@ for test in tests: ...@@ -178,5 +183,8 @@ for test in tests:
sys.exit(2) sys.exit(2)
test_run = False test_run = False
if any(passed):
print("TEST PASSED")
print("waiting %d seconds of cool-down period" % cooldown_time) print("waiting %d seconds of cool-down period" % cooldown_time)
time.sleep(cooldown_time) time.sleep(cooldown_time)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment