Files
zosbuilder/components/rfs/tests/docker_test.rs
Jan De Landtsheer bf62e887e8 feat: Create minimal Zero-OS initramfs with console support
- Fixed build system to clone source repositories instead of downloading binaries
- Enhanced scripts/fetch-github.sh with proper git repo cloning and branch handling
- Updated scripts/compile-components.sh for RFS compilation with build-binary feature
- Added minimal firmware installation for essential network drivers (73 modules)
- Created comprehensive zinit configuration set (15 config files including getty)
- Added util-linux package for getty/agetty console support
- Optimized package selection for minimal 27MB initramfs footprint
- Successfully builds bootable vmlinuz.efi with embedded initramfs
- Confirmed working: VM boot, console login, network drivers, zinit init system

Components:
- initramfs.cpio.xz: 27MB compressed minimal Zero-OS image
- vmlinuz.efi: 35MB bootable kernel with embedded initramfs
- Complete Zero-OS toolchain: zinit, rfs, mycelium compiled from source
2025-08-16 23:25:59 +02:00

67 lines
2.0 KiB
Rust

#[cfg(test)]
mod docker_tests {
use anyhow::Result;
use std::path::Path;
use tempdir::TempDir;
use tokio::runtime::Runtime;
use uuid::Uuid;
use rfs::fungi;
use rfs::store::{self, dir::DirStore};
use rfs::DockerImageToFlist;
#[test]
fn test_docker_conversion() -> Result<()> {
// Skip test if docker is not available
if !is_docker_available() {
println!("Docker is not available, skipping test");
return Ok(());
}
// Create a runtime for async operations
let rt = Runtime::new()?;
rt.block_on(async {
// Create temporary directories
let temp_dir = TempDir::new("docker-test")?;
let store_dir = temp_dir.path().join("store");
std::fs::create_dir_all(&store_dir)?;
// Create a store
let store = DirStore::new(&store_dir).await?;
// Create a flist writer
let fl_path = temp_dir.path().join("alpine-test.fl");
let meta = fungi::Writer::new(&fl_path, true).await?;
// Create a temporary directory for docker extraction
let container_name = Uuid::new_v4().to_string();
let docker_tmp_dir = TempDir::new(&container_name)?;
// Create DockerImageToFlist instance
let mut docker_to_fl = DockerImageToFlist::new(
meta,
"alpine:latest".to_string(),
None, // No credentials for public image
docker_tmp_dir,
);
// Convert docker image to flist
docker_to_fl.convert(store, None).await?;
// Verify the flist was created
assert!(Path::new(&fl_path).exists(), "Flist file was not created");
Ok(())
})
}
// Helper function to check if docker is available
fn is_docker_available() -> bool {
std::process::Command::new("docker")
.arg("--version")
.output()
.is_ok()
}
}