aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/disable_werror_flag_test.go
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2020-10-16 15:54:21 -0700
committerGeorge Burgess <gbiv@chromium.org>2020-10-23 19:03:34 +0000
commit84b5c8fad9e67e74fd14d26fc45a03329f3d1b56 (patch)
tree8faf49760a232ea83b0364fb4a6e9b4f8a21105b /compiler_wrapper/disable_werror_flag_test.go
parent49187a5efe3ee2e23d99484a1d25500f116dd4f7 (diff)
downloadtoolchain-utils-84b5c8fad9e67e74fd14d26fc45a03329f3d1b56.tar.gz
compiler_wrapper: report parent processes' info in warnings tarballs
The bug I'm chasing down right now depends on environment variables, and could be due to a `make` invocation in one of N places. Having this context available to me is useful. It seriously pollutes the JSON we dump, but use of `jq` that I've put in the doc about this makes that a non-issue. BUG=None TEST=Ran on stress-ng. parent process info was dumped. Change-Id: Ib4d3b6c9887b4cf2a38472ef299c81af27e9a617 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2481829 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Tested-by: George Burgess <gbiv@chromium.org>
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)
+ }
+ }
+}