mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-07 23:43:42 +00:00
Further integration tests
This commit is contained in:
parent
6e5f2635d1
commit
46b41a4a04
6 changed files with 71 additions and 35 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import unittest
|
||||
|
||||
testmodules = [
|
||||
# 'tests.TestConnect',
|
||||
# 'tests.TestMode',
|
||||
# 'tests.TestVNASweep',
|
||||
'tests.TestConnect',
|
||||
'tests.TestMode',
|
||||
'tests.TestVNASweep',
|
||||
'tests.TestCalibration',
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from signal import SIGINT
|
|||
|
||||
class TestBase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.gui = subprocess.Popen([defs.GUI_PATH, '-p', '19543'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
self.gui = subprocess.Popen([defs.GUI_PATH, '-p', '19544'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
|
||||
# wait for the SCPI server to become available
|
||||
timeout = time.time() + 3;
|
||||
|
|
@ -18,13 +18,17 @@ class TestBase(unittest.TestCase):
|
|||
poll_result = poll_obj.poll(0)
|
||||
if poll_result:
|
||||
line = self.gui.stdout.readline().decode().strip()
|
||||
if "Listening on port 19543" in line:
|
||||
if "Listening on port 19544" in line:
|
||||
break
|
||||
|
||||
time.sleep(0.2)
|
||||
|
||||
self.vna = libreVNA('localhost', 19543)
|
||||
self.vna.cmd(":DEV:CONN")
|
||||
self.vna = libreVNA('localhost', 19544)
|
||||
try:
|
||||
self.vna.cmd(":DEV:CONN")
|
||||
except Exception as e:
|
||||
self.tearDown()
|
||||
raise e
|
||||
if self.vna.query(":DEV:CONN?") == "Not connected":
|
||||
self.tearDown()
|
||||
raise AssertionError("Not connected")
|
||||
|
|
|
|||
|
|
@ -2,6 +2,13 @@ from tests.TestBase import TestBase
|
|||
import time
|
||||
|
||||
class TestVNASweep(TestBase):
|
||||
def waitSweepTimeout(self, timeout = 1):
|
||||
self.assertEqual(self.vna.query(":VNA:ACQ:FIN?"), "FALSE")
|
||||
stoptime = time.time() + timeout
|
||||
while self.vna.query(":VNA:ACQ:FIN?") == "FALSE":
|
||||
if time.time() > stoptime:
|
||||
raise AssertionError("Sweep timed out")
|
||||
|
||||
def test_sweep_frequency(self):
|
||||
self.vna.cmd(":DEV:MODE VNA")
|
||||
self.vna.cmd(":VNA:SWEEP FREQUENCY")
|
||||
|
|
@ -11,8 +18,7 @@ class TestVNASweep(TestBase):
|
|||
self.vna.cmd(":VNA:ACQ:POINTS 501")
|
||||
self.vna.cmd(":VNA:FREQuency:START 1000000")
|
||||
self.vna.cmd(":VNA:FREQuency:STOP 6000000000")
|
||||
while self.vna.query(":VNA:ACQ:FIN?") == "FALSE":
|
||||
time.sleep(0.1)
|
||||
self.waitSweepTimeout(2)
|
||||
|
||||
S11 = self.vna.parse_trace_data(self.vna.query(":VNA:TRACE:DATA? S11"))
|
||||
self.assertEqual(S11[0][0], 1000000)
|
||||
|
|
@ -28,8 +34,7 @@ class TestVNASweep(TestBase):
|
|||
self.vna.cmd(":VNA:FREQuency:START 500000000")
|
||||
self.vna.cmd(":VNA:FREQuency:STOP 1500000000")
|
||||
self.vna.cmd(":VNA:FREQuency:ZERO 1500000000")
|
||||
while self.vna.query(":VNA:ACQ:FIN?") == "FALSE":
|
||||
time.sleep(0.1)
|
||||
self.waitSweepTimeout(2)
|
||||
|
||||
S11 = self.vna.parse_trace_data(self.vna.query(":VNA:TRACE:DATA? S11"))
|
||||
self.assertEqual(S11[0][0], 0.0)
|
||||
|
|
@ -46,9 +51,23 @@ class TestVNASweep(TestBase):
|
|||
self.vna.cmd(":VNA:ACQ:POINTS 501")
|
||||
self.vna.cmd(":VNA:POWER:START -30")
|
||||
self.vna.cmd(":VNA:POWER:STOP -10")
|
||||
while self.vna.query(":VNA:ACQ:FIN?") == "FALSE":
|
||||
time.sleep(0.1)
|
||||
self.waitSweepTimeout(2)
|
||||
|
||||
S11 = self.vna.parse_trace_data(self.vna.query(":VNA:TRACE:DATA? S11"))
|
||||
self.assertEqual(S11[0][0], -30)
|
||||
self.assertEqual(S11[-1][0], -10)
|
||||
self.assertEqual(S11[-1][0], -10)
|
||||
|
||||
def test_fast_single_sweeps(self):
|
||||
self.vna.cmd(":DEV:MODE VNA")
|
||||
self.vna.cmd(":VNA:SWEEP FREQUENCY")
|
||||
self.vna.cmd(":VNA:STIM:LVL -10")
|
||||
self.vna.cmd(":VNA:ACQ:IFBW 50000")
|
||||
self.vna.cmd(":VNA:ACQ:AVG 1")
|
||||
self.vna.cmd(":VNA:ACQ:POINTS 501")
|
||||
self.vna.cmd(":VNA:FREQuency:START 1000000")
|
||||
self.vna.cmd(":VNA:FREQuency:STOP 6000000000")
|
||||
|
||||
for i in range(10):
|
||||
# Change something irrelevant (to force reconfiguration of device)
|
||||
self.vna.cmd(":VNA:FREQuency:START "+str(1000000+i))
|
||||
self.waitSweepTimeout(2)
|
||||
Loading…
Add table
Add a link
Reference in a new issue