test/runner: use proper filters for test cases

The benchmark_filter options accepts regex-s, but
the gtest-filter option accepts shell-like wildcards.

Fixes #2034

Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
Andrei Vagin 2020-03-03 15:53:48 -08:00
parent 844e4d284c
commit 504c9e14d6
2 changed files with 5 additions and 3 deletions

View File

@ -66,13 +66,12 @@ func (tc TestCase) Args() []string {
} }
if tc.benchmark { if tc.benchmark {
return []string{ return []string{
fmt.Sprintf("%s=^$", filterTestFlag),
fmt.Sprintf("%s=^%s$", filterBenchmarkFlag, tc.Name), fmt.Sprintf("%s=^%s$", filterBenchmarkFlag, tc.Name),
fmt.Sprintf("%s=", filterTestFlag),
} }
} }
return []string{ return []string{
fmt.Sprintf("%s=^%s$", filterTestFlag, tc.FullName()), fmt.Sprintf("%s=%s", filterTestFlag, tc.FullName()),
fmt.Sprintf("%s=^$", filterBenchmarkFlag),
} }
} }
@ -147,6 +146,8 @@ func ParseTestCases(testBin string, benchmarks bool, extraArgs ...string) ([]Tes
return nil, fmt.Errorf("could not enumerate gtest benchmarks: %v\nstderr\n%s", err, exitErr.Stderr) return nil, fmt.Errorf("could not enumerate gtest benchmarks: %v\nstderr\n%s", err, exitErr.Stderr)
} }
out = []byte(strings.Trim(string(out), "\n"))
// Parse benchmark output. // Parse benchmark output.
for _, line := range strings.Split(string(out), "\n") { for _, line := range strings.Split(string(out), "\n") {
// Strip comments. // Strip comments.

View File

@ -26,6 +26,7 @@ namespace {
TEST(TuntapHostInetTest, NoNetTun) { TEST(TuntapHostInetTest, NoNetTun) {
SKIP_IF(!IsRunningOnGvisor()); SKIP_IF(!IsRunningOnGvisor());
SKIP_IF(!IsRunningWithHostinet());
struct stat statbuf; struct stat statbuf;
ASSERT_THAT(stat("/dev/net/tun", &statbuf), SyscallFailsWithErrno(ENOENT)); ASSERT_THAT(stat("/dev/net/tun", &statbuf), SyscallFailsWithErrno(ENOENT));