Commit 0a180751 authored by Matthieu Cattin's avatar Matthieu Cattin

Move exception raise after end of test and time print.

parent b8c38bb0
...@@ -87,13 +87,14 @@ def main (default_directory='.'): ...@@ -87,13 +87,14 @@ def main (default_directory='.'):
periph_addr = fmc.sys_i2c_scan() periph_addr = fmc.sys_i2c_scan()
print "" print ""
error = ""
# Check that the EEPROM is detected on the I2C bus # Check that the EEPROM is detected on the I2C bus
if(0 == len(periph_addr)): if(0 == len(periph_addr)):
raise PtsError("No peripheral detected on system management I2C bus") error = "No peripheral detected on system management I2C bus"
if(1 != len(periph_addr)): if(1 != len(periph_addr)):
raise PtsError("Signal integrity problem detected on system management I2C bus, %d devices detected instead of 1" % len(periph_addr)) error = "Signal integrity problem detected on system management I2C bus, %d devices detected instead of 1" % len(periph_addr)
if(EEPROM_ADDR != periph_addr[0]): if(EEPROM_ADDR != periph_addr[0]):
raise PtsError("Wrong device mounted on system management I2C bus or soldering issues, address is:0x%.2X expected:0x%.2X" % (periph_addr[0],EEPROM_ADDR)) error = "Wrong device mounted on system management I2C bus or soldering issues, address is:0x%.2X expected:0x%.2X" % (periph_addr[0],EEPROM_ADDR)
# Write, read back and compare two different patterns # Write, read back and compare two different patterns
try: try:
...@@ -104,7 +105,7 @@ def main (default_directory='.'): ...@@ -104,7 +105,7 @@ def main (default_directory='.'):
raise PtsError("EEPROM write/read/compare test failed: %s" % e) raise PtsError("EEPROM write/read/compare test failed: %s" % e)
if(mismatch != 0): if(mismatch != 0):
raise PtsError("EEPROM data comparison mismatch!") error = "EEPROM data comparison mismatch!"
else: else:
print('Data comparison OK.') print('Data comparison OK.')
...@@ -115,6 +116,9 @@ def main (default_directory='.'): ...@@ -115,6 +116,9 @@ def main (default_directory='.'):
end_test_time = time.time() end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time) print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
if(error != ""):
raise PtsError(error)
if __name__ == '__main__' : if __name__ == '__main__' :
main() main()
...@@ -118,7 +118,6 @@ def main (default_directory='.'): ...@@ -118,7 +118,6 @@ def main (default_directory='.'):
print("One or both LEDs not switching ON. Check for soldering or connection problem, grounded control line.") print("One or both LEDs not switching ON. Check for soldering or connection problem, grounded control line.")
if(error[1] != 0): if(error[1] != 0):
print("One or both LEDs not switching OFF. Check for short-cut.") print("One or both LEDs not switching OFF. Check for short-cut.")
raise PtsError('An error occured during LEDs test, check log for details.')
else: else:
print('LEDs are working ok.') print('LEDs are working ok.')
...@@ -131,6 +130,10 @@ def main (default_directory='.'): ...@@ -131,6 +130,10 @@ def main (default_directory='.'):
end_test_time = time.time() end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time) print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
# Check if an error occured during LED test
if (error != [0]*2):
raise PtsError('An error occured during LEDs test, check log for details.')
if __name__ == '__main__' : if __name__ == '__main__' :
main() main()
...@@ -97,6 +97,7 @@ def main (default_directory='.'): ...@@ -97,6 +97,7 @@ def main (default_directory='.'):
print "FOUT_MAX : %3.3f" % f_out_max print "FOUT_MAX : %3.3f" % f_out_max
# Check that output frequency is within the limits # Check that output frequency is within the limits
error = 0
f_out_limit_min = SI570_FOUT - SI570_FOUT_TOL f_out_limit_min = SI570_FOUT - SI570_FOUT_TOL
f_out_limit_max = SI570_FOUT + SI570_FOUT_TOL f_out_limit_max = SI570_FOUT + SI570_FOUT_TOL
print "FOUT_LIMIT_MIN : %3.3f" % f_out_limit_min print "FOUT_LIMIT_MIN : %3.3f" % f_out_limit_min
...@@ -107,7 +108,9 @@ def main (default_directory='.'): ...@@ -107,7 +108,9 @@ def main (default_directory='.'):
print "Si570 frequency output is within tolerance" print "Si570 frequency output is within tolerance"
else: else:
print "FAILED" print "FAILED"
raise PtsError('Si570 frequency output is outside of the tolerance') error += 1
except FmcAdc100mOperationError as e: except FmcAdc100mOperationError as e:
raise PtsError("Test failed: %s" % e) raise PtsError("Test failed: %s" % e)
...@@ -118,6 +121,10 @@ def main (default_directory='.'): ...@@ -118,6 +121,10 @@ def main (default_directory='.'):
end_test_time = time.time() end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time) print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
# Raise an exception if Si570 frequency is outside the tolerance
if(error != 0):
raise PtsError('Si570 frequency output is outside of the tolerance.')
if __name__ == '__main__' : if __name__ == '__main__' :
main() main()
...@@ -91,8 +91,6 @@ def main (default_directory='.'): ...@@ -91,8 +91,6 @@ def main (default_directory='.'):
if((TEST_PATTERN<<2) != adc_value): if((TEST_PATTERN<<2) != adc_value):
print('Error: value mismatch!') print('Error: value mismatch!')
error += 1 error += 1
if(error != 0):
raise PtsError('Data read from LTC2174 ADC are wrong for one or more channels.')
except FmcAdc100mOperationError as e: except FmcAdc100mOperationError as e:
raise PtsError("Test failed: %s" % e) raise PtsError("Test failed: %s" % e)
...@@ -104,6 +102,10 @@ def main (default_directory='.'): ...@@ -104,6 +102,10 @@ def main (default_directory='.'):
end_test_time = time.time() end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time) print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
# Check if an error occured during LTC2174 ADC test
if(error != 0):
raise PtsError('Data read from LTC2174 ADC are wrong for one or more channels.')
if __name__ == '__main__' : if __name__ == '__main__' :
main() main()
...@@ -114,7 +114,6 @@ def main (default_directory='.'): ...@@ -114,7 +114,6 @@ def main (default_directory='.'):
# Check if the trigger has been received # Check if the trigger has been received
if('WAIT_TRIG' == fmc.get_acq_fsm_state()): if('WAIT_TRIG' == fmc.get_acq_fsm_state()):
print "Acquisition FSM state : %s" % fmc.get_acq_fsm_state() print "Acquisition FSM state : %s" % fmc.get_acq_fsm_state()
raise PtsError('External trigger input is not working.')
else: else:
print "The external trigger input is working fine." print "The external trigger input is working fine."
...@@ -128,6 +127,10 @@ def main (default_directory='.'): ...@@ -128,6 +127,10 @@ def main (default_directory='.'):
end_test_time = time.time() end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time) print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
# Raise excepetion if the trigger hasn't been received
if('WAIT_TRIG' == fmc.get_acq_fsm_state()):
raise PtsError('External trigger input is not working.')
if __name__ == '__main__' : if __name__ == '__main__' :
main() main()
...@@ -211,10 +211,6 @@ def main (default_directory='.'): ...@@ -211,10 +211,6 @@ def main (default_directory='.'):
fmc.dc_offset_reset() fmc.dc_offset_reset()
time.sleep(DAC_SET_SLEEP) time.sleep(DAC_SET_SLEEP)
# Check if an error occured during offset DAC test
if(error != 0):
raise PtsError('An error occured during offset DAC test, check log for details.')
except(FmcAdc100mSpecOperationError, FmcAdc100mOperationError) as e: except(FmcAdc100mSpecOperationError, FmcAdc100mOperationError) as e:
raise PtsError("Test failed: %s" % e) raise PtsError("Test failed: %s" % e)
...@@ -225,6 +221,10 @@ def main (default_directory='.'): ...@@ -225,6 +221,10 @@ def main (default_directory='.'):
end_test_time = time.time() end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time) print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
# Check if an error occured during offset DAC test
if(error != 0):
raise PtsError('An error occured during offset DAC test, check log for details.')
if __name__ == '__main__' : if __name__ == '__main__' :
main() main()
...@@ -273,10 +273,7 @@ def main (default_directory='.'): ...@@ -273,10 +273,7 @@ def main (default_directory='.'):
gen.output = False gen.output = False
gen.close() gen.close()
# Check if an error occured during switches test if(error == 0):
if(error != 0):
raise PtsError('An error occured during switches test, check log for details.')
else:
print "\nAll switches are working fine!" print "\nAll switches are working fine!"
except(FmcAdc100mSpecOperationError, FmcAdc100mOperationError, CalibrBoxOperationError) as e: except(FmcAdc100mSpecOperationError, FmcAdc100mOperationError, CalibrBoxOperationError) as e:
...@@ -289,6 +286,10 @@ def main (default_directory='.'): ...@@ -289,6 +286,10 @@ def main (default_directory='.'):
end_test_time = time.time() end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time) print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
# Check if an error occured during switches test
if(error != 0):
raise PtsError('An error occured during switches test, check log for details.')
# Following commented code scan all SSR configurations to find good ones for testing switches # Following commented code scan all SSR configurations to find good ones for testing switches
""" """
......
...@@ -307,10 +307,6 @@ def main (default_directory='.'): ...@@ -307,10 +307,6 @@ def main (default_directory='.'):
gen.output = False gen.output = False
gen.close() gen.close()
# Check if an error occured during frequency response test
if(error != 0):
raise PtsError('An error occured during frequency response test, check log for details.')
except(FmcAdc100mSpecOperationError, FmcAdc100mOperationError, CalibrBoxOperationError) as e: except(FmcAdc100mSpecOperationError, FmcAdc100mOperationError, CalibrBoxOperationError) as e:
raise PtsError("Test failed: %s" % e) raise PtsError("Test failed: %s" % e)
...@@ -321,6 +317,10 @@ def main (default_directory='.'): ...@@ -321,6 +317,10 @@ def main (default_directory='.'):
end_test_time = time.time() end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time) print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
# Check if an error occured during frequency response test
if(error != 0):
raise PtsError('An error occured during frequency response test, check log for details.')
if __name__ == '__main__' : if __name__ == '__main__' :
main() main()
...@@ -471,10 +471,6 @@ def main (default_directory = '.'): ...@@ -471,10 +471,6 @@ def main (default_directory = '.'):
# Close AWG # Close AWG
gen.close() gen.close()
# Check if an error occured during frequency response test
if(error != 0):
raise PtsError('An error occured during calibration, check log for details.')
except(FmcAdc100mSpecOperationError,FmcAdc100mOperationError, except(FmcAdc100mSpecOperationError,FmcAdc100mOperationError,
CalibrBoxOperationError, CP210xEepromOperationError) as e: CalibrBoxOperationError, CP210xEepromOperationError) as e:
...@@ -487,6 +483,10 @@ def main (default_directory = '.'): ...@@ -487,6 +483,10 @@ def main (default_directory = '.'):
end_test_time = time.time() end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time) print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
# Check if an error occured during calibration
if(error != 0):
raise PtsError('An error occured during calibration (unstable voltage), check log for details.')
if __name__ == '__main__' : if __name__ == '__main__' :
main() main()
...@@ -505,10 +505,6 @@ def main (default_directory = '.'): ...@@ -505,10 +505,6 @@ def main (default_directory = '.'):
# Close AWG # Close AWG
gen.close() gen.close()
# Check if an error occured during frequency response test
if(error != 0):
raise PtsError('An error occured during calibration verification, check log for details.')
except(FmcAdc100mSpecOperationError,FmcAdc100mOperationError, except(FmcAdc100mSpecOperationError,FmcAdc100mOperationError,
CalibrBoxOperationError, CP210xEepromOperationError) as e: CalibrBoxOperationError, CP210xEepromOperationError) as e:
raise PtsError("Test failed: %s" % e) raise PtsError("Test failed: %s" % e)
...@@ -520,6 +516,10 @@ def main (default_directory = '.'): ...@@ -520,6 +516,10 @@ def main (default_directory = '.'):
end_test_time = time.time() end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time) print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
# Check if an error occured during calibration verification
if(error != 0):
raise PtsError('An error occured during calibration verification, check log for details.')
if __name__ == '__main__' : if __name__ == '__main__' :
main() main()
...@@ -221,7 +221,6 @@ def main (default_directory='.'): ...@@ -221,7 +221,6 @@ def main (default_directory='.'):
print "OK" print "OK"
else: else:
print "FAILED" print "FAILED"
raise PtsError("EEPROM comparison failed: %d mismatch found." % mismatch)
except FmcAdc100mOperationError as e: except FmcAdc100mOperationError as e:
raise PtsError("Test failed: %s" % e) raise PtsError("Test failed: %s" % e)
...@@ -234,5 +233,10 @@ def main (default_directory='.'): ...@@ -234,5 +233,10 @@ def main (default_directory='.'):
end_test_time = time.time() end_test_time = time.time()
print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time) print "Test%02d elapsed time: %.2f seconds\n" % (TEST_NB, end_test_time-start_test_time)
# Check if an error occured during EEPROM verification
if(mismatch != 0):
raise PtsError("EEPROM comparison failed: %d mismatch found. Check log for details." % mismatch)
if __name__ == '__main__' : if __name__ == '__main__' :
main() main()
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