diff options
author | kjellander@webrtc.org <kjellander@webrtc.org> | 2014-09-29 11:47:28 +0000 |
---|---|---|
committer | kjellander@webrtc.org <kjellander@webrtc.org> | 2014-09-29 11:47:28 +0000 |
commit | e794c3663786bb43d5b3f305acbe2dfb8e1bc09f (patch) | |
tree | d470ddb2fdb9ddd8150aca686599e10dfefaa3a7 /webrtc/test/testsupport/fileutils_unittest.cc | |
parent | d71118194faf15f091071ca38727d191a50678d0 (diff) | |
download | webrtc-e794c3663786bb43d5b3f305acbe2dfb8e1bc09f.tar.gz |
Fix parallel test execution for tools, testsupport and metrics tests.
BUG=2600
TESTED=Passing tests using:
python third_party/gtest-parallel/gtest-parallel -w 10 -r 20 out/Release/test_support_unittests
python third_party/gtest-parallel/gtest-parallel -w 10 -r 20 out/Release/tools_unittests
python third_party/gtest-parallel/gtest-parallel -w 10 -r 20 out/Release/video_engine_tests
R=pbos@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/31479004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7322 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'webrtc/test/testsupport/fileutils_unittest.cc')
-rw-r--r-- | webrtc/test/testsupport/fileutils_unittest.cc | 48 |
1 files changed, 10 insertions, 38 deletions
diff --git a/webrtc/test/testsupport/fileutils_unittest.cc b/webrtc/test/testsupport/fileutils_unittest.cc index 4cd4513729..114f108359 100644 --- a/webrtc/test/testsupport/fileutils_unittest.cc +++ b/webrtc/test/testsupport/fileutils_unittest.cc @@ -29,8 +29,6 @@ static const std::string kResourcesDir = "resources"; static const std::string kTestName = "fileutils_unittest"; static const std::string kExtension = "tmp"; -typedef std::list<std::string> FileList; - namespace webrtc { // Test fixture to restore the working directory between each test, since some @@ -44,38 +42,6 @@ class FileUtilsTest : public testing::Test { // Runs before the first test static void SetUpTestCase() { original_working_dir_ = webrtc::test::WorkingDir(); - std::string resources_path = original_working_dir_ + kPathDelimiter + - kResourcesDir + kPathDelimiter; - webrtc::test::CreateDir(resources_path); - - files_.push_back(resources_path + kTestName + "." + kExtension); - files_.push_back(resources_path + kTestName + "_32." + kExtension); - files_.push_back(resources_path + kTestName + "_64." + kExtension); - files_.push_back(resources_path + kTestName + "_linux." + kExtension); - files_.push_back(resources_path + kTestName + "_mac." + kExtension); - files_.push_back(resources_path + kTestName + "_win." + kExtension); - files_.push_back(resources_path + kTestName + "_linux_32." + kExtension); - files_.push_back(resources_path + kTestName + "_mac_32." + kExtension); - files_.push_back(resources_path + kTestName + "_win_32." + kExtension); - files_.push_back(resources_path + kTestName + "_linux_64." + kExtension); - files_.push_back(resources_path + kTestName + "_mac_64." + kExtension); - files_.push_back(resources_path + kTestName + "_win_64." + kExtension); - - // Now that the resources dir exists, write some empty test files into it. - for (FileList::iterator file_it = files_.begin(); - file_it != files_.end(); ++file_it) { - FILE* file = fopen(file_it->c_str(), "wb"); - ASSERT_TRUE(file != NULL) << "Failed to write file: " << file_it->c_str(); - ASSERT_GT(fprintf(file, "%s", "Dummy data"), 0); - fclose(file); - } - } - static void TearDownTestCase() { - // Clean up all resource files written - for (FileList::iterator file_it = files_.begin(); - file_it != files_.end(); ++file_it) { - remove(file_it->c_str()); - } } void SetUp() { ASSERT_EQ(chdir(original_working_dir_.c_str()), 0); @@ -83,13 +49,10 @@ class FileUtilsTest : public testing::Test { void TearDown() { ASSERT_EQ(chdir(original_working_dir_.c_str()), 0); } - protected: - static FileList files_; private: static std::string original_working_dir_; }; -FileList FileUtilsTest::files_; std::string FileUtilsTest::original_working_dir_ = ""; // Tests that the project root path is returned for the default working @@ -159,7 +122,16 @@ TEST_F(FileUtilsTest, ResourcePathFromRootWorkingDir) { } TEST_F(FileUtilsTest, GetFileSizeExistingFile) { - ASSERT_GT(webrtc::test::GetFileSize(files_.front()), 0u); + // Create a file with some dummy data in. + std::string temp_filename = webrtc::test::TempFilename( + webrtc::test::OutputPath(), "fileutils_unittest"); + FILE* file = fopen(temp_filename.c_str(), "wb"); + ASSERT_TRUE(file != NULL) << "Failed to open file: " << temp_filename; + ASSERT_GT(fprintf(file, "%s", "Dummy data"), 0) << + "Failed to write to file: " << temp_filename; + fclose(file); + ASSERT_GT(webrtc::test::GetFileSize(std::string(temp_filename.c_str())), 0u); + remove(temp_filename.c_str()); } TEST_F(FileUtilsTest, GetFileSizeNonExistingFile) { |