mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-09 20:04:20 +00:00
1dab58a2cf
This search/replace updates all copyright notices to drop the "All rights reserved", Use "ChromiumOS" instead of "Chromium OS" and drops the trailing dots. This fulfills the request from legal and unifies our notices. ./tools/health-check has been updated to only accept this style. BUG=b:246579983 TEST=./tools/health-check Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Dennis Kempin <denniskempin@google.com>
43 lines
1.1 KiB
Rust
43 lines
1.1 KiB
Rust
// Copyright 2022 The ChromiumOS Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
//! Testing virtio-block.
|
|
|
|
pub mod fixture;
|
|
|
|
use std::process::Command;
|
|
|
|
use fixture::Config;
|
|
use fixture::TestVm;
|
|
use tempfile::NamedTempFile;
|
|
|
|
fn prepare_disk_img() -> NamedTempFile {
|
|
let mut disk = NamedTempFile::new().unwrap();
|
|
disk.as_file_mut().set_len(1024 * 1024).unwrap();
|
|
|
|
// TODO(b/243127910): Use `mkfs.ext4 -d` to include test data.
|
|
Command::new("sudo")
|
|
.arg("mkfs.ext4")
|
|
.arg(disk.path().to_str().unwrap())
|
|
.output()
|
|
.expect("failed to execute process");
|
|
disk
|
|
}
|
|
|
|
// TODO(b/243127498): Add tests for write and sync operations.
|
|
#[test]
|
|
fn mount_block() {
|
|
let disk = prepare_disk_img();
|
|
let disk_path = disk.path().to_str().unwrap().to_string();
|
|
println!("disk={disk_path}");
|
|
|
|
let config = Config::new().extra_args(vec!["--rwdisk".to_string(), disk_path]);
|
|
let mut vm = TestVm::new(config).unwrap();
|
|
assert_eq!(
|
|
vm.exec_in_guest("mount -t ext4 /dev/vdb /mnt && echo 42")
|
|
.unwrap()
|
|
.trim(),
|
|
"42"
|
|
);
|
|
}
|