summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/i965_test_environment.cpp7
-rw-r--r--test/object_heap_test.cpp4
-rw-r--r--test/test_utils.h19
3 files changed, 18 insertions, 12 deletions
diff --git a/test/i965_test_environment.cpp b/test/i965_test_environment.cpp
index 0049c143..ee8b1cc4 100644
--- a/test/i965_test_environment.cpp
+++ b/test/i965_test_environment.cpp
@@ -24,6 +24,8 @@
#include "i965_test_environment.h"
+#include <cstdlib>
+#include <ctime>
#include <fcntl.h> // for O_RDWR
#include <unistd.h> // for close()
#include <va/va_drm.h>
@@ -44,6 +46,11 @@ I965TestEnvironment::I965TestEnvironment()
void I965TestEnvironment::SetUp()
{
+ std::time_t seed(std::time(0));
+ std::srand(seed);
+ ::testing::Test::RecordProperty("rand_seed", seed);
+ std::cout << "Seeded std::rand() with " << seed << "." << std::endl;
+
ASSERT_EQ(-1, m_handle);
ASSERT_PTR_NULL(m_vaDisplay);
diff --git a/test/object_heap_test.cpp b/test/object_heap_test.cpp
index 70257f63..89fd8d78 100644
--- a/test/object_heap_test.cpp
+++ b/test/object_heap_test.cpp
@@ -181,10 +181,6 @@ TEST(ObjectHeapTest, DataIntegrity)
ASSERT_EQ(0, object_heap_init(&heap, sizeof(test_object), 0));
- std::time_t seed = std::time(0);
- std::srand(seed);
- RecordProperty("seed", seed);
-
std::vector<int> values;
auto generator = [&]{
diff --git a/test/test_utils.h b/test/test_utils.h
index 333106c2..8083591f 100644
--- a/test/test_utils.h
+++ b/test/test_utils.h
@@ -26,25 +26,28 @@
#define TEST_UTILS_H
#include <chrono>
-#include <random>
+#include <cstdlib>
template <typename T>
class RandomValueGenerator
{
public:
RandomValueGenerator(const T& min, const T& max)
- : dis(min, max)
- { }
+ : minVal(min)
+ , maxVal(max)
+ {
+ return;
+ }
- const T operator()()
+ const T operator()() const
{
- static std::random_device rd;
- static std::default_random_engine gen(rd());
- return dis(gen);
+ return static_cast<T>(
+ std::rand() % (maxVal + 1 - minVal) + minVal);
}
private:
- std::uniform_int_distribution<T> dis;
+ T minVal;
+ T maxVal;
};
class Timer