blob: 62521e88efc1ccfd0911d5ad732d83238b65a427 [file] [log] [blame]
Shri Borde7cd81492011-11-02 13:20:24 -07001/*
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -08002 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
Shri Borde7cd81492011-11-02 13:20:24 -07003 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -080011#ifndef UNIT_TEST_UNIT_TEST_H_
12#define UNIT_TEST_UNIT_TEST_H_
Shri Borde7cd81492011-11-02 13:20:24 -070013
14#include <gtest/gtest.h>
15
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -080016#define align_buffer_16(var, size) \
17 uint8* var; \
18 uint8* var##_mem; \
19 var##_mem = reinterpret_cast<uint8*>(malloc((size) + 15)); \
20 var = reinterpret_cast<uint8*> \
21 ((reinterpret_cast<intptr_t>(var##_mem) + 15) & ~15);
22
23#define free_aligned_buffer_16(var) \
24 free(var##_mem); \
25 var = 0;
26
27
28#define align_buffer_page_end(var, size) \
29 uint8* var; \
30 uint8* var##_mem; \
31 var##_mem = reinterpret_cast<uint8*>(malloc(((size) + 4095) & ~4095)); \
32 var = var##_mem + (-(size) & 4095);
33
34#define free_aligned_buffer_page_end(var) \
35 free(var##_mem); \
36 var = 0;
37
38#ifdef WIN32
39#include <windows.h>
40static inline double get_time() {
41 LARGE_INTEGER t, f;
42 QueryPerformanceCounter(&t);
43 QueryPerformanceFrequency(&f);
44 return static_cast<double>(t.QuadPart) / static_cast<double>(f.QuadPart);
45}
46
47#define random rand
48#define srandom srand
49#else
50
51#include <sys/time.h>
52#include <sys/resource.h>
53
54static inline double get_time() {
55 struct timeval t;
56 struct timezone tzp;
57 gettimeofday(&t, &tzp);
58 return t.tv_sec + t.tv_usec * 1e-6;
59}
60#endif
61
Shri Borde7cd81492011-11-02 13:20:24 -070062class libyuvTest : public ::testing::Test {
63 protected:
64 libyuvTest();
Shri Borde7cd81492011-11-02 13:20:24 -070065
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -080066 const int rotate_max_w_;
67 const int rotate_max_h_;
Shri Borde7cd81492011-11-02 13:20:24 -070068
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -080069 int benchmark_iterations_;
70 const int benchmark_width_;
71 const int benchmark_height_;
Shri Borde7cd81492011-11-02 13:20:24 -070072};
73
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -080074#endif // UNIT_TEST_UNIT_TEST_H_