Skip to content

Commit 5cdaf2f

Browse files
committed
turns out only the comma seperated way works
1 parent 38ca09d commit 5cdaf2f

File tree

3 files changed

+23
-31
lines changed

3 files changed

+23
-31
lines changed

kani-compiler/src/codegen_cprover_gotoc/codegen/function.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -405,16 +405,3 @@ fn extract_integer_argument(attr: &Attribute) -> Option<u128> {
405405
None
406406
}
407407
}
408-
409-
// /// Extracts the integer value argument from the attribute provided
410-
// /// For example, `unwind(8)` return `Some(8)`
411-
// fn extract_integer_arguments(attr: &Attribute) -> Result<Vec<u128>, String> {
412-
// // Vector of meta items , that contain the arguments given the attribute
413-
// let attr_args = attr.meta_item_list().unwrap;
414-
// Ok(attr_args.iter().map(|a| {
415-
// match a.literal()?.kind {
416-
// LitKind::Int(y, ..) => Some(y),
417-
// _ => None,
418-
// }
419-
// }).collect())
420-
// }

kani-driver/src/call_cbmc.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,14 @@ impl KaniSession {
9696
}
9797

9898
if !harness_metadata.mmio_regions.is_empty() {
99-
for (start, len) in &harness_metadata.mmio_regions {
100-
args.push("--mmio-regions".into());
101-
args.push(format!("{}:{}", start, len).into());
102-
}
99+
args.push("--mmio-regions".into());
100+
let mmio_string = harness_metadata
101+
.mmio_regions
102+
.iter()
103+
.map(|(s, l)| format!("{}:{}", s, l))
104+
.collect::<Vec<String>>()
105+
.join(",");
106+
args.push(mmio_string.into());
103107
}
104108

105109
args.push("--slice-formula".into());

tests/kani/MMIO/test.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33

4-
#[cfg(kani)]
5-
const BUFFER: *mut u32 = 0xb8000 as *mut u32;
4+
const BUFFER: *mut u32 = 0x8000 as *mut u32;
5+
const BUFFER2: *mut u32 = 0x1000 as *mut u32;
66

7+
#[cfg(kani)]
78
#[kani::proof]
8-
#[kani::mmio_region(0xb8000, 4)]
9+
#[kani::mmio_region(0x8000, 4)]
910
fn test_write() {
1011
let val = 12;
1112
unsafe {
1213
core::ptr::write_volatile(BUFFER, val);
1314
}
1415
}
1516

16-
// #[cfg(kani)]
17-
// #[kani::proof]
18-
// #[kani::mmio_region(0xb8000, 4)]
19-
// #[kani::mmio_region(0xbF000, 4)]
20-
// fn test_write2() {
21-
// let val = 12;
22-
// unsafe {
23-
// core::ptr::write_volatile(BUFFER, val);
24-
// core::ptr::write_volatile(BUFFER2, val);
17+
#[cfg(kani)]
18+
#[kani::proof]
19+
#[kani::mmio_region(0x8000, 4)]
20+
#[kani::mmio_region(0x1000, 4)]
21+
fn test_write2() {
22+
let val = 12;
23+
unsafe {
24+
core::ptr::write_volatile(BUFFER, val);
25+
core::ptr::write_volatile(BUFFER2, val);
2526

26-
// }
27-
// }
27+
}
28+
}

0 commit comments

Comments
 (0)