MCPcopy Index your code
hub / github.com/foxcpp/maddy / Run

Method Run

tests/t.go:306–357  ·  view source on GitHub ↗

Run completes the configuration of test environment and starts the test server. T.Close should be called by the end of test to release any resources and shutdown the server. The parameter waitListeners specifies the amount of listeners the server is supposed to configure. Run() will block before a

(waitListeners int)

Source from the content-addressed store, hash-verified

304// The parameter waitListeners specifies the amount of listeners the server is
305// supposed to configure. Run() will block before all of them are up.
306func (t *T) Run(waitListeners int) {
307 t.ensureCanRun()
308 cmd := t.buildCmd("run")
309
310 // Capture maddy log and redirect it.
311 logOut, err := cmd.StderrPipe()
312 if err != nil {
313 t.Fatal("Test configuration failed:", err)
314 }
315
316 t.Log("launching maddy", cmd.Args)
317 if err := cmd.Start(); err != nil {
318 t.Fatal("Test configuration failed:", err)
319 }
320
321 serverStarted := make(chan bool)
322
323 go func() {
324 defer close(serverStarted)
325 scnr := bufio.NewScanner(logOut)
326 for scnr.Scan() {
327 line := scnr.Text()
328
329 t.Log("maddy:", line)
330
331 if strings.HasPrefix(line, "server started") {
332 serverStarted <- true
333 }
334
335 if strings.HasPrefix(line, "new server started") {
336 select {
337 case t.reloadedChan <- struct{}{}:
338 t.Log("server reload confirmed, continuing test")
339 default:
340 t.Log("unexpected reloads detected")
341 t.Fail()
342 }
343 }
344 }
345 if err := scnr.Err(); err != nil {
346 t.Log("stderr I/O error:", err)
347 }
348 }()
349
350 if !<-serverStarted {
351 t.Fatal("Log ended before all expected listeners are up. Start-up error?")
352 }
353
354 t.servProc = cmd
355
356 t.Cleanup(t.killServer)
357}
358
359func (t *T) StateDir() string {
360 return filepath.Join(t.testDir, "statedir")

Callers 15

TestConcurrencyLimitFunction · 0.95
TestPerIPConcurrencyFunction · 0.95
TestImapsqlDeliveryFunction · 0.95
TestImapsqlDeliveryMapFunction · 0.95
TestImapsqlAuthMapFunction · 0.95
TestLMTPClient_Issue308Function · 0.95
TestLDAPInjectionFilterFunction · 0.95
TestDovecotSASLClientFunction · 0.95

Calls 4

ensureCanRunMethod · 0.95
buildCmdMethod · 0.95
ErrMethod · 0.80
StartMethod · 0.65

Tested by 15

TestConcurrencyLimitFunction · 0.76
TestPerIPConcurrencyFunction · 0.76
TestImapsqlDeliveryFunction · 0.76
TestImapsqlDeliveryMapFunction · 0.76
TestImapsqlAuthMapFunction · 0.76
TestLMTPClient_Issue308Function · 0.76
TestLDAPInjectionFilterFunction · 0.76
TestDovecotSASLClientFunction · 0.76