Refactor: rename SimDUT, restructure DUT simulation and test flow

This commit is contained in:
2025-07-21 15:57:15 -06:00
parent 27064417dd
commit 4a1f943126
28 changed files with 750 additions and 5 deletions

43
docs/_static/custom.css vendored Normal file
View File

@@ -0,0 +1,43 @@
/* custom.css: Modernized Sphinx Theme Tweaks */
body {
font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
line-height: 1.6;
background-color: #fefefe;
color: #333;
max-width: 1000px;
margin: auto;
padding: 2em;
}
h1, h2, h3, h4 {
color: #005f73;
}
a {
color: #0a9396;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
code, pre {
background-color: #f0f0f0;
padding: 0.2em 0.4em;
border-radius: 4px;
font-family: Consolas, monospace;
color: #1e1e1e;
}
.rst-content table.docutils {
border-collapse: collapse;
border: 1px solid #ccc;
}
.rst-content table.docutils th,
.rst-content table.docutils td {
border: 1px solid #ccc;
padding: 6px 12px;
}

View File

@@ -0,0 +1,4 @@
Architecture
============
(coming soon)

View File

@@ -0,0 +1,20 @@
# docs/conf.py
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
project = 'Hardware Test Framework'
author = 'Nathan Corwin'
release = '0.1'
extensions = [
'sphinx.ext.autodoc',
]
templates_path = ['_templates']
exclude_patterns = []
html_theme = 'alabaster'
html_static_path = ['_static']
html_css_files = ['custom.css']

View File

@@ -0,0 +1,35 @@
Getting Started
===============
This guide helps you bootstrap your first test project using the framework.
Setup
-----
1. Clone the repo:
.. code-block:: bash
git clone ssh://git@git.corwin.life:23231/hw-test-template.git
2. Create a virtual environment and install dependencies:
.. code-block:: bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
3. Run a simulation-mode test:
.. code-block:: bash
pytest --sim
Next Steps
----------
- Edit or extend the `SimDUT` class for your DUT logic
- Add custom test cases in `tests/`
- Build docs using:
.. code-block:: bash
sphinx-build -b html . _build/html

31
docs/hardware.rst Normal file
View File

@@ -0,0 +1,31 @@
Real Hardware Integration
=========================
This page describes how to implement real instrument interfaces.
Backends
--------
Interfaces expected:
- Serial-based DUT communication
- SCPI commands over USB or LAN
- Future support for Modbus, I2C, or CAN (if needed)
Adding a Real DUT
------------------
1. Create a `RealDUT` class in `src/instruments/dut_controller.py`
2. Match the interface used in `SimDUT`
3. Uncomment the fixture in `conftest.py` to enable
.. code-block:: python
# return RealDUT(port="/dev/ttyUSB0")
Safety Tips
-----------
- Use proper delays when enabling outputs
- Confirm settings before triggering loads
- Log all commands during development

View File

@@ -0,0 +1,24 @@
Welcome to the Hardware Test Framework!
=======================================
.. toctree::
:maxdepth: 2
:caption: Contents:
getting_started
usage
architecture
simulation
hardware
modules
----
Overview
--------
This project is a reusable Python test harness for validating electronic hardware designs using Pytest, SCPI/serial interfaces, and optional simulation mode.
* Easy to extend
* Supports both bench instruments and DUT interaction
* Includes automatic HTML test reporting

22
docs/modules.rst Normal file
View File

@@ -0,0 +1,22 @@
Module Reference
================
This section provides an overview of Python modules in the framework.
Instrument Interfaces
---------------------
.. automodule:: src.instruments.dut_controller
:members:
Utilities
---------
.. automodule:: src.utils.logger
:members:
Serial Interfaces
-----------------
.. automodule:: src.interfaces.serial
:members:

23
docs/simulation.rst Normal file
View File

@@ -0,0 +1,23 @@
Simulation Mode
===============
The simulation backend allows you to test framework logic without connecting real hardware.
How It Works
------------
Fixtures like `dut` use mock classes defined in `src/instruments/dut_controller.py`.
Example Methods:
- `get_version()`
- `read_temperature()`
- `set_output_enabled()`
Extending Sim Mode
------------------
You can expand simulation by:
- Creating additional dummy instruments
- Returning randomized or patterned values
- Adding logs to mimic hardware responses

31
docs/usage.rst Normal file
View File

@@ -0,0 +1,31 @@
Usage Guide
===========
This section describes how to set up and run the test framework.
Quick Start
-----------
1. Clone the repo and create a virtual environment:
.. code-block:: bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
2. Run tests in simulation mode:
.. code-block:: bash
pytest --sim
3. View the report:
- Open `report.html` in your browser.
Switching Between Sim and Hardware
----------------------------------
Use the `--sim` flag to control which backend is used.
The system defaults to skipping hardware tests