Fixing neteq_unittests for VS 2012

For Visual Studio versions older than 2012, we are using a
separate reference output file for windows. (All other platforms
share the same generic reference file.) In VS 2012, the output
matches the generic reference, and not the platform-specific one.

Since, the ResourcePath() method cannot change behavior depending
on compiler version, this fix will short-cut ResourcePath() for
VS 2012 or newer (_MSC_VER >= 1700).

Also made NetEqDecodingTest.TestBitExactnes stop on the first diff.
Once there is a difference, the output is no longer bit-exact, and
the test should be declared a failure.

BUG=
TEST=neteq_unittests on VS2012, try bots

Review URL: https://webrtc-codereview.appspot.com/966028

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3199 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org 2012-11-29 12:03:18 +00:00
parent 34dab50bb4
commit 8552c71290

View File

@ -15,6 +15,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> // memset #include <string.h> // memset
#include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
@ -103,7 +104,7 @@ void RefFiles::ReadFromFileAndCompare(const T (&test_results)[n],
T* ref = new T[length]; T* ref = new T[length];
ASSERT_EQ(length, fread(ref, sizeof(T), length, input_fp_)); ASSERT_EQ(length, fread(ref, sizeof(T), length, input_fp_));
// Compare // Compare
EXPECT_EQ(0, memcmp(&test_results, ref, sizeof(T) * length)); ASSERT_EQ(0, memcmp(&test_results, ref, sizeof(T) * length));
delete [] ref; delete [] ref;
} }
} }
@ -295,10 +296,14 @@ void NetEqDecodingTest::DecodeAndCompare(const std::string &rtp_file,
NETEQTEST_RTPpacket rtp; NETEQTEST_RTPpacket rtp;
ASSERT_GT(rtp.readFromFile(rtp_fp_), 0); ASSERT_GT(rtp.readFromFile(rtp_fp_), 0);
int i = 0;
while (rtp.dataLen() >= 0) { while (rtp.dataLen() >= 0) {
std::ostringstream ss;
ss << "Lap number " << i++ << " in DecodeAndCompare while loop";
SCOPED_TRACE(ss.str()); // Print out the parameter values on failure.
int16_t out_len; int16_t out_len;
Process(&rtp, &out_len); ASSERT_NO_FATAL_FAILURE(Process(&rtp, &out_len));
ref_files.ProcessReference(out_data_, out_len); ASSERT_NO_FATAL_FAILURE(ref_files.ProcessReference(out_data_, out_len));
} }
} }
@ -370,16 +375,30 @@ void NetEqDecodingTest::PopulateCng(int frame_index,
TEST_F(NetEqDecodingTest, TestBitExactness) { TEST_F(NetEqDecodingTest, TestBitExactness) {
const std::string kInputRtpFile = webrtc::test::ProjectRootPath() + const std::string kInputRtpFile = webrtc::test::ProjectRootPath() +
"resources/neteq_universal.rtp"; "resources/neteq_universal.rtp";
#if defined(_MSC_VER) && (_MSC_VER >= 1700)
// For Visual Studio 2012 and later, we will have to use the generic reference
// file, rather than the windows-specific one.
const std::string kInputRefFile = webrtc::test::ProjectRootPath() +
"resources/neteq_universal_ref.pcm";
#else
const std::string kInputRefFile = const std::string kInputRefFile =
webrtc::test::ResourcePath("neteq_universal_ref", "pcm"); webrtc::test::ResourcePath("neteq_universal_ref", "pcm");
#endif
DecodeAndCompare(kInputRtpFile, kInputRefFile); DecodeAndCompare(kInputRtpFile, kInputRefFile);
} }
TEST_F(NetEqDecodingTest, TestNetworkStatistics) { TEST_F(NetEqDecodingTest, TestNetworkStatistics) {
const std::string kInputRtpFile = webrtc::test::ProjectRootPath() + const std::string kInputRtpFile = webrtc::test::ProjectRootPath() +
"resources/neteq_universal.rtp"; "resources/neteq_universal.rtp";
#if defined(_MSC_VER) && (_MSC_VER >= 1700)
// For Visual Studio 2012 and later, we will have to use the generic reference
// file, rather than the windows-specific one.
const std::string kNetworkStatRefFile = webrtc::test::ProjectRootPath() +
"resources/neteq_network_stats.dat";
#else
const std::string kNetworkStatRefFile = const std::string kNetworkStatRefFile =
webrtc::test::ResourcePath("neteq_network_stats", "dat"); webrtc::test::ResourcePath("neteq_network_stats", "dat");
#endif
const std::string kRtcpStatRefFile = const std::string kRtcpStatRefFile =
webrtc::test::ResourcePath("neteq_rtcp_stats", "dat"); webrtc::test::ResourcePath("neteq_rtcp_stats", "dat");
DecodeAndCheckStats(kInputRtpFile, kNetworkStatRefFile, kRtcpStatRefFile); DecodeAndCheckStats(kInputRtpFile, kNetworkStatRefFile, kRtcpStatRefFile);