dlv_test: fix TestChildProcessExitWhenNoDebugInfo to actually test strip binary (#2949)

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
This commit is contained in:
polinasok 2022-03-29 11:01:04 -07:00 committed by GitHub
parent 97405bbdd9
commit 65e03d673d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -295,9 +295,15 @@ func TestChildProcessExitWhenNoDebugInfo(t *testing.T) {
fix := protest.BuildFixture("http_server", protest.LinkStrip) fix := protest.BuildFixture("http_server", protest.LinkStrip)
// dlv exec the binary file and expect error. // dlv exec the binary file and expect error.
if _, err := exec.Command(dlvbin, "exec", fix.Path).CombinedOutput(); err == nil { out, err := exec.Command(dlvbin, "exec", "--headless", "--log", fix.Path).CombinedOutput()
t.Log(string(out))
if err == nil {
t.Fatalf("Expected err when launching the binary without debug info, but got nil") t.Fatalf("Expected err when launching the binary without debug info, but got nil")
} }
// Test only for dlv's prefix of the error like "could not launch process: could not open debug info"
if !strings.Contains(string(out), "could not launch process") {
t.Fatalf("Expected logged error 'could not launch process: ...'")
}
// search the running process named fix.Name // search the running process named fix.Name
cmd := exec.Command("ps", "-aux") cmd := exec.Command("ps", "-aux")