From 97451f837ef8f7af3a38dc9fce4b1fdd5e81c054 Mon Sep 17 00:00:00 2001 From: Lei Jin Date: Wed, 29 Oct 2014 12:02:11 -0700 Subject: [PATCH] add an env var ROCKSDB_TESTS_FROM to control where to start from a list of tests Summary: Sometimes, I got a test failure. After fixing that, I want to resume db_test from that test. ROCKSDB_TESTS_FROM is for this purpose. Test Plan: as title Reviewers: yhchiang, rven, igor, sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D27807 --- util/testharness.cc | 25 ++++++++++++++++++------- util/testharness.h | 8 +++++--- 2 files changed, 23 insertions(+), 10 deletions(-) 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