From 0a229ef4f5005b4bdd06a56cc3ce4e8f9ba65961 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 18 Sep 2019 13:23:02 -0700 Subject: [PATCH] ci: Extend vhost-user-blk test to validate the content This commit extends the existing integration test related to vhost-user-blk by validating the block image contains one file "foo" containing "bar". Signed-off-by: Sebastien Boeuf --- scripts/run_integration_tests.sh | 13 ++++++++++--- src/main.rs | 25 ++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh index fc3f78532..d4a3dc447 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_integration_tests.sh @@ -96,10 +96,17 @@ if [ ! -f "$VIRTIOFSD" ] || [ ! -f "$VUBRIDGE" ] || [ ! -f "$VUBD" ]; then popd fi -BLKFILE="$WORKLOADS_DIR/blk" -if [ ! -f "$BLKFILE" ]; then +BLK_IMAGE="$WORKLOADS_DIR/blk.img" +MNT_DIR="mount_image" +if [ ! -f "$BLK_IMAGE" ]; then pushd $WORKLOADS_DIR - dd if=/dev/zero of=$BLKFILE bs=1M count=64 + fallocate -l 16M $BLK_IMAGE + mkfs.ext4 -j $BLK_IMAGE + mkdir $MNT_DIR + sudo mount -t ext4 $BLK_IMAGE $MNT_DIR + sudo bash -c "echo bar > $MNT_DIR/foo" + sudo umount $BLK_IMAGE + rm -r $MNT_DIR popd fi diff --git a/src/main.rs b/src/main.rs index 539f46640..312333d7d 100755 --- a/src/main.rs +++ b/src/main.rs @@ -603,7 +603,7 @@ mod tests { let vubd_path = String::from(vubd_path.to_str().unwrap()); let mut blk_file_path = workload_path.clone(); - blk_file_path.push("blk"); + blk_file_path.push("blk.img"); let blk_file_path = String::from(blk_file_path.to_str().unwrap()); let vubd_socket_path = String::from(tmp_dir.path().join("vub.sock").to_str().unwrap()); @@ -1301,11 +1301,11 @@ mod tests { thread::sleep(std::time::Duration::new(20, 0)); - // Check both if /dev/vdc exists and if the block size is 64M. + // Check both if /dev/vdc exists and if the block size is 16M. aver_eq!( tb, guest - .ssh_command("lsblk | grep vdc | grep -c 64M") + .ssh_command("lsblk | grep vdc | grep -c 16M") .unwrap_or_default() .trim() .parse::() @@ -1313,6 +1313,25 @@ mod tests { 1 ); + // Mount the device + guest.ssh_command("mkdir mount_image")?; + guest.ssh_command("sudo mount -t ext4 /dev/vdc mount_image/")?; + + // Check the content of the block device. The file "foo" should + // contain "bar". + aver_eq!( + tb, + guest + .ssh_command("cat mount_image/foo") + .unwrap_or_default() + .trim(), + "bar" + ); + + // Unmount the device + guest.ssh_command("sudo umount /dev/vdc")?; + guest.ssh_command("rm -r mount_image")?; + guest.ssh_command("sudo shutdown -h now")?; thread::sleep(std::time::Duration::new(5, 0)); let _ = cloud_child.kill();