author | coleenp |
Tue, 31 Oct 2017 11:55:09 -0400 | |
changeset 47765 | b7c7428eaab9 |
parent 47216 | 71c04702a3d5 |
child 49180 | 9637557def32 |
permissions | -rw-r--r-- |
41676
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
1 |
/* |
46560
388aa8d67c80
8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
44997
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
41676
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
4 |
* |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
8 |
* |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
44997
3f875168ce21
8179889: Fix typographic errors in copyright headers
ihse
parents:
43431
diff
changeset
|
13 |
* accompanied this code). |
41676
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
14 |
* |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
18 |
* |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
21 |
* questions. |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
22 |
* |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
23 |
*/ |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
24 |
#include "precompiled.hpp" |
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47216
diff
changeset
|
25 |
#include "jvm.h" |
41676
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
26 |
#include "logTestUtils.inline.hpp" |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
27 |
#include "logging/logConfiguration.hpp" |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
28 |
#include "logging/logTagSet.hpp" |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
29 |
#include "logging/logTagSetDescriptions.hpp" |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
30 |
#include "memory/resourceArea.hpp" |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
31 |
#include "unittest.hpp" |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
32 |
#include "utilities/ostream.hpp" |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
33 |
|
43431
5ffa076f526d
8172098: A lot of gtests uses TEST instead of TEST_VM
kzhaldyb
parents:
41676
diff
changeset
|
34 |
TEST_VM(LogTagSetDescriptions, describe) { |
41676
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
35 |
for (LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) { |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
36 |
char expected[1 * K]; |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
37 |
d->tagset->label(expected, sizeof(expected), "+"); |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
38 |
jio_snprintf(expected + strlen(expected), |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
39 |
sizeof(expected) - strlen(expected), |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
40 |
": %s", d->descr); |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
41 |
|
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
42 |
ResourceMark rm; |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
43 |
stringStream stream; |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
44 |
LogConfiguration::describe(&stream); |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
45 |
EXPECT_PRED2(string_contains_substring, stream.as_string(), expected) |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
46 |
<< "missing log tag set descriptions in LogConfiguration::describe"; |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
47 |
} |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
48 |
} |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
49 |
|
43431
5ffa076f526d
8172098: A lot of gtests uses TEST instead of TEST_VM
kzhaldyb
parents:
41676
diff
changeset
|
50 |
TEST_VM(LogTagSetDescriptions, command_line_help) { |
41676
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
51 |
const char* filename = "logtagset_descriptions"; |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
52 |
FILE* fp = fopen(filename, "w+"); |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
53 |
ASSERT_NE((void*)NULL, fp); |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
54 |
LogConfiguration::print_command_line_help(fp); |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
55 |
fclose(fp); |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
56 |
|
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
57 |
for (LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) { |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
58 |
char expected[1 * K]; |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
59 |
d->tagset->label(expected, sizeof(expected), "+"); |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
60 |
jio_snprintf(expected + strlen(expected), |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
61 |
sizeof(expected) - strlen(expected), |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
62 |
": %s", d->descr); |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
63 |
|
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
64 |
EXPECT_TRUE(file_contains_substring(filename, expected)) << "missing log tag set descriptions in -Xlog:help output"; |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
65 |
} |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
66 |
delete_file(filename); |
45778d817919
8165698: Convert LogTagSet related internal tests to GTest
mlarsson
parents:
diff
changeset
|
67 |
} |