This directory contains LLVM-style lit tests for xunused.
You need the following tools installed:
- LLVM package: Provides
FileCheckandlittesting infrastructure- On Ubuntu/Debian:
sudo apt-get install llvm
- On Ubuntu/Debian:
- xunused binary: Build the project first with
cmakeandmake
The simplest way to run tests is using the check target:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --build build --target checkThe check target automatically:
- Finds
lit.pyfrom your LLVM installation - Sets up the correct PATH to include the xunused binary and LLVM tools (FileCheck, etc.)
- Runs the tests with proper configuration
If you want to run tests manually:
-
Build xunused:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build -
Add xunused and LLVM tools to PATH:
export PATH="$(pwd)/build:$PATH" # Also add LLVM tools directory for FileCheck export PATH="/usr/lib/llvm-18/bin:$PATH"
-
Set up llvm-lit (if not already available):
# Find and use the lit.py script from your LLVM installation LIT_PATH=$(find /usr/lib/llvm-*/build/utils/lit/lit.py -print -quit 2>/dev/null) if [ -n "$LIT_PATH" ]; then alias llvm-lit="python3 $LIT_PATH" fi
-
Run the tests:
llvm-lit -v tests
lit.cfg.py: Configuration file for the lit test runner- Test files (
.test,.c,.cpp,.sh) in thetests/directory - Each test file uses LLVM-style
RUN:andCHECK:directives
Tests use the LLVM FileCheck format:
RUN:lines specify commands to executeCHECK:lines specify patterns to match in the output%tis a temporary directory for test artifactssplit-filecan be used to embed multiple input files in a single test
See basic.test for an example using split-file.