mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-05 06:25:16 +00:00
Startup and communication bugfixes
- reduce amount of mode switched when starting and loading setups - improve logging for errors during HIL tests - fix small USB communication bugs
This commit is contained in:
parent
733d0ffbf4
commit
ca25969574
14 changed files with 148 additions and 44 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import unittest
|
||||
import glob, os
|
||||
|
||||
testmodules = [
|
||||
'tests.TestUpdate', # Must go first because it updates the connected VNA to the firwmare which should be tested
|
||||
|
|
@ -16,6 +17,12 @@ testmodules = [
|
|||
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
# Clean up potential error logs from previous test runs
|
||||
for f in glob.glob("errorlog_*"):
|
||||
os.remove(f)
|
||||
for f in glob.glob("packetlog_*"):
|
||||
os.remove(f)
|
||||
|
||||
for t in testmodules:
|
||||
try:
|
||||
# If the module defines a suite() function, call it to get the suite.
|
||||
|
|
|
|||
22
Software/Integrationtests/errorlog_20250106173311.txt
Normal file
22
Software/Integrationtests/errorlog_20250106173311.txt
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
0.027: [debug] Application start
|
||||
0.045: [info] Listening on port 19544
|
||||
0.060: [debug] Activating mode "Vector Network Analyzer"
|
||||
0.068: [debug] Updated device list, found 1
|
||||
0.068: [debug] Trying to connect to "208A367A4B42"
|
||||
0.068: [debug] Attempting to connect to device...
|
||||
0.075: [info] USB connection established
|
||||
0.075: [debug] Receive thread started
|
||||
0.075: [debug] Transmission started (packet type 15 ), queue at 1
|
||||
0.078: [info] Connected to "208A367A4B42"
|
||||
0.079: [debug] Transmission started (packet type 26 ), queue at 1
|
||||
0.082: [debug] No default calibration file set for this device
|
||||
0.082: [debug] Transmission started (packet type 11 ), queue at 1
|
||||
0.187: [debug] Transmission started (packet type 2 ), queue at 1
|
||||
0.533: [debug] Attempting to open calibration from file "LIBRECAL.cal"
|
||||
0.533: [debug] Associated calibration kit expected in "LIBRECAL.calkit"
|
||||
0.533: [debug] Opening calkit to file "LIBRECAL.calkit"
|
||||
0.533: [debug] Parsing of calibration kit failed while opening calibration file: Unable to open file (ignore for calibration format >= 3)
|
||||
0.899: [debug] Transmission started (packet type 2 ), queue at 1
|
||||
1.007: [debug] Deactivated mode "Vector Network Analyzer"
|
||||
1.007: [debug] Transmission started (packet type 20 ), queue at 1
|
||||
1.050: [debug] Disconnected, receive thread exiting
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -4,43 +4,72 @@ import tests.definitions as defs
|
|||
import subprocess
|
||||
import time
|
||||
import select
|
||||
import os
|
||||
from signal import SIGINT
|
||||
|
||||
class TestBase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.gui = subprocess.Popen([defs.GUI_PATH, '-p', '19544', '--reset-preferences', '--no-gui', '-platform', 'offscreen'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
f = open("log.txt", "w")
|
||||
self.gui = subprocess.Popen([defs.GUI_PATH, '-p', '19544', '--reset-preferences', '--no-gui', '-platform', 'offscreen'], stdout=f, stderr=subprocess.STDOUT)
|
||||
|
||||
# wait for the SCPI server to become available
|
||||
timeout = time.time() + 3;
|
||||
poll_obj = select.poll()
|
||||
poll_obj.register(self.gui.stdout, select.POLLIN)
|
||||
fread = open("log.txt", "r")
|
||||
while True:
|
||||
poll_result = poll_obj.poll(0)
|
||||
if poll_result:
|
||||
line = self.gui.stdout.readline().decode().strip()
|
||||
if "Listening on port 19544" in line:
|
||||
break
|
||||
text = fread.read()
|
||||
if text and "Listening on port 19544" in text:
|
||||
break
|
||||
if time.time() >= timeout:
|
||||
self.tearDown()
|
||||
raise AssertionError("Timed out waiting for SCPI server")
|
||||
|
||||
self.vna = libreVNA('localhost', 19544, timeout=4)
|
||||
try:
|
||||
self.vna.cmd("*CLS;:DEV:CONN")
|
||||
self.vna.cmd("*CLS")
|
||||
except Exception as e:
|
||||
self.tearDown()
|
||||
raise e
|
||||
if self.vna.query(":DEV:CONN?") == "Not connected":
|
||||
self.tearDown()
|
||||
raise AssertionError("Not connected")
|
||||
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
if hasattr(self._outcome, 'errors'):
|
||||
# Python 3.4 - 3.10 (These two methods have no side effects)
|
||||
result = self.defaultTestResult()
|
||||
self._feedErrorsToResult(result, self._outcome.errors)
|
||||
else:
|
||||
# Python 3.11+
|
||||
result = self._outcome.result
|
||||
ok = all(test != self for test, text in result.errors + result.failures)
|
||||
|
||||
if not ok:
|
||||
try:
|
||||
# Try to grab the packet log and save it
|
||||
packetlog = self.vna.query(":DEV:PACKETLOG?", timeout=5)
|
||||
f = open("packetlog_"+time.strftime("%Y%m%d%H%M%S.vnalog"), "w")
|
||||
f.write(packetlog)
|
||||
f.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
# make sure the GUI did not crash during the test
|
||||
self.assertEqual(self.gui.poll(), None)
|
||||
crashed = self.gui.poll() is not None
|
||||
self.gui.send_signal(SIGINT)
|
||||
try:
|
||||
self.gui.wait(timeout = 3)
|
||||
except subprocess.TimeoutExpired:
|
||||
self.gui.kill()
|
||||
|
||||
|
||||
if ok and not crashed:
|
||||
# remove log file
|
||||
os.remove("log.txt")
|
||||
else:
|
||||
os.rename("log.txt", "errorlog_"+time.strftime("%Y%m%d%H%M%S.txt"))
|
||||
|
||||
if(crashed):
|
||||
raise Exception("GUI crashed")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue