aboutsummaryrefslogtreecommitdiff
path: root/regress/unittests/bitmap/tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'regress/unittests/bitmap/tests.c')
-rw-r--r--regress/unittests/bitmap/tests.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/regress/unittests/bitmap/tests.c b/regress/unittests/bitmap/tests.c
index 576b863f4066..6470f983d447 100644
--- a/regress/unittests/bitmap/tests.c
+++ b/regress/unittests/bitmap/tests.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tests.c,v 1.2 2021/12/14 21:25:27 deraadt Exp $ */
+/* $OpenBSD: tests.c,v 1.3 2025/04/15 04:00:42 djm Exp $ */
/*
* Regress test for bitmap.h bitmap API
*
@@ -9,9 +9,7 @@
#include <sys/types.h>
#include <stdio.h>
-#ifdef HAVE_STDINT_H
#include <stdint.h>
-#endif
#include <stdlib.h>
#include <string.h>
@@ -23,7 +21,7 @@
#include "bitmap.h"
-#define NTESTS 131
+#define DEFAULT_NTESTS 131
void
tests(void)
@@ -32,10 +30,15 @@ tests(void)
struct bitmap *b;
BIGNUM *bn;
size_t len;
- int i, j, k, n;
+ int i, j, k, n, ntests = DEFAULT_NTESTS;
u_char bbuf[1024], bnbuf[1024];
int r;
+ if (test_is_fast())
+ ntests /= 4;
+ else if (test_is_slow())
+ ntests *= 2;
+
TEST_START("bitmap_new");
b = bitmap_new();
ASSERT_PTR_NE(b, NULL);
@@ -44,9 +47,9 @@ tests(void)
TEST_DONE();
TEST_START("bitmap_set_bit / bitmap_test_bit");
- for (i = -1; i < NTESTS; i++) {
- for (j = -1; j < NTESTS; j++) {
- for (k = -1; k < NTESTS; k++) {
+ for (i = -1; i < ntests; i++) {
+ for (j = -1; j < ntests; j++) {
+ for (k = -1; k < ntests; k++) {
bitmap_zero(b);
BN_clear(bn);
@@ -67,7 +70,7 @@ tests(void)
/* Check perfect match between bitmap and bn */
test_subtest_info("match %d/%d/%d", i, j, k);
- for (n = 0; n < NTESTS; n++) {
+ for (n = 0; n < ntests; n++) {
ASSERT_INT_EQ(BN_is_bit_set(bn, n),
bitmap_test_bit(b, n));
}
@@ -99,7 +102,7 @@ tests(void)
bitmap_zero(b);
ASSERT_INT_EQ(bitmap_from_string(b, bnbuf,
len), 0);
- for (n = 0; n < NTESTS; n++) {
+ for (n = 0; n < ntests; n++) {
ASSERT_INT_EQ(BN_is_bit_set(bn, n),
bitmap_test_bit(b, n));
}
@@ -107,7 +110,7 @@ tests(void)
/* Test clearing bits */
test_subtest_info("clear %d/%d/%d",
i, j, k);
- for (n = 0; n < NTESTS; n++) {
+ for (n = 0; n < ntests; n++) {
ASSERT_INT_EQ(bitmap_set_bit(b, n), 0);
ASSERT_INT_EQ(BN_set_bit(bn, n), 1);
}
@@ -123,7 +126,7 @@ tests(void)
bitmap_clear_bit(b, k);
BN_clear_bit(bn, k);
}
- for (n = 0; n < NTESTS; n++) {
+ for (n = 0; n < ntests; n++) {
ASSERT_INT_EQ(BN_is_bit_set(bn, n),
bitmap_test_bit(b, n));
}
@@ -135,4 +138,9 @@ tests(void)
TEST_DONE();
#endif
}
+void
+benchmarks(void)
+{
+ printf("no benchmarks\n");
+}