1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. See the AUTHORS file for names of contributors.
5 #include "util/testharness.h"
10 #include <sys/types.h>
21 std::vector<Test>* tests;
24 bool RegisterTest(const char* base, const char* name, void (*func)()) {
26 tests = new std::vector<Test>;
37 const char* matcher = getenv("LEVELDB_TESTS");
41 for (size_t i = 0; i < tests->size(); i++) {
42 const Test& t = (*tests)[i];
43 if (matcher != NULL) {
44 std::string name = t.base;
47 if (strstr(name.c_str(), matcher) == NULL) {
51 fprintf(stderr, "==== Test %s.%s\n", t.base, t.name);
56 fprintf(stderr, "==== PASSED %d tests\n", num);
60 std::string TmpDir() {
62 Status s = Env::Default()->GetTestDirectory(&dir);
63 ASSERT_TRUE(s.ok()) << s.ToString();
68 const char* env = getenv("TEST_RANDOM_SEED");
69 int result = (env != NULL ? atoi(env) : 301);
77 } // namespace leveldb