RFR: 8149591 - Prepare hotspot for GTest

Jesper Wilhelmsson jesper.wilhelmsson at oracle.com
Thu Feb 11 00:34:13 UTC 2016


Den 11/2/16 kl. 00:40, skrev Kim Barrett:
>> On Feb 10, 2016, at 2:47 PM, Jesper Wilhelmsson <jesper.wilhelmsson at oracle.com> wrote:
>>
>> Hi,
>>
>> Please review this change to prepare the Hotspot code for the Google unit test framework. From the RFE:
>>
>> A few changes are needed in the hotspot code to start using the Google Test framework.
>>
>> 1. The new() operator as defined in allocation.cpp can not be used together with GTest. This needs to be moved to a separate file so that we can avoid compiling it when building the GTest enabled JVM.
>>
>> 2. In management.cpp there is a local variable called err_msg. This variable is shadowing a global variable in debug.hpp. In the GTest work the global err_msg variable is used in the vmassert macro and this creates a conflict with the local variable in management.cpp.
>
> Where does this happen?  The current vmassert macro doesn't use err_msg.
>
> A better way to address this might be to fix the problematic macro.
> For safety, macros whose expansions refer to some namespace-scoped
> name should qualify the reference.

The vmassert macro looks like this with the GTest changes applied:

#define vmassert(p, ...)                                                       \
do {                                                                           \
   if (!(p)) {                                                                  \
     if (is_executing_unit_tests()) {                                           \
       report_assert_msg(err_msg(__VA_ARGS__).buffer());                        \
     }                                                                          \
     report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", __VA_ARGS__); \
     BREAKPOINT;                                                                \
   }                                                                            \
} while (0)

This is done so that the framework can pick up the assertion when running "death 
tests" - tests that are supposed to trigger an assertion.

If there is a better way to implement this I'm open to any suggestions.
/Jesper


>
>>
>> 3. If SuppressFatalErrorMessage is set ALL error messages should be suppressed, even the ones in error_is_suppressed() in debug.cpp.
>>
>> This is what is done by this change.
>>
>> RFE: https://bugs.openjdk.java.net/browse/JDK-8149591
>> Webrev: http://cr.openjdk.java.net/~jwilhelm/8149591/webrev.00/index.html
>>
>> Thanks,
>> /Jesper
>
>


More information about the hotspot-dev mailing list