Skip to content

Commit 8642eca

Browse files
committed
updates
1 parent 836e6a6 commit 8642eca

File tree

5 files changed

+44
-82
lines changed

5 files changed

+44
-82
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import os
2+
import signal
3+
import subprocess
4+
import time
5+
6+
import pytest
7+
from fprime_gds.common.testing_fw.api import IntegrationTestAPI
8+
9+
10+
@pytest.fixture(scope="session")
11+
def start_gds(fprime_test_api_session: IntegrationTestAPI):
12+
pro = subprocess.Popen(
13+
["make", "gds-integration"],
14+
cwd=os.getcwd(),
15+
stdout=subprocess.PIPE,
16+
preexec_fn=os.setsid,
17+
)
18+
19+
gds_working = False
20+
timeout_time = time.time() + 30
21+
while time.time() < timeout_time:
22+
try:
23+
fprime_test_api_session.send_and_assert_command(
24+
command="CdhCore.cmdDisp.CMD_NO_OP"
25+
)
26+
gds_working = True
27+
break
28+
except Exception:
29+
time.sleep(1)
30+
assert gds_working
31+
32+
yield
33+
os.killpg(os.getpgid(pro.pid), signal.SIGTERM)

FprimeZephyrReference/test/int/imu_manager_test.py

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,11 @@
44
Integration tests for the IMU Manager component.
55
"""
66

7-
import os
8-
import subprocess
9-
import time
10-
117
import pytest
128
from fprime_gds.common.data_types.ch_data import ChData
139
from fprime_gds.common.testing_fw.api import IntegrationTestAPI
1410

1511

16-
@pytest.fixture(scope="session", autouse=True)
17-
def start_gds(fprime_test_api_session: IntegrationTestAPI):
18-
process = subprocess.Popen(["make", "gds-integration"], cwd=os.getcwd())
19-
20-
gds_working = False
21-
timeout_time = time.time() + 30
22-
while time.time() < timeout_time:
23-
try:
24-
fprime_test_api_session.send_and_assert_command(
25-
command="CdhCore.cmdDisp.CMD_NO_OP"
26-
)
27-
gds_working = True
28-
break
29-
except Exception:
30-
time.sleep(1)
31-
assert gds_working
32-
33-
yield
34-
process.kill()
35-
36-
3712
@pytest.fixture(autouse=True)
3813
def send_packet(fprime_test_api: IntegrationTestAPI):
3914
"""Fixture to clear histories and send the IMU packet before each test"""
@@ -43,7 +18,7 @@ def send_packet(fprime_test_api: IntegrationTestAPI):
4318
)
4419

4520

46-
def test_01_acceleration_telemetry(fprime_test_api: IntegrationTestAPI):
21+
def test_01_acceleration_telemetry(fprime_test_api: IntegrationTestAPI, start_gds):
4722
"""Test that we can get Acceleration telemetry"""
4823
result: ChData = fprime_test_api.assert_telemetry(
4924
"ReferenceDeployment.lsm6dsoManager.Acceleration", start="NOW", timeout=3
@@ -55,7 +30,7 @@ def test_01_acceleration_telemetry(fprime_test_api: IntegrationTestAPI):
5530
)
5631

5732

58-
def test_02_angular_velocity_telemetry(fprime_test_api: IntegrationTestAPI):
33+
def test_02_angular_velocity_telemetry(fprime_test_api: IntegrationTestAPI, start_gds):
5934
"""Test that we can get AngularVelocity telemetry"""
6035
result: ChData = fprime_test_api.assert_telemetry(
6136
"ReferenceDeployment.lsm6dsoManager.AngularVelocity", start="NOW", timeout=3
@@ -67,7 +42,7 @@ def test_02_angular_velocity_telemetry(fprime_test_api: IntegrationTestAPI):
6742
)
6843

6944

70-
def test_03_temperature_telemetry(fprime_test_api: IntegrationTestAPI):
45+
def test_03_temperature_telemetry(fprime_test_api: IntegrationTestAPI, start_gds):
7146
"""Test that we can get Temperature telemetry"""
7247
result: ChData = fprime_test_api.assert_telemetry(
7348
"ReferenceDeployment.lsm6dsoManager.Temperature", start="NOW", timeout=3
@@ -77,7 +52,7 @@ def test_03_temperature_telemetry(fprime_test_api: IntegrationTestAPI):
7752
assert reading != 0, "Temperature reading should be non-zero"
7853

7954

80-
def test_04_magnetic_field_telemetry(fprime_test_api: IntegrationTestAPI):
55+
def test_04_magnetic_field_telemetry(fprime_test_api: IntegrationTestAPI, start_gds):
8156
"""Test that we can get MagneticField telemetry"""
8257
result: ChData = fprime_test_api.assert_telemetry(
8358
"ReferenceDeployment.lis2mdlManager.MagneticField", start="NOW", timeout=3

FprimeZephyrReference/test/int/rtc_test.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
"""
66

77
import json
8-
import os
9-
import subprocess
108
import time
119
from datetime import datetime, timezone
1210

@@ -18,27 +16,6 @@
1816
from fprime_gds.common.testing_fw.api import IntegrationTestAPI
1917

2018

21-
@pytest.fixture(scope="session", autouse=True)
22-
def start_gds(fprime_test_api_session: IntegrationTestAPI):
23-
process = subprocess.Popen(["make", "gds-integration"], cwd=os.getcwd())
24-
25-
gds_working = False
26-
timeout_time = time.time() + 30
27-
while time.time() < timeout_time:
28-
try:
29-
fprime_test_api_session.send_and_assert_command(
30-
command="CdhCore.cmdDisp.CMD_NO_OP"
31-
)
32-
gds_working = True
33-
break
34-
except Exception:
35-
time.sleep(1)
36-
assert gds_working
37-
38-
yield
39-
process.kill()
40-
41-
4219
@pytest.fixture(autouse=True)
4320
def set_now_time(fprime_test_api: IntegrationTestAPI):
4421
"""Fixture to set the time to test runner's time after each test"""
@@ -71,7 +48,7 @@ def set_time(fprime_test_api: IntegrationTestAPI, dt: datetime = None):
7148
fprime_test_api.assert_event("ReferenceDeployment.rtcManager.TimeSet", timeout=2)
7249

7350

74-
def test_01_time_set(fprime_test_api: IntegrationTestAPI):
51+
def test_01_time_set(fprime_test_api: IntegrationTestAPI, start_gds):
7552
"""Test that we can set the time"""
7653

7754
# Set time to Curiosity landing on Mars (7 minutes of terror! https://youtu.be/Ki_Af_o9Q9s)
@@ -114,7 +91,7 @@ def test_01_time_set(fprime_test_api: IntegrationTestAPI):
11491
pytest.approx(event_time, abs=30) == datetime.now(timezone.utc)
11592

11693

117-
def test_02_time_incrementing(fprime_test_api: IntegrationTestAPI):
94+
def test_02_time_incrementing(fprime_test_api: IntegrationTestAPI, start_gds):
11895
"""Test that time increments over time"""
11996

12097
# Fetch initial time
@@ -145,7 +122,7 @@ def test_02_time_incrementing(fprime_test_api: IntegrationTestAPI):
145122
)
146123

147124

148-
def test_03_time_not_set_event(fprime_test_api: IntegrationTestAPI):
125+
def test_03_time_not_set_event(fprime_test_api: IntegrationTestAPI, start_gds):
149126
"""Test that a TimeNotSet event is emitted when setting time with invalid data"""
150127

151128
# Clear histories

FprimeZephyrReference/test/int/watchdog_test.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,13 @@
44
Integration tests for the Watchdog component.
55
"""
66

7-
import os
8-
import subprocess
97
import time
108

119
import pytest
1210
from fprime_gds.common.data_types.ch_data import ChData
1311
from fprime_gds.common.testing_fw.api import IntegrationTestAPI
1412

1513

16-
@pytest.fixture(scope="session", autouse=True)
17-
def start_gds(fprime_test_api_session: IntegrationTestAPI):
18-
process = subprocess.Popen(["make", "gds-integration"], cwd=os.getcwd())
19-
20-
gds_working = False
21-
timeout_time = time.time() + 30
22-
while time.time() < timeout_time:
23-
try:
24-
fprime_test_api_session.send_and_assert_command(
25-
command="CdhCore.cmdDisp.CMD_NO_OP"
26-
)
27-
gds_working = True
28-
break
29-
except Exception:
30-
time.sleep(1)
31-
assert gds_working
32-
33-
yield
34-
process.kill()
35-
36-
3714
@pytest.fixture(autouse=True)
3815
def ensure_watchdog_running(fprime_test_api: IntegrationTestAPI):
3916
"""Fixture to ensure watchdog is started before and after each test"""
@@ -64,13 +41,13 @@ def get_watchdog_transitions(fprime_test_api: IntegrationTestAPI) -> int:
6441
return result.get_val()
6542

6643

67-
def test_01_watchdog_telemetry_basic(fprime_test_api: IntegrationTestAPI):
44+
def test_01_watchdog_telemetry_basic(fprime_test_api: IntegrationTestAPI, start_gds):
6845
"""Test that we can read WatchdogTransitions telemetry"""
6946
value = get_watchdog_transitions(fprime_test_api)
7047
assert value >= 0, f"WatchdogTransitions should be >= 0, got {value}"
7148

7249

73-
def test_02_watchdog_increments(fprime_test_api: IntegrationTestAPI):
50+
def test_02_watchdog_increments(fprime_test_api: IntegrationTestAPI, start_gds):
7451
"""Test that WatchdogTransitions increments over time"""
7552

7653
initial_value = get_watchdog_transitions(fprime_test_api)
@@ -82,7 +59,7 @@ def test_02_watchdog_increments(fprime_test_api: IntegrationTestAPI):
8259
)
8360

8461

85-
def test_03_stop_watchdog_command(fprime_test_api: IntegrationTestAPI):
62+
def test_03_stop_watchdog_command(fprime_test_api: IntegrationTestAPI, start_gds):
8663
"""
8764
Test STOP_WATCHDOG command sends and emits WatchdogStop
8865
event and WatchdogTransitions stops incrementing

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ gds: ## Run FPrime GDS
9191

9292
.PHONY: gds-integration
9393
gds-integration:
94-
@$(GDS_COMMAND)
94+
@$(GDS_COMMAND) --gui=none
9595

9696
##@ Build Tools
9797
BIN_DIR ?= $(shell pwd)/bin

0 commit comments

Comments
 (0)