diff --git a/Jenkinsfile b/Jenkinsfile index 050356722..886f7a0ab 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,6 +5,7 @@ stage ("Builds") { } stage ('Install system packages') { sh "sudo apt-get -y install build-essential mtools libssl-dev pkg-config" + sh 'sudo apt-get -y install flex bison libelf-dev' } stage ('Install Rust') { sh "nohup curl https://sh.rustup.rs -sSf | sh -s -- -y" diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh index 56fade8d5..aa38ad732 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_integration_tests.sh @@ -24,6 +24,27 @@ if [ ! -f "$OS_IMAGE" ]; then popd fi + +VMLINUX_IMAGE="$WORKLOADS_DIR/vmlinux" +BZIMAGE_IMAGE="$WORKLOADS_DIR/bzImage" + +if [ ! -f "$VMLINUX_IMAGE" ]; then + SRCDIR=$PWD + pushd $WORKLOADS_DIR + wget --quiet https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.21.tar.xz + tar xf linux-5.0.21.tar.xz + pushd linux-5.0.21 + cp $SRCDIR/resources/linux-5.0-config .config + make bzImage -j `nproc` + cp vmlinux $VMLINUX_IMAGE + cp arch/x86/boot/bzImage $BZIMAGE_IMAGE + popd + rm linux-5.0.21.tar.xz + rm -r linux-5.0.21 + popd +fi + + rm /tmp/cloudinit.img mkdosfs -n config-2 -C /tmp/cloudinit.img 8192 mcopy -oi /tmp/cloudinit.img -s test_data/cloud-init/openstack :: diff --git a/src/main.rs b/src/main.rs index 7549ca1f2..5ad2a8337 100755 --- a/src/main.rs +++ b/src/main.rs @@ -324,4 +324,46 @@ mod tests { Ok(()) }); } + + #[test] + fn test_vmlinux_boot() { + test_block!(tb, "", { + let (disks, _) = prepare_files(); + let mut workload_path = dirs::home_dir().unwrap(); + workload_path.push("workloads"); + + let mut kernel_path = workload_path.clone(); + kernel_path.push("vmlinux"); + + let mut child = Command::new("target/debug/cloud-hypervisor") + .args(&["--cpus", "1"]) + .args(&["--memory", "512"]) + .args(&["--kernel", kernel_path.to_str().unwrap()]) + .args(&["--disk", disks[0], disks[1]]) + .args(&["--net", "tap=,mac=,ip=192.168.2.1,mask=255.255.255.0"]) + .args(&["--cmdline", "root=PARTUUID=3cb0e0a5-925d-405e-bc55-edf0cec8f10a console=tty0 console=ttyS0,115200n8 console=hvc0 quiet init=/usr/lib/systemd/systemd-bootchart initcall_debug tsc=reliable no_timer_check noreplace-smp cryptomgr.notests rootfstype=ext4,btrfs,xfs kvm-intel.nested=1 rw"]) + .spawn() + .unwrap(); + + thread::sleep(std::time::Duration::new(10, 0)); + + aver_eq!(tb, get_cpu_count(), 1); + aver!(tb, get_total_memory() > 496_000); + aver!(tb, get_entropy() >= 1000); + aver_eq!( + tb, + ssh_command("grep -c PCI-MSI /proc/interrupts") + .trim() + .parse::() + .unwrap(), + 8 + ); + + ssh_command("sudo reboot"); + thread::sleep(std::time::Duration::new(10, 0)); + let _ = child.kill(); + let _ = child.wait(); + Ok(()) + }); + } }