aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorgabor@google.com <gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529>2011-08-16 01:21:01 +0000
committergabor@google.com <gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529>2011-08-16 01:21:01 +0000
commit7e50a01f8a2820ed7a50c673b5affe0131560ff5 (patch)
treebc6b5343550f7fad533dabd36452544d8bfb5a14 /util
parentfbe4e3af3f4e368e0779b6d75cd6005d67469aa2 (diff)
downloadsrc-7e50a01f8a2820ed7a50c673b5affe0131560ff5.tar.gz
Bugfixes for iterator and documentation.
- Fix bug in Iterator::Prev where it would return the wrong key. Fixes issues 29 and 30. - Added a tweak to testharness to allow running just some tests. - Fixing two minor documentation errors based on issues 28 and 25. - Cleanup; fix namespaces of export-to-C code. Also fix one "const char*" vs "char*" mismatch. git-svn-id: http://leveldb.googlecode.com/svn/trunk@48 62dab493-f737-651d-591e-8d6aee1b9529
Diffstat (limited to 'util')
-rw-r--r--util/testharness.cc12
-rw-r--r--util/testharness.h11
2 files changed, 22 insertions, 1 deletions
diff --git a/util/testharness.cc b/util/testharness.cc
index b686ac3..6f42700 100644
--- a/util/testharness.cc
+++ b/util/testharness.cc
@@ -4,6 +4,8 @@
#include "util/testharness.h"
+#include <string>
+#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -32,10 +34,20 @@ bool RegisterTest(const char* base, const char* name, void (*func)()) {
}
int RunAllTests() {
+ const char* matcher = getenv("LEVELDB_TESTS");
+
int num = 0;
if (tests != NULL) {
for (int i = 0; i < tests->size(); i++) {
const Test& t = (*tests)[i];
+ if (matcher != NULL) {
+ std::string name = t.base;
+ name.push_back('.');
+ name.append(t.name);
+ if (strstr(name.c_str(), matcher) == NULL) {
+ continue;
+ }
+ }
fprintf(stderr, "==== Test %s.%s\n", t.base, t.name);
(*t.func)();
++num;
diff --git a/util/testharness.h b/util/testharness.h
index 13ab914..6f1a9c3 100644
--- a/util/testharness.h
+++ b/util/testharness.h
@@ -15,7 +15,16 @@
namespace leveldb {
namespace test {
-// Run all tests registered by the TEST() macro.
+// Run some of the tests registered by the TEST() macro. If the
+// environment variable "LEVELDB_TESTS" is not set, runs all tests.
+// Otherwise, runs only the tests whose name contains the value of
+// "LEVELDB_TESTS" as a substring. E.g., suppose the tests are:
+// TEST(Foo, Hello) { ... }
+// TEST(Foo, World) { ... }
+// LEVELDB_TESTS=Hello will run the first test
+// LEVELDB_TESTS=o will run both tests
+// LEVELDB_TESTS=Junk will run no tests
+//
// Returns 0 if all tests pass.
// Dies or returns a non-zero value if some test fails.
extern int RunAllTests();