Skip to content

Commit

Permalink
CI: test on hardware
Browse files Browse the repository at this point in the history
  • Loading branch information
hnez committed Dec 22, 2023
1 parent 1a68038 commit 43ab55b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/pytest-on-hardware.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: pytest on hardware

on: [push, pull_request]

jobs:
python-pytest:
name: Python pytest on hardware
runs-on: [self-hosted, dut-usb-sd-mux]
steps:
- uses: actions/checkout@v3
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pytest pytest-mock
- name: Run pytest
run: |
python -m pytest -vv
30 changes: 30 additions & 0 deletions tests/test_on_hardware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pathlib
import time

import pytest

from usbsdmux.usbsdmux import autoselect_driver


@pytest.fixture
def mux():
usbsdmux_path = pathlib.Path("/dev/usb-sd-mux")

while True:
time.sleep(0.5)

if not usbsdmux_path.is_dir():
continue

muxes = list(str(d) for d in usbsdmux_path.iterdir() if d.is_symlink())

if len(muxes) >= 1:
return autoselect_driver(muxes[0])


def test_switching(mux):
print("Switch to DUT mode")
mux.mode_DUT()

print("Switch to host mode")
mux.mode_host()

0 comments on commit 43ab55b

Please sign in to comment.