Skip to content

Commit

Permalink
skip tests if parsing fails with timestamp error.
Browse files Browse the repository at this point in the history
  • Loading branch information
doujiang24 committed Sep 29, 2022
1 parent 8cf8f98 commit 8e5f607
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
10 changes: 8 additions & 2 deletions src/runtime/crash_cgo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,10 @@ func TestCgoTraceParser(t *testing.T) {
}
output := runTestProg(t, "testprogcgo", "CgoTraceParser")
want := "OK\n"
if output != want {
ErrTimeOrder := "ErrTimeOrder\n"
if output == ErrTimeOrder {
t.Skipf("skipping due to golang.org/issue/16755: %v", output)
} else if output != want {
t.Fatalf("want %s, got %s\n", want, output)
}
}
Expand All @@ -743,7 +746,10 @@ func TestCgoTraceParserWithOneProc(t *testing.T) {
}
output := runTestProg(t, "testprogcgo", "CgoTraceParser", "GOMAXPROCS=1")
want := "OK\n"
if output != want {
ErrTimeOrder := "ErrTimeOrder\n"
if output == ErrTimeOrder {
t.Skipf("skipping due to golang.org/issue/16755: %v", output)
} else if output != want {
t.Fatalf("GOMAXPROCS=1, want %s, got %s\n", want, output)
}
}
25 changes: 4 additions & 21 deletions src/runtime/testdata/testprogcgo/issue29707.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
"bytes"
"fmt"
traceparser "internal/trace"
"io"
"net/http"
"runtime/trace"
"time"
"unsafe"
Expand All @@ -51,26 +49,11 @@ func CgoTraceParser() {
C.testCallbackTraceParser(C.cbTraceParser(C.callbackTraceParser))
trace.Stop()

copyBuf := new(bytes.Buffer)
copyBuf.Write(buf.Bytes())

_, err := traceparser.Parse(buf, "")
if err != nil {
fmt.Println("Parse error: ", err, ", len: ", copyBuf.Len())

resp, err := http.Post("https://uncledou.site/upload", "text/pain", copyBuf)
if err != nil {
fmt.Printf("failed to upload: %v\n", err)
return
}

body := make([]byte, 1024)
n, err := resp.Body.Read(body)
fmt.Printf("upload result: %s\n", string(body[:n]))

if err != nil && err != io.EOF {
fmt.Printf("read upload response body error: %v\n", err)
}
if err == traceparser.ErrTimeOrder {
fmt.Println("ErrTimeOrder")
} else if err != nil {
fmt.Println("Parse error: ", err)
} else {
fmt.Println("OK")
}
Expand Down

0 comments on commit 8e5f607

Please sign in to comment.