@@ -588,31 +588,17 @@ func TestAutoPortSelection(t *testing.T) {
588588
589589 defer cm .StopServer ()
590590
591- scanner := bufio .NewScanner (logFile )
592-
593- var contents bytes.Buffer
594-
595- deadline := time .Now ().Add (30 * time .Second )
596-
597- for scanner .Scan () {
598- text := scanner .Text ()
599- contents .WriteString (text )
600-
601- if strings .Contains (text , "port is unspecified" ) {
602- break
603- }
604-
605- if time .Now ().After (deadline ) {
606- t .Fatalf ("timed out waiting for kernel-chosen port log line" )
607- }
608- }
591+ found , err := test .ReadLogFileAndSearchString (logFile .Name (), "port is unspecified" , 30 * time .Second )
592+ So (err , ShouldBeNil )
593+ So (found , ShouldBeTrue )
609594
610- So (scanner .Err (), ShouldBeNil )
611- So (contents .String (), ShouldContainSubstring ,
595+ contents , err := os .ReadFile (logFile .Name ())
596+ So (err , ShouldBeNil )
597+ So (string (contents ), ShouldContainSubstring ,
612598 "port is unspecified, listening on kernel chosen port" ,
613599 )
614- So (contents . String ( ), ShouldContainSubstring , "\" address\" :\" 127.0.0.1\" " )
615- So (contents . String ( ), ShouldContainSubstring , "\" port\" :" )
600+ So (string ( contents ), ShouldContainSubstring , "\" address\" :\" 127.0.0.1\" " )
601+ So (string ( contents ), ShouldContainSubstring , "\" port\" :" )
616602
617603 So (ctlr .GetPort (), ShouldBeGreaterThan , 0 )
618604 So (ctlr .GetPort (), ShouldBeLessThan , 65536 )
0 commit comments