diff options
author | 2015-11-27 08:05:35 +0100 | |
---|---|---|
committer | 2015-11-27 08:05:35 +0100 | |
commit | 447c2562dec4bde02593e91a6b16e1daa2163f32 (patch) | |
tree | ad5d14a396f06707df3f664f995c3c2d485746cc | |
parent | 7665b2cfe821853466216be3072a87ab155c69c6 (diff) | |
download | rust-x86-447c2562dec4bde02593e91a6b16e1daa2163f32.tar.gz rust-x86-447c2562dec4bde02593e91a6b16e1daa2163f32.tar.zst rust-x86-447c2562dec4bde02593e91a6b16e1daa2163f32.zip |
Test for counter retrieval.
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | src/irq.rs | 1 | ||||
-rw-r--r-- | src/perfcnt/intel/counters.rs | 6 | ||||
-rw-r--r-- | src/perfcnt/mod.rs | 11 |
4 files changed, 18 insertions, 4 deletions
@@ -12,9 +12,11 @@ documentation = "http://gz.github.io/rust-x86/x86/" readme = "README.md" keywords = ["ia32", "os", "amd64", "x86", "x86-64"] license = "MIT" - build = "build.rs" +[features] +cached_counters = [] + [[test]] name = "no_std_build" harness = false @@ -179,7 +179,6 @@ impl fmt::Debug for PageFaultError { #[test] fn bit_macro() { - assert!(PFAULT_ERROR_PK.bits() == 0b100000); assert!(PFAULT_ERROR_ID.bits() == 0b10000); assert!(PFAULT_ERROR_RSVD.bits() == 0b1000); diff --git a/src/perfcnt/intel/counters.rs b/src/perfcnt/intel/counters.rs index d05fd5c..9d046bf 100644 --- a/src/perfcnt/intel/counters.rs +++ b/src/perfcnt/intel/counters.rs @@ -5,4 +5,8 @@ use super::description::PebsType; use super::description::Tuple; use super::description::MSRIndex; -include!(concat!(env!("OUT_DIR"), "/counters.rs"));
\ No newline at end of file +#[cfg(not(feature = "cached_counters"))] +include!(concat!(env!("OUT_DIR"), "/counters.rs")); + +#[cfg(feature = "cached_counters")] +include!("generated.rs"); diff --git a/src/perfcnt/mod.rs b/src/perfcnt/mod.rs index 79e536c..fba94bd 100644 --- a/src/perfcnt/mod.rs +++ b/src/perfcnt/mod.rs @@ -6,7 +6,7 @@ use core::str; pub mod intel; -const MODEL_LEN: usize = 20; +const MODEL_LEN: usize = 30; #[derive(Default)] struct ModelWriter { @@ -64,3 +64,12 @@ pub fn core_counters() -> Option<&'static phf::Map<&'static str, intel::descript pub fn uncore_counters() -> Option<&'static phf::Map<&'static str, intel::description::IntelPerformanceCounterDescription>> { get_counters!("{}-{}-{:X}{:X}-uncore") } + +#[test] +fn counter_test() { + core_counters().map(|cc| { + cc.get("INST_RETIRED.ANY").map(|p| { + assert!(p.event_name == "INST_RETIRED.ANY"); + }); + }); +}
\ No newline at end of file |