mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 12:34:31 +00:00
aarch64: fdt: add PSCI compatible string tests
Move the PSCI version to compatible code to a function so it can be more easily tested and add a few basic unit tests. BUG=b:227142928 TEST=tools/dev_container tools/run_tests --target=vm:aarch64 Change-Id: I383b6e9df76f26995adab6fe980fd29fe1fcdf0a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3573362 Reviewed-by: Junichi Uekawa <uekawa@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
1d1372f742
commit
ceb5ef155a
1 changed files with 54 additions and 1 deletions
|
@ -223,7 +223,7 @@ fn create_serial_nodes(fdt: &mut FdtWriter) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn create_psci_node(fdt: &mut FdtWriter, version: &PsciVersion) -> Result<()> {
|
||||
fn psci_compatible(version: &PsciVersion) -> Vec<&str> {
|
||||
// The PSCI kernel driver only supports compatible strings for the following
|
||||
// backward-compatible versions.
|
||||
let supported = [(PSCI_1_0, "arm,psci-1.0"), (PSCI_0_2, "arm,psci-0.2")];
|
||||
|
@ -239,6 +239,11 @@ fn create_psci_node(fdt: &mut FdtWriter, version: &PsciVersion) -> Result<()> {
|
|||
compatible = vec!["arm,psci"];
|
||||
}
|
||||
|
||||
compatible
|
||||
}
|
||||
|
||||
fn create_psci_node(fdt: &mut FdtWriter, version: &PsciVersion) -> Result<()> {
|
||||
let compatible = psci_compatible(version);
|
||||
let psci_node = fdt.begin_node("psci")?;
|
||||
fdt.property_string_list("compatible", &compatible)?;
|
||||
// Only support aarch64 guest
|
||||
|
@ -509,3 +514,51 @@ pub fn create_fdt(
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn psci_compatible_v0_1() {
|
||||
assert_eq!(
|
||||
psci_compatible(&PsciVersion::new(0, 1).unwrap()),
|
||||
vec!["arm,psci"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn psci_compatible_v0_2() {
|
||||
assert_eq!(
|
||||
psci_compatible(&PsciVersion::new(0, 2).unwrap()),
|
||||
vec!["arm,psci-0.2"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn psci_compatible_v0_5() {
|
||||
// Only the 0.2 version supported by the kernel should be added.
|
||||
assert_eq!(
|
||||
psci_compatible(&PsciVersion::new(0, 5).unwrap()),
|
||||
vec!["arm,psci-0.2"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn psci_compatible_v1_0() {
|
||||
// Both 1.0 and 0.2 should be listed, in that order.
|
||||
assert_eq!(
|
||||
psci_compatible(&PsciVersion::new(1, 0).unwrap()),
|
||||
vec!["arm,psci-1.0", "arm,psci-0.2"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn psci_compatible_v1_5() {
|
||||
// Only the 1.0 and 0.2 versions supported by the kernel should be listed.
|
||||
assert_eq!(
|
||||
psci_compatible(&PsciVersion::new(1, 5).unwrap()),
|
||||
vec!["arm,psci-1.0", "arm,psci-0.2"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue