Exemple #1
0
func TestSymbolizeApple(t *testing.T) {
	files := []string{
		"crash_10.6_v6.crash",
		"crash_10.7_v9.crash",
		"crash_10.8_v10.crash",
		"crash_10.8_v10_2.crash",
		"crash_10.9_v11.crash",
		"crash_iOS6_v104.crash",
		"crash_iOS7_v104.crash",
		"hang_10.7_v7.crash",
		"hang_10.8_v7.crash",
		"hang_10.9_v18.crash",
	}

	for _, input := range files {
		inputData, err := testutils.ReadSourceFile(testdata(input))
		if err != nil {
			t.Errorf("Failed to read file: %v", err)
			continue
		}

		tables := []breakpad.SymbolTable{
			&testTable{name: "Chrome", symbol: "ChromeiOS"},
			&testTable{name: "Google Chrome Framework", symbol: "Framework"},
			&testTable{name: "Google Chrome Canary", symbol: "Chrome"},
		}

		parser := NewAppleParser()
		err = parser.ParseInput(string(inputData))
		if err != nil {
			t.Errorf("%s: %s", input, err)
			continue
		}

		// Write the output to a .actual file, which can be used to create a new baseline
		// .expected file by copying it into the testdata/ directory.

		actual := parser.Symbolize(tables)
		actualFileName, actualFile, err := testutils.CreateTempFile(input + ".actual")
		if err != nil {
			t.Errorf("Could not create actual file output: %v", err)
			continue
		}
		fmt.Fprint(actualFile, actual)
		actualFile.Close()

		expectedFileName := testutils.GetSourceFilePath(testdata(input + ".expected"))
		err = testutils.CheckFilesEqual(expectedFileName, actualFileName)
		if err != nil {
			t.Errorf("Input data for %s does not symbolize to expected output", input)
			t.Error(err)
		}
	}
}
Exemple #2
0
// TestSymbolizeAndroid tests the symbolize function of androidParser.  This function
// is almost identical to the TestSymbolize function in input_apple_test.go.
func TestSymbolizeAndroid(t *testing.T) {
	files := []string{
		"android1.txt",
		"android2.txt",
	}

	for _, file := range files {
		var testmod testModuleInfoServiceAndroid

		inputData, err := testutils.ReadSourceFile(testdata(file))
		if err != nil {
			t.Errorf("Failed to read file : " + file)
			continue
		}

		tables := []breakpad.SymbolTable{
			&testTable{name: "libchromeview.so", symbol: "Framework"},
		}

		parser := NewAndroidParser(context.Background(), &testmod, "")
		err = parser.ParseInput(string(inputData))
		if err != nil {
			t.Errorf("%s: %s", file, err)
			continue
		}

		// Write the output to a .actual file, which can be used to create a new baseline
		// .expected file by copying it into the testdata/ directory.

		actual := parser.Symbolize(tables)
		actualFileName, actualFile, err := testutils.CreateTempFile(file + ".actual")
		if err != nil {
			t.Errorf("Could not create actual file output: %v", err)
			continue
		}
		fmt.Fprint(actualFile, actual)
		actualFile.Close()

		expectedFileName := testutils.GetSourceFilePath(testdata(file + ".expected"))
		err = testutils.CheckFilesEqual(expectedFileName, actualFileName)
		if err != nil {
			t.Errorf("Input data for %s does not symbolize to expected output", file)
			t.Error(err)
		}
	}
}