vmm: api: Use 'BTreeMap' for 'HttpRoutes'

In this way, we get the values sorted by its key by default, which is
useful for the 'http_api' fuzzer.

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen
2022-07-29 12:52:45 -07:00
committed by Rob Bradford
parent e5155bab62
commit 1125fd2667
2 changed files with 5 additions and 10 deletions

View File

@@ -14,13 +14,8 @@ use vmm::{EpollContext, EpollDispatch};
use vmm_sys_util::eventfd::EventFd;
// Need to be ordered for test case reproducibility
static ROUTES: Lazy<Vec<&Box<dyn EndpointHandler + Sync + Send>>> = Lazy::new(|| {
let mut keys: Vec<&String> = HTTP_ROUTES.routes.keys().collect();
keys.sort();
keys.iter()
.map(|k| HTTP_ROUTES.routes.get(*k).unwrap())
.collect()
});
static ROUTES: Lazy<Vec<&Box<dyn EndpointHandler + Sync + Send>>> =
Lazy::new(|| HTTP_ROUTES.routes.values().collect());
fuzz_target!(|bytes| {
if bytes.len() < 2 {