Skip to content

Commit

Permalink
Allow filtering of testapp tests
Browse files Browse the repository at this point in the history
Allow a second parameter to memcached_testapp to be specified to
filter which tests are run. For example, running testapp as:

    ./memcached_testapp plain get

will only run tests whose name includes the string 'get'.

Change-Id: I24eff268e6f7e63bd6d48e79af3294d0980cfe3a
Reviewed-on: http://review.couchbase.org/47450
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Mark Woosey <mark.woosey@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information
daverigby authored and trondn committed Feb 28, 2015
1 parent 5e37302 commit bd5604b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/testapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4335,6 +4335,20 @@ struct testcase {
const int phases; /*1 bit per phase*/
};

/* Returns true if the specified test is required and it cannot be skipped
* be skipped.
*/
static bool test_required(const struct testcase* testcase) {
/* Always require setup and cleanup. */
const int phases_required = phase_setup | phase_cleanup;
if ((testcase->phases & phases_required) != 0) {
return true;
}

/* Only one unskippable test so far - need `connect` to do anything useful. */
return testcase->function == test_connect_to_server;
}

/*
Test cases currently run as follows.
Expand Down Expand Up @@ -4474,6 +4488,12 @@ int main(int argc, char **argv)
}
}

/* Check if user specified a subset of tests to run. */
const char* test_subset = NULL;
if (argc > 2) {
test_subset = argv[2];
}

cb_initialize_sockets();
/* Use unbuffered stdio */
setbuf(stdout, NULL);
Expand All @@ -4493,6 +4513,12 @@ int main(int argc, char **argv)
continue;
}

if (!test_required(&testcases[ii]) &&
test_subset != NULL &&
strstr(testcases[ii].description, test_subset) == NULL) {
continue;
}

fprintf(stdout, "\r");
for (jj = 0; jj < 60; ++jj) {
fprintf(stdout, " ");
Expand Down

0 comments on commit bd5604b

Please sign in to comment.