aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/disable_werror_flag_test.go
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-03-11 02:05:40 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-03-11 02:05:40 +0000
commitd5c05e19bb94a877ee8bbf36811a44d4969b9f46 (patch)
tree73936aba47fe1dc71e9cc05af9747036e935608c /compiler_wrapper/disable_werror_flag_test.go
parent0a2e146349f3b643b1a905928e4658aab1f5cba6 (diff)
parent898f8d62d1305674635d1e341b5839154d4e6acd (diff)
downloadtoolchain-utils-android12-d1-s5-release.tar.gz
Change-Id: Iabe2625a82e68fd0731085e9dfe8c0b5cb8abab3
Diffstat (limited to 'compiler_wrapper/disable_werror_flag_test.go')
-rw-r--r--compiler_wrapper/disable_werror_flag_test.go65
1 files changed, 65 insertions, 0 deletions
diff --git a/compiler_wrapper/disable_werror_flag_test.go b/compiler_wrapper/disable_werror_flag_test.go
index ecc1090b..0c43dbe0 100644
--- a/compiler_wrapper/disable_werror_flag_test.go
+++ b/compiler_wrapper/disable_werror_flag_test.go
@@ -500,3 +500,68 @@ func TestClangTidyDoubleBuildClangError(t *testing.T) {
}
})
}
+
+func TestProcPidStatParsingWorksAsIntended(t *testing.T) {
+ t.Parallel()
+
+ type expected struct {
+ parent int
+ ok bool
+ }
+
+ testCases := []struct {
+ input string
+ expected expected
+ }{
+ {
+ input: "2556041 (cat) R 2519408 2556041 2519408 34818 2556041 4194304",
+ expected: expected{
+ parent: 2519408,
+ ok: true,
+ },
+ },
+ {
+ input: "2556041 (c a t) R 2519408 2556041 2519408 34818 2556041 4194304",
+ expected: expected{
+ parent: 2519408,
+ ok: true,
+ },
+ },
+ {
+ input: "",
+ expected: expected{
+ ok: false,
+ },
+ },
+ {
+ input: "foo (bar)",
+ expected: expected{
+ ok: false,
+ },
+ },
+ {
+ input: "foo (bar) baz",
+ expected: expected{
+ ok: false,
+ },
+ },
+ {
+ input: "foo (bar) baz 1qux2",
+ expected: expected{
+ ok: false,
+ },
+ },
+ }
+
+ for _, tc := range testCases {
+ parent, ok := parseParentPidFromPidStat(tc.input)
+ if tc.expected.ok != ok {
+ t.Errorf("Got ok=%v when parsing %q; expected %v", ok, tc.input, tc.expected.ok)
+ continue
+ }
+
+ if tc.expected.parent != parent {
+ t.Errorf("Got parent=%v when parsing %q; expected %v", parent, tc.input, tc.expected.parent)
+ }
+ }
+}