Commit Graph

1709 Commits (c725b9d69e9db663191171b344068ecc151db764)
 

Author SHA1 Message Date
Tamir Duberstein 893ab76afa
Merge pull request #665 from aya-rs/dead-code-rm
aya: avoid an allocation
1 year ago
Tamir Duberstein 6f2a8c8a5c
aya: avoid an allocation
str::rsplitn(2, c) is a special case that can be expressed as
str::rsplit_once(c).
1 year ago
Tamir Duberstein d71d1e1993
aya: remove dead code
This logic moved in bb595c4e69. The
mutation here prevented the compiler from noticing.
1 year ago
Tamir Duberstein af54a819a3
Merge pull request #660 from aya-rs/log-test
Make logging test output more legible
1 year ago
Tamir Duberstein 703e7108f2
Make logging test output more legible
Presently when this test fails you just get "5 items instead of 6" but
not which item was lost.
1 year ago
Tamir Duberstein bbc6a73f4b
Merge pull request #657 from aya-rs/build-rs-invalidate-deps
integration-test: better cache invalidation
1 year ago
Tamir Duberstein 232cd45e41
Merge pull request #656 from aya-rs/kernel-version-fml
Handle WSL kernel version strings
1 year ago
Tamir Duberstein 581d5c8f5f
integration-test: bust cache on bpf-linker
This is useful when iterating on bpf-linker locally, which is otherwise
an undeclared input to this build.

We could use an artifact dependency[0] here, but they are unstable and
bpf-linker requires gymnastics to build correctly (for now).

[0] https://doc.rust-lang.org/cargo/reference/unstable.html#artifact-dependencies-dependency-declarations
1 year ago
Tamir Duberstein 2a6d2a6402
integration-test: transitive dep on Rust ebpf
Emit "cargo:rerun-if-changed={}" for each transitive dependency on
integration-ebpf. In a normal world we'd just add integration-ebpf to
our build-dependencies, but cargo ignores this because integration-ebpf
has no library targets.
1 year ago
Tamir Duberstein 35ed85a87f
Handle WSL kernel version strings
Fixes #654.
1 year ago
Tamir Duberstein 961f45da37
Replace matches with assert_matches
The matches crate has been archived now that `matches!` is in std.
However `assert_matches!` is still unstable in std, and the
assert_matches crate provides a more expressive form:

```
assert_matches!(foo, Ok(bar) => {
  assert_eq!(bar, baz);
});
```
1 year ago
Tamir Duberstein b875f83f22
Remove duplicate entry 1 year ago
Tamir Duberstein 61608e6458
Merge pull request #650 from aya-rs/test-cleanup
Remove async feature; misc test cleanup
1 year ago
Alessandro Decina 0766e70548
Merge pull request #584 from marysaka/fix/btf-kern-optional
aya: Ignore embedded BTF error if not truely required
1 year ago
Tamir Duberstein 8e9712ac02
Run tests with powerset of features 1 year ago
Tamir Duberstein 6d06e2bf3a
Include ~all crates in default members
Several tests were not running due to being omitted from this list.
1 year ago
Tamir Duberstein 5407d4a9a1
Don't use env::tempdir
This can cause test pollution. Create a new temp directory on each run.
1 year ago
Tamir Duberstein fa91fb4f59
Remove "async" feature
This feature is equivalent to async_tokio || async_std; removing it
avoids warnings emitted during `cargo hack check --feature-powerset`
where async is selected without either of the other features.

Use cargo hack to ensure clippy runs on the powerset of features.
1 year ago
Tamir Duberstein dc38b7eff0
.github: fail-fast: false 1 year ago
Tamir Duberstein 464fb54b25
Merge pull request #655 from aya-rs/logs-docs
site: generate docs for logging crates
1 year ago
Tamir Duberstein 40f24fe8e1
site: generate docs for logging crates 1 year ago
Mary 74b546827c aya: Ignore embedded BTF error if not truely required
This allows fallback to BTF manual relocation when BTF loading fail when not truely required.
1 year ago
Tamir Duberstein 76ad93268f
Merge pull request #652 from aya-rs/docs
xtask: remove assumptions from docs command
1 year ago
ajwerner 28c4ad3e1a
Merge pull request #653 from aya-rs/rebuild-on-changed
integration-test: properly rebuild bpf on change
1 year ago
Tamir Duberstein c250c6c9db
integration-test: avoid cargo deadflock 1 year ago
Tamir Duberstein 38a2711720
integration-test: properly rebuild bpf on change 1 year ago
Tamir Duberstein b86d42d1b0
xtask: remove assumptions from docs command
This slightly changes the site layout: crate documentation is now flat
rather than being nested under "user" and  "bpf".

- Run `cargo clean --doc` before generating docs to ensure hermiticity.
- Generate header.html into a temporary directory.
- Remove "site" on each run to ensure hermiticity.
- Invoke cargo only once.
- Avoid editing sources.
1 year ago
Alessandro Decina e2b673eb41
Merge pull request #651 from alessandrod/bpf-cargo-config
Add back bpf/.cargo/config.toml
1 year ago
Alessandro Decina c64d8e2bb7 Add back bpf/.cargo/config.toml
So to build/check things using the bpf target one can:

    cd bpf && cargo check && cargo build

without having to manually pass --target=bpfel-unknown-none -Z
build-std=core.

It also fixes cargo xtask docs, since the command relies on bpf docs
being built with the bpfel-unknown-none target.
1 year ago
Alessandro Decina 242d8c33c4 Fix build 1 year ago
Alessandro Decina eb60d65613
Merge pull request #520 from astoycos/unsupported-map
Add Unsupported Map type
1 year ago
Andrew Stoycos edb7baf9a3
Merge pull request #560 from astoycos/fix-perf-link-pin
Implement FdLink conversions
1 year ago
Andrew Stoycos 94f554a52f
fix loaded_programs() race in int-tests
in the integration tests we recenctly switched to using
our internal api to list programs. I was seeing times when
this would race and panic internally (program fd was deleted
by aya WHILE we were trying to get it).  This ensures that
the list succeeded without panicking.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
1 year ago
Andrew Stoycos 80b371f6d1
add FdLink documentation and example
Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
1 year ago
Andrew Stoycos fb075636c1
Add integration test for perf link pin
Add integration testing for link pinning and
loading/unloading of tracepoint, kprobe, and
uprobe programs.

Redo how we utilize bpftool to verify that programs
are loaded to be explicit with names. Also add a helper
to verify that a program is loaded AND linked.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
1 year ago
Tamir Duberstein 7def6d7218
Merge pull request #644 from aya-rs/build-script
Steps toward hermetic integration tests
1 year ago
Andrew Stoycos e668ae0c1b
re-add bpftool to integration tests
We need bpftool to add tests for the link APIs since we don't yet have
and aya API for listing links.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
1 year ago
Andrew Stoycos 58895db9b4
Implement FdLink conversions
Implement TryFrom functions to convert Fdlink to PerfLink/TracePointLink/
KprobeLink, and UprobeLink and vice-versa.

This allows us to pin taken links for perf programs, ultimately
ensuring the link isn't dropped when the loading process exits.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
1 year ago
Tamir Duberstein 23bea22ac1
integration-test: build one binary instead of N
"integration tests" as defined by Cargo produce a binary per file in the
tests directory. This is really not what we want and has a number of
downsides, but the main one is binary size.

Before:
  tamird@pc:~/src/aya$ cargo xtask build-integration-test | xargs ls -lah
      Finished dev [unoptimized + debuginfo] target(s) in 0.05s
       Running `target/debug/xtask build-integration-test`
     Compiling integration-test v0.1.0 (/home/tamird/src/aya/test/integration-test)
      Finished dev [unoptimized + debuginfo] target(s) in 0.68s
  -rwxrwxr-x 1 tamird tamird  34M Jul 12 15:21 /home/tamird/src/aya/target/debug/deps/bpf_probe_read-e03eb905a5e6209c
  -rwxrwxr-x 1 tamird tamird  35M Jul 12 15:21 /home/tamird/src/aya/target/debug/deps/btf_relocations-57a4fbb38bf06064
  -rwxrwxr-x 1 tamird tamird  31M Jul 12 15:21 /home/tamird/src/aya/target/debug/deps/elf-98b7a32d6d04effb
  -rwxrwxr-x 1 tamird tamird 6.9M Jul 12 15:21 /home/tamird/src/aya/target/debug/deps/integration_test-0dd55ce96bfdad77
  -rwxrwxr-x 1 tamird tamird  34M Jul 12 15:21 /home/tamird/src/aya/target/debug/deps/load-0718562e85b86d03
  -rwxrwxr-x 1 tamird tamird  40M Jul 12 15:21 /home/tamird/src/aya/target/debug/deps/log-dbf355f9ea34068a
  -rwxrwxr-x 1 tamird tamird  36M Jul 12 15:21 /home/tamird/src/aya/target/debug/deps/rbpf-89a1bb848fa5cc3c
  -rwxrwxr-x 1 tamird tamird  34M Jul 12 15:21 /home/tamird/src/aya/target/debug/deps/relocations-cfe655c3bb413d8b
  -rwxrwxr-x 1 tamird tamird  34M Jul 12 15:21 /home/tamird/src/aya/target/debug/deps/smoke-ccd3974180a3fd29

After:
  tamird@pc:~/src/aya$ cargo xtask build-integration-test | xargs ls -lah
      Finished dev [unoptimized + debuginfo] target(s) in 0.05s
       Running `target/debug/xtask build-integration-test`
     Compiling integration-test v0.1.0 (/home/tamird/src/aya/test/integration-test)
      Finished dev [unoptimized + debuginfo] target(s) in 0.90s
  -rwxrwxr-x 1 tamird tamird 47M Jul 12 15:21 /home/tamird/src/aya/target/debug/deps/integration_test-0dd55ce96bfdad77

Since we plan to run these tests in a VM, copying 10x fewer bytes seems
like a win.
1 year ago
Tamir Duberstein 728a25d9d9
vscode: check all targets
Now that building integration tests works out of the box, we can.
1 year ago
Tamir Duberstein 6ac1320707
integration-test: build "fake" by default
Use the environment variable AYA_BUILD_INTEGRATION_BPF to indicate to
the build script that it should *actually* build bpf, otherwise emitting
empty files.

This allows metadata builds to skip costly build steps without
sacrificing ergonomics; all compile-time tools such as cargo clippy work
out of the box.

Cargo even gives each of these builds (depending on the value of the
environment variable) its own cache key, so they do not invalidate each
other when the user alternates between metadata and real builds.

This allows the lint action to move out of the VM.
1 year ago
Tamir Duberstein 9086265ac0
xtask: reimplement build-integration-test
This command builds the integration test binaries and prints their paths
to stdout.
1 year ago
Tamir Duberstein c76d5a9950
integration-test: compile without touching disk 1 year ago
Tamir Duberstein 3d463a3610
integration-test: compile Rust probes using build.rs 1 year ago
Tamir Duberstein bc9f059d53
xtask: inline build_ebpf 1 year ago
Tamir Duberstein 8c61fc9ea6
integration-test: compile C probes using build.rs
- Add libbpf as a submodule. This prevents having to plumb its location
  around (which can't be passed to Cargo build scripts) and also
  controls the version against which codegen has run.
- Move bpf written in C to the integration-test crate and define
  constants for each probe.
- Remove magic; each C source file must be directly enumerated in the
  build script and in lib.rs.
1 year ago
Tamir Duberstein 6ca7d53733
Remove detritus
- rustfmt settings are hierarchical.
- integration-ebpf is always compiled at a distance with flags provided.
- .cargo/config.toml is not respected except at the root of the
  workspace[0].

[0] https://doc.rust-lang.org/cargo/reference/config.html#hierarchical-structure
1 year ago
Tamir Duberstein a840a17308
Merge pull request #648 from aya-rs/clippy-more
Clippy over tests and integration-ebpf
1 year ago
Tamir Duberstein 4fef255823
disallow (some) as conversions
See https://rust-lang.github.io/rust-clippy/master/#/as_conversions.
1 year ago
Tamir Duberstein e621a09181
Clippy over tests and integration-ebpf
Replace all `assert!(matches!(..))` with `assert_matches!(..)`.

Remove the now-unused build-integration-test xtask command whose logic
doesn't match that of the build-and-run command.
1 year ago