@@ -8,6 +8,7 @@ use std::*;
88use fail:: fail_point;
99
1010#[ test]
11+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
1112fn test_off ( ) {
1213 let f = || {
1314 fail_point ! ( "off" , |_| 2 ) ;
@@ -21,6 +22,7 @@ fn test_off() {
2122
2223#[ test]
2324#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
25+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
2426fn test_return ( ) {
2527 let f = || {
2628 fail_point ! ( "return" , |s: Option <String >| s
@@ -38,6 +40,7 @@ fn test_return() {
3840
3941#[ test]
4042#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
43+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
4144fn test_sleep ( ) {
4245 let f = || {
4346 fail_point ! ( "sleep" ) ;
@@ -55,6 +58,7 @@ fn test_sleep() {
5558#[ test]
5659#[ should_panic]
5760#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
61+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
5862fn test_panic ( ) {
5963 let f = || {
6064 fail_point ! ( "panic" ) ;
@@ -65,6 +69,7 @@ fn test_panic() {
6569
6670#[ test]
6771#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
72+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
6873fn test_print ( ) {
6974 struct LogCollector ( Arc < Mutex < Vec < String > > > ) ;
7075 impl log:: Log for LogCollector {
@@ -99,6 +104,7 @@ fn test_print() {
99104
100105#[ test]
101106#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
107+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
102108fn test_pause ( ) {
103109 let f = || {
104110 fail_point ! ( "pause" ) ;
@@ -131,6 +137,7 @@ fn test_pause() {
131137}
132138
133139#[ test]
140+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
134141fn test_yield ( ) {
135142 let f = || {
136143 fail_point ! ( "yield" ) ;
@@ -141,6 +148,7 @@ fn test_yield() {
141148
142149#[ test]
143150#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
151+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
144152fn test_callback ( ) {
145153 let f1 = || {
146154 fail_point ! ( "cb" ) ;
@@ -162,6 +170,7 @@ fn test_callback() {
162170
163171#[ test]
164172#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
173+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
165174fn test_delay ( ) {
166175 let f = || fail_point ! ( "delay" ) ;
167176 let timer = Instant :: now ( ) ;
@@ -172,6 +181,7 @@ fn test_delay() {
172181
173182#[ test]
174183#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
184+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
175185fn test_freq_and_count ( ) {
176186 let f = || {
177187 fail_point ! ( "freq_and_count" , |s: Option <String >| s
@@ -193,6 +203,7 @@ fn test_freq_and_count() {
193203
194204#[ test]
195205#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
206+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
196207fn test_condition ( ) {
197208 let f = |_enabled| {
198209 fail_point ! ( "condition" , _enabled, |_| 2 ) ;
@@ -214,3 +225,43 @@ fn test_list() {
214225 fail:: cfg ( "list" , "return" ) . unwrap ( ) ;
215226 assert ! ( fail:: list( ) . contains( & ( "list" . to_string( ) , "return" . to_string( ) ) ) ) ;
216227}
228+
229+ #[ cfg( feature = "crate-isolation" ) ]
230+ #[ test]
231+ #[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
232+ fn test_crate_isolation_return_parse ( ) {
233+ let f = || {
234+ fail_point ! ( "isolated_return_parse" , |s: Option <String >| s
235+ . map_or( 2 , |s| s. parse( ) . unwrap( ) ) ) ;
236+ 0
237+ } ;
238+ assert_eq ! ( f( ) , 0 ) ;
239+
240+ fail:: cfg ( "isolated_return_parse" , "return(1000)" ) . unwrap ( ) ;
241+ assert_eq ! ( f( ) , 0 ) ;
242+
243+ fail:: cfg ( "fail::isolated_return_parse" , "return(1000)" ) . unwrap ( ) ;
244+ assert_eq ! ( f( ) , 1000 ) ;
245+
246+ fail:: cfg ( "fail::isolated_return_parse" , "return" ) . unwrap ( ) ;
247+ assert_eq ! ( f( ) , 2 ) ;
248+ }
249+
250+ #[ cfg( feature = "crate-isolation" ) ]
251+ #[ test]
252+ #[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
253+ fn test_crate_isolation_return_default ( ) {
254+ let f = || {
255+ fail_point ! ( "isolated_return_default" ) ;
256+ 0
257+ } ;
258+ assert_eq ! ( f( ) , 0 ) ;
259+
260+ fail:: cfg ( "isolated_return_default" , "return(1000)" ) . unwrap ( ) ;
261+ let result = std:: panic:: catch_unwind ( f)
262+ . expect ( "callback should not panic as fail point should not be set" ) ;
263+ assert_eq ! ( result, 0 ) ;
264+
265+ fail:: cfg ( "fail::isolated_return_default" , "return(1000)" ) . unwrap ( ) ;
266+ std:: panic:: catch_unwind ( f) . expect_err ( "callback should panic as fail point is set" ) ;
267+ }
0 commit comments