diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 693cbdd7511..4ed4233efff 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -568,11 +568,15 @@ proc search_for { file pattern } { proc gcc-dg-runtest { testcases flags default-extra-flags } { global runtests + # Some callers initialize torture testing themselves; don't override those. + set existing_torture_init [torture-init-done] + if { $existing_torture_init == 0 } { + torture-init + } # Some callers set torture options themselves; don't override those. set existing_torture_options [torture-options-exist] if { $existing_torture_options == 0 } { global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS - torture-init set-torture-options $DG_TORTURE_OPTIONS [list {}] $LTO_TORTURE_OPTIONS } dump-torture-options @@ -603,7 +607,7 @@ proc gcc-dg-runtest { testcases flags default-extra-flags } { } } - if { $existing_torture_options == 0 } { + if { $existing_torture_init == 0 } { torture-finish } } diff --git a/gcc/testsuite/lib/gfortran-dg.exp b/gcc/testsuite/lib/gfortran-dg.exp index 3c813d3c8fb..e85f791fa94 100644 --- a/gcc/testsuite/lib/gfortran-dg.exp +++ b/gcc/testsuite/lib/gfortran-dg.exp @@ -126,11 +126,15 @@ proc gfortran-dg-runtest { testcases flags default-extra-flags } { global runtests global torture_with_loops + # Some callers initialize torture testing themselves; don't override those. + set existing_torture_init [torture-init-done] + if { $existing_torture_init == 0 } { + torture-init + } # Some callers set torture options themselves; don't override those. set existing_torture_options [torture-options-exist] if { $existing_torture_options == 0 } { global DG_TORTURE_OPTIONS - torture-init set-torture-options $DG_TORTURE_OPTIONS } dump-torture-options @@ -160,7 +164,7 @@ proc gfortran-dg-runtest { testcases flags default-extra-flags } { } } - if { $existing_torture_options == 0 } { + if { $existing_torture_init == 0 } { torture-finish } } diff --git a/gcc/testsuite/lib/obj-c++-dg.exp b/gcc/testsuite/lib/obj-c++-dg.exp index 9123240f033..8deaed005dc 100644 --- a/gcc/testsuite/lib/obj-c++-dg.exp +++ b/gcc/testsuite/lib/obj-c++-dg.exp @@ -32,11 +32,15 @@ proc obj-c++-dg-prune { system text } { proc obj-c++-dg-runtest { testcases flags default-extra-flags } { global runtests + # Some callers initialize torture testing themselves; don't override those. + set existing_torture_init [torture-init-done] + if { $existing_torture_init == 0 } { + torture-init + } # Some callers set torture options themselves; don't override those. set existing_torture_options [torture-options-exist] if { $existing_torture_options == 0 } { global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS - torture-init set-torture-options $DG_TORTURE_OPTIONS [list {}] $LTO_TORTURE_OPTIONS } dump-torture-options @@ -67,7 +71,7 @@ proc obj-c++-dg-runtest { testcases flags default-extra-flags } { } } - if { $existing_torture_options == 0 } { + if { $existing_torture_init == 0 } { torture-finish } } \ No newline at end of file diff --git a/gcc/testsuite/lib/objc-dg.exp b/gcc/testsuite/lib/objc-dg.exp index 9ca751c8f48..cf08cdcabbd 100644 --- a/gcc/testsuite/lib/objc-dg.exp +++ b/gcc/testsuite/lib/objc-dg.exp @@ -33,11 +33,15 @@ proc objc-dg-prune { system text } { proc objc-dg-runtest { testcases flags default-extra-flags } { global runtests + # Some callers initialize torture testing themselves; don't override those. + set existing_torture_init [torture-init-done] + if { $existing_torture_init == 0 } { + torture-init + } # Some callers set torture options themselves; don't override those. set existing_torture_options [torture-options-exist] if { $existing_torture_options == 0 } { global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS - torture-init set-torture-options $DG_TORTURE_OPTIONS [list {}] $LTO_TORTURE_OPTIONS } dump-torture-options @@ -68,7 +72,7 @@ proc objc-dg-runtest { testcases flags default-extra-flags } { } } - if { $existing_torture_options == 0 } { + if { $existing_torture_init == 0 } { torture-finish } } diff --git a/gcc/testsuite/lib/torture-options.exp b/gcc/testsuite/lib/torture-options.exp index 394418e9a02..d00d07e9378 100644 --- a/gcc/testsuite/lib/torture-options.exp +++ b/gcc/testsuite/lib/torture-options.exp @@ -51,6 +51,12 @@ proc torture-init { args } { } } +# Return 1 if 'torture-init' has already been done, 0 otherwise. +proc torture-init-done { args } { + global LTO_TORTURE_OPTIONS + return [info exists LTO_TORTURE_OPTIONS] +} + # Return 1 if torture options have already been set, 0 otherwise. proc torture-options-exist { args } { global torture_with_loops