File: codegen-tests.sh

package info (click to toggle)
bpftrace 0.24.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,496 kB
  • sloc: cpp: 60,982; ansic: 10,952; python: 953; yacc: 665; sh: 536; lex: 295; makefile: 22
file content (52 lines) | stat: -rwxr-xr-x 1,048 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

# Runs or updates codegen tests' expected LLVM IR.
# Requires nix.
#
# Example usage:
#
#     ./tests/codegen-tests.sh
#

set -eu

BUILD_DIR=build-codegen-update
UPDATE_TESTS=${BPFTRACE_UPDATE_TESTS:-0}
SCRIPT_NAME=$0

function run() {
  nix develop .#bpftrace-llvm18 --command "$@"
}

usage() {
  echo "Usage:"
  echo "    ${SCRIPT_NAME} [OPTIONS]"
  echo ""
  echo " Run or update the codegen tests with nix."
  echo ""
  echo "OPTIONS"
  echo "    -u      Update the tests."
  echo "    -d <BUILD_DIR>   Change the default build directory. Default: ${BUILD_DIR}"
}

while getopts ":d:uh" opt; do
case ${opt} in
    u )
        UPDATE_TESTS=1
        ;;
    d )
        BUILD_DIR=${OPTARG}
        ;;
    h )
        usage
        exit 0
        ;;
esac
done

# Change dir to project root
cd "$(git rev-parse --show-toplevel)"

run cmake -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Debug
run make -C "$BUILD_DIR" -j $(nproc) bpftrace_test
BPFTRACE_UPDATE_TESTS=${UPDATE_TESTS} run ./"$BUILD_DIR"/tests/bpftrace_test --gtest_filter="codegen*"