Bug 70688 - [chromium] Manage webkit_unit_tests TestSuite lifetime explicitly in DLL build
Summary: [chromium] Manage webkit_unit_tests TestSuite lifetime explicitly in DLL build
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nat Duca
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-22 19:53 PDT by Nat Duca
Modified: 2011-10-24 12:52 PDT (History)
5 users (show)

See Also:


Attachments
Patch (4.45 KB, patch)
2011-10-22 19:54 PDT, Nat Duca
no flags Details | Formatted Diff | Diff
Patch (5.45 KB, patch)
2011-10-24 10:34 PDT, Nat Duca
no flags Details | Formatted Diff | Diff
Patch (4.42 KB, patch)
2011-10-24 11:49 PDT, Nat Duca
tony: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nat Duca 2011-10-22 19:53:35 PDT
[chromium] Manage TestSuite lifetime explicitly, fixing crash in webkit_unit_tests in DLL build."
Comment 1 Nat Duca 2011-10-22 19:54:03 PDT
Created attachment 112103 [details]
Patch
Comment 2 WebKit Review Bot 2011-10-22 19:57:08 PDT
Attachment 112103 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit/chromium/ChangeLog', u'Sourc..." exit_code: 1

Source/WebKit/chromium/tests/WebUnitTests.h:46:  WEBKIT_EXPORT should only appear in the chromium public directory.  [readability/webkit_export] [5]
Source/WebKit/chromium/tests/WebUnitTests.h:49:  WEBKIT_EXPORT should only appear in the chromium public directory.  [readability/webkit_export] [5]
Source/WebKit/chromium/tests/WebUnitTests.h:52:  WEBKIT_EXPORT should only appear in the chromium public directory.  [readability/webkit_export] [5]
Total errors found: 3 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Nat Duca 2011-10-22 20:00:21 PDT
On component/dll builds, the existing code çreates two test suites -- main() creates a TestSuite, then WebKit::RunAllTests creates another. This leads to two nasty side effects:
- webkit_unit_tests crashes after it runs. The tests show as passing, but then we get a stack dump in ~CommandLine.
- The "real" testsuite thinks it doesn't have a command line. This makes things like --gtest_filter don't work

This patch replaces the RunAllTests with three functions: InitTestSuite,RunAllTests,DeleteTestSuite. This allows the overall main() function to create the suite, initialize webkit support, run the tests, then tear everything down again in the right order.

I'm not sure how to make the style bot happy. Should tests/WebUnitTests.h be in public?
Comment 4 Tony Chang 2011-10-24 10:22:55 PDT
Comment on attachment 112103 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=112103&action=review

> Source/WebKit/chromium/tests/RunAllTests.cpp:47
> +// and run inside awebkit.dll.

Nit: awebkit typo

> Source/WebKit/chromium/tests/WebUnitTests.cpp:38
> +namespace {
> +static TestSuite* testSuite = 0;

Nit: No namespace (it's redundant with static and WebKit style prefers static).

>> Source/WebKit/chromium/tests/WebUnitTests.h:46
>> +WEBKIT_EXPORT void InitTestSuite(int argc, char** argv);
> 
> WEBKIT_EXPORT should only appear in the chromium public directory.  [readability/webkit_export] [5]

We could add a WEBKIT_EXPORT_PRIVATE for these.  See src/net/base/net_export.h for an example of this.
Comment 5 Nat Duca 2011-10-24 10:34:10 PDT
Created attachment 112208 [details]
Patch
Comment 6 WebKit Review Bot 2011-10-24 10:38:47 PDT
Please wait for approval from fishd@chromium.org before submitting because this patch contains changes to the Chromium public API.
Comment 7 Tony Chang 2011-10-24 10:41:49 PDT
LGTM, but let's let Darin review the addition of WEBKIT_EXPORT_PRIVATE.
Comment 8 Darin Fisher (:fishd, Google) 2011-10-24 11:07:55 PDT
Comment on attachment 112208 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=112208&action=review

> Source/WebKit/chromium/public/WebCommon.h:72
> +            #define WEBKIT_EXPORT_PRIVATE __declspec(dllexport)

I don't think WEBKIT_EXPORT_PRIVATE is all that helpful.  I'm also don't
think it is that helpful for net/ to have NET_EXPORT_PRIVATE :)

The only reason we have NET_EXPORT_PRIVATE is because Ricardo took the
time to carefully separate net/ entry points used only by tests from
those used by Chrome.  The downside of this approach is that it is really
hard to maintain.  I would not be surprised to see NET_EXPORT_PRIVATE
being used by Chrome now since there is no mechanism to prevent it.

Let's just stick with WEBKIT_EXPORT.  It is easier to understand.  I'm not
too worried about using it outside of the public/ directory for this one
case.
Comment 9 Nat Duca 2011-10-24 11:49:13 PDT
Created attachment 112220 [details]
Patch
Comment 10 Tony Chang 2011-10-24 11:51:23 PDT
Comment on attachment 112220 [details]
Patch

Feel free to ignore the style bot.  We can fix that the style checker in a follow up bug to ignore the tests directory.
Comment 11 WebKit Review Bot 2011-10-24 11:52:24 PDT
Attachment 112220 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit/chromium/ChangeLog', u'Sourc..." exit_code: 1

Source/WebKit/chromium/tests/WebUnitTests.h:46:  WEBKIT_EXPORT should only appear in the chromium public directory.  [readability/webkit_export] [5]
Source/WebKit/chromium/tests/WebUnitTests.h:49:  WEBKIT_EXPORT should only appear in the chromium public directory.  [readability/webkit_export] [5]
Source/WebKit/chromium/tests/WebUnitTests.h:52:  WEBKIT_EXPORT should only appear in the chromium public directory.  [readability/webkit_export] [5]
Total errors found: 3 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 12 Nat Duca 2011-10-24 12:52:14 PDT
Committed r98269: <http://trac.webkit.org/changeset/98269>