From 9da81a4d61c60baa205a6465acabf15bf38c3824 Mon Sep 17 00:00:00 2001 From: Jordan Rome Date: Mon, 4 Sep 2023 16:45:07 -0700 Subject: [PATCH 1/2] [docs] consolidate test documentation --- docs/developers.md | 19 ++----------------- tests/README.md | 17 +++++++++-------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/docs/developers.md b/docs/developers.md index 36cc82c5..1492d574 100644 --- a/docs/developers.md +++ b/docs/developers.md @@ -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 `/tests/bpftrace_test`. - -- Runtime tests that execute bpftrace in various scenarios. These are located in - `tests/runtime` and can be executed using `/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 - `/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 diff --git a/tests/README.md b/tests/README.md index 1638653f..81cfdb5a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -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 `/tests/bpftrace_test`. ### Codegen tests @@ -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 /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 @@ -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 /tests/tools-parsing-test.sh` ### Flags and variables From e6e4318a2005992df121c6d25412c725e1cfb6d1 Mon Sep 17 00:00:00 2001 From: Daniel Xu Date: Tue, 5 Sep 2023 09:31:44 -0600 Subject: [PATCH 2/2] appimage: Trim appimage size (#2749) This commit trims the appimage size down to ~140M (down from ~300M) by excluding unnecessary files. This brings the regression from the semi-static build down to ~3x (143/46.6). --- flake.lock | 8 ++++---- flake.nix | 29 ++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index e3c9ed4e..37e9b448 100644 --- a/flake.lock +++ b/flake.lock @@ -63,17 +63,17 @@ "squashfuse": "squashfuse" }, "locked": { - "lastModified": 1693585308, - "narHash": "sha256-ic7iw7zmJ3D34b/7MYz/iEQaWQVYN2IPA+su21QwRqY=", + "lastModified": 1693845781, + "narHash": "sha256-E7jJuRU5ntWARmIWhFJfvpXEvxyDwWBtqPWx++4fhtc=", "owner": "danobi", "repo": "nix-appimage", - "rev": "5d5093111a1ec4f116c1c57b7a807d41404bfa5e", + "rev": "83c61d93ee96d4d530f5382edca51ee30ce2769f", "type": "github" }, "original": { "owner": "danobi", "repo": "nix-appimage", - "rev": "5d5093111a1ec4f116c1c57b7a807d41404bfa5e", + "rev": "83c61d93ee96d4d530f5382edca51ee30ce2769f", "type": "github" } }, diff --git a/flake.nix b/flake.nix index ac1d0f61..dc19173c 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; @@ -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`