@@ -46,7 +46,7 @@ var mkdirAll_MkdirAllHandle mkdirAllFunc = func(t *testing.T, root, unsafePath s
4646 require .NoError (t , err )
4747
4848 // Now double-check that the handle is correct.
49- gotPath , err := procSelfFdReadlink (handle )
49+ gotPath , err := ProcSelfFdReadlink (handle )
5050 require .NoError (t , err , "get real path of returned handle" )
5151 assert .Equal (t , expectedPath , gotPath , "wrong final path from MkdirAllHandle" )
5252 // Also check that the f.Name() is correct while we're at it (this is
@@ -404,9 +404,13 @@ func TestMkdirAllHandle_RacingRename(t *testing.T) { //nolint:revive // undersco
404404 }(rootCh )
405405
406406 // Do several runs to try to catch bugs.
407- const testRuns = 2000
407+ const (
408+ testRuns = 800
409+ minPassCount = 10
410+ )
408411 m := newRacingMkdirMeta ()
409- for i := 0 ; i < testRuns ; i ++ {
412+ doneRuns := 0
413+ for ; doneRuns < testRuns || m .passOkCount < minPassCount ; doneRuns ++ {
410414 root := createTree (t , treeSpec ... )
411415
412416 rootCh <- root
@@ -417,15 +421,26 @@ func TestMkdirAllHandle_RacingRename(t *testing.T) { //nolint:revive // undersco
417421 // Clean up the root after each run so we don't exhaust all
418422 // space in the tmpfs.
419423 _ = os .RemoveAll (root )
424+
425+ // Make sure we don't infinite loop here.
426+ if doneRuns >= 50 * testRuns {
427+ break
428+ }
420429 }
421430
422431 pct := func (count int ) string {
423- return fmt .Sprintf ("%d(%.3f%%)" , count , 100.0 * float64 (count )/ float64 (testRuns ))
432+ return fmt .Sprintf ("%d(%.3f%%)" , count , 100.0 * float64 (count )/ float64 (doneRuns ))
433+ }
434+
435+ // No passing runs is a bit unfortunate, but some of our tests
436+ // can do that and failing here would just lead to flaky tests.
437+ if m .passOkCount == 0 {
438+ t .Logf ("WARNING: NO PASSING RUNS!" )
424439 }
425440
426441 // Output some stats.
427442 t .Logf ("after %d runs: passOk=%s passErr=%s fail=%s" ,
428- testRuns , pct (m .passOkCount ), pct (m .passErrCount ), pct (m .failCount ))
443+ doneRuns , pct (m .passOkCount ), pct (m .passErrCount ), pct (m .failCount ))
429444 if len (m .passErrCounts ) > 0 {
430445 t .Logf (" passErr breakdown:" )
431446 for err , count := range m .passErrCounts {
@@ -475,9 +490,13 @@ func TestMkdirAllHandle_RacingDelete(t *testing.T) { //nolint:revive // undersco
475490 }(rootCh )
476491
477492 // Do several runs to try to catch bugs.
478- const testRuns = 2000
493+ const (
494+ testRuns = 800
495+ minPassCount = 10
496+ )
479497 m := newRacingMkdirMeta ()
480- for i := 0 ; i < testRuns ; i ++ {
498+ doneRuns := 0
499+ for ; doneRuns < testRuns ; doneRuns ++ {
481500 root := createTree (t , treeSpec ... )
482501
483502 rootCh <- root
@@ -487,15 +506,26 @@ func TestMkdirAllHandle_RacingDelete(t *testing.T) { //nolint:revive // undersco
487506 // Clean up the root after each run so we don't exhaust all
488507 // space in the tmpfs.
489508 _ = os .RemoveAll (root + "/.." )
509+
510+ // Make sure we don't infinite loop here.
511+ if doneRuns >= 50 * testRuns {
512+ break
513+ }
490514 }
491515
492516 pct := func (count int ) string {
493- return fmt .Sprintf ("%d(%.3f%%)" , count , 100.0 * float64 (count )/ float64 (testRuns ))
517+ return fmt .Sprintf ("%d(%.3f%%)" , count , 100.0 * float64 (count )/ float64 (doneRuns ))
518+ }
519+
520+ // No passing runs is a bit unfortunate, but some of our tests
521+ // can do that and failing here would just lead to flaky tests.
522+ if m .passOkCount == 0 {
523+ t .Logf ("WARNING: NO PASSING RUNS!" )
494524 }
495525
496526 // Output some stats.
497527 t .Logf ("after %d runs: passOk=%s passErr=%s fail=%s" ,
498- testRuns , pct (m .passOkCount ), pct (m .passErrCount ), pct (m .failCount ))
528+ doneRuns , pct (m .passOkCount ), pct (m .passErrCount ), pct (m .failCount ))
499529 if len (m .passErrCounts ) > 0 {
500530 t .Logf (" passErr breakdown:" )
501531 for err , count := range m .passErrCounts {
0 commit comments