author | stuefe |
Thu, 28 Feb 2019 14:22:03 +0100 | |
changeset 54011 | 21ea4076a275 |
parent 53573 | 556122252316 |
permissions | -rw-r--r-- |
38255 | 1 |
/* |
49177
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
38255 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
39394 | 24 |
#include "precompiled.hpp" |
49177
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
25 |
#include "memory/resourceArea.hpp" |
38255 | 26 |
#include "runtime/os.hpp" |
49177
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
27 |
#include "utilities/ostream.hpp" |
38255 | 28 |
#include "unittest.hpp" |
29 |
||
42056 | 30 |
static size_t small_page_size() { |
31 |
return os::vm_page_size(); |
|
32 |
} |
|
33 |
||
34 |
static size_t large_page_size() { |
|
35 |
const size_t large_page_size_example = 4 * M; |
|
36 |
return os::page_size_for_region_aligned(large_page_size_example, 1); |
|
37 |
} |
|
38 |
||
38255 | 39 |
TEST_VM(os, page_size_for_region) { |
40 |
size_t large_page_example = 4 * M; |
|
41 |
size_t large_page = os::page_size_for_region_aligned(large_page_example, 1); |
|
42 |
||
43 |
size_t small_page = os::vm_page_size(); |
|
44 |
if (large_page > small_page) { |
|
45 |
size_t num_small_in_large = large_page / small_page; |
|
46 |
size_t page = os::page_size_for_region_aligned(large_page, num_small_in_large); |
|
47 |
ASSERT_EQ(page, small_page) << "Did not get a small page"; |
|
48 |
} |
|
49 |
} |
|
50 |
||
42056 | 51 |
TEST_VM(os, page_size_for_region_aligned) { |
52 |
if (UseLargePages) { |
|
53 |
const size_t small_page = small_page_size(); |
|
54 |
const size_t large_page = large_page_size(); |
|
55 |
||
56 |
if (large_page > small_page) { |
|
57 |
size_t num_small_pages_in_large = large_page / small_page; |
|
58 |
size_t page = os::page_size_for_region_aligned(large_page, num_small_pages_in_large); |
|
59 |
||
60 |
ASSERT_EQ(page, small_page); |
|
61 |
} |
|
62 |
} |
|
63 |
} |
|
64 |
||
65 |
TEST_VM(os, page_size_for_region_alignment) { |
|
66 |
if (UseLargePages) { |
|
67 |
const size_t small_page = small_page_size(); |
|
68 |
const size_t large_page = large_page_size(); |
|
69 |
if (large_page > small_page) { |
|
70 |
const size_t unaligned_region = large_page + 17; |
|
71 |
size_t page = os::page_size_for_region_aligned(unaligned_region, 1); |
|
72 |
ASSERT_EQ(page, small_page); |
|
73 |
||
74 |
const size_t num_pages = 5; |
|
75 |
const size_t aligned_region = large_page * num_pages; |
|
76 |
page = os::page_size_for_region_aligned(aligned_region, num_pages); |
|
77 |
ASSERT_EQ(page, large_page); |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
||
82 |
TEST_VM(os, page_size_for_region_unaligned) { |
|
83 |
if (UseLargePages) { |
|
84 |
// Given exact page size, should return that page size. |
|
85 |
for (size_t i = 0; os::_page_sizes[i] != 0; i++) { |
|
86 |
size_t expected = os::_page_sizes[i]; |
|
87 |
size_t actual = os::page_size_for_region_unaligned(expected, 1); |
|
88 |
ASSERT_EQ(expected, actual); |
|
89 |
} |
|
90 |
||
91 |
// Given slightly larger size than a page size, return the page size. |
|
92 |
for (size_t i = 0; os::_page_sizes[i] != 0; i++) { |
|
93 |
size_t expected = os::_page_sizes[i]; |
|
94 |
size_t actual = os::page_size_for_region_unaligned(expected + 17, 1); |
|
95 |
ASSERT_EQ(expected, actual); |
|
96 |
} |
|
97 |
||
98 |
// Given a slightly smaller size than a page size, |
|
99 |
// return the next smaller page size. |
|
100 |
if (os::_page_sizes[1] > os::_page_sizes[0]) { |
|
101 |
size_t expected = os::_page_sizes[0]; |
|
102 |
size_t actual = os::page_size_for_region_unaligned(os::_page_sizes[1] - 17, 1); |
|
103 |
ASSERT_EQ(actual, expected); |
|
104 |
} |
|
105 |
||
106 |
// Return small page size for values less than a small page. |
|
107 |
size_t small_page = small_page_size(); |
|
108 |
size_t actual = os::page_size_for_region_unaligned(small_page - 17, 1); |
|
109 |
ASSERT_EQ(small_page, actual); |
|
110 |
} |
|
111 |
} |
|
112 |
||
46587
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
113 |
TEST(os, test_random) { |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
114 |
const double m = 2147483647; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
115 |
double mean = 0.0, variance = 0.0, t; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
116 |
const int reps = 10000; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
117 |
unsigned int seed = 1; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
118 |
|
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
119 |
// tty->print_cr("seed %ld for %ld repeats...", seed, reps); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
120 |
os::init_random(seed); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
121 |
int num; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
122 |
for (int k = 0; k < reps; k++) { |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
123 |
num = os::random(); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
124 |
double u = (double)num / m; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
125 |
ASSERT_TRUE(u >= 0.0 && u <= 1.0) << "bad random number!"; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
126 |
|
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
127 |
// calculate mean and variance of the random sequence |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
128 |
mean += u; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
129 |
variance += (u*u); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
130 |
} |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
131 |
mean /= reps; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
132 |
variance /= (reps - 1); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
133 |
|
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
134 |
ASSERT_EQ(num, 1043618065) << "bad seed"; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
135 |
// tty->print_cr("mean of the 1st 10000 numbers: %f", mean); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
136 |
int intmean = mean*100; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
137 |
ASSERT_EQ(intmean, 50); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
138 |
// tty->print_cr("variance of the 1st 10000 numbers: %f", variance); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
139 |
int intvariance = variance*100; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
140 |
ASSERT_EQ(intvariance, 33); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
141 |
const double eps = 0.0001; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
142 |
t = fabsd(mean - 0.5018); |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
143 |
ASSERT_LT(t, eps) << "bad mean"; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
144 |
t = (variance - 0.3355) < 0.0 ? -(variance - 0.3355) : variance - 0.3355; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
145 |
ASSERT_LT(t, eps) << "bad variance"; |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
146 |
} |
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
147 |
|
6c97f34cb194
8182554: Code for os::random() assumes long is 32 bits
coleenp
parents:
42056
diff
changeset
|
148 |
|
38255 | 149 |
#ifdef ASSERT |
150 |
TEST_VM_ASSERT_MSG(os, page_size_for_region_with_zero_min_pages, "sanity") { |
|
151 |
size_t region_size = 16 * os::vm_page_size(); |
|
152 |
os::page_size_for_region_aligned(region_size, 0); // should assert |
|
153 |
} |
|
154 |
#endif |
|
49177
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
155 |
|
54011
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
156 |
static void do_test_print_hex_dump(address addr, size_t len, int unitsize, const char* expected) { |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
157 |
char buf[256]; |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
158 |
buf[0] = '\0'; |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
159 |
stringStream ss(buf, sizeof(buf)); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
160 |
os::print_hex_dump(&ss, addr, addr + len, unitsize); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
161 |
// tty->print_cr("expected: %s", expected); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
162 |
// tty->print_cr("result: %s", buf); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
163 |
ASSERT_NE(strstr(buf, expected), (char*)NULL); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
164 |
} |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
165 |
|
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
166 |
TEST_VM(os, test_print_hex_dump) { |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
167 |
const char* pattern [4] = { |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
168 |
#ifdef VM_LITTLE_ENDIAN |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
169 |
"00 01 02 03 04 05 06 07", |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
170 |
"0100 0302 0504 0706", |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
171 |
"03020100 07060504", |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
172 |
"0706050403020100" |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
173 |
#else |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
174 |
"00 01 02 03 04 05 06 07", |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
175 |
"0001 0203 0405 0607", |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
176 |
"00010203 04050607", |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
177 |
"0001020304050607" |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
178 |
#endif |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
179 |
}; |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
180 |
|
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
181 |
const char* pattern_not_readable [4] = { |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
182 |
"?? ?? ?? ?? ?? ?? ?? ??", |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
183 |
"???? ???? ???? ????", |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
184 |
"???????? ????????", |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
185 |
"????????????????" |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
186 |
}; |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
187 |
|
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
188 |
// On AIX, zero page is readable. |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
189 |
address unreadable = |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
190 |
#ifdef AIX |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
191 |
(address) 0xFFFFFFFFFFFF0000ULL; |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
192 |
#else |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
193 |
(address) 0 |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
194 |
#endif |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
195 |
; |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
196 |
|
53573
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
51277
diff
changeset
|
197 |
ResourceMark rm; |
54011
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
198 |
char buf[64]; |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
199 |
stringStream ss(buf, sizeof(buf)); |
53573
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
51277
diff
changeset
|
200 |
outputStream* out = &ss; |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
51277
diff
changeset
|
201 |
// outputStream* out = tty; // enable for printout |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
51277
diff
changeset
|
202 |
|
54011
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
203 |
// Test dumping unreadable memory |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
204 |
// Exclude test for Windows for now, since it needs SEH handling to work which cannot be |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
205 |
// guaranteed when we call directly into VM code. (see JDK-8220220) |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
206 |
#ifndef _WIN32 |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
207 |
do_test_print_hex_dump(unreadable, 100, 1, pattern_not_readable[0]); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
208 |
do_test_print_hex_dump(unreadable, 100, 2, pattern_not_readable[1]); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
209 |
do_test_print_hex_dump(unreadable, 100, 4, pattern_not_readable[2]); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
210 |
do_test_print_hex_dump(unreadable, 100, 8, pattern_not_readable[3]); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
211 |
#endif |
53573
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
51277
diff
changeset
|
212 |
|
54011
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
213 |
// Test dumping readable memory |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
214 |
address arr = (address)os::malloc(100, mtInternal); |
53573
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
51277
diff
changeset
|
215 |
for (int c = 0; c < 100; c++) { |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
51277
diff
changeset
|
216 |
arr[c] = c; |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
51277
diff
changeset
|
217 |
} |
54011
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
218 |
|
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
219 |
// properly aligned |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
220 |
do_test_print_hex_dump(arr, 100, 1, pattern[0]); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
221 |
do_test_print_hex_dump(arr, 100, 2, pattern[1]); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
222 |
do_test_print_hex_dump(arr, 100, 4, pattern[2]); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
223 |
do_test_print_hex_dump(arr, 100, 8, pattern[3]); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
224 |
|
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
225 |
// Not properly aligned. Should automatically down-align by unitsize |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
226 |
do_test_print_hex_dump(arr + 1, 100, 2, pattern[1]); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
227 |
do_test_print_hex_dump(arr + 1, 100, 4, pattern[2]); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
228 |
do_test_print_hex_dump(arr + 1, 100, 8, pattern[3]); |
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
229 |
|
21ea4076a275
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump"
stuefe
parents:
53573
diff
changeset
|
230 |
os::free(arr); |
53573
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
51277
diff
changeset
|
231 |
} |
556122252316
8217994: os::print_hex_dump should be more resilient against unreadable memory
shade
parents:
51277
diff
changeset
|
232 |
|
49177
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
233 |
////////////////////////////////////////////////////////////////////////////// |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
234 |
// Test os::vsnprintf and friends. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
235 |
|
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
236 |
static void check_snprintf_result(int expected, size_t limit, int actual, bool expect_count) { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
237 |
if (expect_count || ((size_t)expected < limit)) { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
238 |
ASSERT_EQ(expected, actual); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
239 |
} else { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
240 |
ASSERT_GT(0, actual); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
241 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
242 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
243 |
|
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
244 |
// PrintFn is expected to be int (*)(char*, size_t, const char*, ...). |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
245 |
// But jio_snprintf is a C-linkage function with that signature, which |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
246 |
// has a different type on some platforms (like Solaris). |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
247 |
template<typename PrintFn> |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
248 |
static void test_snprintf(PrintFn pf, bool expect_count) { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
249 |
const char expected[] = "abcdefghijklmnopqrstuvwxyz"; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
250 |
const int expected_len = sizeof(expected) - 1; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
251 |
const size_t padding_size = 10; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
252 |
char buffer[2 * (sizeof(expected) + padding_size)]; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
253 |
char check_buffer[sizeof(buffer)]; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
254 |
const char check_char = '1'; // Something not in expected. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
255 |
memset(check_buffer, check_char, sizeof(check_buffer)); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
256 |
const size_t sizes_to_test[] = { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
257 |
sizeof(buffer) - padding_size, // Fits, with plenty of space to spare. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
258 |
sizeof(buffer)/2, // Fits, with space to spare. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
259 |
sizeof(buffer)/4, // Doesn't fit. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
260 |
sizeof(expected) + padding_size + 1, // Fits, with a little room to spare |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
261 |
sizeof(expected) + padding_size, // Fits exactly. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
262 |
sizeof(expected) + padding_size - 1, // Doesn't quite fit. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
263 |
2, // One char + terminating NUL. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
264 |
1, // Only space for terminating NUL. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
265 |
0 }; // No space at all. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
266 |
for (unsigned i = 0; i < ARRAY_SIZE(sizes_to_test); ++i) { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
267 |
memset(buffer, check_char, sizeof(buffer)); // To catch stray writes. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
268 |
size_t test_size = sizes_to_test[i]; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
269 |
ResourceMark rm; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
270 |
stringStream s; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
271 |
s.print("test_size: " SIZE_FORMAT, test_size); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
272 |
SCOPED_TRACE(s.as_string()); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
273 |
size_t prefix_size = padding_size; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
274 |
guarantee(test_size <= (sizeof(buffer) - prefix_size), "invariant"); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
275 |
size_t write_size = MIN2(sizeof(expected), test_size); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
276 |
size_t suffix_size = sizeof(buffer) - prefix_size - write_size; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
277 |
char* write_start = buffer + prefix_size; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
278 |
char* write_end = write_start + write_size; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
279 |
|
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
280 |
int result = pf(write_start, test_size, "%s", expected); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
281 |
|
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
282 |
check_snprintf_result(expected_len, test_size, result, expect_count); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
283 |
|
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
284 |
// Verify expected output. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
285 |
if (test_size > 0) { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
286 |
ASSERT_EQ(0, strncmp(write_start, expected, write_size - 1)); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
287 |
// Verify terminating NUL of output. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
288 |
ASSERT_EQ('\0', write_start[write_size - 1]); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
289 |
} else { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
290 |
guarantee(test_size == 0, "invariant"); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
291 |
guarantee(write_size == 0, "invariant"); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
292 |
guarantee(prefix_size + suffix_size == sizeof(buffer), "invariant"); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
293 |
guarantee(write_start == write_end, "invariant"); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
294 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
295 |
|
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
296 |
// Verify no scribbling on prefix or suffix. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
297 |
ASSERT_EQ(0, strncmp(buffer, check_buffer, prefix_size)); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
298 |
ASSERT_EQ(0, strncmp(write_end, check_buffer, suffix_size)); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
299 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
300 |
|
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
301 |
// Special case of 0-length buffer with empty (except for terminator) output. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
302 |
check_snprintf_result(0, 0, pf(NULL, 0, "%s", ""), expect_count); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
303 |
check_snprintf_result(0, 0, pf(NULL, 0, ""), expect_count); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
304 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
305 |
|
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
306 |
// This is probably equivalent to os::snprintf, but we're being |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
307 |
// explicit about what we're testing here. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
308 |
static int vsnprintf_wrapper(char* buf, size_t len, const char* fmt, ...) { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
309 |
va_list args; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
310 |
va_start(args, fmt); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
311 |
int result = os::vsnprintf(buf, len, fmt, args); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
312 |
va_end(args); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
313 |
return result; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
314 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
315 |
|
51277
dfe1cff5c2f6
8174691: [TESTBUG] A number of native hotspot unit tests fail when executed in stand-alone mode
iignatyev
parents:
49177
diff
changeset
|
316 |
TEST_VM(os, vsnprintf) { |
49177
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
317 |
test_snprintf(vsnprintf_wrapper, true); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
318 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
319 |
|
51277
dfe1cff5c2f6
8174691: [TESTBUG] A number of native hotspot unit tests fail when executed in stand-alone mode
iignatyev
parents:
49177
diff
changeset
|
320 |
TEST_VM(os, snprintf) { |
49177
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
321 |
test_snprintf(os::snprintf, true); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
322 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
323 |
|
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
324 |
// These are declared in jvm.h; test here, with related functions. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
325 |
extern "C" { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
326 |
int jio_vsnprintf(char*, size_t, const char*, va_list); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
327 |
int jio_snprintf(char*, size_t, const char*, ...); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
328 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
329 |
|
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
330 |
// This is probably equivalent to jio_snprintf, but we're being |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
331 |
// explicit about what we're testing here. |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
332 |
static int jio_vsnprintf_wrapper(char* buf, size_t len, const char* fmt, ...) { |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
333 |
va_list args; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
334 |
va_start(args, fmt); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
335 |
int result = jio_vsnprintf(buf, len, fmt, args); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
336 |
va_end(args); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
337 |
return result; |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
338 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
339 |
|
51277
dfe1cff5c2f6
8174691: [TESTBUG] A number of native hotspot unit tests fail when executed in stand-alone mode
iignatyev
parents:
49177
diff
changeset
|
340 |
TEST_VM(os, jio_vsnprintf) { |
49177
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
341 |
test_snprintf(jio_vsnprintf_wrapper, false); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
342 |
} |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
343 |
|
51277
dfe1cff5c2f6
8174691: [TESTBUG] A number of native hotspot unit tests fail when executed in stand-alone mode
iignatyev
parents:
49177
diff
changeset
|
344 |
TEST_VM(os, jio_snprintf) { |
49177
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
345 |
test_snprintf(jio_snprintf, false); |
eebf559c9e0d
8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
kbarrett
parents:
47216
diff
changeset
|
346 |
} |