Skip to content

Rename tests requiring root #451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ jobs:
- name: Build
run: cargo build --profile=${{ matrix.profile }} --locked --verbose --workspace --exclude runqslower
- name: Run tests
# Skip BTF & map tests which require sudo
run: cargo test --profile=${{ matrix.profile }} --locked --verbose --workspace --exclude runqslower -- --skip test_object --skip test_tc --skip test_map_info --include-ignored
- name: Run BTF tests
run: cd libbpf-rs && cargo test --profile=${{ matrix.profile }} --locked --verbose -- test_object test_tc
# Skip tests which require sudo
run: cargo test --profile=${{ matrix.profile }} --locked --verbose --workspace --exclude runqslower -- --skip test_sudo_ --include-ignored
- name: Run root tests
run: cd libbpf-rs && cargo test --profile=${{ matrix.profile }} --locked --verbose -- test_sudo_

build-minimum:
name: Build using minimum versions of dependencies
Expand Down
45 changes: 0 additions & 45 deletions libbpf-rs/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,48 +987,3 @@ impl MapInfo {
MapFlags::from_bits_truncate(self.info.map_flags as u64)
}
}

#[cfg(test)]
mod tests {
use super::*;

use crate::Map;
use crate::MapFlags;
use crate::MapInfo;
use crate::MapType;

/// Test whether `MapInfo` works properly
#[test]
pub fn test_map_info() {
let opts = libbpf_sys::bpf_map_create_opts {
sz: mem::size_of::<libbpf_sys::bpf_map_create_opts>() as libbpf_sys::size_t,
map_flags: libbpf_sys::BPF_ANY,
btf_fd: 0,
btf_key_type_id: 0,
btf_value_type_id: 0,
btf_vmlinux_value_type_id: 0,
inner_map_fd: 0,
map_extra: 0,
numa_node: 0,
map_ifindex: 0,
};

let map = Map::create(MapType::Hash, Some("simple_map"), 8, 64, 1024, &opts).unwrap();
let map_info = MapInfo::new(map.fd()).unwrap();
let name_received = map_info.name().unwrap();
assert_eq!(name_received, "simple_map");
assert_eq!(map_info.map_type(), MapType::Hash);
assert_eq!(map_info.flags() & MapFlags::ANY, MapFlags::ANY);

let map_info = &map_info.info;
assert_eq!(map_info.key_size, 8);
assert_eq!(map_info.value_size, 64);
assert_eq!(map_info.max_entries, 1024);
assert_eq!(map_info.btf_id, 0);
assert_eq!(map_info.btf_key_type_id, 0);
assert_eq!(map_info.btf_value_type_id, 0);
assert_eq!(map_info.btf_vmlinux_value_type_id, 0);
assert_eq!(map_info.map_extra, 0);
assert_eq!(map_info.ifindex, 0);
}
}
Loading