-
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.
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
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,50 @@ | ||
# hwci/tests/button_print_should_fail.py | ||
|
||
# Licensed under the Apache License, Version 2.0 or the MIT License. | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
# Copyright Tock Contributors 2024. | ||
|
||
import logging | ||
from utils.test_helpers import OneshotTest | ||
|
||
|
||
class ButtonPressTest(OneshotTest): | ||
def __init__(self): | ||
super().__init__(apps=["tests/button_print"]) | ||
|
||
def oneshot_test(self, board): | ||
gpio = board.gpio | ||
serial = board.serial | ||
|
||
button_pin = gpio.pin("P0.11") | ||
# Set the pin as output to simulate button press (active low) | ||
button_pin.set_mode("output") | ||
button_pin.write(1) # Ensure button is not pressed initially | ||
|
||
# Start the test | ||
logging.info("Starting Button Press Test") | ||
|
||
# Wait for initial message | ||
output = serial.expect(r"\[TEST\] Button Press", timeout=10) | ||
if not output: | ||
raise Exception("Did not receive expected test start message") | ||
|
||
# Simulate button press | ||
button_pin.write(0) # Active low, so writing 0 simulates press | ||
logging.info("Button pressed (simulated)") | ||
|
||
# Wait for the expected output | ||
output = serial.expect(r"Button Press! Button: 1 Status: 1", timeout=5) | ||
if not output: | ||
raise Exception("Did not receive expected button press message") | ||
|
||
logging.info("Button press message received") | ||
|
||
# Release button | ||
button_pin.write(1) | ||
logging.info("Button released (simulated)") | ||
|
||
logging.info("Button Press Test completed successfully") | ||
|
||
|
||
test = ButtonPressTest() |