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_IdctResAddPred.cpp (1 of 16 files). Show all

Unified · Split

test/decoder/DecUT_IdctResAddPred.cpp+0−2
@@ -1,5 +1,4 @@
1#include <gtest/gtest.h>1#include <gtest/gtest.h>
2#include <time.h>
3#include "macros.h"2#include "macros.h"
4#include "decode_mb_aux.h"3#include "decode_mb_aux.h"
5using namespace WelsDec;4using namespace WelsDec;
@@ -51,7 +50,6 @@ TEST(DecoderDecodeMbAux, pred) {\ · 45 unmodified lines
51 int16_t iRefRS[16];\50 int16_t iRefRS[16];\
52 uint8_t uiRefPred[16*kiStride];\51 uint8_t uiRefPred[16*kiStride];\
53 int32_t iRunTimes = 1000;\52 int32_t iRunTimes = 1000;\
54 srand((unsigned int)time(NULL));\
55 while(iRunTimes--) {\53 while(iRunTimes--) {\
56 for(int i = 0; i < 4; i++)\54 for(int i = 0; i < 4; i++)\
57 for(int j = 0; j < 4; j++)\55 for(int j = 0; j < 4; j++)\

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