var remasterflag … func TestFuncProperties(t *testing.T) { … } func propBitsToString[T interface{ … } func compareEntries(t *testing.T, tc string, dentry *fnInlHeur, dcsites encodedCallSiteTab, eentry *fnInlHeur, ecsites encodedCallSiteTab) { … } type dumpReader … // readDump reads in the contents of a dump file produced // by the "-d=dumpinlfuncprops=..." command line flag by the Go // compiler. It breaks the dump down into separate sections // by function, then deserializes each func section into a // fnInlHeur object and returns a slice of those objects. func readDump(t *testing.T, path string) ([]fnInlHeur, []encodedCallSiteTab, error) { … } func (dr *dumpReader) scan() bool { … } func (dr *dumpReader) curLine() string { … } // readObjBlob reads in a series of commented lines until // it hits a delimiter, then returns the contents of the comments. func (dr *dumpReader) readObjBlob(delim string) (string, error) { … } // readEntry reads a single function's worth of material from // a file produced by the "-d=dumpinlfuncprops=..." command line // flag. It deserializes the json for the func properties and // returns the resulting properties and function name. EOF is // signaled by a nil FuncProps return (with no error func (dr *dumpReader) readEntry() (fnInlHeur, encodedCallSiteTab, error) { … } // gatherPropsDumpForFile builds the specified testcase 'testcase' from // testdata/props passing the "-d=dumpinlfuncprops=..." compiler option, // to produce a properties dump, then returns the path of the newly // created file. NB: we can't use "go tool compile" here, since // some of the test cases import stdlib packages (such as "os"). // This means using "go build", which is problematic since the // Go command can potentially cache the results of the compile step, // causing the test to fail when being run interactively. E.g. // // $ rm -f dump.txt // $ go build -o foo.a -gcflags=-d=dumpinlfuncprops=dump.txt foo.go // $ rm -f dump.txt foo.a // $ go build -o foo.a -gcflags=-d=dumpinlfuncprops=dump.txt foo.go // $ ls foo.a dump.txt > /dev/null // ls : cannot access 'dump.txt': No such file or directory // $ // // For this reason, pick a unique filename for the dump, so as to // defeat the caching. func gatherPropsDumpForFile(t *testing.T, testcase string, td string) (string, error) { … } // genExpected reads in a given Go testcase file, strips out all the // unindented (column 0) commands, writes them out to a new file, and // returns the path of that new file. By picking out just the comments // from the Go file we wind up with something that resembles the // output from a "-d=dumpinlfuncprops=..." compilation. func genExpected(td string, testcase string) (string, error) { … } type upexState … func mkUpexState(dentries []fnInlHeur) *upexState { … } // updateExpected takes a given Go testcase file X.go and writes out a // new/updated version of the file to X.go.new, where the column-0 // "expected" comments have been updated using fresh data from // "dentries". // // Writing of expected results is complicated by closures and by // generics, where you can have multiple functions that all share the // same starting line. Currently we combine up all the dups and // closures into the single pre-func comment. func updateExpected(t *testing.T, testcase string, dentries []fnInlHeur, dcsites []encodedCallSiteTab) { … } // interestingToCompare returns TRUE if we want to compare results // for function 'fname'. func interestingToCompare(fname string) bool { … }