Skip to content

Commit

Permalink
test(aya): iter: Disable the init system assertion in containers
Browse files Browse the repository at this point in the history
It's hard to predict what's the PID of the first process in a container.
Use this assertion only on non-containerized systems.
  • Loading branch information
vadorovsky committed Nov 27, 2024
1 parent ae8eece commit c7a306b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/integration-test/src/tests/iter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::io::BufRead;
use std::{env, io::BufRead};

use aya::{programs::Iter, Btf, Ebpf};
use test_log::test;
Expand All @@ -20,11 +20,15 @@ fn iter_task() {
let line_init = lines.next().unwrap().unwrap();

assert_eq!(line_title, "tgid pid name");
let expected_values = ["1 1 init", "1 1 systemd"];
assert!(
expected_values.contains(&line_init.as_str()),
"Unexpected line_init value: '{}', expected one of: {:?}",
line_init,
expected_values
);
// It's hard to predict what's the PID of the first process in a container.
// Use this assertion only on non-containerized systems.
if env::var_os("container").is_none() {
let expected_values = ["1 1 init", "1 1 systemd"];
assert!(
expected_values.contains(&line_init.as_str()),
"Unexpected line_init value: '{}', expected one of: {:?}",
line_init,
expected_values
);
}
}

0 comments on commit c7a306b

Please sign in to comment.