mock-tests/README.md
The FIO mock test suite provides isolated unit testing for specific algorithms, calculations, and edge cases within FIO. These tests use mock implementations to validate correctness without requiring the full FIO infrastructure.
make test for that)mock-tests/
├── lib/ # Common test infrastructure
│ └── tap.h # TAP (Test Anything Protocol) output support
├── tests/ # Individual test programs
│ └── test_*.c # Test source files
├── build/ # Build artifacts (created by make)
└── Makefile # Build system for mock tests
make mock-tests
cd mock-tests
make test # Run all tests
make test-tap # Run with TAP harness (if prove is installed)
make test-latency_precision # Run specific test
make clean # From mock-tests directory
# or
make clean # From main FIO directory (cleans everything)
Tests produce TAP (Test Anything Protocol) output for easy parsing:
TAP version 13
1..12
ok 1 - Microsecond latency: 123456000 == 123456000
ok 2 - Millisecond latency: 1234567890000 == 1234567890000
not ok 3 - Some failing test
# All tests passed
This format is understood by many test harnesses and CI systems.
tests/:#include "../lib/tap.h"
int main(void) {
tap_init();
tap_plan(3); // Number of tests
tap_ok(1 == 1, "Basic equality");
tap_ok(2 + 2 == 4, "Addition works");
tap_skip("Not implemented yet");
return tap_done();
}
Edit mock-tests/Makefile and add your test name to the TESTS variable.
Each test should have a comprehensive header comment explaining:
Purpose: Validates numerical precision improvements in steady state latency calculations.
Background: When calculating total latency from mean and sample count, large values can cause precision loss or overflow. This test validates the improvement from:
// Before: potential precision loss
total = (uint64_t)(mean * samples);
// After: explicit double precision
total = (uint64_t)(mean * (double)samples);
Test Cases:
The TAP output format makes these tests easy to integrate with CI systems:
# In CI script
make mock-tests || exit 1
Or with TAP parsing for better reports:
prove -v mock-tests/build/*
Potential areas for expansion:
When adding new mock tests: