package sysdig_test import ( "flag" "fmt" "io/ioutil" "os" "path/filepath" "reflect" "runtime" "testing" "github.com/mic92/callgraph/sysdig" ) func assert(tb testing.TB, condition bool, msg string, v ...interface{}) { if !condition { _, file, line, _ := runtime.Caller(1) fmt.Printf("\033[31m%s:%d: "+msg+"\033[39m\n\n", append([]interface{}{filepath.Base(file), line}, v...)...) tb.FailNow() } } func ok(tb testing.TB, err error) { if err != nil { _, file, line, _ := runtime.Caller(1) fmt.Printf("\033[31m%s:%d: unexpected error: %s\033[39m\n\n", filepath.Base(file), line, err.Error()) tb.FailNow() } } func equals(tb testing.TB, exp, act interface{}) { if !reflect.DeepEqual(exp, act) { _, file, line, _ := runtime.Caller(1) fmt.Printf("\033[31m%s:%d:\n\n\texp: %#v\n\n\tgot: %#v\033[39m\n\n", filepath.Base(file), line, exp, act) tb.FailNow() } } var ( cwd_arg = flag.String("cwd", "", "set cwd") ) func init() { flag.Parse() if *cwd_arg != "" { if err := os.Chdir(*cwd_arg); err != nil { fmt.Println("Chdir error:", err) } } } func TestPrintGraph(t *testing.T) { f, e := os.Open("./captured-connections.tsv") ok(t, e) c, e := ioutil.ReadAll(f) ok(t, e) _, e = sysdig.ParseOutput(string(c)) ok(t, e) //(sysdig.Records(r)).PrintGraph() //t.Fatal() }