Now using fileutils.h OutputPath to write output to the right directory and ResourcePath to read resource files from the resource bundle.
Removed some Valgrind warnings by closing output files. There are still some Valgrind warnings left, that needs to be fixed by a developer with more insight. Updated all include paths to contain full paths to header files. Tested in Debug+Release on Linux, Mac and Windows. All tests ran successfully except the VideoProcessingModuleTest.ContentAnalysis test that fails on Windows with the following error: unknown file: error: SEH exception with code 0xc0000005 thrown in the test body. Fixing that is out of scope for this CL. Review URL: http://webrtc-codereview.appspot.com/266011 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1217 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
554ae1ad4e
commit
08dec7f449
2
DEPS
2
DEPS
@ -14,7 +14,7 @@ vars = {
|
||||
|
||||
# External resources like video and audio files used for testing purposes.
|
||||
# Downloaded on demand when needed.
|
||||
"webrtc_resources_revision": "3",
|
||||
"webrtc_resources_revision": "4",
|
||||
}
|
||||
|
||||
# NOTE: Prefer revision numbers to tags for svn deps.
|
||||
|
@ -8,14 +8,15 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "unit_test.h"
|
||||
#include "video_processing.h"
|
||||
#include "tick_util.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace webrtc;
|
||||
#include "modules/video_processing/main/interface/video_processing.h"
|
||||
#include "modules/video_processing/main/test/unit_test/unit_test.h"
|
||||
#include "system_wrappers/interface/tick_util.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TEST_F(VideoProcessingModuleTest, ColorEnhancement)
|
||||
{
|
||||
@ -23,7 +24,17 @@ TEST_F(VideoProcessingModuleTest, ColorEnhancement)
|
||||
TickTime t1;
|
||||
TickInterval accTicks;
|
||||
|
||||
FILE* modFile = fopen("foremanColorEnhancedVPM.yuv", "w+b");
|
||||
// Use a shorter version of the Foreman clip for this test.
|
||||
fclose(_sourceFile);
|
||||
const std::string video_file =
|
||||
webrtc::test::ResourcePath("foreman_cif_short", "yuv");
|
||||
_sourceFile = fopen(video_file.c_str(), "rb");
|
||||
ASSERT_TRUE(_sourceFile != NULL) <<
|
||||
"Cannot read source file: " + video_file + "\n";
|
||||
|
||||
std::string output_file = webrtc::test::OutputPath() +
|
||||
"foremanColorEnhancedVPM_cif_short.yuv";
|
||||
FILE* modFile = fopen(output_file.c_str(), "w+b");
|
||||
ASSERT_TRUE(modFile != NULL) << "Could not open output file.\n";
|
||||
|
||||
WebRtc_UWord32 frameNum = 0;
|
||||
@ -43,8 +54,11 @@ TEST_F(VideoProcessingModuleTest, ColorEnhancement)
|
||||
rewind(modFile);
|
||||
|
||||
printf("Comparing files...\n\n");
|
||||
FILE* refFile = fopen("foremanColorEnhanced.yuv", "rb");
|
||||
ASSERT_TRUE(refFile != NULL) << "Cannot open reference file foremanColorEnhanced.yuv\n"
|
||||
std::string reference_filename =
|
||||
webrtc::test::ResourcePath("foremanColorEnhanced_cif_short", "yuv");
|
||||
FILE* refFile = fopen(reference_filename.c_str(), "rb");
|
||||
ASSERT_TRUE(refFile != NULL) << "Cannot open reference file: " <<
|
||||
reference_filename << "\n"
|
||||
"Create the reference by running Matlab script createTable.m.";
|
||||
|
||||
// get file lenghts
|
||||
@ -102,7 +116,10 @@ TEST_F(VideoProcessingModuleTest, ColorEnhancement)
|
||||
&refFrame[safeGuard + numPixels], numPixels / 2)) <<
|
||||
"Function is not modifying all chrominance pixels";
|
||||
|
||||
ASSERT_EQ(0, fclose(refFile));
|
||||
ASSERT_EQ(0, fclose(modFile));
|
||||
delete [] testFrame;
|
||||
delete [] refFrame;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,11 +8,11 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "unit_test.h"
|
||||
#include "video_processing.h"
|
||||
#include "content_analysis.h"
|
||||
#include "modules/video_processing/main/interface/video_processing.h"
|
||||
#include "modules/video_processing/main/source/content_analysis.h"
|
||||
#include "modules/video_processing/main/test/unit_test/unit_test.h"
|
||||
|
||||
using namespace webrtc;
|
||||
namespace webrtc {
|
||||
|
||||
TEST_F(VideoProcessingModuleTest, ContentAnalysis)
|
||||
{
|
||||
@ -36,3 +36,5 @@ TEST_F(VideoProcessingModuleTest, ContentAnalysis)
|
||||
}
|
||||
ASSERT_NE(0, feof(_sourceFile)) << "Error reading source file";
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,14 +8,15 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "unit_test.h"
|
||||
#include "video_processing.h"
|
||||
#include "tick_util.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace webrtc;
|
||||
#include "modules/video_processing/main/interface/video_processing.h"
|
||||
#include "modules/video_processing/main/test/unit_test/unit_test.h"
|
||||
#include "system_wrappers/interface/tick_util.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TEST_F(VideoProcessingModuleTest, Deflickering)
|
||||
{
|
||||
@ -28,12 +29,17 @@ TEST_F(VideoProcessingModuleTest, Deflickering)
|
||||
|
||||
// Close automatically opened Foreman.
|
||||
fclose(_sourceFile);
|
||||
_sourceFile = fopen("deflicker_testfile_before.yuv", "rb");
|
||||
const std::string input_file =
|
||||
webrtc::test::ResourcePath("deflicker_before_cif_short", "yuv");
|
||||
_sourceFile = fopen(input_file.c_str(), "rb");
|
||||
ASSERT_TRUE(_sourceFile != NULL) <<
|
||||
"Cannot read input file deflicker_testfile_before.yuv\n";
|
||||
"Cannot read input file: " << input_file << "\n";
|
||||
|
||||
FILE* deflickerFile = fopen("deflicker_testfile.yuv", "wb");
|
||||
ASSERT_TRUE(deflickerFile != NULL) << "Could not open output file.\n";
|
||||
const std::string output_file =
|
||||
webrtc::test::OutputPath() + "deflicker_output_cif_short.yuv";
|
||||
FILE* deflickerFile = fopen(output_file.c_str(), "wb");
|
||||
ASSERT_TRUE(deflickerFile != NULL) <<
|
||||
"Could not open output file: " << output_file << "\n";
|
||||
|
||||
printf("\nRun time [us / frame]:\n");
|
||||
for (WebRtc_UWord32 runIdx = 0; runIdx < NumRuns; runIdx++)
|
||||
@ -73,9 +79,13 @@ TEST_F(VideoProcessingModuleTest, Deflickering)
|
||||
|
||||
rewind(_sourceFile);
|
||||
}
|
||||
ASSERT_EQ(0, fclose(deflickerFile));
|
||||
// TODO(kjellander): Add verification of deflicker output file.
|
||||
|
||||
printf("\nAverage run time = %d us / frame\n",
|
||||
static_cast<int>(avgRuntime / frameNum / NumRuns));
|
||||
printf("Min run time = %d us / frame\n\n",
|
||||
static_cast<int>(minRuntime / frameNum));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,15 +8,15 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "unit_test.h"
|
||||
#include "video_processing.h"
|
||||
|
||||
#include "tick_util.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace webrtc;
|
||||
#include "modules/video_processing/main/interface/video_processing.h"
|
||||
#include "modules/video_processing/main/test/unit_test/unit_test.h"
|
||||
#include "system_wrappers/interface/tick_util.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TEST_F(VideoProcessingModuleTest, Denoising)
|
||||
{
|
||||
@ -26,11 +26,17 @@ TEST_F(VideoProcessingModuleTest, Denoising)
|
||||
WebRtc_Word64 minRuntime = 0;
|
||||
WebRtc_Word64 avgRuntime = 0;
|
||||
|
||||
FILE* denoiseFile = fopen("denoise_testfile.yuv", "wb");
|
||||
ASSERT_TRUE(denoiseFile != NULL) << "Could not open output file.\n";
|
||||
const std::string denoise_filename =
|
||||
webrtc::test::OutputPath() + "denoise_testfile.yuv";
|
||||
FILE* denoiseFile = fopen(denoise_filename.c_str(), "wb");
|
||||
ASSERT_TRUE(denoiseFile != NULL) <<
|
||||
"Could not open output file: " << denoise_filename << "\n";
|
||||
|
||||
FILE* noiseFile = fopen("noise_testfile.yuv", "wb");
|
||||
ASSERT_TRUE(noiseFile != NULL) << "Could not open noisy file.\n";
|
||||
const std::string noise_filename =
|
||||
webrtc::test::OutputPath() + "noise_testfile.yuv";
|
||||
FILE* noiseFile = fopen(noise_filename.c_str(), "wb");
|
||||
ASSERT_TRUE(noiseFile != NULL) <<
|
||||
"Could not open noisy file: " << noise_filename << "\n";
|
||||
|
||||
printf("\nRun time [us / frame]:\n");
|
||||
for (WebRtc_UWord32 runIdx = 0; runIdx < NumRuns; runIdx++)
|
||||
@ -110,9 +116,12 @@ TEST_F(VideoProcessingModuleTest, Denoising)
|
||||
|
||||
rewind(_sourceFile);
|
||||
}
|
||||
|
||||
ASSERT_EQ(0, fclose(denoiseFile));
|
||||
ASSERT_EQ(0, fclose(noiseFile));
|
||||
printf("\nAverage run time = %d us / frame\n",
|
||||
static_cast<int>(avgRuntime / frameNum / NumRuns));
|
||||
printf("Min run time = %d us / frame\n\n",
|
||||
static_cast<int>(minRuntime / frameNum));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -8,33 +8,20 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "unit_test.h"
|
||||
#include "modules/video_processing/main/test/unit_test/unit_test.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "common_video/libyuv/include/libyuv.h"
|
||||
#include "tick_util.h"
|
||||
#include "trace.h"
|
||||
#include "system_wrappers/interface/tick_util.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
|
||||
|
||||
using webrtc::Trace;
|
||||
namespace webrtc {
|
||||
|
||||
void TestSize(VideoFrame& sourceFrame,
|
||||
WebRtc_UWord32 targetWidth, WebRtc_UWord32 targetHeight,
|
||||
WebRtc_UWord32 mode, VideoProcessingModule *vpm);
|
||||
|
||||
class VPMEnvironment : public ::testing::Environment
|
||||
{
|
||||
public:
|
||||
virtual void SetUp()
|
||||
{
|
||||
Trace::CreateTrace();
|
||||
ASSERT_EQ(0, Trace::SetTraceFile("VPMTrace.txt"));
|
||||
}
|
||||
|
||||
virtual void TearDown()
|
||||
{
|
||||
Trace::ReturnTrace();
|
||||
}
|
||||
};
|
||||
VideoProcessingModuleTest::VideoProcessingModuleTest() :
|
||||
_vpm(NULL),
|
||||
_sourceFile(NULL),
|
||||
@ -53,9 +40,11 @@ void VideoProcessingModuleTest::SetUp()
|
||||
_videoFrame.SetWidth(_width);
|
||||
_videoFrame.SetHeight(_height);
|
||||
|
||||
_sourceFile = fopen("testFiles/foreman_cif.yuv","rb");
|
||||
const std::string video_file =
|
||||
webrtc::test::ResourcePath("foreman_cif", "yuv");
|
||||
_sourceFile = fopen(video_file.c_str(),"rb");
|
||||
ASSERT_TRUE(_sourceFile != NULL) <<
|
||||
"Cannot read source file: testFiles/foreman_cif.yuv\n";
|
||||
"Cannot read source file: " + video_file + "\n";
|
||||
}
|
||||
|
||||
void VideoProcessingModuleTest::TearDown()
|
||||
@ -357,8 +346,9 @@ void TestSize(VideoFrame& sourceFrame, WebRtc_UWord32 targetWidth,
|
||||
{
|
||||
VideoFrame *outFrame = NULL;
|
||||
std::ostringstream filename;
|
||||
filename << "Resampler_"<< mode <<"_" << targetWidth << "x" <<
|
||||
targetHeight << "_30Hz_P420.yuv";
|
||||
filename << webrtc::test::OutputPath() << "Resampler_"<< mode << "_" <<
|
||||
targetWidth << "x" << targetHeight << "_30Hz_P420.yuv";
|
||||
// TODO(kjellander): Add automatic verification of these output files:
|
||||
std::cout << "Watch " << filename.str() << " and verify that it is okay."
|
||||
<< std::endl;
|
||||
FILE* standAloneFile = fopen(filename.str().c_str(), "wb");
|
||||
@ -375,14 +365,4 @@ void TestSize(VideoFrame& sourceFrame, WebRtc_UWord32 targetWidth,
|
||||
fclose(standAloneFile);
|
||||
}
|
||||
|
||||
// TODO(kjellander): Get rid of this main and use test_support_main instead
|
||||
// This can be done by inheriting TestSuite instead of testing::Test and
|
||||
// override Initialize().
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
VPMEnvironment* env = new VPMEnvironment;
|
||||
::testing::AddGlobalTestEnvironment(env);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
@ -8,15 +8,15 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VPM_UNIT_TEST_H
|
||||
#define VPM_UNIT_TEST_H
|
||||
#ifndef WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_TEST_UNIT_TEST_VPM_UNIT_TEST_H
|
||||
#define WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_TEST_UNIT_TEST_VPM_UNIT_TEST_H
|
||||
|
||||
#include "video_processing.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "modules/video_processing/main/interface/video_processing.h"
|
||||
#include "system_wrappers/interface/trace.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using namespace webrtc;
|
||||
namespace webrtc {
|
||||
|
||||
class VideoProcessingModuleTest : public ::testing::Test
|
||||
{
|
||||
@ -24,7 +24,16 @@ protected:
|
||||
VideoProcessingModuleTest();
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
Trace::CreateTrace();
|
||||
std::string trace_file = webrtc::test::OutputPath() + "VPMTrace.txt";
|
||||
ASSERT_EQ(0, Trace::SetTraceFile(trace_file.c_str()));
|
||||
}
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
Trace::ReturnTrace();
|
||||
}
|
||||
VideoProcessingModule* _vpm;
|
||||
FILE* _sourceFile;
|
||||
VideoFrame _videoFrame;
|
||||
@ -33,5 +42,6 @@ protected:
|
||||
const WebRtc_UWord32 _frameLength;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // VPM_UNIT_TEST_H
|
||||
#endif // WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_TEST_UNIT_TEST_VPM_UNIT_TEST_H
|
||||
|
@ -14,17 +14,12 @@
|
||||
'dependencies': [
|
||||
'video_processing',
|
||||
'webrtc_utility',
|
||||
'<(webrtc_root)/../test/test.gyp:test_support_main',
|
||||
'<(webrtc_root)/../testing/gtest.gyp:gtest',
|
||||
],
|
||||
'include_dirs': [
|
||||
'../../../../system_wrappers/interface',
|
||||
'<(webrtc_root)/common_video/libyuv/include',
|
||||
'../../../../modules/video_processing/main/source',
|
||||
],
|
||||
'sources': [
|
||||
# headers
|
||||
'unit_test/unit_test.h',
|
||||
|
||||
# sources
|
||||
'unit_test/brightness_detection_test.cc',
|
||||
'unit_test/color_enhancement_test.cc',
|
||||
@ -32,7 +27,7 @@
|
||||
'unit_test/deflickering_test.cc',
|
||||
'unit_test/denoising_test.cc',
|
||||
'unit_test/unit_test.cc',
|
||||
], # source
|
||||
], # sources
|
||||
},
|
||||
],
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user