Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8294623

gtests does not work with googletest release-1.12.0+

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 20
    • infrastructure

      The scope of `GTEST_DECLARE_string_(internal_run_death_test)` has been changed in googletest 1.12.0 [1]. So we can see some new compiler errors as below:

      ```
      $ bash configure --with-gtest=/home/dingli/jdk-tools/googletest && make run-test TEST="gtest:all"

      * For target hotspot_variant-server_libjvm_gtest_objs_gtestMain.o:
      In file included from /home/dingli/jdk-tools/googletest/googlemock/include/gmock/internal/gmock-port.h:57,
                       from /home/dingli/jdk-tools/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:49,
                       from /home/dingli/jdk-tools/googletest/googlemock/include/gmock/gmock-actions.h:145,
                       from /home/dingli/jdk-tools/googletest/googlemock/include/gmock/gmock.h:56,
                       from /home/dingli/jdk/test/hotspot/gtest/unittest.hpp:51,
                       from /home/dingli/jdk/test/hotspot/gtest/gtestMain.cpp:39:
      /home/dingli/jdk/test/hotspot/gtest/gtestMain.cpp: In function 'void runUnitTestsInner(int, char**)':
      /home/dingli/jdk-tools/googletest/googletest/include/gtest/internal/gtest-port.h:2181:26: error: 'FLAGS_gtest_internal_run_death_test' is not a member of 'testing::internal'; did you mean 'testing::FLAGS_gtest_internal_run_death_test'?
       2181 | #define GTEST_FLAG(name) FLAGS_gtest_##name
            | ^~~~~~~~~~~~
      /home/dingli/jdk/test/hotspot/gtest/gtestMain.cpp:235:28: note: in expansion of macro 'GTEST_FLAG'
        235 | if (::testing::internal::GTEST_FLAG(internal_run_death_test).length() > 0) {
            | ^~~~~~~~~~
      /home/dingli/jdk-tools/googletest/googletest/include/gtest/internal/gtest-port.h:2181:26: note: 'testing::FLAGS_gtest_internal_run_death_test' declared here
       2181 | #define GTEST_FLAG(name) FLAGS_gtest_##name
         ... (rest of output omitted)
      ```

      I use `GTEST_FLAG_GET` macro to detect googletest version because it was introduced at the same time as the scope of `GTEST_DECLARE_string_(internal_run_death_test)` changed. We can fix it with following patch:

      ```
      diff --git a/test/hotspot/gtest/gtestMain.cpp b/test/hotspot/gtest/gtestMain.cpp
      index e4db3dc9dc5..4ff5d1d4d46 100644
      --- a/test/hotspot/gtest/gtestMain.cpp
      +++ b/test/hotspot/gtest/gtestMain.cpp
      @@ -232,7 +232,11 @@ static void runUnitTestsInner(int argc, char** argv) {
         bool is_vmassert_test = false;
         bool is_othervm_test = false;
         // death tests facility is used for both regular death tests, other vm and vmassert tests
      +#ifndef GTEST_FLAG_GET
         if (::testing::internal::GTEST_FLAG(internal_run_death_test).length() > 0) {
      +#else
      + if (::testing::GTEST_FLAG(internal_run_death_test).length() > 0) {
      +#endif
           // when we execute death test, filter value equals to test name
           const char* test_name = ::testing::GTEST_FLAG(filter).c_str();
           const char* const othervm_suffix = "_other_vm"; // TEST_OTHER_VM
      ```

      [1] https://github.com/google/googletest/commit/977cffc4423a2d6c0df3fc9a7b5253b8f79c3f18

            Unassigned Unassigned
            dzhang Dingli Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: