Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: source/libvpx/test/register_state_check.h

Issue 232133009: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/test/pp_filter_test.cc ('k') | source/libvpx/test/set_roi.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/test/register_state_check.h
===================================================================
--- source/libvpx/test/register_state_check.h (revision 263011)
+++ source/libvpx/test/register_state_check.h (working copy)
@@ -11,14 +11,15 @@
#ifndef TEST_REGISTER_STATE_CHECK_H_
#define TEST_REGISTER_STATE_CHECK_H_
-#ifdef _WIN64
+#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "./vpx_config.h"
+#if defined(_WIN64)
+
#define _WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winnt.h>
-#include "third_party/googletest/src/include/gtest/gtest.h"
-
namespace testing {
namespace internal {
@@ -81,10 +82,64 @@
} // namespace libvpx_test
-#else // !_WIN64
+#elif defined(CONFIG_SHARED) && defined(HAVE_NEON) \
+ && !CONFIG_SHARED && HAVE_NEON
+#include "vpx/vpx_integer.h"
+
+extern "C" {
+// Save the d8-d15 registers into store.
+void vp9_push_neon(int64_t *store);
+}
+
namespace libvpx_test {
+// Compares the state of d8-d15 at construction with their state at
+// destruction. These registers should be preserved by the callee on
+// arm platform.
+// Usage:
+// {
+// RegisterStateCheck reg_check;
+// FunctionToVerify();
+// }
+class RegisterStateCheck {
+ public:
+ RegisterStateCheck() { initialized_ = StoreRegisters(pre_store_); }
+ ~RegisterStateCheck() { EXPECT_TRUE(Check()); }
+
+ private:
+ static bool StoreRegisters(int64_t store[8]) {
+ vp9_push_neon(store);
+ return true;
+ }
+
+ // Compares the register state. Returns true if the states match.
+ bool Check() const {
+ if (!initialized_) return false;
+ int64_t post_store[8];
+ vp9_push_neon(post_store);
+ for (int i = 0; i < 8; ++i) {
+ EXPECT_EQ(pre_store_[i], post_store[i]) << "d"
+ << i + 8 << " has been modified";
+ }
+ return !testing::Test::HasNonfatalFailure();
+ }
+
+ bool initialized_;
+ int64_t pre_store_[8];
+};
+
+#define REGISTER_STATE_CHECK(statement) do { \
+ libvpx_test::RegisterStateCheck reg_check; \
+ statement; \
+} while (false)
+
+} // namespace libvpx_test
+
+#else
+
+namespace libvpx_test {
+
class RegisterStateCheck {};
#define REGISTER_STATE_CHECK(statement) statement
« no previous file with comments | « source/libvpx/test/pp_filter_test.cc ('k') | source/libvpx/test/set_roi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698