xref: /aosp_15_r20/external/cronet/third_party/libc++/src/utils/libcxx-lit (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1#!/usr/bin/env bash
2
3set -e
4
5PROGNAME="$(basename "${0}")"
6function usage() {
7cat <<EOF
8Usage:
9${PROGNAME} [-h|--help] [-b|--bootstrap] <build-directory> [lit options...] tests...
10
11Shortcut to build the libc++ testing dependencies and run the libc++ tests with Lit.
12
13[-b|--bootstrap]   Configure tests to run against a bootstrap build of libcxx.
14<build-directory>  The path to the build directory to use for building the library.
15[lit options...]   Optional options to pass to 'llvm-lit'.
16tests...           Paths of the tests to run. Those paths are relative to '<monorepo-root>'.
17
18Example
19=======
20$ cmake -S runtimes -B build/ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"
21$ libcxx-lit build/ -sv libcxx/test/std/utilities/
22EOF
23}
24
25type="cxx"
26if [[ "${1}" == "-h" || "${1}" == "--help" ]]; then
27    usage
28    exit 0
29fi
30
31if [[ "${1}" == "-b" || "${1}" == "--bootstrap" ]]; then
32    type="runtimes"
33		shift
34fi
35
36if [[ $# -lt 1 ]]; then
37    usage
38    exit 1
39fi
40
41build_dir="${1}"
42shift
43
44if [[ "${type}" == "runtimes" ]]; then
45        echo "N.B.: In a bootstrap build, lit needs a prefix to work correctly;"
46        echo "      See libcxx/docs/Testinglibcxx.rst for more information."
47fi
48cmake --build "${build_dir}" --target ${type}-test-depends
49"${build_dir}/bin/llvm-lit" ${@}
50