-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tokc-hardware-ci: ported test script
- Loading branch information
Showing
25 changed files
with
341 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Licensed under the Apache License, Version 2.0 or the MIT License. | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
# Copyright Tock Contributors 2024. | ||
|
||
from .console_hello_test import ( | ||
OneshotTest, | ||
AnalyzeConsoleTest, | ||
WaitForConsoleMessageTest, | ||
) | ||
from .c_hello import test as c_hello_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from utils.test_helpers import AnalyzeConsoleTest | ||
import logging | ||
|
||
|
||
class AdcTest(AnalyzeConsoleTest): | ||
def __init__(self): | ||
super().__init__(apps=["tests/adc/adc"]) | ||
|
||
def analyze(self, lines): | ||
adc_driver_found = False | ||
adc_readings_found = False | ||
for line in lines: | ||
if "ADC driver exists" in line: | ||
adc_driver_found = True | ||
if "ADC Reading:" in line: | ||
adc_readings_found = True | ||
break | ||
if "No ADC driver!" in line: | ||
logging.warning("No ADC driver available.") | ||
return # Test passes if ADC is not available | ||
if adc_driver_found and adc_readings_found: | ||
logging.info("ADC Test passed with readings.") | ||
elif adc_driver_found: | ||
raise Exception("ADC Test failed: Driver found but no readings.") | ||
else: | ||
logging.warning("ADC Test skipped: No ADC driver.") | ||
return # Test passes if ADC is not available | ||
|
||
|
||
test = AdcTest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from utils.test_helpers import WaitForConsoleMessageTest | ||
|
||
test = WaitForConsoleMessageTest(["tests/adc/adc_continuous"], "No ADC driver!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from utils.test_helpers import WaitForConsoleMessageTest | ||
|
||
test = WaitForConsoleMessageTest( | ||
["ble_advertising"], "Now advertising every 300 ms as 'TockOS'" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from utils.test_helpers import WaitForConsoleMessageTest | ||
|
||
test = WaitForConsoleMessageTest( | ||
["services/ble-env-sense", "services/ble-env-sense/test-with-sensors"], | ||
"BLE ERROR: Code = 16385", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from utils.test_helpers import AnalyzeConsoleTest | ||
import logging | ||
|
||
|
||
class BlePassiveScanningTest(AnalyzeConsoleTest): | ||
def __init__(self): | ||
super().__init__(apps=["ble_passive_scanning"]) | ||
|
||
def analyze(self, lines): | ||
found_advertisements = False | ||
for line in lines: | ||
if "PDU Type:" in line: | ||
found_advertisements = True | ||
break | ||
if found_advertisements: | ||
logging.info("BLE Passive Scanning Test passed.") | ||
else: | ||
logging.warning( | ||
"BLE Passive Scanning Test could not detect advertisements. Ensure BLE devices are nearby." | ||
) | ||
raise Exception( | ||
"BLE Passive Scanning Test failed: No advertisements detected." | ||
) | ||
|
||
|
||
test = BlePassiveScanningTest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from utils.test_helpers import AnalyzeConsoleTest | ||
import logging | ||
|
||
|
||
class CHelloAndPrintfLongTest(AnalyzeConsoleTest): | ||
def __init__(self): | ||
super().__init__(apps=["c_hello", "tests/printf_long"]) | ||
|
||
def analyze(self, lines): | ||
expected_messages = [ | ||
"Hello World!", | ||
"Hi welcome to Tock. This test makes sure that a greater than 64 byte message can be printed.", | ||
"And a short message.", | ||
] | ||
messages_found = {msg: False for msg in expected_messages} | ||
|
||
for line in lines: | ||
for msg in expected_messages: | ||
if msg in line: | ||
messages_found[msg] = True | ||
|
||
for msg, found in messages_found.items(): | ||
if not found: | ||
raise Exception(f"Did not find expected message: '{msg}'") | ||
logging.info("C Hello and Printf Long Test passed.") | ||
|
||
|
||
test = CHelloAndPrintfLongTest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from utils.test_helpers import WaitForConsoleMessageTest | ||
|
||
test = WaitForConsoleMessageTest( | ||
["tests/console/console_recv_long"], "[SHORT] Error doing UART receive: -2" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from utils.test_helpers import WaitForConsoleMessageTest | ||
|
||
test = WaitForConsoleMessageTest( | ||
["tests/console/console_recv_short"], "[SHORT] Error doing UART receive: -2" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from utils.test_helpers import AnalyzeConsoleTest | ||
import logging | ||
|
||
|
||
class GpioInterruptTest(AnalyzeConsoleTest): | ||
def __init__(self): | ||
super().__init__(apps=["tests/gpio/gpio_interrupt"]) | ||
|
||
def analyze(self, lines): | ||
interrupt_detected = False | ||
for line in lines: | ||
if "GPIO Interrupt!" in line: | ||
interrupt_detected = True | ||
break | ||
if interrupt_detected: | ||
logging.info("GPIO Interrupt Test passed.") | ||
else: | ||
raise Exception("GPIO Interrupt Test failed: No interrupt detected.") | ||
|
||
|
||
test = GpioInterruptTest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from utils.test_helpers import AnalyzeConsoleTest | ||
import logging | ||
|
||
|
||
class IpcLogicTest(AnalyzeConsoleTest): | ||
def __init__(self): | ||
super().__init__( | ||
apps=[ | ||
"tutorials/05_ipc/led", | ||
"tutorials/05_ipc/rng", | ||
"tutorials/05_ipc/logic", | ||
] | ||
) | ||
|
||
def analyze(self, lines): | ||
expected_output = "Number of LEDs:" | ||
for line in lines: | ||
if expected_output in line: | ||
logging.info("IPC Logic Test passed.") | ||
return | ||
raise Exception("IPC Logic Test failed: Expected output not found.") | ||
|
||
|
||
test = IpcLogicTest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from utils.test_helpers import WaitForConsoleMessageTest | ||
|
||
test = WaitForConsoleMessageTest(["lua-hello"], "Hello from Lua!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from utils.test_helpers import WaitForConsoleMessageTest | ||
|
||
test = WaitForConsoleMessageTest(["tests/malloc_test01"], "malloc01: success") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from utils.test_helpers import WaitForConsoleMessageTest | ||
|
||
test = WaitForConsoleMessageTest(["tests/malloc_test02"], "malloc02: success") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from utils.test_helpers import AnalyzeConsoleTest | ||
|
||
|
||
class MpuStackGrowthTest(AnalyzeConsoleTest): | ||
def __init__(self): | ||
super().__init__(apps=["tests/mpu/mpu_stack_growth"]) | ||
|
||
def analyze(self, lines): | ||
for line in lines: | ||
if "[TEST] MPU Stack Growth" in line: | ||
# Test started successfully | ||
return | ||
raise Exception("MPU Stack Growth test did not start") | ||
|
||
|
||
test = MpuStackGrowthTest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from utils.test_helpers import AnalyzeConsoleTest | ||
|
||
|
||
class MpuWalkRegionTest(AnalyzeConsoleTest): | ||
def __init__(self): | ||
super().__init__(apps=["tests/mpu/mpu_walk_region"]) | ||
|
||
def analyze(self, lines): | ||
for line in lines: | ||
if "[TEST] MPU Walk Regions" in line: | ||
# Test started successfully | ||
return | ||
raise Exception("MPU Walk Region test did not start") | ||
|
||
|
||
test = MpuWalkRegionTest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from utils.test_helpers import AnalyzeConsoleTest | ||
import logging | ||
|
||
|
||
class MultiAlarmSimpleTest(AnalyzeConsoleTest): | ||
def __init__(self): | ||
super().__init__(apps=["tests/multi_alarm_simple_test"]) | ||
|
||
def analyze(self, lines): | ||
# Initialize counts for each alarm | ||
alarm_counts = {1: 0, 2: 0} | ||
|
||
for line in lines: | ||
tokens = line.strip().split() | ||
if len(tokens) >= 3: | ||
try: | ||
alarm_index = int(tokens[0]) | ||
# Optional: parse timestamps if needed | ||
# now = int(tokens[1]) | ||
# expiration = int(tokens[2]) | ||
|
||
# Record counts | ||
if alarm_index in [1, 2]: | ||
alarm_counts[alarm_index] += 1 | ||
except ValueError: | ||
continue # Skip lines that don't parse correctly | ||
|
||
logging.info(f"Alarm counts: {alarm_counts}") | ||
count1 = alarm_counts.get(1, 0) | ||
count2 = alarm_counts.get(2, 0) | ||
if count1 < 2 or count2 < 1: | ||
raise Exception("MultiAlarmSimpleTest failed: Not enough alarms fired") | ||
if count1 < 2 * count2: | ||
raise Exception( | ||
"MultiAlarmSimpleTest failed: Alarm 1 did not fire at least twice as often as Alarm 2" | ||
) | ||
|
||
logging.info("MultiAlarmSimpleTest passed") | ||
|
||
|
||
test = MultiAlarmSimpleTest() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from utils.test_helpers import WaitForConsoleMessageTest | ||
|
||
test = WaitForConsoleMessageTest( | ||
["tests/printf_long"], | ||
"Hi welcome to Tock. This test makes sure that a greater than 64 byte message can be printed.", | ||
) |
Oops, something went wrong.