Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions Server/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ def make_suite(board_folder):
return discovered_tests

def run_tests() -> None:
# monitor script
import subprocess, datetime, time

ts = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
os.makedirs("logs", exist_ok=True)
serial_log = os.path.abspath(f"logs/{ts}_serial.txt")

monitor_path = "/home/solarcar/solarcar/Rivanna3/monitor.py"
monitor_proc = subprocess.Popen(
[sys.executable, monitor_path, "--log", serial_log],
cwd=os.path.dirname(monitor_path), # important: run from monitor's folder
stdout=open(os.path.join("logs", "monitor_stdout.log"), "ab"),
stderr=open(os.path.join("logs", "monitor_stderr.log"), "ab"),
)
print(f"[ARTIFACT] serial_log={serial_log}")
print(f"[DEBUG] monitor_path={monitor_path}")

board_names = config.REPO_CONFIG["boards"].keys()

all_suites = unittest.TestSuite()
Expand All @@ -50,6 +67,14 @@ def run_tests() -> None:
else:
print(f"Warning: Folder for board '{board}' not found at path: {board_folder}")

with open("test-results.xml", "wb") as output:
runner = xmlrunner.XMLTestRunner(output=output, buffer=True)
runner.run(all_suites)
try:
with open("test-results.xml", "wb") as output:
runner = xmlrunner.XMLTestRunner(output=output, buffer=True)
runner.run(all_suites)
finally:
monitor_proc.terminate()
try:
monitor_proc.wait(timeout=2)
except Exception:
monitor_proc.kill()

24 changes: 12 additions & 12 deletions Testing_Library/gpioPins.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@ def reset_all_pins() -> None:
pass #TODO

def reset_nucleo() -> None:
print("[RESET] Resetting Nucleo via PC10...")
print("[RESET] Resetting Nucleo via GPIO3...")

# intiialize reset pin as output (active low)
reset_pin = DigitalOutput(14)
# intiialize reset pin as output (active low)
reset_pin = gpiozero.DigitalOutputDevice("GPIO3")

try:
# hold reset low
reset_pin.write(False)
time.sleep(0.1) # 100 ms pulse
try:
# hold reset low
reset_pin.off()
time.sleep(0.1) # 100 ms pulse

# release reset (set high)
reset_pin.write(True)
# release reset (set high)
reset_pin.on()

print("[RESET] Nucleo reset complete.")
finally:
pass
print("[RESET] Nucleo reset complete.")
finally:
pass


class DigitalOutput:
Expand Down
23 changes: 23 additions & 0 deletions Testing_Library/sandbox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import sys
sys.path.append("/home/solarcar/solarcar/HiL_Testing/Server")

import gpiozero
import time


print("[RESET] Resetting Nucleo via GPIO3...")

# intiialize reset pin as output (active low)
reset_pin = gpiozero.DigitalOutputDevice("GPIO3")

try:
# hold reset low
reset_pin.off()
time.sleep(0.1) # 100 ms pulse

# release reset (set high)
reset_pin.on()

print("[RESET] Nucleo reset complete.")
finally:
pass
2 changes: 1 addition & 1 deletion Testing_Library/upload_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def upload_firmware(board_name: str):

# Construct path to Rivanna3/upload.py
script_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), "../../Rivanna3/upload.py")
os.path.join(os.path.dirname(__file__), "../../Rivanna3/upload_old.py")
)

# Clean up board name (PowerBoard → power)
Expand Down