mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +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
|
||||
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
|
||||
|
||||
|
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 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::<u32>()
|
||||
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user