mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
a014cdd4de
Currently there is no testing for ClangTypeParser even though it's used in production. This is because adding integration tests is very hard: they require testing the build time behaviour at runtime, or else they'd be build failures intead of test failures. There's a PR available for integration tests but it's incomplete. In contrast ClangTypeParser can be sort of unit tested. This follows the structure of `test/test_drgn_parser.cpp` with some differences. There is a tonne of boilerplate for setting up the Clang tool, and this set of testing operates on type names instead of OID functions. The new tests are also incredibly slow as they compile the entire `integration_test_target.cpp` (which is huge) for every test case. I don't think this is avoidable without compromising the separation of the tests somewhat due to the way Clang tooling forces the code to be structured. Currently I can't run these tests locally on a Meta devserver due to some weirdness with the internal build and the `compile_commands.json` file. They run in the CI and on any other open source machine though so I'm happy to merge it - it's still useful. I'm going to close the PR to change the devserver build given I'll be unable to follow up if it ends up being bad. Test plan: - CI
225 lines
7.2 KiB
YAML
225 lines
7.2 KiB
YAML
version: 2.1
|
|
|
|
workflows:
|
|
object-introspection:
|
|
jobs:
|
|
- build:
|
|
name: build-gcc
|
|
cc: /usr/bin/gcc
|
|
cxx: /usr/bin/g++
|
|
warnings_as_errors: "OFF"
|
|
- test:
|
|
name: test-gcc
|
|
requires:
|
|
- build-gcc
|
|
exclude_regex: ".*inheritance_polymorphic.*|.*arrays_member_int0|ClangTypeParserTest.*"
|
|
- coverage:
|
|
name: coverage
|
|
requires:
|
|
- test-gcc
|
|
|
|
- build:
|
|
name: build-clang
|
|
cc: /usr/bin/clang-12
|
|
cxx: /usr/bin/clang++-12
|
|
warnings_as_errors: "ON"
|
|
- test:
|
|
name: test-clang
|
|
requires:
|
|
- build-clang
|
|
# Tests disabled due to bad DWARF generated by the old clang compiler in CI
|
|
exclude_regex: ".*inheritance_polymorphic.*|.*arrays_member_int0|.*fbstring.*|.*std_string_*|.*multi_arg_tb_.*|.*ignored_member|OilIntegration.fbstring_.*|OilIntegration.capture_keys_string|OilIntegration.capture_keys_multi_level"
|
|
|
|
executors:
|
|
ubuntu-docker:
|
|
docker:
|
|
- image: ubuntu:jammy
|
|
resource_class: small
|
|
big-boy:
|
|
machine:
|
|
image: ubuntu-2204:2022.10.2
|
|
resource_class: 2xlarge
|
|
|
|
jobs:
|
|
build:
|
|
# TODO this job could be run in Docker
|
|
executor: big-boy
|
|
parameters:
|
|
cc:
|
|
type: string
|
|
cxx:
|
|
type: string
|
|
warnings_as_errors:
|
|
type: string
|
|
environment:
|
|
CC: << parameters.cc >>
|
|
CXX: << parameters.cxx >>
|
|
working_directory:
|
|
/tmp/object-introspection
|
|
steps:
|
|
- run:
|
|
name: Install dependencies
|
|
command: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
bison \
|
|
build-essential \
|
|
clang-12 \
|
|
clang-15 \
|
|
cmake \
|
|
flex \
|
|
gawk \
|
|
libboost-all-dev \
|
|
libbz2-dev \
|
|
libcap2-bin \
|
|
libclang-15-dev \
|
|
libcurl4-gnutls-dev \
|
|
libdouble-conversion-dev \
|
|
libdw-dev \
|
|
libfmt-dev \
|
|
libgflags-dev \
|
|
libgmock-dev \
|
|
libgoogle-glog-dev \
|
|
libgtest-dev \
|
|
libjemalloc-dev \
|
|
libmsgpack-dev \
|
|
libzstd-dev \
|
|
llvm-15-dev \
|
|
ninja-build \
|
|
pkg-config \
|
|
python3-setuptools
|
|
pip3 install toml
|
|
environment:
|
|
DEBIAN_FRONTEND: noninteractive
|
|
- checkout
|
|
- run:
|
|
name: Build
|
|
command: |
|
|
cmake -G Ninja -B build/ -DWITH_FLAKY_TESTS=Off -DCODE_COVERAGE=On -DWARNINGS_AS_ERRORS=<< parameters.warnings_as_errors >>
|
|
cmake --build build/
|
|
# Testing rubbish:
|
|
cp test/ci.oid.toml build/testing.oid.toml
|
|
- persist_to_workspace:
|
|
root: .
|
|
paths:
|
|
- build/*
|
|
- extern/*
|
|
- include/*
|
|
- types/*
|
|
|
|
test:
|
|
executor: big-boy
|
|
parameters:
|
|
oid_test_args:
|
|
type: string
|
|
default: ""
|
|
tests_regex:
|
|
type: string
|
|
default: ".*"
|
|
exclude_regex:
|
|
type: string
|
|
default: ""
|
|
working_directory:
|
|
/tmp/object-introspection
|
|
steps:
|
|
- attach_workspace:
|
|
at: .
|
|
- run:
|
|
name: Install dependencies
|
|
command: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
clang-15 \
|
|
libboost-all-dev \
|
|
libgflags-dev \
|
|
llvm-15-dev \
|
|
libfmt-dev \
|
|
libjemalloc-dev
|
|
environment:
|
|
DEBIAN_FRONTEND: noninteractive
|
|
- run:
|
|
name: Test
|
|
environment:
|
|
# disable drgn multithreading as tests are already run in parallel
|
|
OMP_NUM_THREADS: 1
|
|
command: |
|
|
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
|
|
OID_TEST_ARGS='<< parameters.oid_test_args >>' ctest \
|
|
--test-dir build/test/ \
|
|
--test-action Test \
|
|
-j 16 \
|
|
--tests-regex '<< parameters.tests_regex >>' \
|
|
--exclude-regex '<< parameters.exclude_regex >>' \
|
|
--no-compress-output \
|
|
--output-on-failure \
|
|
--schedule-random \
|
|
--timeout 60 \
|
|
--repeat until-pass:2 \
|
|
--output-junit results.xml
|
|
- store_test_results:
|
|
path: build/test/results.xml
|
|
- persist_to_workspace:
|
|
# Save code coverage data
|
|
root: .
|
|
paths:
|
|
- build/*
|
|
|
|
coverage:
|
|
executor: ubuntu-docker
|
|
working_directory:
|
|
/tmp/object-introspection
|
|
steps:
|
|
- run:
|
|
name: Install dependencies
|
|
command: |
|
|
apt-get update
|
|
apt-get install -y \
|
|
build-essential \
|
|
cpanminus \
|
|
curl \
|
|
git \
|
|
gpg
|
|
# Install lcov 2.0 - required for the "--filter branch" option.
|
|
# This improves C++ branch coverage by excluding compiler-generated
|
|
# branches, which primarily come from exception handling in
|
|
# standard library functions.
|
|
cpanm --notest Capture::Tiny DateTime
|
|
pushd /tmp
|
|
curl -sLO https://github.com/linux-test-project/lcov/releases/download/v2.0/lcov-2.0.tar.gz
|
|
tar -xf lcov-2.0.tar.gz
|
|
cd lcov-2.0
|
|
make install
|
|
popd
|
|
environment:
|
|
DEBIAN_FRONTEND: noninteractive
|
|
- checkout
|
|
- attach_workspace:
|
|
at: .
|
|
- run:
|
|
name: Code Coverage
|
|
when: always
|
|
command: |
|
|
lcov --capture --directory . --filter branch --no-external --ignore-errors mismatch --ignore-errors source --rc lcov_branch_coverage=1 --output-file coverage.info
|
|
# Empirically, extract-then-remove is faster than remove-then-extract
|
|
lcov --extract coverage.info '/tmp/object-introspection/*' --rc lcov_branch_coverage=1 --output-file coverage.info
|
|
lcov --remove coverage.info '/tmp/object-introspection/build/*' '/tmp/object-introspection/extern/*' --rc lcov_branch_coverage=1 --output-file coverage.info
|
|
lcov --list --rc lcov_branch_coverage=1 coverage.info
|
|
|
|
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
|
|
curl -Os https://uploader.codecov.io/latest/linux/codecov
|
|
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
|
|
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
|
|
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
|
|
shasum -a 256 -c codecov.SHA256SUM
|
|
chmod +x codecov
|
|
|
|
# It appears that codecov wants to scan through all directories
|
|
# other than "build", looking for files to upload, even if we
|
|
# specify a file name on the command line.
|
|
#
|
|
# "extern" is huge and makes uploading the coverage report take
|
|
# forever. Delete it for a speedup.
|
|
rm -rf extern
|
|
|
|
./codecov -Z -f coverage.info -t $CODECOV_TOKEN
|