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

Side by Side Diff: mojo/public/tests/test_support_private.cc

Issue 229683005: Validate MessageHeader before using (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove debug printfs Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/tests/test_support_private.h ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/tests/test_support_private.h" 5 #include "mojo/public/tests/test_support_private.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <stddef.h>
9 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h>
10 10
11 static mojo::test::TestSupport* g_test_support = NULL; 11 static mojo::test::TestSupport* g_test_support = NULL;
12 12
13 extern "C" { 13 extern "C" {
14 14
15 void MojoTestSupportLogPerfResult(const char* test_name, 15 void MojoTestSupportLogPerfResult(const char* test_name,
16 double value, 16 double value,
17 const char* units) { 17 const char* units) {
18 if (g_test_support) 18 if (g_test_support)
19 g_test_support->LogPerfResult(test_name, value, units); 19 g_test_support->LogPerfResult(test_name, value, units);
20 else 20 else
21 printf("[no test runner]\t%s\t%g\t%s\n", test_name, value, units); 21 printf("[no test runner]\t%s\t%g\t%s\n", test_name, value, units);
22 } 22 }
23 23
24 FILE* MojoTestSupportOpenSourceRootRelativeFile(const char* relative_path) {
25 if (g_test_support)
26 return g_test_support->OpenSourceRootRelativeFile(relative_path);
27 printf("[no test runner]\n");
28 return NULL;
29 }
30
31 char** MojoTestSupportEnumerateSourceRootRelativeDirectory(
32 const char* relative_path) {
33 if (g_test_support)
34 return g_test_support->EnumerateSourceRootRelativeDirectory(relative_path);
35
36 printf("[no test runner]\n");
37
38 // Return empty list:
39 char** rv = static_cast<char**>(calloc(1, sizeof(char*)));
40 rv[0] = NULL;
41 return rv;
42 }
43
24 } // extern "C" 44 } // extern "C"
25 45
26 namespace mojo { 46 namespace mojo {
27 namespace test { 47 namespace test {
28 48
29 TestSupport::~TestSupport() { 49 TestSupport::~TestSupport() {
30 } 50 }
31 51
32 // static 52 // static
33 void TestSupport::Init(TestSupport* test_support) { 53 void TestSupport::Init(TestSupport* test_support) {
34 assert(!g_test_support); 54 assert(!g_test_support);
35 g_test_support = test_support; 55 g_test_support = test_support;
36 } 56 }
37 57
38 // static 58 // static
39 TestSupport* TestSupport::Get() { 59 TestSupport* TestSupport::Get() {
40 return g_test_support; 60 return g_test_support;
41 } 61 }
42 62
43 // static 63 // static
44 void TestSupport::Reset() { 64 void TestSupport::Reset() {
45 g_test_support = NULL; 65 g_test_support = NULL;
46 } 66 }
47 67
48 } // namespace test 68 } // namespace test
49 } // namespace mojo 69 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/tests/test_support_private.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698