-
Notifications
You must be signed in to change notification settings - Fork 6
Play around
As a user of the framework, you have complete freedom in altering its behavior. This document describes some common ways to do so.
foamut is built with bashly, making it easy to extend and customize.
The source code is organized under src/:
-
src/bashly.yml- CLI configuration and help text -
src/initialize.sh- Pre-execution setup -
src/root_command.sh- Main orchestration logic -
src/lib/*.sh- Helper functions for compilation, test execution, and cleanup
To modify behavior, edit the relevant file and regenerate:
./generate.shControl foamut behavior with these environment variables:
| Variable | Default | Description |
|---|---|---|
CATCH_TIMEOUT |
60 |
Test timeout in seconds |
FOAM_FOAMUT_TESTS |
- | External tests directory (auto-symlinked) |
FOAM_FOAMUT |
auto | Path to foamUT repository root |
FOAM_FOAMUT_NPROCS |
2 |
Number of processors for parallel standalone tests |
To support all OpenFOAM forks, foamut creates dummy libraries for missing dependencies.
For example, Foam-Extend doesn't have libPstream.so (functionality is in libfoam.so).
This is handled in src/lib/create_dummy_libs.sh:
dummyLibChecks="Pstream dynamicFvMesh"Dummy libraries are created if missing and cleaned up after tests finish.
Test cases are run off-tree to minimize interaction:
- Location:
/tmp/foamUtCases(defined insrc/root_command.sh) - Cases are copied here before each test run
- Cleaned up automatically after tests complete
To change the location, edit caseRun variable in src/root_command.sh:
caseRun=/your/custom/path
./generate.shIn CI environments, timeouts prevent hanging processes:
# Set custom timeout (default: 60 seconds)
export CATCH_TIMEOUT=120
# Run tests
./foamutTimeout is automatically disabled when using --test-prefix (for debugging).
Use --force-timeout to keep it:
./foamut --test-prefix "gdb --args" --force-timeoutThe test driver works with any OpenFOAM fork by letting each fork handle OpenFOAM initialization on its own.
The test driver splits arguments using --- as separator:
/path/to/testDriver [Catch2_params] --- [OpenFOAM_params]Example - run on cavity case in parallel:
mpirun -np 4 ./testDriver -s --- -case /dev/shm/cavity -parallelNote: With foamut, you don't need to worry about this - it's handled automatically!
Use --test-driver to provide your own test driver source:
./foamut --test-driver /path/to/myTestDriver.CYour custom driver will be compiled and used instead of the default one.
The test driver instructs FatalError to throw exceptions instead of aborting:
Foam::FatalError.throwExceptions();This allows Catch2 to catch errors and continue with other tests. You won't see "FOAM FATAL ERROR" messages on the console anymore.
To see full error messages in a specific test:
TEST_CASE("My test", "[serial]") {
// Disable exception throwing for this test only
Foam::FatalError.dontThrowExceptions();
// Your test code that might trigger FatalError
// ...
}In standalone mode (--standalone), the test driver sets:
argsPtr = nullptr;
timePtr = nullptr;Your tests should check for this:
TEST_CASE("Standalone test", "[serial]") {
if (timePtr == nullptr) {
// Running in standalone mode - no OpenFOAM case
// Test pure C++ logic without mesh/time objects
}
}Moved to its own Wiki page
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
This is foamUT Wiki, here is a link back to Home