< prev index next >

test/native/unittest.hpp

Print this page
rev 11753 : 8159817: Convert FreeRegionList_test to GTest
Reviewed-by: duke

*** 51,88 **** #define TEST_VM_F(test_fixture, name) \ GTEST_TEST_(test_fixture, name ## _test_vm, test_fixture, \ ::testing::internal::GetTypeId<test_fixture>()) ! #define TEST_OTHER_VM(category, name) \ static void test_ ## category ## _ ## name ## _(); \ \ static void child_ ## category ## _ ## name ## _() { \ ::testing::GTEST_FLAG(throw_on_failure) = true; \ test_ ## category ## _ ## name ## _(); \ ! fprintf(stderr, "OKIDOKI"); \ exit(0); \ ! } \ \ TEST(category, CONCAT(name, _other_vm)) { \ ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \ ::testing::ExitedWithCode(0), \ ! ".*OKIDOKI.*"); \ } \ \ void test_ ## category ## _ ## name ## _() ! #ifdef ASSERT ! #define TEST_VM_ASSERT(category, name) \ ! static void test_ ## category ## _ ## name ## _(); \ \ ! static void child_ ## category ## _ ## name ## _() { \ ! ::testing::GTEST_FLAG(throw_on_failure) = true; \ ! test_ ## category ## _ ## name ## _(); \ ! exit(0); \ } \ \ TEST(category, CONCAT(name, _vm_assert)) { \ ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \ ::testing::ExitedWithCode(1), \ "assert failed"); \ } \ --- 51,126 ---- #define TEST_VM_F(test_fixture, name) \ GTEST_TEST_(test_fixture, name ## _test_vm, test_fixture, \ ::testing::internal::GetTypeId<test_fixture>()) ! #define str(s) #s ! ! #define TEST_SUCCESS(category, name) \ ! str(category) ":" str(name) ":" "OKIDOKI" ! ! #define CHILD_VM(category, name) \ static void test_ ## category ## _ ## name ## _(); \ \ static void child_ ## category ## _ ## name ## _() { \ ::testing::GTEST_FLAG(throw_on_failure) = true; \ test_ ## category ## _ ## name ## _(); \ ! fprintf(stderr, "%s", TEST_SUCCESS(category, name)); \ exit(0); \ ! } ! ! #define TEST_OTHER_VM(category, name) \ ! CHILD_VM(category, name) \ \ TEST(category, CONCAT(name, _other_vm)) { \ ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \ ::testing::ExitedWithCode(0), \ ! ".*" TEST_SUCCESS(category, name) ".*"); \ } \ \ void test_ ## category ## _ ## name ## _() ! #define TEST_OTHER_VM_WITH_FLAGS(category, name, flags) \ \ ! CHILD_VM(category, name) \ ! \ ! TEST(category, CONCAT(name, _other_vm_with_flags)) { \ ! const char *old_flags = getenv("_JAVA_OPTIONS"); \ ! const char *safe_old_flags = \ ! (old_flags == NULL) ? "" : old_flags; \ ! const char *safe_new_flags = (flags == NULL) ? "" : flags; \ ! const size_t new_options_len = strlen("_JAVA_OPTIONS=") \ ! + strlen(safe_new_flags) + 1; \ ! \ ! char *new_options = (char*) malloc(new_options_len); \ ! jio_snprintf(new_options, new_options_len, "_JAVA_OPTIONS=%s", \ ! safe_new_flags); \ ! ASSERT_EQ(putenv(new_options), 0) \ ! << "Unable to setup new flags: " << new_options \ ! << "; errno = " << errno; \ ! \ ! ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \ ! ::testing::ExitedWithCode(0), \ ! ".*" TEST_SUCCESS(category, name) ".*"); \ ! \ ! const size_t stored_options_len = strlen("_JAVA_OPTIONS=") \ ! + strlen(safe_old_flags) + 1; \ ! char *stored_options = (char*) malloc (stored_options_len); \ ! jio_snprintf(stored_options, stored_options_len, \ ! "_JAVA_OPTIONS=%s", safe_old_flags); \ ! \ ! ASSERT_EQ(putenv(stored_options), 0) \ ! << "Unable to restore flags: " << stored_options \ ! << "; errno = " << errno; \ } \ \ + void test_ ## category ## _ ## name ## _() + + #ifdef ASSERT + #define TEST_VM_ASSERT(category, name) \ + CHILD_VM(category, name) \ + \ TEST(category, CONCAT(name, _vm_assert)) { \ ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \ ::testing::ExitedWithCode(1), \ "assert failed"); \ } \
*** 93,109 **** TEST_VM_ASSERT is only available in debug builds #endif #ifdef ASSERT #define TEST_VM_ASSERT_MSG(category, name, msg) \ ! static void test_ ## category ## _ ## name ## _(); \ ! \ ! static void child_ ## category ## _ ## name ## _() { \ ! ::testing::GTEST_FLAG(throw_on_failure) = true; \ ! test_ ## category ## _ ## name ## _(); \ ! exit(0); \ ! } \ \ TEST(category, CONCAT(name, _vm_assert)) { \ ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \ ::testing::ExitedWithCode(1), \ "assert failed: " msg); \ --- 131,141 ---- TEST_VM_ASSERT is only available in debug builds #endif #ifdef ASSERT #define TEST_VM_ASSERT_MSG(category, name, msg) \ ! CHILD_VM(category, name) \ \ TEST(category, CONCAT(name, _vm_assert)) { \ ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \ ::testing::ExitedWithCode(1), \ "assert failed: " msg); \
< prev index next >