This directory contains unit tests for the DMLOG library.
mkdir build
cd build
cmake ..
makectest --output-on-failure./tests/test_dmlog_unit
./tests/test_simple
./tests/test_benchmark./tests/test_benchmarkThis will display performance metrics including:
- Time to write 3000 log messages
- Throughput in logs/second
- Average time per log entry
- Performance with different message sizes
- Read performance metrics
- Buffer wraparound performance
To generate code coverage reports:
mkdir build
cd build
cmake -DENABLE_COVERAGE=ON ..
makemake coverageThe coverage report will be generated in build/coverage/html/index.html.
The make coverage command will also print a summary to the console showing line coverage percentages for each file.
- test_common.h: Common test utilities and macros
- test_simple.c: Basic smoke tests
- test_dmlog_unit.c: Comprehensive unit tests covering:
- Context creation and validation
- Write operations (putc, puts, putsn)
- Read operations (read_next, getc, gets)
- Buffer management and space tracking
- Buffer clear operations
- Multiple entry handling
- Auto-flush on newline
- Buffer wraparound scenarios
- Edge cases and error handling
- Stress testing
- Maximum entry size handling
- Invalid context operations
- test_benchmark.c: Performance benchmarks including:
- 3000 log messages write performance test
- Varying message size benchmarks (small, medium, large)
- Read performance measurements
- Buffer wraparound performance under heavy load
- test_input.c: Tests for bidirectional communication (PC → firmware input)
- Input buffer initialization
- Single and multiple character input
- Line-based input reading
- Buffer wraparound handling
- Input request functionality
-
test_app_interactive.c: Configurable test application for automated testing
- Reads test scenarios from input files
- Logs messages line-by-line to dmlog
- Supports
<user_input>marker for input testing - Configurable buffer size
- Designed for gdbserver integration testing
-
test_automated_gdb.sh: Automated integration test script
- Tests complete end-to-end GDB server integration
- Validates output path (firmware → PC via dmlog_monitor)
- Multiple test scenarios with different buffer sizes
- Runs automatically in CI on every build
- Requires gdbserver (install with:
apt-get install gdbserver)
Located in scenarios/ directory:
- test_output_only.txt: Simple output test without user input (✓ Working)
- test_input_single.txt: Test with one user input request (future)
- test_input_multiple.txt: Test with multiple input requests (future)
- test_mixed_complex.txt: Complex mixed output/input scenario (future)
sudo apt-get install gdbservercd tests
./test_automated_gdb.shThis script will:
- Build and start the test application under gdbserver
- Connect dmlog_monitor using GDB backend
- Validate that expected log messages are received
- Test different scenarios and buffer sizes
- Report pass/fail for each test
# Build the project first
cd build
make test_app_interactive
# Run with a test scenario
./tests/test_app_interactive ../tests/scenarios/test_output_only.txt 4096
# In another terminal, connect dmlog_monitor
./tools/monitor/dmlog_monitor --gdb --addr <buffer_address>The tests aim to achieve >80% line coverage of the dmlog library code.