From 556d154bed5329abb479def1a32431ca6721df39 Mon Sep 17 00:00:00 2001 From: miloyip Date: Thu, 16 Apr 2015 10:34:45 +0800 Subject: [PATCH] Search sample data in more folders for perftest --- test/perftest/perftest.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/perftest/perftest.h b/test/perftest/perftest.h index 2fca20338..4c955a421 100644 --- a/test/perftest/perftest.h +++ b/test/perftest/perftest.h @@ -71,9 +71,20 @@ class PerfTest : public ::testing::Test { PerfTest() : filename_(), json_(), length_(), whitespace_(), whitespace_length_() {} virtual void SetUp() { - FILE *fp = fopen(filename_ = "data/sample.json", "rb"); - if (!fp) - fp = fopen(filename_ = "../../bin/data/sample.json", "rb"); + + const char *paths[] = { + "data/sample.json", + "bin/data/sample.json", + "../bin/data/sample.json", + "../../bin/data/sample.json", + "../../../bin/data/sample.json" + }; + FILE *fp = 0; + for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) { + fp = fopen(paths[i], "rb"); + if (fp) + break; + } ASSERT_TRUE(fp != 0); fseek(fp, 0, SEEK_END);