mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +00:00
agent: Remove many "panic message is not string literal" warnings
Rust 1.51 appears to have added a new warning in anticipation of Rust 2021, which requires the format string for panic!()s (including via the various assert!() macros) to be a string literal. This triggers quite a few times in the agent code. This patch fixes them. fixes #1626 Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
503039482b
commit
ed08980fc1
@ -1365,7 +1365,7 @@ mod tests {
|
|||||||
let msg = format!("{}, result: {:?}", msg, result);
|
let msg = format!("{}, result: {:?}", msg, result);
|
||||||
|
|
||||||
// Perform the checks
|
// Perform the checks
|
||||||
assert!(result == t.result, msg);
|
assert!(result == t.result, "{}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ mod tests {
|
|||||||
if $expected_result.is_ok() {
|
if $expected_result.is_ok() {
|
||||||
let expected_level = $expected_result.as_ref().unwrap();
|
let expected_level = $expected_result.as_ref().unwrap();
|
||||||
let actual_level = $actual_result.unwrap();
|
let actual_level = $actual_result.unwrap();
|
||||||
assert!(*expected_level == actual_level, $msg);
|
assert!(*expected_level == actual_level, "{}", $msg);
|
||||||
} else {
|
} else {
|
||||||
let expected_error = $expected_result.as_ref().unwrap_err();
|
let expected_error = $expected_result.as_ref().unwrap_err();
|
||||||
let expected_error_msg = format!("{:?}", expected_error);
|
let expected_error_msg = format!("{:?}", expected_error);
|
||||||
@ -342,9 +342,9 @@ mod tests {
|
|||||||
if let Err(actual_error) = $actual_result {
|
if let Err(actual_error) = $actual_result {
|
||||||
let actual_error_msg = format!("{:?}", actual_error);
|
let actual_error_msg = format!("{:?}", actual_error);
|
||||||
|
|
||||||
assert!(expected_error_msg == actual_error_msg, $msg);
|
assert!(expected_error_msg == actual_error_msg, "{}", $msg);
|
||||||
} else {
|
} else {
|
||||||
assert!(expected_error_msg == "expected error, got OK", $msg);
|
assert!(expected_error_msg == "expected error, got OK", "{}", $msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -900,7 +900,7 @@ mod tests {
|
|||||||
let msg = format!("{}: result: {:?}", msg, result);
|
let msg = format!("{}: result: {:?}", msg, result);
|
||||||
|
|
||||||
if d.error_contains.is_empty() {
|
if d.error_contains.is_empty() {
|
||||||
assert!(result.is_ok(), msg);
|
assert!(result.is_ok(), "{}", msg);
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -912,7 +912,7 @@ mod tests {
|
|||||||
|
|
||||||
let msg = format!("{}: umount result: {:?}", msg, result);
|
let msg = format!("{}: umount result: {:?}", msg, result);
|
||||||
|
|
||||||
assert!(ret == 0, msg);
|
assert!(ret == 0, "{}", msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -920,7 +920,7 @@ mod tests {
|
|||||||
|
|
||||||
let err = result.unwrap_err();
|
let err = result.unwrap_err();
|
||||||
let error_msg = format!("{}", err);
|
let error_msg = format!("{}", err);
|
||||||
assert!(error_msg.contains(d.error_contains), msg);
|
assert!(error_msg.contains(d.error_contains), "{}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1026,13 +1026,13 @@ mod tests {
|
|||||||
let msg = format!("{}: result: {:?}", msg, result);
|
let msg = format!("{}: result: {:?}", msg, result);
|
||||||
|
|
||||||
if d.error_contains.is_empty() {
|
if d.error_contains.is_empty() {
|
||||||
assert!(result.is_ok(), msg);
|
assert!(result.is_ok(), "{}", msg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let error_msg = format!("{:#}", result.unwrap_err());
|
let error_msg = format!("{:#}", result.unwrap_err());
|
||||||
|
|
||||||
assert!(error_msg.contains(d.error_contains), msg);
|
assert!(error_msg.contains(d.error_contains), "{}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1108,6 +1108,7 @@ mod tests {
|
|||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
format!("{}", err).contains("No such file or directory"),
|
format!("{}", err).contains("No such file or directory"),
|
||||||
|
"{}",
|
||||||
msg
|
msg
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1136,13 +1137,13 @@ mod tests {
|
|||||||
if d.error_contains.is_empty() {
|
if d.error_contains.is_empty() {
|
||||||
let fs_type = result.unwrap();
|
let fs_type = result.unwrap();
|
||||||
|
|
||||||
assert!(d.fs_type == fs_type, msg);
|
assert!(d.fs_type == fs_type, "{}", msg);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let error_msg = format!("{}", result.unwrap_err());
|
let error_msg = format!("{}", result.unwrap_err());
|
||||||
assert!(error_msg.contains(d.error_contains), msg);
|
assert!(error_msg.contains(d.error_contains), "{}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1291,34 +1292,34 @@ mod tests {
|
|||||||
let msg = format!("{}: result: {:?}", msg, result);
|
let msg = format!("{}: result: {:?}", msg, result);
|
||||||
|
|
||||||
if !d.error_contains.is_empty() {
|
if !d.error_contains.is_empty() {
|
||||||
assert!(result.is_err(), msg);
|
assert!(result.is_err(), "{}", msg);
|
||||||
|
|
||||||
let error_msg = format!("{}", result.unwrap_err());
|
let error_msg = format!("{}", result.unwrap_err());
|
||||||
assert!(error_msg.contains(d.error_contains), msg);
|
assert!(error_msg.contains(d.error_contains), "{}", msg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert!(result.is_ok(), msg);
|
assert!(result.is_ok(), "{}", msg);
|
||||||
|
|
||||||
let mounts = result.unwrap();
|
let mounts = result.unwrap();
|
||||||
let count = mounts.len();
|
let count = mounts.len();
|
||||||
|
|
||||||
if !d.devices_cgroup {
|
if !d.devices_cgroup {
|
||||||
assert!(count == 0, msg);
|
assert!(count == 0, "{}", msg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_cgroup_mounts() adds the device cgroup plus two other mounts.
|
// get_cgroup_mounts() adds the device cgroup plus two other mounts.
|
||||||
assert!(count == (1 + 2), msg);
|
assert!(count == (1 + 2), "{}", msg);
|
||||||
|
|
||||||
// First mount
|
// First mount
|
||||||
assert!(mounts[0].eq(&first_mount), msg);
|
assert!(mounts[0].eq(&first_mount), "{}", msg);
|
||||||
|
|
||||||
// Last mount
|
// Last mount
|
||||||
assert!(mounts[2].eq(&last_mount), msg);
|
assert!(mounts[2].eq(&last_mount), "{}", msg);
|
||||||
|
|
||||||
// Devices cgroup
|
// Devices cgroup
|
||||||
assert!(mounts[1].eq(&cg_devices_mount), msg);
|
assert!(mounts[1].eq(&cg_devices_mount), "{}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2018,9 +2018,9 @@ mod tests {
|
|||||||
let msg = format!("{}, result: {:?}", msg, result);
|
let msg = format!("{}, result: {:?}", msg, result);
|
||||||
|
|
||||||
if result.is_ok() {
|
if result.is_ok() {
|
||||||
assert!(!d.expect_error, msg);
|
assert!(!d.expect_error, "{}", msg);
|
||||||
} else {
|
} else {
|
||||||
assert!(d.expect_error, msg);
|
assert!(d.expect_error, "{}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user