From b81e97da4f6db938d5af99192e6e63347a93f7e0 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Penna Date: Tue, 10 Feb 2026 16:04:41 -0800 Subject: [PATCH] Update Nanvix and Cache Handling Logic Signed-off-by: Pedro Henrique Penna --- Cargo.lock | 96 +++++++++++++++++++----------------- Cargo.toml | 3 +- src/bin/hyperlight-nanvix.rs | 25 +++++----- src/cache.rs | 78 +++++++++++++++++++++-------- src/runtime.rs | 70 ++++++++++++++------------ tests/integration_tests.rs | 5 +- 6 files changed, 163 insertions(+), 114 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c04cef6..31c1642 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,8 +90,8 @@ checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "arch" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "cfg-if", "config", @@ -333,8 +333,8 @@ dependencies = [ [[package]] name = "config" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "cfg-if", ] @@ -347,8 +347,8 @@ checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "control-plane-api" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "config", "num_enum", @@ -526,8 +526,8 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "error" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "sysapi", ] @@ -829,8 +829,8 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hwloc" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "anyhow", "libc", @@ -963,6 +963,7 @@ version = "0.1.0" dependencies = [ "anyhow", "clap", + "dirs", "libc", "nanvix", "napi", @@ -1245,8 +1246,8 @@ dependencies = [ [[package]] name = "linuxd" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "anyhow", "config", @@ -1354,8 +1355,8 @@ dependencies = [ [[package]] name = "nanvix" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "anyhow", "config", @@ -1373,8 +1374,8 @@ dependencies = [ [[package]] name = "nanvix-http" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "anyhow", "config", @@ -1397,14 +1398,16 @@ dependencies = [ [[package]] name = "nanvix-registry" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "anyhow", + "bytes", "dirs", "reqwest", "serde", "serde_json", + "sha2", "syslog", "tokio", "uuid", @@ -1412,8 +1415,8 @@ dependencies = [ [[package]] name = "nanvix-sandbox" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "anyhow", "cfg-if", @@ -1422,6 +1425,7 @@ dependencies = [ "hwloc", "libc", "linuxd", + "rand", "sys", "syscomm", "syslog", @@ -1432,8 +1436,8 @@ dependencies = [ [[package]] name = "nanvix-sandbox-cache" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "anyhow", "config", @@ -1445,8 +1449,8 @@ dependencies = [ [[package]] name = "nanvix-terminal" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "anyhow", "libc", @@ -1687,8 +1691,8 @@ dependencies = [ [[package]] name = "profiler" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "cfg-if", "syslog", @@ -2336,8 +2340,8 @@ checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "static_assert" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" [[package]] name = "strsim" @@ -2384,8 +2388,8 @@ dependencies = [ [[package]] name = "sys" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "config", "error", @@ -2394,8 +2398,8 @@ dependencies = [ [[package]] name = "sysapi" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "config", "static_assert", @@ -2403,8 +2407,8 @@ dependencies = [ [[package]] name = "syscall" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "arch", "cfg-if", @@ -2418,8 +2422,8 @@ dependencies = [ [[package]] name = "syscomm" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "config", "libc", @@ -2430,8 +2434,8 @@ dependencies = [ [[package]] name = "syslog" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "flexi_logger", "log", @@ -2440,8 +2444,8 @@ dependencies = [ [[package]] name = "syslog-macros" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "proc-macro2", "quote", @@ -2697,8 +2701,8 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "type-safe" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" [[package]] name = "typenum" @@ -2744,8 +2748,8 @@ dependencies = [ [[package]] name = "user-vm-api" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "config", "serde", @@ -2756,8 +2760,8 @@ dependencies = [ [[package]] name = "uservm" -version = "0.11.112" -source = "git+https://github.com/nanvix/nanvix?rev=7752e9f2deb4a5606f9885e4c130eec4ea583de1#7752e9f2deb4a5606f9885e4c130eec4ea583de1" +version = "0.11.133" +source = "git+https://github.com/nanvix/nanvix?rev=cc9c508918bd17678e9d790f10a6a7c20b7902da#cc9c508918bd17678e9d790f10a6a7c20b7902da" dependencies = [ "anyhow", "arch", diff --git a/Cargo.toml b/Cargo.toml index c4472dd..c81a7d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,13 +5,14 @@ edition = "2021" description = "A Hyperlight VMM wrapper with out-of-the-box support for running Nanvix microkernel guests" [dependencies] -nanvix = { git = "https://github.com/nanvix/nanvix", rev = "7752e9f2deb4a5606f9885e4c130eec4ea583de1", features = [ +nanvix = { git = "https://github.com/nanvix/nanvix", rev = "cc9c508918bd17678e9d790f10a6a7c20b7902da", features = [ "single-process", "hyperlight", ] } tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] } anyhow = "1.0" clap = { version = "4", features = ["derive"] } +dirs = "6" libc = "0.2.178" # NAPI bindings (optional) diff --git a/src/bin/hyperlight-nanvix.rs b/src/bin/hyperlight-nanvix.rs index 30b2204..f99fe7a 100644 --- a/src/bin/hyperlight-nanvix.rs +++ b/src/bin/hyperlight-nanvix.rs @@ -2,7 +2,6 @@ use anyhow::Result; use clap::{Parser, Subcommand}; use hyperlight_nanvix::{cache, RuntimeConfig, Sandbox}; use nanvix::log; -use nanvix::registry::Registry; use std::path::PathBuf; /// A Hyperlight VMM wrapper with out-of-the-box support for running Nanvix microkernel guests @@ -39,7 +38,7 @@ const DEFAULT_LOG_LEVEL: &str = "info"; async fn setup_registry_command() -> Result<()> { println!("Setting up Nanvix registry..."); - // Check cache status first using shared cache utilities + // Check cache status first using local filesystem probes let kernel_cached = cache::is_binary_cached("kernel.elf"); let qjs_cached = cache::is_binary_cached("qjs"); let python_cached = cache::is_binary_cached("python3"); @@ -47,14 +46,12 @@ async fn setup_registry_command() -> Result<()> { if kernel_cached && qjs_cached && python_cached { println!("Registry already set up at ~/.cache/nanvix-registry/"); } else { - // Trigger registry download by requesting key binaries - let registry = Registry::new(None); - + // Download missing binaries via get_cached_binary_path (local first, registry fallback) if !kernel_cached { print!("Downloading kernel.elf... "); - let _kernel = registry - .get_cached_binary("hyperlight", "single-process", "kernel.elf") - .await?; + cache::get_cached_binary_path("kernel.elf") + .await + .ok_or_else(|| anyhow::anyhow!("Failed to download kernel.elf"))?; println!("done"); } else { println!("kernel.elf already cached"); @@ -62,9 +59,9 @@ async fn setup_registry_command() -> Result<()> { if !qjs_cached { print!("Downloading qjs binary... "); - let _qjs = registry - .get_cached_binary("hyperlight", "single-process", "qjs") - .await?; + cache::get_cached_binary_path("qjs") + .await + .ok_or_else(|| anyhow::anyhow!("Failed to download qjs"))?; println!("done"); } else { println!("qjs already cached"); @@ -72,9 +69,9 @@ async fn setup_registry_command() -> Result<()> { if !python_cached { print!("Downloading python3 binary... "); - let _python = registry - .get_cached_binary("hyperlight", "single-process", "python3") - .await?; + cache::get_cached_binary_path("python3") + .await + .ok_or_else(|| anyhow::anyhow!("Failed to download python3"))?; println!("done"); } else { println!("python3 already cached"); diff --git a/src/cache.rs b/src/cache.rs index 1523e56..66242d4 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -1,31 +1,69 @@ use std::path::PathBuf; -/// Get the default cache directory for nanvix registry -pub fn get_cache_directory() -> PathBuf { - let home_dir = std::env::var("HOME").unwrap_or_else(|_| ".".to_string()); - std::path::Path::new(&home_dir) - .join(".cache") - .join("nanvix-registry") -} +use nanvix::registry::Registry; + +/// Default machine type for hyperlight-nanvix +const DEFAULT_MACHINE: &str = "hyperlight"; + +/// Default deployment type for hyperlight-nanvix +const DEFAULT_DEPLOYMENT: &str = "single-process"; -/// Get the binary cache directory -pub fn get_binary_cache_directory() -> PathBuf { - get_cache_directory().join("bin") +/// Name of the nanvix-registry cache directory (matches the upstream constant). +const CACHE_DIRECTORY_NAME: &str = "nanvix-registry"; + +/// Return the base nanvix-registry cache directory. +/// +/// Uses `dirs::cache_dir()` (e.g. `~/.cache` on Linux) and falls back to the +/// current directory when unavailable. +fn get_cache_directory() -> PathBuf { + dirs::cache_dir() + .unwrap_or_else(|| PathBuf::from(".")) + .join(CACHE_DIRECTORY_NAME) } -/// Check if a binary exists in the cache and return its path if found -pub async fn get_cached_binary_path(binary_name: &str) -> Option { - let cache_path = get_binary_cache_directory().join(binary_name); +/// Perform a pure filesystem probe for a cached binary. +/// +/// Scans every `--*/bin/` path inside the +/// cache directory and returns the first match. This never hits the network. +fn find_in_local_cache(binary_name: &str) -> Option { + let cache_dir = get_cache_directory(); + let prefix = format!("{}-{}-", DEFAULT_MACHINE, DEFAULT_DEPLOYMENT); - if tokio::fs::metadata(&cache_path).await.is_ok() { - Some(cache_path.to_string_lossy().to_string()) - } else { - None + let entries = std::fs::read_dir(&cache_dir).ok()?; + for entry in entries.flatten() { + let dir_name = entry.file_name(); + let dir_name_str = dir_name.to_string_lossy(); + if dir_name_str.starts_with(&prefix) && entry.file_type().is_ok_and(|ft| ft.is_dir()) { + let candidate = entry.path().join("bin").join(binary_name); + if candidate.is_file() { + return Some(candidate.to_string_lossy().into_owned()); + } + } } + None } -/// Check if a binary exists in the cache (synchronous version for setup command) +/// Check if a binary exists in the local cache. +/// +/// Pure filesystem probe with no network side effects. pub fn is_binary_cached(binary_name: &str) -> bool { - let cache_path = get_binary_cache_directory().join(binary_name); - cache_path.exists() + find_in_local_cache(binary_name).is_some() +} + +/// Locate a cached binary, downloading it from the registry if not found locally. +/// +/// First probes the local filesystem. If the binary is not present, falls back +/// to the nanvix registry which will download and cache it. +pub async fn get_cached_binary_path(binary_name: &str) -> Option { + // Try local filesystem first. + if let Some(path) = find_in_local_cache(binary_name) { + return Some(path); + } + + // Fall back to the nanvix registry (downloads if needed). + let registry = Registry::new(None); + registry + .get_cached_binary(DEFAULT_MACHINE, DEFAULT_DEPLOYMENT, binary_name) + .await + .ok() } diff --git a/src/runtime.rs b/src/runtime.rs index 89fa19d..ae51583 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -26,6 +26,16 @@ impl WorkloadType { } } + /// Get the registry package name for this workload type. + /// Returns `None` for workload types that don't require a package installation. + pub fn package_name(&self) -> Option<&'static str> { + match self { + WorkloadType::JavaScript => Some("quickjs"), + WorkloadType::Python => Some("python"), + WorkloadType::Binary => None, + } + } + /// Get the file extensions associated with this workload type pub fn extensions(&self) -> &'static [&'static str] { match self { @@ -141,11 +151,6 @@ impl Runtime { Ok(Self { config, registry }) } - /// Check if a binary exists in the cache and return its path if found - async fn get_cached_binary_path(&self, binary_name: &str) -> Option { - cache::get_cached_binary_path(binary_name).await - } - /// Clear the nanvix registry cache to force fresh downloads pub async fn clear_cache(&self) -> Result<()> { log::info!("Clearing nanvix registry cache..."); @@ -163,45 +168,46 @@ impl Runtime { anyhow::anyhow!("Could not determine workload type for {:?}", workload_path) })?; + // Verify the workload file exists before proceeding + if !workload_path.exists() { + anyhow::bail!("Workload file not found: {:?}", workload_path); + } + // Use hardcoded values for machine and deployment type (hyperlight single-process) let machine_type = "hyperlight"; let deployment_type = "single-process"; + // Install the required package (and its dependencies) for scripted workloads, + // but only when the interpreter binary is not already present in the cache. + // This avoids unnecessary I/O and network calls on the common (cached) path. + if let Some(package_name) = workload_type.package_name() { + if !cache::is_binary_cached(workload_type.binary_name()) { + log::info!("Installing package '{}' and dependencies...", package_name); + self.registry + .install(machine_type, deployment_type, package_name, true) + .await?; + } + } + // Get interpreter binary (only needed for scripted workloads) let binary_path = if matches!(workload_type, WorkloadType::Binary) { // For binary workloads, we don't need an interpreter String::new() - } else if let Some(cached_path) = self - .get_cached_binary_path(workload_type.binary_name()) - .await - { - log::info!( - "Using cached {} binary: {}", - workload_type.binary_name(), - cached_path - ); - cached_path } else { - log::info!( - "{} not cached, downloading from registry...", - workload_type.binary_name() - ); - self.registry - .get_cached_binary(machine_type, deployment_type, workload_type.binary_name()) - .await? + cache::get_cached_binary_path(workload_type.binary_name()) + .await + .ok_or_else(|| { + anyhow::anyhow!( + "Failed to locate {} binary in cache or registry", + workload_type.binary_name() + ) + })? }; // Get kernel path for terminal configuration - let kernel_path = if let Some(cached_path) = self.get_cached_binary_path("kernel.elf").await - { - log::info!("Using cached kernel binary: {}", cached_path); - cached_path - } else { - log::info!("kernel.elf not cached, downloading from registry..."); - self.registry - .get_cached_binary(machine_type, deployment_type, "kernel.elf") - .await? - }; + let kernel_path = cache::get_cached_binary_path("kernel.elf") + .await + .ok_or_else(|| anyhow::anyhow!("Failed to locate kernel.elf in cache or registry"))?; // Ensure the temporary directory exists for socket creation std::fs::create_dir_all(&self.config.tmp_directory)?; diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 32c9995..62310a5 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -93,7 +93,10 @@ async fn test_nonexistent_file() { let mut sandbox = Sandbox::new(config).expect("Failed to create sandbox"); let result = sandbox.run("truly_nonexistent_file_12345.js").await; - assert!(result.is_ok()); + assert!( + result.is_err(), + "Running a nonexistent file should return an error" + ); } #[tokio::test]