Skip to content

Commit

Permalink
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Delphix Engineering committed Sep 6, 2023
2 parents d054587 + e6e4318 commit 4ed2a81
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
19 changes: 2 additions & 17 deletions docs/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,10 @@ This document features basic guidelines and recommendations on how to do
bpftrace development. Please read it carefully before submitting pull requests
to simplify reviewing and to speed up the merge process.

## Tests

There are 3 basic kinds of tests in bpftrace:

- Unit tests for individual components (semantic analyser, codegen, etc.) based
on the GoogleTest framework. These are located in `tests/*.cpp` and are
executed by `<builddir>/tests/bpftrace_test`.

- Runtime tests that execute bpftrace in various scenarios. These are located in
`tests/runtime` and can be executed using `<builddir>/tests/runtime-tests.sh`.
The tests are managed by a custom framework.

- Tools parsing tests that run every tool in the `tools/` directory and check
whether it executes without issues. The validity of tools outputs is not
checked at the moment. Tests can be executed by
`<builddir>/tests/tools-parsing-test.sh`.
## [Tests](../tests/README.md)

Every contribution should (1) not break the existing tests and (2) introduce new
tests if relevant. See existing tests for inspiration on how to write new ones.
tests if relevant. See existing tests for inspiration on how to write new ones. [Read more on the different kinds and how to run them](../tests/README.md).

## Continuous integration

Expand Down
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
nixpkgs.url = "github:NixOS/nixpkgs/release-22.11";
flake-utils.url = "github:numtide/flake-utils";
nix-appimage = {
# Use fork until https://github.com/ralismark/nix-appimage/pull/8 is in
url = "github:danobi/nix-appimage/5d5093111a1ec4f116c1c57b7a807d41404bfa5e";
# Use fork until following PRs are in:
# https://github.com/ralismark/nix-appimage/pull/8
# https://github.com/ralismark/nix-appimage/pull/9
url = "github:danobi/nix-appimage/83c61d93ee96d4d530f5382edca51ee30ce2769f";
# Avoid multiple copies of the same dependency
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
Expand Down Expand Up @@ -140,8 +142,29 @@
drv = default;
entrypoint = pkgs.lib.getExe default;
name = default.name;
};

# Exclude the following groups to reduce appimage size:
#
# *.a: Static archives are not necessary at runtime
# *.pyc, *.py, *.whl: bpftrace does not use python at runtime
# libLLVM-11.so: Appimage uses the latest llvm we support, so not llvm11
#
# The basic process to identify large and useless files is to:
#
# ```
# $ nix build .#appimage
# $ ./result --appimage-mount
# $ cd /tmp/.mount_resultXXXX # in new terminal
# $ fd -S +1m -l
# ```
exclude = [
"... *.a"
"... *.pyc"
"... *.py"
"... *.whl"
"... libLLVM-11.so"
];
};
};

# Define apps that can be run with `nix run`
Expand Down
17 changes: 9 additions & 8 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# bpftrace Tests

There are three different types of tests: [unit](#unit-tests), [runtime](#runtime-tests), and [tool parsing](#tool-parsing-tests).

Every contribution should (1) not break the existing tests and (2) introduce new tests if relevant.

## Unit tests

These tests can be run with the `bpftrace_test` executable.
Tests can be selected with the `--gtest_filter` flag or the `GTEST_FILTER`
environment variable, see `--help` for more information.
Unit tests for individual components (semantic analyser, codegen, etc.) are based on the GoogleTest framework. These tests can be run with the `bpftrace_test` executable. Tests can be selected with the `--gtest_filter` flag or the `GTEST_FILTER` environment variable, see `--help` for more information. These are located in `tests/*.cpp` and are executed by `<builddir>/tests/bpftrace_test`.

### Codegen tests

Expand Down Expand Up @@ -36,9 +38,9 @@ instead of running the tests.

## Runtime tests

Runtime tests will call the bpftrace executable.
Runtime tests will call the bpftrace executable. These are located in `tests/runtime` and are managed by a custom framework.

* Run: `sudo make runtime-tests` inside your build folder
* Run: `sudo make runtime-tests` inside your build folder or `sudo <builddir>/tests/runtime-tests.sh`
* By default, runtime-tests will look for the executable in the build folder. You can set a value to the environment variable `BPFTRACE_RUNTIME_TEST_EXECUTABLE` to customize it

Runtime tests are grouped into "suites". A suite is usually a single file. The
Expand Down Expand Up @@ -115,10 +117,9 @@ be used to tightly control what code paths are triggered in the system.

## Tool parsing tests

`./tests/tools-parsing-test.sh`
Tools parsing tests run every tool in the `tools/` directory and ensure that the tools shipped with bpftrace are valid and can run. The validity of tools outputs is not checked at the moment.

The tool parsing tests ensure that the tools shipped with bpftrace are valid and
can run. The actual output is not validated.
Tests can be executed by: `sudo <builddir>/tests/tools-parsing-test.sh`

### Flags and variables

Expand Down

0 comments on commit 4ed2a81

Please sign in to comment.