diff --git a/util/testharness.cc b/util/testharness.cc index 4208d2c46..16773f69f 100644 --- a/util/testharness.cc +++ b/util/testharness.cc @@ -41,18 +41,29 @@ bool RegisterTest(const char* base, const char* name, void (*func)()) { int RunAllTests() { port::InstallStackTraceHandler(); - const char* matcher = getenv("ROCKSDB_TESTS"); + const char* one_matcher = getenv("ROCKSDB_TESTS"); + const char* from_matcher = getenv("ROCKSDB_TESTS_FROM"); int num = 0; + bool tests_on = (one_matcher == nullptr && from_matcher == nullptr); if (tests != nullptr) { for (unsigned int i = 0; i < tests->size(); i++) { const Test& t = (*tests)[i]; - if (matcher != nullptr) { - std::string name = t.base; - name.push_back('.'); - name.append(t.name); - if (strstr(name.c_str(), matcher) == nullptr) { - continue; + if (tests_on == false) { + if (one_matcher != nullptr || from_matcher != nullptr) { + std::string name = t.base; + name.push_back('.'); + name.append(t.name); + if (from_matcher != nullptr && + strstr(name.c_str(), from_matcher) != nullptr) { + tests_on = true; + } + if (!tests_on) { + if (one_matcher == nullptr || + strstr(name.c_str(), one_matcher) == nullptr) { + continue; + } + } } } fprintf(stderr, "==== Test %s.%s\n", t.base, t.name); diff --git a/util/testharness.h b/util/testharness.h index 52c29848d..af4b2858c 100644 --- a/util/testharness.h +++ b/util/testharness.h @@ -21,9 +21,11 @@ namespace rocksdb { namespace test { // Run some of the tests registered by the TEST() macro. If the -// environment variable "ROCKSDB_TESTS" is not set, runs all tests. -// Otherwise, runs only the tests whose name contains the value of -// "ROCKSDB_TESTS" as a substring. E.g., suppose the tests are: +// environment variable "ROCKSDB_TESTS" and "ROCKSDB_TESTS_FROM" +// are not set, runs all tests. Otherwise, run all tests after +// ROCKSDB_TESTS_FROM and those specified by ROCKSDB_TESTS. +// Partial name match also works for ROCKSDB_TESTS and +// ROCKSDB_TESTS_FROM. E.g., suppose the tests are: // TEST(Foo, Hello) { ... } // TEST(Foo, World) { ... } // ROCKSDB_TESTS=Hello will run the first test