xref: /aosp_15_r20/external/crosvm/e2e_tests/benches/gimp.rs (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1 // Copyright 2023 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 use std::time::Duration;
6 
7 use fixture::vm::Config;
8 use fixture::vm::TestVm;
9 
10 #[test]
gimp() -> anyhow::Result<()>11 fn gimp() -> anyhow::Result<()> {
12     let cfg = Config::from_env()
13     .with_kernel("https://storage.googleapis.com/crosvm/integration_tests/guest-bzimage-x86_64-r0009")
14     .with_initrd("https://storage.googleapis.com/crosvm/integration_tests/benchmarks/custom-initramfs.cpio.gz-r0005")
15     // Created by e2e_tests/guest_under_test/rootfs_benches/gimp/make.sh
16     .with_rootfs("https://storage.googleapis.com/crosvm/integration_tests/benchmarks/gimp-rootfs.img.zst-r0001").rootfs_is_rw().rootfs_is_compressed()
17     .with_stdout_hardware("serial").extra_args(vec!["--mem".to_owned(), "1024".to_owned()]);
18     let mut vm = TestVm::new(cfg).unwrap();
19     assert_eq!(
20         vm.exec_in_guest_async("echo 42")?
21             .with_timeout(Duration::from_secs(500))
22             .wait_ok(&mut vm)?
23             .stdout
24             .trim(),
25         "42"
26     );
27     vm.exec_in_guest("cd /workdir")?;
28     // Time initializing all plugins and execute action
29     vm.exec_in_guest(
30         r#"/usr/bin/gimp -i -b '(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE "/workdir/test1.png" "/workdir/test1.png")))(drawable (car (gimp-image-get-active-layer image)))) (plug-in-mblur RUN-NONINTERACTIVE image drawable 1 0 45 200 200) (gimp-file-save RUN-NONINTERACTIVE image drawable "/workdir/out1.png" "/workdir/out1.png"))' -b '(gimp-quit 0)'"#,
31     )?;
32     // Time executing action only
33     vm.exec_in_guest(
34         r#"/usr/bin/gimp -i -b '(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE "/workdir/test2.png" "/workdir/test2.png")))(drawable (car (gimp-image-get-active-layer image)))) (plug-in-mblur RUN-NONINTERACTIVE image drawable 1 0 45 200 200) (gimp-file-save RUN-NONINTERACTIVE image drawable "/workdir/out2.png" "/workdir/out2.png"))' -b '(gimp-quit 0)'"#,
35     )?;
36     Ok(())
37 }
38