From e494df1a3769677138baf59536c42e2313822625 Mon Sep 17 00:00:00 2001 From: Yaowu Xu <yaowu@google.com> Date: Tue, 3 Sep 2013 13:50:17 -0700 Subject: [PATCH] Added ClearSystemState in a unit test There is another unit test that has been failing randomly on win32 build. Investigation has shown that the failure was caused by simd register state is not reset appropriately in the fdct8x8 test. This commit added ClearSystemState() in the teardown of this test, tests showed it resolved the random failure issue for win32 build. Related issue: https://code.google.com/p/webm/issues/detail?id=614 Change-Id: I9381d0c1a6f4b855ccaeef1aca8c417ac8c71ee2 --- test/fdct8x8_test.cc | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/test/fdct8x8_test.cc b/test/fdct8x8_test.cc index 81d242b4da..ee6c9f6b36 100644 --- a/test/fdct8x8_test.cc +++ b/test/fdct8x8_test.cc @@ -13,14 +13,16 @@ #include <string.h> #include "third_party/googletest/src/include/gtest/gtest.h" +#include "test/clear_system_state.h" +#include "test/register_state_check.h" #include "vpx_ports/mem.h" extern "C" { -#include "vp9_rtcd.h" -void vp9_short_idct8x8_add_c(short *input, uint8_t *output, int pitch); +#include "./vp9_rtcd.h" +void vp9_short_idct8x8_add_c(int16_t *input, uint8_t *output, int pitch); } -#include "acm_random.h" +#include "test/acm_random.h" #include "vpx/vpx_integer.h" using libvpx_test::ACMRandom; @@ -62,6 +64,7 @@ class FwdTrans8x8Test : public ::testing::TestWithParam<int> { inv_txfm = iht8x8_add; } } + virtual void TearDown() { libvpx_test::ClearSystemState(); } protected: void RunFwdTxfm(int16_t *in, int16_t *out, uint8_t *dst, @@ -92,8 +95,9 @@ TEST_P(FwdTrans8x8Test, SignBiasCheck) { // Initialize a test block with input range [-255, 255]. for (int j = 0; j < 64; ++j) test_input_block[j] = rnd.Rand8() - rnd.Rand8(); - - RunFwdTxfm(test_input_block, test_output_block, NULL, pitch, tx_type_); + REGISTER_STATE_CHECK( + RunFwdTxfm(test_input_block, test_output_block, + NULL, pitch, tx_type_)); for (int j = 0; j < 64; ++j) { if (test_output_block[j] < 0) @@ -121,8 +125,9 @@ TEST_P(FwdTrans8x8Test, SignBiasCheck) { // Initialize a test block with input range [-15, 15]. for (int j = 0; j < 64; ++j) test_input_block[j] = (rnd.Rand8() >> 4) - (rnd.Rand8() >> 4); - - RunFwdTxfm(test_input_block, test_output_block, NULL, pitch, tx_type_); + REGISTER_STATE_CHECK( + RunFwdTxfm(test_input_block, test_output_block, + NULL, pitch, tx_type_)); for (int j = 0; j < 64; ++j) { if (test_output_block[j] < 0) @@ -165,9 +170,11 @@ TEST_P(FwdTrans8x8Test, RoundTripErrorCheck) { test_input_block[j] = src[j] - dst[j]; const int pitch = 16; - RunFwdTxfm(test_input_block, test_temp_block, dst, pitch, tx_type_); - for (int j = 0; j < 64; ++j){ - if(test_temp_block[j] > 0) { + REGISTER_STATE_CHECK( + RunFwdTxfm(test_input_block, test_temp_block, + dst, pitch, tx_type_)); + for (int j = 0; j < 64; ++j) { + if (test_temp_block[j] > 0) { test_temp_block[j] += 2; test_temp_block[j] /= 4; test_temp_block[j] *= 4; @@ -177,7 +184,9 @@ TEST_P(FwdTrans8x8Test, RoundTripErrorCheck) { test_temp_block[j] *= 4; } } - RunInvTxfm(test_input_block, test_temp_block, dst, pitch, tx_type_); + REGISTER_STATE_CHECK( + RunInvTxfm(test_input_block, test_temp_block, + dst, pitch, tx_type_)); for (int j = 0; j < 64; ++j) { const int diff = dst[j] - src[j]; @@ -216,8 +225,12 @@ TEST_P(FwdTrans8x8Test, ExtremalCheck) { test_input_block[j] = src[j] - dst[j]; const int pitch = 16; - RunFwdTxfm(test_input_block, test_temp_block, dst, pitch, tx_type_); - RunInvTxfm(test_input_block, test_temp_block, dst, pitch, tx_type_); + REGISTER_STATE_CHECK( + RunFwdTxfm(test_input_block, test_temp_block, + dst, pitch, tx_type_)); + REGISTER_STATE_CHECK( + RunInvTxfm(test_input_block, test_temp_block, + dst, pitch, tx_type_)); for (int j = 0; j < 64; ++j) { const int diff = dst[j] - src[j]; -- GitLab