mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-05 21:15:45 +00:00
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 <sebastien.boeuf@intel.com>
This commit is contained in:
parent
6b06cec611
commit
0a229ef4f5
@ -96,10 +96,17 @@ if [ ! -f "$VIRTIOFSD" ] || [ ! -f "$VUBRIDGE" ] || [ ! -f "$VUBD" ]; then
|
|||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BLKFILE="$WORKLOADS_DIR/blk"
|
BLK_IMAGE="$WORKLOADS_DIR/blk.img"
|
||||||
if [ ! -f "$BLKFILE" ]; then
|
MNT_DIR="mount_image"
|
||||||
|
if [ ! -f "$BLK_IMAGE" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
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
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
25
src/main.rs
25
src/main.rs
@ -603,7 +603,7 @@ mod tests {
|
|||||||
let vubd_path = String::from(vubd_path.to_str().unwrap());
|
let vubd_path = String::from(vubd_path.to_str().unwrap());
|
||||||
|
|
||||||
let mut blk_file_path = workload_path.clone();
|
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 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());
|
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));
|
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!(
|
aver_eq!(
|
||||||
tb,
|
tb,
|
||||||
guest
|
guest
|
||||||
.ssh_command("lsblk | grep vdc | grep -c 64M")
|
.ssh_command("lsblk | grep vdc | grep -c 16M")
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.trim()
|
.trim()
|
||||||
.parse::<u32>()
|
.parse::<u32>()
|
||||||
@ -1313,6 +1313,25 @@ mod tests {
|
|||||||
1
|
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")?;
|
guest.ssh_command("sudo shutdown -h now")?;
|
||||||
thread::sleep(std::time::Duration::new(5, 0));
|
thread::sleep(std::time::Duration::new(5, 0));
|
||||||
let _ = cloud_child.kill();
|
let _ = cloud_child.kill();
|
||||||
|
Loading…
Reference in New Issue
Block a user