@@ -11,7 +11,8 @@ use xshell::{cmd, Shell};
1111
1212// Re-export constants from lib for internal use
1313pub ( crate ) use integration_tests:: {
14- IntegrationTest , INTEGRATION_TESTS , INTEGRATION_TEST_LABEL , LIBVIRT_INTEGRATION_TEST_LABEL ,
14+ image_to_test_suffix, IntegrationTest , ParameterizedIntegrationTest , INTEGRATION_TESTS ,
15+ INTEGRATION_TEST_LABEL , LIBVIRT_INTEGRATION_TEST_LABEL , PARAMETERIZED_INTEGRATION_TESTS ,
1516} ;
1617use linkme:: distributed_slice;
1718
@@ -43,30 +44,38 @@ pub(crate) fn get_bck_command() -> Result<String> {
4344 return Ok ( "bcvk" . to_owned ( ) ) ;
4445}
4546
46- /// Get the default bootc image to use for tests
47+ /// Get the primary bootc image to use for tests
4748///
48- /// Checks BCVK_TEST_IMAGE environment variable first, then falls back to default.
49- /// This allows easily overriding the base image for all integration tests.
50- ///
51- /// Default images:
52- /// - Primary: quay.io/fedora/fedora-bootc:42 (Fedora 42 with latest features)
53- /// - Alternative: quay.io/centos-bootc/centos-bootc:stream9 (CentOS Stream 9 for compatibility testing)
49+ /// Checks BCVK_PRIMARY_IMAGE environment variable first, then falls back to BCVK_TEST_IMAGE
50+ /// for backwards compatibility, then to a hardcoded default.
5451pub ( crate ) fn get_test_image ( ) -> String {
55- std:: env:: var ( "BCVK_TEST_IMAGE" )
56- . unwrap_or_else ( |_| "quay.io/fedora/fedora-bootc:42" . to_string ( ) )
52+ std:: env:: var ( "BCVK_PRIMARY_IMAGE" )
53+ . or_else ( |_| std:: env:: var ( "BCVK_TEST_IMAGE" ) )
54+ . unwrap_or_else ( |_| "quay.io/centos-bootc/centos-bootc:stream10" . to_string ( ) )
5755}
5856
59- /// Get an alternative bootc image for cross-platform testing
57+ /// Get all test images for matrix testing
58+ ///
59+ /// Parses BCVK_ALL_IMAGES environment variable, which should be a whitespace-separated
60+ /// list of container images (spaces, tabs, and newlines are all acceptable separators).
61+ /// Falls back to a single-element vec containing the primary image if not set or empty.
6062///
61- /// Returns a different image from the primary test image to test compatibility.
62- /// If BCVK_TEST_IMAGE is set to Fedora, returns CentOS Stream 9.
63- /// If BCVK_TEST_IMAGE is set to CentOS, returns Fedora.
64- pub ( crate ) fn get_alternative_test_image ( ) -> String {
65- let primary = get_test_image ( ) ;
66- if primary. contains ( "centos" ) {
67- "quay.io/fedora/fedora-bootc:42" . to_string ( )
63+ /// Example: `export BCVK_ALL_IMAGES="quay.io/fedora/fedora-bootc:42 quay.io/centos-bootc/centos-bootc:stream9"`
64+ pub ( crate ) fn get_all_test_images ( ) -> Vec < String > {
65+ if let Ok ( all_images) = std:: env:: var ( "BCVK_ALL_IMAGES" ) {
66+ let images: Vec < String > = all_images
67+ . split_whitespace ( )
68+ . map ( |s| s. to_string ( ) )
69+ . collect ( ) ;
70+
71+ if images. is_empty ( ) {
72+ eprintln ! ( "Warning: BCVK_ALL_IMAGES is set but empty, falling back to primary image" ) ;
73+ vec ! [ get_test_image( ) ]
74+ } else {
75+ images
76+ }
6877 } else {
69- "quay.io/centos-bootc/centos-bootc:stream9" . to_string ( )
78+ vec ! [ get_test_image ( ) ]
7079 }
7180}
7281
@@ -183,15 +192,29 @@ fn test_images_list() -> Result<()> {
183192fn main ( ) {
184193 let args = Arguments :: from_args ( ) ;
185194
186- // Collect tests from the distributed slice
187- let tests: Vec < Trial > = INTEGRATION_TESTS
188- . iter ( )
189- . map ( |test| {
190- let name = test. name ;
191- let f = test. f ;
192- Trial :: test ( name, move || f ( ) . map_err ( |e| format ! ( "{:?}" , e) . into ( ) ) )
193- } )
194- . collect ( ) ;
195+ let mut tests: Vec < Trial > = Vec :: new ( ) ;
196+
197+ // Collect regular tests from the distributed slice
198+ tests. extend ( INTEGRATION_TESTS . iter ( ) . map ( |test| {
199+ let name = test. name ;
200+ let f = test. f ;
201+ Trial :: test ( name, move || f ( ) . map_err ( |e| format ! ( "{:?}" , e) . into ( ) ) )
202+ } ) ) ;
203+
204+ // Collect parameterized tests and generate variants for each image
205+ let all_images = get_all_test_images ( ) ;
206+ for param_test in PARAMETERIZED_INTEGRATION_TESTS . iter ( ) {
207+ for image in & all_images {
208+ let image = image. clone ( ) ;
209+ let test_suffix = image_to_test_suffix ( & image) ;
210+ let test_name = format ! ( "{}_{}" , param_test. name, test_suffix) ;
211+ let f = param_test. f ;
212+
213+ tests. push ( Trial :: test ( test_name, move || {
214+ f ( & image) . map_err ( |e| format ! ( "{:?}" , e) . into ( ) )
215+ } ) ) ;
216+ }
217+ }
195218
196219 // Run the tests and exit with the result
197220 libtest_mimic:: run ( & args, tests) . exit ( ) ;
0 commit comments