Skip to content

Commit

Permalink
Merge pull request OptimatistOpenSource#28 from Thaumy/test-arm
Browse files Browse the repository at this point in the history
Add tests for `aarch64` target arch
  • Loading branch information
OptimatistCorp authored Mar 20, 2024
2 parents 1fc8fd2 + e2ca783 commit 2af3fb7
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 11 deletions.
10 changes: 10 additions & 0 deletions src/perf_event/counting/group/tests/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ fn test_ipc() {

test_group(&Event::from(ev_1), &Event::from(ev_2), &mut workload);
}

#[test]
#[cfg(target_arch = "aarch64")]
fn test_r11_r1b() {
let ev_1 = unsafe { crate::RawEvent::new(0x11) };
let ev_2 = unsafe { crate::RawEvent::new(0x1b) };
let mut workload = cpu_workload;

test_group(&Event::from(ev_1), &Event::from(ev_2), &mut workload);
}
2 changes: 1 addition & 1 deletion src/perf_event/counting/group/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn gen_group() -> CounterGroup {
}

fn gen_cfg(ev: &Event) -> Config {
let scopes = [EventScope::User, EventScope::Host];
let scopes = EventScope::all();
Config::new(ev, &scopes)
}

Expand Down
18 changes: 18 additions & 0 deletions src/perf_event/counting/single/tests/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,21 @@ fn test_cpu_cycles() {

test_single(&Event::from(ev), &mut workload);
}

#[test]
#[cfg(target_arch = "aarch64")]
fn test_r11() {
let ev = unsafe { crate::RawEvent::new(0x11) };
let mut workload = cpu_workload;

test_single(&Event::from(ev), &mut workload);
}

#[test]
#[cfg(target_arch = "aarch64")]
fn test_r1b() {
let ev = unsafe { crate::RawEvent::new(0x1b) };
let mut workload = cpu_workload;

test_single(&Event::from(ev), &mut workload);
}
2 changes: 1 addition & 1 deletion src/perf_event/counting/single/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ where
}

fn gen_counter(ev: &Event) -> Counter {
let scopes = [EventScope::User, EventScope::Host];
let scopes = EventScope::all();
let mut cfg = Config::new(ev, &scopes);

Counter::new(&Process::Current, &Cpu::Any, &mut cfg).unwrap()
Expand Down
10 changes: 10 additions & 0 deletions src/perf_event/sampling/group/tests/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ fn test_ipc() {

test_group(&Event::from(ev_1), &Event::from(ev_2), &mut workload);
}

#[test]
#[cfg(target_arch = "aarch64")]
fn test_r11_r1b() {
let ev_1 = unsafe { crate::RawEvent::new(0x11) };
let ev_2 = unsafe { crate::RawEvent::new(0x1b) };
let mut workload = cpu_workload;

test_group(&Event::from(ev_1), &Event::from(ev_2), &mut workload);
}
2 changes: 1 addition & 1 deletion src/perf_event/sampling/group/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn gen_group() -> SamplerGroup {
}

fn gen_cfg(ev: &Event) -> Config {
let scopes = [EventScope::User, EventScope::Host];
let scopes = EventScope::all();
let overflow_by = OverflowBy::Period(1000);
Config::new(&ev, &scopes, &overflow_by)
}
Expand Down
19 changes: 19 additions & 0 deletions src/perf_event/sampling/single/tests/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,24 @@ use crate::{Event, HardwareEvent};
fn test_cpu_cycles() {
let ev = HardwareEvent::CpuCycles;
let mut workload = cpu_workload;

test_single(&Event::from(ev), &mut workload);
}

#[test]
#[cfg(target_arch = "aarch64")]
fn test_r11() {
let ev = unsafe { crate::RawEvent::new(0x11) };
let mut workload = cpu_workload;

test_single(&Event::from(ev), &mut workload);
}

#[test]
#[cfg(target_arch = "aarch64")]
fn test_r1b() {
let ev = unsafe { crate::RawEvent::new(0x1b) };
let mut workload = cpu_workload;

test_single(&Event::from(ev), &mut workload);
}
2 changes: 1 addition & 1 deletion src/perf_event/sampling/single/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn gen_sampler(cfg: &Config) -> Sampler {
}

fn gen_cfg(ev: &Event) -> Config {
let scopes = [EventScope::User, EventScope::Host];
let scopes = EventScope::all();
let overflow_by = OverflowBy::Period(1000);
let mut extra_config = ExtraConfig::default();
extra_config.sample_record_fields.time = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn gen_cfg(sample_regs_intr: u64) -> Config {
extra_config.sample_record_fields.abi_and_regs_intr = Some(sample_regs_intr);

let event = HardwareEvent::CpuCycles;
let scopes = [EventScope::User, EventScope::Host];
let scopes = EventScope::all();
let overflow_by = OverflowBy::Period(1000);
Config::extra_new(&Event::from(event), &scopes, &overflow_by, &extra_config)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn gen_cfg(sample_regs_user: u64) -> Config {
extra_config.sample_record_fields.abi_and_regs_user = Some(sample_regs_user);

let event = HardwareEvent::CpuCycles;
let scopes = [EventScope::User, EventScope::Host];
let scopes = EventScope::all();
let overflow_by = OverflowBy::Period(1000);
Config::extra_new(&Event::from(event), &scopes, &overflow_by, &extra_config)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn gen_sampler(cfg: &Config) -> Sampler {

fn gen_cfg(extra_config: ExtraConfig) -> Config {
let event = HardwareEvent::CpuCycles;
let scopes = [EventScope::User, EventScope::Host];
let scopes = EventScope::all();
let overflow_by = OverflowBy::Period(1000);
Config::extra_new(&Event::from(event), &scopes, &overflow_by, &extra_config)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn gen_cfg(sample_stack_user: u16) -> Config {
extra_config.sample_record_fields.data_stack_user = Some(sample_stack_user);

let event = HardwareEvent::CpuCycles;
let scopes = [EventScope::User, EventScope::Host];
let scopes = EventScope::all();
let overflow_by = OverflowBy::Period(1000);
Config::extra_new(&Event::from(event), &scopes, &overflow_by, &extra_config)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn gen_cfg(sample_max_stack: u16) -> Config {
extra_config.sample_record_fields.ips = Some(sample_max_stack);

let event = HardwareEvent::CpuCycles;
let scopes = [EventScope::User, EventScope::Host];
let scopes = EventScope::all();
let overflow_by = OverflowBy::Period(1000);
Config::extra_new(&Event::from(event), &scopes, &overflow_by, &extra_config)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn gen_sampler(cfg: &Config) -> Sampler {

fn gen_cfg(extra_config: ExtraConfig) -> Config {
let event = HardwareEvent::CpuCycles;
let scopes = [EventScope::User, EventScope::Host];
let scopes = EventScope::all();
let overflow_by = OverflowBy::Period(1000);
Config::extra_new(&Event::from(event), &scopes, &overflow_by, &extra_config)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn gen_cfg(repr: WeightRepr) -> Config {
extra_config.sample_record_fields.weight = Some(repr);

let event = HardwareEvent::CpuCycles;
let scopes = [EventScope::User, EventScope::Host];
let scopes = EventScope::all();
let overflow_by = OverflowBy::Period(1000);
Config::extra_new(&Event::from(event), &scopes, &overflow_by, &extra_config)
}
Expand Down

0 comments on commit 2af3fb7

Please sign in to comment.