Arquivos
erikkay@google.com b2292afc0c Call logging::InitLogging. The lack of this was causing some hangs (and possibly crashes) in ObserverListTest.BUG=6286
This CL has expanded to include some cleanup and refactoring of test_suite and related files, so that this logging change (and other improvements) are applied to all unit tests.


Review URL: http://codereview.chromium.org/18003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7977 0039d316-1c4b-4281-b951-d872f2087c98
2009-01-13 22:35:10 +00:00

46 linhas
1.0 KiB
C++

// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/perftimer.h"
#include <stdio.h>
#include <string>
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
static FILE* perf_log_file = NULL;
bool InitPerfLog(const FilePath& log_file) {
if (perf_log_file) {
// trying to initialize twice
NOTREACHED();
return false;
}
perf_log_file = file_util::OpenFile(log_file, "w");
return perf_log_file != NULL;
}
void FinalizePerfLog() {
if (!perf_log_file) {
// trying to cleanup without initializing
NOTREACHED();
return;
}
file_util::CloseFile(perf_log_file);
}
void LogPerfResult(const char* test_name, double value, const char* units) {
if (!perf_log_file) {
NOTREACHED();
return;
}
fprintf(perf_log_file, "%s\t%g\t%s\n", test_name, value, units);
printf("%s\t%g\t%s\n", test_name, value, units);
}