|
1 /* |
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
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 */ |
|
24 |
|
25 #include "precompiled.hpp" |
|
26 |
|
27 /////////////// Unit tests /////////////// |
|
28 |
|
29 #ifndef PRODUCT |
|
30 |
|
31 #include "logging/log.hpp" |
|
32 #include "logging/logConfiguration.hpp" |
|
33 #include "memory/resourceArea.hpp" |
|
34 |
|
35 void Test_log_length() { |
|
36 remove("loglengthoutput.txt"); |
|
37 |
|
38 // Write long message to output file |
|
39 MutexLocker ml(LogConfiguration_lock); |
|
40 LogConfiguration::parse_log_arguments("loglengthoutput.txt", "logging=develop", |
|
41 NULL, NULL, NULL); |
|
42 ResourceMark rm; |
|
43 outputStream* logstream = LogHandle(logging)::develop_stream(); |
|
44 logstream->print_cr("01:1234567890-" |
|
45 "02:1234567890-" |
|
46 "03:1234567890-" |
|
47 "04:1234567890-" |
|
48 "05:1234567890-" |
|
49 "06:1234567890-" |
|
50 "07:1234567890-" |
|
51 "08:1234567890-" |
|
52 "09:1234567890-" |
|
53 "10:1234567890-" |
|
54 "11:1234567890-" |
|
55 "12:1234567890-" |
|
56 "13:1234567890-" |
|
57 "14:1234567890-" |
|
58 "15:1234567890-" |
|
59 "16:1234567890-" |
|
60 "17:1234567890-" |
|
61 "18:1234567890-" |
|
62 "19:1234567890-" |
|
63 "20:1234567890-" |
|
64 "21:1234567890-" |
|
65 "22:1234567890-" |
|
66 "23:1234567890-" |
|
67 "24:1234567890-" |
|
68 "25:1234567890-" |
|
69 "26:1234567890-" |
|
70 "27:1234567890-" |
|
71 "28:1234567890-" |
|
72 "29:1234567890-" |
|
73 "30:1234567890-" |
|
74 "31:1234567890-" |
|
75 "32:1234567890-" |
|
76 "33:1234567890-" |
|
77 "34:1234567890-" |
|
78 "35:1234567890-" |
|
79 "36:1234567890-" |
|
80 "37:1234567890-"); |
|
81 |
|
82 // Look for end of message in output file |
|
83 FILE* fp; |
|
84 fp = fopen("loglengthoutput.txt", "r"); |
|
85 assert (fp, "File read error"); |
|
86 char output[600]; |
|
87 if (fgets(output, 600, fp) != NULL) { |
|
88 assert(strstr(output, "37:1234567890-"), "logging print size error"); |
|
89 } |
|
90 fclose(fp); |
|
91 remove("loglengthoutput.txt"); |
|
92 } |
|
93 #endif // PRODUCT |
|
94 |