@@ -8,7 +8,10 @@ use serde_json::Value;
88use xshell:: { cmd, Shell } ;
99
1010// Re-export constants from lib for internal use
11- pub ( crate ) use integration_tests:: { INTEGRATION_TEST_LABEL , LIBVIRT_INTEGRATION_TEST_LABEL } ;
11+ pub ( crate ) use integration_tests:: {
12+ IntegrationTest , INTEGRATION_TESTS , INTEGRATION_TEST_LABEL , LIBVIRT_INTEGRATION_TEST_LABEL ,
13+ } ;
14+ use linkme:: distributed_slice;
1215
1316mod tests {
1417 pub mod libvirt_base_disks;
@@ -129,6 +132,9 @@ pub(crate) fn run_bcvk_nocapture(args: &[&str]) -> std::io::Result<()> {
129132 Ok ( ( ) )
130133}
131134
135+ #[ distributed_slice( INTEGRATION_TESTS ) ]
136+ static TEST_IMAGES_LIST : IntegrationTest = IntegrationTest :: new ( "images_list" , test_images_list) ;
137+
132138fn test_images_list ( ) -> Result < ( ) > {
133139 println ! ( "Running test: bcvk images list --json" ) ;
134140
@@ -174,144 +180,15 @@ fn test_images_list() -> Result<()> {
174180fn main ( ) {
175181 let args = Arguments :: from_args ( ) ;
176182
177- let tests = vec ! [
178- Trial :: test( "images_list" , || {
179- test_images_list( ) ?;
180- Ok ( ( ) )
181- } ) ,
182- Trial :: test( "run_ephemeral_correct_kernel" , || {
183- tests:: run_ephemeral:: test_run_ephemeral_correct_kernel( ) ;
184- Ok ( ( ) )
185- } ) ,
186- Trial :: test( "run_ephemeral_poweroff" , || {
187- tests:: run_ephemeral:: test_run_ephemeral_poweroff( ) ;
188- Ok ( ( ) )
189- } ) ,
190- Trial :: test( "run_ephemeral_with_memory_limit" , || {
191- tests:: run_ephemeral:: test_run_ephemeral_with_memory_limit( ) ;
192- Ok ( ( ) )
193- } ) ,
194- Trial :: test( "run_ephemeral_with_vcpus" , || {
195- tests:: run_ephemeral:: test_run_ephemeral_with_vcpus( ) ;
196- Ok ( ( ) )
197- } ) ,
198- Trial :: test( "run_ephemeral_execute" , || {
199- tests:: run_ephemeral:: test_run_ephemeral_execute( ) ;
200- Ok ( ( ) )
201- } ) ,
202- Trial :: test( "run_ephemeral_container_ssh_access" , || {
203- tests:: run_ephemeral:: test_run_ephemeral_container_ssh_access( ) ;
204- Ok ( ( ) )
205- } ) ,
206- Trial :: test( "run_ephemeral_ssh_command" , || {
207- tests:: run_ephemeral_ssh:: test_run_ephemeral_ssh_command( ) ;
208- Ok ( ( ) )
209- } ) ,
210- Trial :: test( "run_ephemeral_ssh_cleanup" , || {
211- tests:: run_ephemeral_ssh:: test_run_ephemeral_ssh_cleanup( ) ;
212- Ok ( ( ) )
213- } ) ,
214- Trial :: test( "run_ephemeral_ssh_system_command" , || {
215- tests:: run_ephemeral_ssh:: test_run_ephemeral_ssh_system_command( ) ;
216- Ok ( ( ) )
217- } ) ,
218- Trial :: test( "run_ephemeral_ssh_exit_code" , || {
219- tests:: run_ephemeral_ssh:: test_run_ephemeral_ssh_exit_code( ) ;
220- Ok ( ( ) )
221- } ) ,
222- Trial :: test( "run_ephemeral_ssh_cross_distro_compatibility" , || {
223- tests:: run_ephemeral_ssh:: test_run_ephemeral_ssh_cross_distro_compatibility( ) ;
224- Ok ( ( ) )
225- } ) ,
226- Trial :: test( "mount_feature_bind" , || {
227- tests:: mount_feature:: test_mount_feature_bind( ) ;
228- Ok ( ( ) )
229- } ) ,
230- Trial :: test( "mount_feature_ro_bind" , || {
231- tests:: mount_feature:: test_mount_feature_ro_bind( ) ;
232- Ok ( ( ) )
233- } ) ,
234- Trial :: test( "to_disk" , || {
235- tests:: to_disk:: test_to_disk( ) ;
236- Ok ( ( ) )
237- } ) ,
238- Trial :: test( "to_disk_qcow2" , || {
239- tests:: to_disk:: test_to_disk_qcow2( ) ;
240- Ok ( ( ) )
241- } ) ,
242- Trial :: test( "to_disk_caching" , || {
243- tests:: to_disk:: test_to_disk_caching( ) ;
244- Ok ( ( ) )
245- } ) ,
246- Trial :: test( "libvirt_list_functionality" , || {
247- tests:: libvirt_verb:: test_libvirt_list_functionality( ) ;
248- Ok ( ( ) )
249- } ) ,
250- Trial :: test( "libvirt_list_json_output" , || {
251- tests:: libvirt_verb:: test_libvirt_list_json_output( ) ;
252- Ok ( ( ) )
253- } ) ,
254- Trial :: test( "libvirt_list_json_ssh_metadata" , || {
255- tests:: libvirt_verb:: test_libvirt_list_json_ssh_metadata( ) ;
256- Ok ( ( ) )
257- } ) ,
258- Trial :: test( "libvirt_run_resource_options" , || {
259- tests:: libvirt_verb:: test_libvirt_run_resource_options( ) ;
260- Ok ( ( ) )
261- } ) ,
262- Trial :: test( "libvirt_run_networking" , || {
263- tests:: libvirt_verb:: test_libvirt_run_networking( ) ;
264- Ok ( ( ) )
265- } ) ,
266- Trial :: test( "libvirt_ssh_integration" , || {
267- tests:: libvirt_verb:: test_libvirt_ssh_integration( ) ;
268- Ok ( ( ) )
269- } ) ,
270- Trial :: test( "libvirt_run_ssh_full_workflow" , || {
271- tests:: libvirt_verb:: test_libvirt_run_ssh_full_workflow( ) ;
272- Ok ( ( ) )
273- } ) ,
274- Trial :: test( "libvirt_vm_lifecycle" , || {
275- tests:: libvirt_verb:: test_libvirt_vm_lifecycle( ) ;
276- Ok ( ( ) )
277- } ) ,
278- Trial :: test( "libvirt_label_functionality" , || {
279- tests:: libvirt_verb:: test_libvirt_label_functionality( ) ;
280- Ok ( ( ) )
281- } ) ,
282- Trial :: test( "libvirt_error_handling" , || {
283- tests:: libvirt_verb:: test_libvirt_error_handling( ) ;
284- Ok ( ( ) )
285- } ) ,
286- Trial :: test( "libvirt_bind_storage_ro" , || {
287- tests:: libvirt_verb:: test_libvirt_bind_storage_ro( ) ;
288- Ok ( ( ) )
289- } ) ,
290- Trial :: test( "libvirt_transient_vm" , || {
291- tests:: libvirt_verb:: test_libvirt_transient_vm( ) ;
292- Ok ( ( ) )
293- } ) ,
294- Trial :: test( "libvirt_base_disk_creation_and_reuse" , || {
295- tests:: libvirt_base_disks:: test_base_disk_creation_and_reuse( ) ;
296- Ok ( ( ) )
297- } ) ,
298- Trial :: test( "libvirt_base_disks_list_command" , || {
299- tests:: libvirt_base_disks:: test_base_disks_list_command( ) ;
300- Ok ( ( ) )
301- } ) ,
302- Trial :: test( "libvirt_base_disks_list_shows_timestamp" , || {
303- tests:: libvirt_base_disks:: test_base_disks_list_shows_timestamp( ) ;
304- Ok ( ( ) )
305- } ) ,
306- Trial :: test( "libvirt_base_disks_prune_dry_run" , || {
307- tests:: libvirt_base_disks:: test_base_disks_prune_dry_run( ) ;
308- Ok ( ( ) )
309- } ) ,
310- Trial :: test( "libvirt_vm_disk_references_base" , || {
311- tests:: libvirt_base_disks:: test_vm_disk_references_base( ) ;
312- Ok ( ( ) )
313- } ) ,
314- ] ;
183+ // Collect tests from the distributed slice
184+ let tests: Vec < Trial > = INTEGRATION_TESTS
185+ . iter ( )
186+ . map ( |test| {
187+ let name = test. name ;
188+ let f = test. f ;
189+ Trial :: test ( name, move || f ( ) . map_err ( |e| format ! ( "{:?}" , e) . into ( ) ) )
190+ } )
191+ . collect ( ) ;
315192
316193 // Run the tests and exit with the result
317194 libtest_mimic:: run ( & args, tests) . exit ( ) ;
0 commit comments