If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

gtest death tests don't work on Windows

RESOLVED FIXED in Firefox 53

Status

Testing
General
RESOLVED FIXED
10 months ago
10 months ago

People

(Reporter: erahm, Assigned: erahm)

Tracking

Trunk
mozilla53
Unspecified
Windows
Points:
---

Firefox Tracking Flags

(firefox53 fixed)

Details

Attachments

(1 attachment)

In bug 1316437 we noticed that death tests don't work on Windows.

Judging from test logs it looked like all gtests would run, it would hit the death test, spawn a new process, all gtests would run, it would hit the death test, spawn a new process, ad infinium.

I'm not sure if it has to do with our hacks to gtest or if it's a bug that's been fixed upstream. To reproduce you can run the windows equivalent of:

> GTEST_ALSO_RUN_DISABLED_TESTS=0 ./mach gtest STLWrapper*
This is almost certainly because Windows lacks fork(), so gtest probably does some fiddling under the hood to re-launch the current process. I don't know that we'll be able to fix this unless gtest offers hooks for customizing that behavior.
(In reply to Ted Mielczarek [:ted.mielczarek] from comment #1)
> This is almost certainly because Windows lacks fork(), so gtest probably
> does some fiddling under the hood to re-launch the current process. I don't
> know that we'll be able to fix this unless gtest offers hooks for
> customizing that behavior.

In theory it's supposed to launch a new process and run the test, so the question is why it's not doing that. I would guess our gtest main hook isn't reading command-line args.
(In reply to Eric Rahm [:erahm] from comment #2)
> (In reply to Ted Mielczarek [:ted.mielczarek] from comment #1)
> > This is almost certainly because Windows lacks fork(), so gtest probably
> > does some fiddling under the hood to re-launch the current process. I don't
> > know that we'll be able to fix this unless gtest offers hooks for
> > customizing that behavior.
> 
> In theory it's supposed to launch a new process and run the test, so the
> question is why it's not doing that. I would guess our gtest main hook isn't
> reading command-line args.

That definitely appears to be the problem, we implement our own main and initialize without passing in args [1], vs the standard gtest main which does [2]. The Windows death test spawns a new process and needs to pass it args indicating this is a child death test [3], but of course those aren't parsed because of [1].

[1] http://searchfox.org/mozilla-central/rev/4b6cab91f93c73ae591dafaea40fd5704b41810e/testing/gtest/mozilla/GTestRunner.cpp#82
[2] http://searchfox.org/mozilla-central/rev/4b6cab91f93c73ae591dafaea40fd5704b41810e/testing/gtest/gtest/src/gtest_main.cc#37
[3] http://searchfox.org/mozilla-central/rev/4b6cab91f93c73ae591dafaea40fd5704b41810e/testing/gtest/gtest/src/gtest-death-test.cc#639-643
https://treeherder.mozilla.org/#/jobs?repo=try&revision=096c1b8440c3
https://treeherder.mozilla.org/#/jobs?repo=try&revision=4d200c3a1d76
Created attachment 8810492 [details] [diff] [review]
Pass command-line args to gtest

MozReview-Commit-ID: 8Xs52E9NnCq
Attachment #8810492 - Flags: review?(ted)
Assignee: nobody → erahm
Status: NEW → ASSIGNED

Comment 7

10 months ago
Comment on attachment 8810492 [details] [diff] [review]
Pass command-line args to gtest

stealing review
Attachment #8810492 - Flags: review?(ted) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/8df58dfdea13c9c79975abb4e0c6514b1b4da5f6
Bug 1316729 - Pass command-line args to gtest. r=ted

Comment 9

10 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/8df58dfdea13
Status: ASSIGNED → RESOLVED
Last Resolved: 10 months ago
status-firefox53: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in before you can comment on or make changes to this bug.