Skip to content

Latest commit

 

History

History
97 lines (71 loc) · 3.17 KB

File metadata and controls

97 lines (71 loc) · 3.17 KB

Contributing to LLTFI

Prerequisites

Before writing any code, read:

Development Setup

mkdir build && cd build
cmake /path/to/LLTFI -DLLVM_GXX_BIN_DIR /usr/lib/llvm-15/bin
# On Ubuntu with apt-installed LLVM, use -DLLVM_GXX_BIN_DIR /usr/lib/llvm-15/bin
../setup

Making Changes

C++ Changes

  • Target C++14; compile against LLVM 15 APIs
  • Use nullptr, #ifndef include guards, RAII memory management
  • LLVM 15 API: arg_size() (not getNumArgOperands()), #include "llvm/IR/CFG.h" (not llvm/Support/CFG.h)
  • runOnModule must return bool

Python Changes

  • Python 3 only; follow PEP 8
  • Always use with open(...) for file I/O
  • Never use shell=True in subprocess calls
  • Use sys.exit(), not exit()
  • Use yaml.safe_load(), not yaml.load()
  • Minimum except Exception: — never bare except:

Adding a Software Fault Mode

  1. Edit tools/FIDL/config/default_failures.yaml
  2. Regenerate selectors: python3 tools/FIDL/FIDL-Algorithm.py -a default
  3. Do not commit the generated llvm_passes/software_failures/_*_*Selector.cpp files — they are regenerated by ./setup
  4. Update test_suite/SCRIPTS/test_fidl_generation.py if expected_count changes

After Any FIDL Template Change

If you modify tools/FIDL/config/Target*Template.cpp, re-run:

python3 tools/FIDL/FIDL-Algorithm.py -a default

Running Tests

From the build directory:

# All core tests (must pass before any PR)
./test_suite/SCRIPTS/llfi_test --all

# Specific subsets
./test_suite/SCRIPTS/llfi_test --all_hardware_faults
./test_suite/SCRIPTS/llfi_test --all_software_faults
./test_suite/SCRIPTS/llfi_test --all_trace_tools_tests
./test_suite/SCRIPTS/llfi_test --all_fidl

# Single test case
./test_suite/SCRIPTS/llfi_test --test_cases <TestName>

ML/ONNX tests

./test_suite/SCRIPTS/llfi_test --all_ml

These are not part of --all because they require optional dependencies. Tests with missing deps report SKIP, not FAIL, and don't affect the pass/fail count.

Group Requirements
SoftwareFailureAutoScan LLTFI build only
ML tool unit tests pip install onnx pygraphviz pydot
TensorFlow → ONNX pip install tensorflow tf2onnx onnx
PyTorch → ONNX pip install torch onnx
ONNX → LLVM IR onnx-mlir binary (ONNX_MLIR_BUILD env var)
Fault injection (ML) LLTFI build + model.ll from sample_programs/.../mnist/compile.sh

All core tests (--all) must pass before submitting a pull request. ML tests (--all_ml) should pass for any change that touches ML-related code.

Pull Request Checklist

  • All tests pass (llfi_test --all)
  • Code follows CODING_GUIDELINES.md
  • FIDL-generated _*_*Selector.cpp files are NOT included in the commit
  • If adding a fault mode: expected_count in test_fidl_generation.py is updated
  • If changing a public API or behavior: README.md is updated
  • New functionality has a corresponding test case