Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: test/cctest/test-log.cc

Issue 799008: Make the assumption on the minimum buffer size for GetLogLines explicit. (Closed)
Patch Set: Added assert, removed failing checks from test. Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/log-utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // 2 //
3 // Tests of logging functions from log.h 3 // Tests of logging functions from log.h
4 4
5 #ifdef ENABLE_LOGGING_AND_PROFILING 5 #ifdef ENABLE_LOGGING_AND_PROFILING
6 6
7 #ifdef __linux__ 7 #ifdef __linux__
8 #include <math.h> 8 #include <math.h>
9 #include <pthread.h> 9 #include <pthread.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 47
48 TEST(GetMessages) { 48 TEST(GetMessages) {
49 SetUp(); 49 SetUp();
50 Logger::StringEvent("aaa", "bbb"); 50 Logger::StringEvent("aaa", "bbb");
51 Logger::StringEvent("cccc", "dddd"); 51 Logger::StringEvent("cccc", "dddd");
52 CHECK_EQ(0, Logger::GetLogLines(0, NULL, 0)); 52 CHECK_EQ(0, Logger::GetLogLines(0, NULL, 0));
53 char log_lines[100]; 53 char log_lines[100];
54 memset(log_lines, 0, sizeof(log_lines)); 54 memset(log_lines, 0, sizeof(log_lines));
55 // Requesting data size which is smaller than first log message length.
56 CHECK_EQ(0, Logger::GetLogLines(0, log_lines, 3));
57 // See Logger::StringEvent. 55 // See Logger::StringEvent.
58 const char* line_1 = "aaa,\"bbb\"\n"; 56 const char* line_1 = "aaa,\"bbb\"\n";
59 const int line_1_len = StrLength(line_1); 57 const int line_1_len = StrLength(line_1);
60 // Still smaller than log message length.
61 CHECK_EQ(0, Logger::GetLogLines(0, log_lines, line_1_len - 1));
62 // The exact size. 58 // The exact size.
63 CHECK_EQ(line_1_len, Logger::GetLogLines(0, log_lines, line_1_len)); 59 CHECK_EQ(line_1_len, Logger::GetLogLines(0, log_lines, line_1_len));
64 CHECK_EQ(line_1, log_lines); 60 CHECK_EQ(line_1, log_lines);
65 memset(log_lines, 0, sizeof(log_lines)); 61 memset(log_lines, 0, sizeof(log_lines));
66 // A bit more than the first line length. 62 // A bit more than the first line length.
67 CHECK_EQ(line_1_len, Logger::GetLogLines(0, log_lines, line_1_len + 3)); 63 CHECK_EQ(line_1_len, Logger::GetLogLines(0, log_lines, line_1_len + 3));
68 log_lines[line_1_len] = '\0'; 64 log_lines[line_1_len] = '\0';
69 CHECK_EQ(line_1, log_lines); 65 CHECK_EQ(line_1, log_lines);
70 memset(log_lines, 0, sizeof(log_lines)); 66 memset(log_lines, 0, sizeof(log_lines));
71 const char* line_2 = "cccc,\"dddd\"\n"; 67 const char* line_2 = "cccc,\"dddd\"\n";
72 const int line_2_len = StrLength(line_2); 68 const int line_2_len = StrLength(line_2);
73 // Now start with line_2 beginning. 69 // Now start with line_2 beginning.
74 CHECK_EQ(0, Logger::GetLogLines(line_1_len, log_lines, 0)); 70 CHECK_EQ(0, Logger::GetLogLines(line_1_len, log_lines, 0));
75 CHECK_EQ(0, Logger::GetLogLines(line_1_len, log_lines, 3));
76 CHECK_EQ(0, Logger::GetLogLines(line_1_len, log_lines, line_2_len - 1));
77 CHECK_EQ(line_2_len, Logger::GetLogLines(line_1_len, log_lines, line_2_len)); 71 CHECK_EQ(line_2_len, Logger::GetLogLines(line_1_len, log_lines, line_2_len));
78 CHECK_EQ(line_2, log_lines); 72 CHECK_EQ(line_2, log_lines);
79 memset(log_lines, 0, sizeof(log_lines)); 73 memset(log_lines, 0, sizeof(log_lines));
80 CHECK_EQ(line_2_len, 74 CHECK_EQ(line_2_len,
81 Logger::GetLogLines(line_1_len, log_lines, line_2_len + 3)); 75 Logger::GetLogLines(line_1_len, log_lines, line_2_len + 3));
82 CHECK_EQ(line_2, log_lines); 76 CHECK_EQ(line_2, log_lines);
83 memset(log_lines, 0, sizeof(log_lines)); 77 memset(log_lines, 0, sizeof(log_lines));
84 // Now get entire buffer contents. 78 // Now get entire buffer contents.
85 const char* all_lines = "aaa,\"bbb\"\ncccc,\"dddd\"\n"; 79 const char* all_lines = "aaa,\"bbb\"\ncccc,\"dddd\"\n";
86 const int all_lines_len = StrLength(all_lines); 80 const int all_lines_len = StrLength(all_lines);
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 // Make sure that all log data is written prior crash due to CHECK failure. 1188 // Make sure that all log data is written prior crash due to CHECK failure.
1195 fflush(stdout); 1189 fflush(stdout);
1196 CHECK(results_equal); 1190 CHECK(results_equal);
1197 1191
1198 env->Exit(); 1192 env->Exit();
1199 Logger::TearDown(); 1193 Logger::TearDown();
1200 i::FLAG_always_compact = saved_always_compact; 1194 i::FLAG_always_compact = saved_always_compact;
1201 } 1195 }
1202 1196
1203 #endif // ENABLE_LOGGING_AND_PROFILING 1197 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW
« no previous file with comments | « src/log-utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698