patches and low-level development discussion
 help / color / mirror / code / Atom feed
2b136639fc22d5182bd7ffce6e69990dad6d2a9c blob 1363 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
// SPDX-License-Identifier: EUPL-1.2+
// SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>

use std::fs::{create_dir, create_dir_all, File};
use std::os::unix::fs::symlink;

use start_vm::vm_command;
use test_helper::TempDir;

fn contains_seq<H: PartialEq<N>, N>(haystack: &[H], needle: &[N]) -> bool {
    let start_indexes = 0..=(haystack.len() - needle.len());
    let mut candidates = start_indexes.map(|i| &haystack[i..][..needle.len()]);
    candidates.any(|c| c == needle)
}

fn main() -> std::io::Result<()> {
    let tmp_dir = TempDir::new()?;

    let service_dir = tmp_dir.path().join("testvm");
    let vm_config = tmp_dir.path().join("svc/data/testvm");

    create_dir(&service_dir)?;
    create_dir_all(&vm_config)?;
    File::create(vm_config.join("vmlinux"))?;
    create_dir(vm_config.join("blk"))?;
    symlink("/dev/null", vm_config.join("blk/root.img"))?;

    create_dir(vm_config.join("shared-dirs"))?;
    create_dir(vm_config.join("shared-dirs/root"))?;
    symlink("/", vm_config.join("shared-dirs/root/dir"))?;

    let expected_args = [
        "--fs",
        "tag=root,socket=../testvm-fs-root/env/virtiofsd.sock",
    ];

    let command = vm_command(service_dir, &tmp_dir.path().join("svc/data")).unwrap();
    let args: Box<[_]> = command.get_args().collect();
    assert!(contains_seq(&args, &expected_args));
    Ok(())
}
debug log:

solving 2b13663 ...
found 2b13663 in https://spectrum-os.org/git/spectrum

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).