History

Don't reset the random number generator within the unit tests

This makes sure we don't accidentally return the same sequence of random numbers multiple times within one test (which would be very non-random). Every time srand(time()) is called, the pseudo random number generator is initialized to the same value (as long as time() returned the same value). By initializing the random number generator once and for all before starting to run the unit tests, we are sure we don't need to reinitialize it within all the tests and all the functions that use random numbers. This fixes occasional errors in MotionEstimateTest. MotionEstimateTest was designed to allow the test to occasionally not succeed - if it didn't succeed, it tried again, up to 100 times. However, since the YUVPixelDataGenerator function reset the random seed to time(), every attempt actually ran with the same random data (as long as all 100 attempts ran within 1 second) - thus if one attempt in MotionEstimateTest failed, all 100 of them would fail. If the utility functions don't touch the random seed, this is not an issue.

Martin Storsjö committed 12 years ago

Commit 4f594de1 parent 806e59f16 files · +12 −114Browse files

Showing the changes to test/decoder/DecUT_MotionCompensation.cpp (1 of 16 files). Show all

Unified · Split

test/decoder/DecUT_MotionCompensation.cpp+0−3
@@ -136,7 +136,6 @@ TEST(McCopy_c,iW##x##iH) \ · 135 unmodified lines
136136 uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
137137 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
138138 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
139− srand((unsigned int)time(0)); \
140139 for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
141140 { \
142141 for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \
@@ -183,7 +182,6 @@ TEST(McHorVer##a##b##_c,iW##x##iH) \ · 40 unmodified lines
183182 uSrcInputAnchor[1] = &uSrcAnchor[1][4][4]; \
184183 uSrcInputAnchor[2] = &uSrcAnchor[2][4][4]; \
185184 uSrcInputAnchor[3] = &uSrcAnchor[3][4][4]; \
186− srand((unsigned int)time(0)); \
187185 for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
188186 {\
189187 for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \
@@ -252,7 +250,6 @@ TEST(McChromaWithFragMv_##a##b##_c,iW##x##iH) \ · 62 unmodified lines
252250 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor1, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
253251 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor2, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
254252 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
255− srand((unsigned int)time(0)); \
256253 for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
257254 {\
258255 for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t