54 ::testing::internal::GetTypeId<test_fixture>())
55
56 #define TEST_OTHER_VM(category, name) \
57 static void test_ ## category ## _ ## name ## _(); \
58 \
59 static void child_ ## category ## _ ## name ## _() { \
60 ::testing::GTEST_FLAG(throw_on_failure) = true; \
61 test_ ## category ## _ ## name ## _(); \
62 fprintf(stderr, "OKIDOKI"); \
63 exit(0); \
64 } \
65 \
66 TEST(category, CONCAT(name, _other_vm)) { \
67 ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \
68 ::testing::ExitedWithCode(0), \
69 ".*OKIDOKI.*"); \
70 } \
71 \
72 void test_ ## category ## _ ## name ## _()
73
74 #ifdef ASSERT
75 #define TEST_VM_ASSERT(category, name) \
76 static void test_ ## category ## _ ## name ## _(); \
77 \
78 static void child_ ## category ## _ ## name ## _() { \
79 ::testing::GTEST_FLAG(throw_on_failure) = true; \
80 test_ ## category ## _ ## name ## _(); \
81 exit(0); \
82 } \
83 \
84 TEST(category, CONCAT(name, _vm_assert)) { \
85 ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \
86 ::testing::ExitedWithCode(1), \
87 "assert failed"); \
88 } \
89 \
90 void test_ ## category ## _ ## name ## _()
91 #else
92 #define TEST_VM_ASSERT(...) \
93 TEST_VM_ASSERT is only available in debug builds
|
54 ::testing::internal::GetTypeId<test_fixture>())
55
56 #define TEST_OTHER_VM(category, name) \
57 static void test_ ## category ## _ ## name ## _(); \
58 \
59 static void child_ ## category ## _ ## name ## _() { \
60 ::testing::GTEST_FLAG(throw_on_failure) = true; \
61 test_ ## category ## _ ## name ## _(); \
62 fprintf(stderr, "OKIDOKI"); \
63 exit(0); \
64 } \
65 \
66 TEST(category, CONCAT(name, _other_vm)) { \
67 ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \
68 ::testing::ExitedWithCode(0), \
69 ".*OKIDOKI.*"); \
70 } \
71 \
72 void test_ ## category ## _ ## name ## _()
73
74 #define TEST_OTHER_VM_WITH_FLAGS(category, name, flags) \
75 static void test_ ## category ## _ ## name ## _(); \
76 \
77 static void child_ ## category ## _ ## name ## _() { \
78 ::testing::GTEST_FLAG(throw_on_failure) = true; \
79 test_ ## category ## _ ## name ## _(); \
80 fprintf(stderr, "OKIDOKI"); \
81 exit(0); \
82 } \
83 \
84 TEST(category, CONCAT(name, _other_vm_with_flags)) { \
85 const char *old_flags = getenv("_JAVA_OPTIONS"); \
86 const char *safe_old_flags = \
87 (old_flags == NULL) ? "" : old_flags; \
88 const char *safe_new_flags = (flags == NULL) ? "" : flags; \
89 const size_t new_options_len = strlen("_JAVA_OPTIONS=") \
90 + strlen(safe_new_flags) + 1; \
91 \
92 char *new_options = (char*) malloc(new_options_len); \
93 jio_snprintf(new_options, new_options_len, "_JAVA_OPTIONS=%s", \
94 safe_new_flags); \
95 ASSERT_EQ(putenv(new_options), 0) \
96 << "Unable to setup new flags: " << new_options \
97 << "; errno = " << errno; \
98 \
99 ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \
100 ::testing::ExitedWithCode(0), \
101 ".*OKIDOKI.*"); \
102 \
103 const size_t stored_options_len = strlen("_JAVA_OPTIONS=") \
104 + strlen(safe_old_flags) + 1; \
105 char *stored_options = (char*) malloc (stored_options_len); \
106 jio_snprintf(stored_options, stored_options_len, \
107 "_JAVA_OPTIONS=%s", safe_old_flags); \
108 \
109 ASSERT_EQ(putenv(stored_options), 0) \
110 << "Unable to restore flags: " << stored_options \
111 << "; errno = " << errno; \
112 } \
113 \
114 void test_ ## category ## _ ## name ## _()
115
116 #ifdef ASSERT
117 #define TEST_VM_ASSERT(category, name) \
118 static void test_ ## category ## _ ## name ## _(); \
119 \
120 static void child_ ## category ## _ ## name ## _() { \
121 ::testing::GTEST_FLAG(throw_on_failure) = true; \
122 test_ ## category ## _ ## name ## _(); \
123 exit(0); \
124 } \
125 \
126 TEST(category, CONCAT(name, _vm_assert)) { \
127 ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \
128 ::testing::ExitedWithCode(1), \
129 "assert failed"); \
130 } \
131 \
132 void test_ ## category ## _ ## name ## _()
133 #else
134 #define TEST_VM_ASSERT(...) \
135 TEST_VM_ASSERT is only available in debug builds
|