[instanceId] Hard code an instance ID for non-protected rialto
The hard-coded ID is only used in non-protected rialto tests.
Bug: 327593612
Test: atest rialto_test
Change-Id: If0cd1812048cca886f0a66a8a7c49c9fde579d88
diff --git a/rialto/tests/test.rs b/rialto/tests/test.rs
index 422dfc9..9151ce1 100644
--- a/rialto/tests/test.rs
+++ b/rialto/tests/test.rs
@@ -22,7 +22,7 @@
binder::{ParcelFileDescriptor, ProcessState},
};
use anyhow::{bail, Context, Result};
-use bssl_avf::{sha256, EcKey, PKey};
+use bssl_avf::{rand_bytes, sha256, EcKey, PKey};
use client_vm_csr::generate_attestation_key_and_csr;
use coset::{CborSerializable, CoseMac0, CoseSign};
use hwtrust::{rkp, session::Session};
@@ -306,12 +306,18 @@
fn nonprotected_vm_instance() -> Result<VmInstance> {
let rialto = File::open(UNSIGNED_RIALTO_PATH).context("Failed to open Rialto kernel binary")?;
+ // Do not use `#allocateInstanceId` to generate the instance ID because the method
+ // also adds an instance ID to the database it manages.
+ // This is not necessary for this test.
+ let mut instance_id = [0u8; 64];
+ rand_bytes(&mut instance_id).unwrap();
let config = VirtualMachineConfig::RawConfig(VirtualMachineRawConfig {
name: String::from("Non protected rialto"),
bootloader: Some(ParcelFileDescriptor::new(rialto)),
protectedVm: false,
memoryMib: 300,
platformVersion: "~1.0".to_string(),
+ instanceId: instance_id,
..Default::default()
});
let console = Some(service_vm_manager::android_log_fd()?);