1 // Copyright 2022 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 fixture::vm::Config; 6 use fixture::vm::TestVm; 7 8 // Tests for possible backwards compatibility issues. 9 // 10 // There is no backwards compatibility policy yet, these are just "change detector" tests. If you 11 // break a test, make sure the change is intended and then ask in go/crosvm-chat to see if anyone 12 // objects to updating the golden file. 13 14 // Many changes to PCI devices can cause issues, e.g. some users depend on crosvm always choosing 15 // the same PCI slots for particular devices. 16 #[test] backcompat_test()17fn backcompat_test() { 18 let mut vm = TestVm::new(Config::new()).unwrap(); 19 backcompat_test_simple_lspci(&mut vm); 20 } 21 22 #[test] backcompat_test_disable_sandbox()23fn backcompat_test_disable_sandbox() { 24 let mut vm = TestVm::new(Config::new().disable_sandbox()).unwrap(); 25 backcompat_test_simple_lspci(&mut vm); 26 } 27 backcompat_test_simple_lspci(vm: &mut TestVm)28fn backcompat_test_simple_lspci(vm: &mut TestVm) { 29 let expected = if cfg!(windows) { 30 include_str!("goldens/backcompat_test_simple_lspci_win.txt").trim() 31 } else { 32 include_str!("goldens/backcompat_test_simple_lspci.txt").trim() 33 }; 34 let result = vm 35 .exec_in_guest("lspci -n") 36 .unwrap() 37 .stdout 38 .trim() 39 .replace("\r", ""); 40 assert_eq!( 41 expected, 42 result, 43 "PCI Devices changed:\n<<< Expected <<<\n{}\n<<<<<<<<<<<<<<<<\n>>> Got >>>\n{}\n>>>>>>>>>>>>>>>>\n", 44 expected, result 45 ); 46 } 47