Skip to content

Commit 9a545eb

Browse files
authored
Merge pull request #10 from ThijsRay/merge_crates
Merge crates
2 parents 740395f + 67e8c66 commit 9a545eb

9 files changed

Lines changed: 18 additions & 44 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,16 @@ description = "Coppers is a custom test harnass that measures the energy usage o
66
license = "Apache-2.0"
77
repository = "https://github.com/ThijsRay/coppers"
88

9-
[lib]
10-
name = "coppers"
11-
path = "coppers_test_runner/lib.rs"
12-
139
[workspace]
1410

1511
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1612

1713
[dependencies]
18-
coppers_sensors = { path = "coppers_sensors"}
1914
serde = { version = "1.0", features = ["derive"] }
2015
serde_json = "1.0"
2116
git2 = "0.14.2"
2217
hex = "0.4.3"
18+
regex = "1"
2319
pyo3 = { version = "0.16", optional = true, features = ["auto-initialize"] }
2420

2521
[features]

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ error. This can be solved in one of two ways:
114114
2. `cargo test`
115115
3. `sudo chmod o-r /sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/energy_uj`
116116

117+
### ModuleNotFoundError
118+
If you run with the [`visualization` feature](#visualization) enabled, then you also need to install the required Python packages. This can be done by installing the packages defined in this
119+
repositories [`requirements.txt`](/requirements.txt) with `pip install -r requirements.txt`.
117120

118121
## About
119122
This project was done in the context of the [2022 edition of Sustainable Software Engineering course at Delft University of Technology](https://luiscruz.github.io/course_sustainableSE/2022/). We chose the name "Coppers" because our project relates to both green software and Rust, and oxidized copper has a green-ish color.

coppers_sensors/Cargo.toml

Lines changed: 0 additions & 9 deletions
This file was deleted.

coppers_sensors/tests/sensors.rs

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// information.
2323
extern crate test;
2424

25+
mod sensors;
2526
mod test_runner;
2627

2728
// Export the runner funcion so crates that depend on this crate can use it
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ impl RAPLSensor {
146146
#[cfg(test)]
147147
mod tests {
148148
use super::*;
149+
use std::thread::sleep;
149150

150151
#[test]
151152
fn raplsensor_convert_read_string_to_u128_zero() {
@@ -178,4 +179,15 @@ mod tests {
178179
));
179180
assert_eq!(result, 12345678901234567890123456789);
180181
}
182+
#[test]
183+
fn test_rapl_sensor() {
184+
let mut sensor = RAPLSensor::new(String::from(
185+
"/sys/devices/virtual/powercap/intel-rapl/intel-rapl:0",
186+
))
187+
.unwrap();
188+
sensor.start_measuring();
189+
sleep(Duration::new(2, 0));
190+
sensor.stop_measuring();
191+
println!("measured {}uJ", sensor.get_measured_uj());
192+
}
181193
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// Note that this is heavily inspired by libtest that is part of the Rust language.
1616

1717
use self::json::write_to_json;
18-
use coppers_sensors::{RAPLSensor, Sensor};
18+
use super::sensors::{RAPLSensor, Sensor};
1919
use std::any::Any;
2020
use std::io::{self, Write};
2121
use std::panic::{catch_unwind, AssertUnwindSafe};
File renamed without changes.

0 commit comments

Comments
 (0)