From 778bd4457a08ecd552a243cfa3969a8f7c3b53af Mon Sep 17 00:00:00 2001 From: Thaumy Date: Tue, 19 Mar 2024 15:40:42 +0800 Subject: [PATCH] add `test_kunpeng` --- .../counting/group/tests/hardware.rs | 51 ++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/src/perf_event/counting/group/tests/hardware.rs b/src/perf_event/counting/group/tests/hardware.rs index 29ebe99..441face 100644 --- a/src/perf_event/counting/group/tests/hardware.rs +++ b/src/perf_event/counting/group/tests/hardware.rs @@ -12,9 +12,10 @@ // You should have received a copy of the GNU Lesser General Public License along with Perf-event-rs. If not, // see . -use crate::counting::group::tests::test_group; +use crate::counting::group::tests::{gen_group, test_group}; +use crate::counting::Config; use crate::test::cpu_workload; -use crate::{Event, HardwareEvent}; +use crate::{Event, EventScope, HardwareEvent, RawEvent}; #[test] fn test_ipc() { @@ -24,3 +25,49 @@ fn test_ipc() { test_group(&Event::from(ev_1), &Event::from(ev_2), &mut workload); } + +#[test] +fn test_kunpeng() { + let mut group = gen_group(); + + let configs = [ + 0x11, // r11 + 0x1b, // r1b + 0x70, // r70 + 0x71, // r71 + 0x73, // r73 + 0x75, // r75 + 0x8004, // r8004 + ]; + + let scopes = EventScope::all(); + + let guards = configs.map(|config| { + let event = unsafe { RawEvent::new(config) }; + let mut config = Config::new(&event.into(), &scopes); + group.add_member(&mut config).unwrap() + }); + + let fixed_group = group.enable().unwrap(); + cpu_workload(); + fixed_group.disable().unwrap(); + + #[rustfmt::skip] + let [ + r11, + r1b, + r70, + r71, + r73, + r75, + r8004 + ] = guards.map(|mut guard| guard.stat().unwrap().event_count); + + dbg!(r11); + dbg!(r1b); + dbg!(r70); + dbg!(r71); + dbg!(r73); + dbg!(r75); + dbg!(r8004); +}