File: coverage_test.go

package info (click to toggle)
dnss 0.0~git20180721.0.2de63ab0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 232 kB
  • sloc: sh: 246; makefile: 5
file content (39 lines) | stat: -rw-r--r-- 813 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Test file used to build a coverage-enabled binary.
//
// Go lacks support for properly building a coverage binary, it can only build
// coverage test binaries.  As a workaround, we have a test that just runs
// main. We then build a binary of this test, which we use instead of the
// normal binary in integration tests.
//
// This is hacky and horrible.
//
// The test has a build label so it's not accidentally executed during normal
// "go test" invocations.
// +build coveragebin

package main

import (
	"os"
	"os/signal"
	"syscall"
	"testing"
)

func TestRunMain(t *testing.T) {
	done := make(chan bool)

	signals := make(chan os.Signal, 1)
	go func() {
		<-signals
		done <- true
	}()
	signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGTERM)

	go func() {
		main()
		done <- true
	}()

	<-done
}