Skip to content

Commit d86c4a4

Browse files
adpaco-awstedinski
authored andcommitted
Move balloon standalone example to firecracker folder (rust-lang#167)
1 parent d621529 commit d86c4a4

File tree

1 file changed

+13
-30
lines changed

1 file changed

+13
-30
lines changed

rust-tests/nightly/virtio-balloon-compact/main.rs renamed to rust-tests/firecracker-like/virtio-balloon-compact/ignore-main.rs

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
1-
// --unwind 3 --unwinding-assertions
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
23
//
3-
// Example from Firecracker balloon device
4-
// We test the functional correctness of the compact function
5-
// Outstanding issues:
6-
// - Padstone-4988 (vector sort not supported)
7-
// - Padstone-4856 (vector tuple iteration)
4+
// Try with: rmc ignore-main.rs -- --unwind 3 --unwinding-assertions --pointer-check --object-bits 11
5+
// With kissat as the solver (--external-sat-solver /path/to/kissat) this takes ~5mins
86

9-
#[allow(dead_code)]
7+
pub const MAX_PAGE_COMPACT_BUFFER: usize = 2048;
108

11-
pub const MAX_PAGES_IN_DESC: usize = 256;
12-
13-
pub(crate) fn compact_page_frame_numbers(v: &mut Vec<u32>) -> Vec<(u32, u32)> {
9+
pub(crate) fn compact_page_frame_numbers(v: &mut [u32]) -> Vec<(u32, u32)> {
1410
if v.is_empty() {
1511
return vec![];
1612
}
1713

1814
// Since the total number of pages that can be
19-
// received at once from a single descriptor is `MAX_PAGES_IN_DESC`,
15+
// received at once is `MAX_PAGE_COMPACT_BUFFER`,
2016
// this sort does not change the complexity of handling
2117
// an inflation.
22-
// v.sort(); //< Padstone-4988 (vector sort not supported)
18+
v.sort_unstable();
2319

24-
// Since there are at most `MAX_PAGES_IN_DESC` pages, setting the
20+
// Since there are at most `MAX_PAGE_COMPACT_BUFFER` pages, setting the
2521
// capacity of `result` to this makes sense.
26-
let mut result = Vec::with_capacity(MAX_PAGES_IN_DESC);
22+
let mut result = Vec::with_capacity(MAX_PAGE_COMPACT_BUFFER);
2723

2824
// The most recent range of pages is [previous..previous + length).
2925
let mut previous = v[0];
@@ -57,27 +53,14 @@ fn expand(ranges: Vec<(u32, u32)>) -> Vec<u32> {
5753
return v;
5854
}
5955

60-
// Padstone-4856 this version of expand required instead of fn above
61-
fn rmc_expand(ranges: Vec<(u32, u32)>) -> Vec<u32> {
62-
let mut i = 0;
63-
let mut v: Vec<u32> = Vec::new();
64-
while i < ranges.len() {
65-
let (start, len) = ranges[i];
66-
for j in start..=(start + len - 1) {
67-
v.push(j)
68-
}
69-
i += 1;
70-
}
71-
return v;
72-
}
73-
7456
fn __nondet<T>() -> T {
7557
unimplemented!()
7658
}
7759

7860
fn main() {
79-
let mut input = vec![__nondet(); 2];
61+
let mut input = vec![0; 2];
8062
for i in 0..input.len() {
63+
input[i] = __nondet();
8164
if input[i] == u32::MAX {
8265
return;
8366
}
@@ -87,7 +70,7 @@ fn main() {
8770
assert!(1 <= *len);
8871
}
8972
assert!(output.len() <= input.len());
90-
let expanded_output = rmc_expand(output);
73+
let expanded_output = expand(output);
9174
let i: usize = __nondet();
9275
if i < expanded_output.len() {
9376
assert!(expanded_output[i] == input[i]);

0 commit comments

Comments
 (0)