summaryrefslogtreecommitdiff
path: root/lib/mesa/src/util/tests
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2019-01-29 10:48:22 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2019-01-29 10:48:22 +0000
commitc3fdbed0e06c6096cb4ac3222201a6b6d81fe0ee (patch)
tree88747e5c0c99b4d6545122d8c4f432d61651c34e /lib/mesa/src/util/tests
parent27f1603bcb35dc0629966529c5b85cd8936ea1c8 (diff)
Import Mesa 18.3.2
Diffstat (limited to 'lib/mesa/src/util/tests')
-rw-r--r--lib/mesa/src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp15
-rw-r--r--lib/mesa/src/util/tests/fast_idiv_by_const/meson.build9
-rw-r--r--lib/mesa/src/util/tests/set/meson.build8
-rw-r--r--lib/mesa/src/util/tests/set/set_test.cpp58
-rw-r--r--lib/mesa/src/util/tests/string_buffer/meson.build9
5 files changed, 20 insertions, 79 deletions
diff --git a/lib/mesa/src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp b/lib/mesa/src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp
index abf607994..3983a39ed 100644
--- a/lib/mesa/src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp
+++ b/lib/mesa/src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp
@@ -21,8 +21,6 @@
* IN THE SOFTWARE.
*/
-#undef NDEBUG
-
#include <gtest/gtest.h>
#include "util/bigmath.h"
#include "util/fast_idiv_by_const.h"
@@ -30,6 +28,9 @@
#define RAND_TEST_ITERATIONS 100000
+#define MAX_UINT(bits) \
+ (((bits) == 64) ? UINT64_MAX : ((1ull << (bits)) - 1))
+
static inline uint64_t
utrunc(uint64_t x, unsigned num_bits)
{
@@ -45,7 +46,7 @@ strunc(int64_t x, unsigned num_bits)
if (num_bits == 64)
return x;
- return (int64_t)((uint64_t)x << (64 - num_bits)) >> (64 - num_bits);
+ return (x << (64 - num_bits)) >> (64 - num_bits);
}
static inline bool
@@ -79,7 +80,7 @@ uadd_sat(uint64_t a, uint64_t b, unsigned num_bits)
return sum < a ? UINT64_MAX : sum;
} else {
/* Check if sum is more than num_bits */
- return (sum >> num_bits) ? u_uintN_max(num_bits) : sum;
+ return (sum >> num_bits) ? MAX_UINT(num_bits) : sum;
}
}
@@ -198,7 +199,7 @@ rand_uint(unsigned bits, unsigned min)
if (k == 17) {
return min + (rand() % 16);
} else if (k == 42) {
- return u_uintN_max(bits) - (rand() % 16);
+ return MAX_UINT(bits) - (rand() % 16);
} else if (k == 9) {
uint64_t r;
do {
@@ -227,7 +228,7 @@ rand_sint(unsigned bits, unsigned min_abs)
{
/* Make sure we hit MIN_INT every once in a while */
if (rand() % 64 == 37)
- return u_intN_min(bits);
+ return -(1 << (bits - 1));
int64_t s = rand_uint(bits - 1, min_abs);
return rand() & 1 ? s : -s;
@@ -303,7 +304,7 @@ random_sdiv_test(unsigned bits)
int64_t d;
do {
d = rand_sint(bits, 2);
- } while (d == INT64_MIN || util_is_power_of_two_or_zero64(llabs(d)));
+ } while (util_is_power_of_two_or_zero64(llabs(d)));
assert(sint_is_in_range(n, bits));
assert(sint_is_in_range(d, bits) && llabs(d) >= 2);
diff --git a/lib/mesa/src/util/tests/fast_idiv_by_const/meson.build b/lib/mesa/src/util/tests/fast_idiv_by_const/meson.build
index 9c8c03d97..8c3b79493 100644
--- a/lib/mesa/src/util/tests/fast_idiv_by_const/meson.build
+++ b/lib/mesa/src/util/tests/fast_idiv_by_const/meson.build
@@ -23,9 +23,8 @@ test(
executable(
'fast_idiv_by_const_test',
'fast_idiv_by_const_test.cpp',
- dependencies : [idep_gtest, idep_mesautil],
- include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
- ),
- suite : ['util'],
- timeout: 60,
+ dependencies : [dep_thread, dep_dl, idep_gtest],
+ include_directories : inc_common,
+ link_with : [libmesa_util],
+ )
)
diff --git a/lib/mesa/src/util/tests/set/meson.build b/lib/mesa/src/util/tests/set/meson.build
index e9b00629b..add3fc560 100644
--- a/lib/mesa/src/util/tests/set/meson.build
+++ b/lib/mesa/src/util/tests/set/meson.build
@@ -23,8 +23,8 @@ test(
executable(
'set_test',
'set_test.cpp',
- dependencies : [dep_thread, dep_dl, idep_gtest, idep_mesautil],
- include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
- ),
- suite : ['util'],
+ dependencies : [dep_thread, dep_dl, idep_gtest],
+ include_directories : inc_common,
+ link_with : [libmesa_util],
+ )
)
diff --git a/lib/mesa/src/util/tests/set/set_test.cpp b/lib/mesa/src/util/tests/set/set_test.cpp
index 67e3085ee..a1eef0b3d 100644
--- a/lib/mesa/src/util/tests/set/set_test.cpp
+++ b/lib/mesa/src/util/tests/set/set_test.cpp
@@ -51,27 +51,6 @@ TEST(set, basic)
entry = _mesa_set_search(s, a);
EXPECT_FALSE(entry);
- _mesa_set_clear(s, NULL);
- EXPECT_EQ(s->entries, 0);
- EXPECT_EQ(s->deleted_entries, 0);
- set_foreach(s, he) {
- GTEST_FAIL();
- }
-
- _mesa_set_add(s, a);
- _mesa_set_add(s, b);
- EXPECT_EQ(s->entries, 2);
- unsigned count = s->entries;
- set_foreach_remove(s, he) {
- EXPECT_TRUE(he->key == a || he->key == b);
- EXPECT_EQ(s->entries, count--);
- EXPECT_EQ(s->deleted_entries, 0);
- }
- EXPECT_EQ(s->entries, 0);
- set_foreach(s, he) {
- GTEST_FAIL();
- }
-
_mesa_set_destroy(s, NULL);
}
@@ -134,40 +113,3 @@ TEST(set, remove_key)
_mesa_set_destroy(s, NULL);
}
-
-static uint32_t hash_int(const void *p)
-{
- int i = *(const int *)p;
- return i;
-}
-
-static bool cmp_int(const void *p1, const void *p2)
-{
- int i1 = *(const int *)p1, i2 = *(const int *)p2;
- return i1 == i2;
-}
-
-TEST(set, search_or_add)
-{
- struct set *s = _mesa_set_create(NULL, hash_int, cmp_int);
-
- int a = 10, b = 20, c = 20, d = 30;
-
- _mesa_set_add(s, &a);
- _mesa_set_add(s, &b);
- EXPECT_EQ(s->entries, 2);
-
- bool found = false;
- struct set_entry *entry = _mesa_set_search_or_add(s, &c, &found);
- EXPECT_EQ(entry->key, (void *)&b);
- EXPECT_EQ(found, true);
- EXPECT_EQ(s->entries, 2);
-
- found = false;
- struct set_entry *entry3 = _mesa_set_search_or_add(s, &d, &found);
- EXPECT_EQ(entry3->key, &d);
- EXPECT_EQ(found, false);
- EXPECT_EQ(s->entries, 3);
-
- _mesa_set_destroy(s, NULL);
-}
diff --git a/lib/mesa/src/util/tests/string_buffer/meson.build b/lib/mesa/src/util/tests/string_buffer/meson.build
index acb6abca4..9f42e3550 100644
--- a/lib/mesa/src/util/tests/string_buffer/meson.build
+++ b/lib/mesa/src/util/tests/string_buffer/meson.build
@@ -23,9 +23,8 @@ test(
executable(
'string_buffer_test',
'string_buffer_test.cpp',
- cpp_args : [cpp_msvc_compat_args],
- dependencies : [idep_gtest, idep_mesautil],
- include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
- ),
- suite : ['util'],
+ dependencies : [dep_thread, dep_dl, idep_gtest],
+ include_directories : inc_common,
+ link_with : [libmesa_util],
+ )
)