aboutsummaryrefslogtreecommitdiff
path: root/external/unbound/testcode
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--external/unbound/testcode/checklocks.c25
-rw-r--r--external/unbound/testcode/fake_event.c2
-rw-r--r--external/unbound/testcode/lock_verify.c3
-rw-r--r--external/unbound/testcode/replay.c78
-rw-r--r--external/unbound/testcode/testbound.c5
-rw-r--r--external/unbound/testcode/testpkts.h2
-rw-r--r--external/unbound/testcode/unitlruhash.c2
-rw-r--r--external/unbound/testcode/unitmain.c2
-rw-r--r--external/unbound/testcode/unitslabhash.c2
-rw-r--r--external/unbound/testcode/unitverify.c4
10 files changed, 73 insertions, 52 deletions
diff --git a/external/unbound/testcode/checklocks.c b/external/unbound/testcode/checklocks.c
index 5815e4fd0..dab98491e 100644
--- a/external/unbound/testcode/checklocks.c
+++ b/external/unbound/testcode/checklocks.c
@@ -430,7 +430,7 @@ finish_acquire_lock(struct thr_check* thr, struct checked_lock* lock,
* @param timedfunc: the pthread_mutex_timedlock or similar function.
* Uses absolute timeout value.
* @param arg: what to pass to tryfunc and timedlock.
- * @param exclusive: if lock must be exlusive (only one allowed).
+ * @param exclusive: if lock must be exclusive (only one allowed).
* @param getwr: if attempts to get writelock (or readlock) for rwlocks.
*/
static void
@@ -502,6 +502,8 @@ void
checklock_rdlock(enum check_lock_type type, struct checked_lock* lock,
const char* func, const char* file, int line)
{
+ if(key_deleted)
+ return;
log_assert(type == check_lock_rwlock);
checklock_lockit(type, lock, func, file, line,
@@ -520,6 +522,8 @@ void
checklock_wrlock(enum check_lock_type type, struct checked_lock* lock,
const char* func, const char* file, int line)
{
+ if(key_deleted)
+ return;
log_assert(type == check_lock_rwlock);
checklock_lockit(type, lock, func, file, line,
try_wr, timed_wr, &lock->u.rwlock, 0, 1);
@@ -555,6 +559,8 @@ void
checklock_lock(enum check_lock_type type, struct checked_lock* lock,
const char* func, const char* file, int line)
{
+ if(key_deleted)
+ return;
log_assert(type != check_lock_rwlock);
switch(type) {
case check_lock_mutex:
@@ -577,8 +583,10 @@ void
checklock_unlock(enum check_lock_type type, struct checked_lock* lock,
const char* func, const char* file, int line)
{
- struct thr_check *thr = (struct thr_check*)pthread_getspecific(
- thr_debug_key);
+ struct thr_check *thr;
+ if(key_deleted)
+ return;
+ thr = (struct thr_check*)pthread_getspecific(thr_debug_key);
checktype(type, lock, func, file, line);
if(!thr) lock_error(lock, func, file, line, "no thread info");
@@ -755,7 +763,8 @@ static void
lock_debug_info(struct checked_lock* lock)
{
if(!lock) return;
- log_info("+++ Lock %x, %d %d create %s %s %d", (int)lock,
+ log_info("+++ Lock %llx, %d %d create %s %s %d",
+ (unsigned long long)(size_t)lock,
lock->create_thread, lock->create_instance,
lock->create_func, lock->create_file, lock->create_line);
log_info("lock type: %s",
@@ -790,8 +799,9 @@ thread_debug_info(struct thr_check* thr)
struct checked_lock* l = NULL;
if(!thr) return;
log_info("pthread id is %x", (int)thr->id);
- log_info("thread func is %x", (int)thr->func);
- log_info("thread arg is %x (%d)", (int)thr->arg,
+ log_info("thread func is %llx", (unsigned long long)(size_t)thr->func);
+ log_info("thread arg is %llx (%d)",
+ (unsigned long long)(size_t)thr->arg,
(thr->arg?*(int*)thr->arg:0));
log_info("thread num is %d", thr->num);
log_info("locks created %d", thr->locks_created);
@@ -801,7 +811,8 @@ thread_debug_info(struct thr_check* thr)
w = thr->waiting;
f = thr->holding_first;
l = thr->holding_last;
- log_info("thread waiting for a lock: %s %x", w?"yes":"no", (int)w);
+ log_info("thread waiting for a lock: %s %llx", w?"yes":"no",
+ (unsigned long long)(size_t)w);
lock_debug_info(w);
log_info("thread holding first: %s, last: %s", f?"yes":"no",
l?"yes":"no");
diff --git a/external/unbound/testcode/fake_event.c b/external/unbound/testcode/fake_event.c
index 4335a8f22..e371cfdaa 100644
--- a/external/unbound/testcode/fake_event.c
+++ b/external/unbound/testcode/fake_event.c
@@ -569,7 +569,7 @@ do_infra_rtt(struct replay_runtime* runtime)
free(dp);
}
-/** perform exponential backoff on the timout */
+/** perform exponential backoff on the timeout */
static void
expon_timeout_backoff(struct replay_runtime* runtime)
{
diff --git a/external/unbound/testcode/lock_verify.c b/external/unbound/testcode/lock_verify.c
index a46d5d99e..786d523c3 100644
--- a/external/unbound/testcode/lock_verify.c
+++ b/external/unbound/testcode/lock_verify.c
@@ -44,6 +44,9 @@
*/
#include "config.h"
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
#include "util/log.h"
#include "util/rbtree.h"
#include "util/locks.h"
diff --git a/external/unbound/testcode/replay.c b/external/unbound/testcode/replay.c
index 01b17a7f7..22670eb93 100644
--- a/external/unbound/testcode/replay.c
+++ b/external/unbound/testcode/replay.c
@@ -499,8 +499,7 @@ replay_scenario_delete(struct replay_scenario* scen)
struct replay_range* rng, *rngn;
if(!scen)
return;
- if(scen->title)
- free(scen->title);
+ free(scen->title);
mom = scen->mom_first;
while(mom) {
momn = mom->mom_next;
@@ -909,118 +908,127 @@ macro_assign(rbtree_t* store, char* name, char* value)
return x->value != NULL;
}
+/* testbound assert function for selftest. counts the number of tests */
+#define tb_assert(x) \
+ do { if(!(x)) fatal_exit("%s:%d: %s: assertion %s failed", \
+ __FILE__, __LINE__, __func__, #x); \
+ num_asserts++; \
+ } while(0);
+
void testbound_selftest(void)
{
/* test the macro store */
rbtree_t* store = macro_store_create();
char* v;
int r;
- log_assert(store);
+ int num_asserts = 0;
+ tb_assert(store);
v = macro_lookup(store, "bla");
- log_assert(strcmp(v, "") == 0);
+ tb_assert(strcmp(v, "") == 0);
free(v);
v = macro_lookup(store, "vlerk");
- log_assert(strcmp(v, "") == 0);
+ tb_assert(strcmp(v, "") == 0);
free(v);
r = macro_assign(store, "bla", "waarde1");
- log_assert(r);
+ tb_assert(r);
v = macro_lookup(store, "vlerk");
- log_assert(strcmp(v, "") == 0);
+ tb_assert(strcmp(v, "") == 0);
free(v);
v = macro_lookup(store, "bla");
- log_assert(strcmp(v, "waarde1") == 0);
+ tb_assert(strcmp(v, "waarde1") == 0);
free(v);
r = macro_assign(store, "vlerk", "kanteel");
- log_assert(r);
+ tb_assert(r);
v = macro_lookup(store, "bla");
- log_assert(strcmp(v, "waarde1") == 0);
+ tb_assert(strcmp(v, "waarde1") == 0);
free(v);
v = macro_lookup(store, "vlerk");
- log_assert(strcmp(v, "kanteel") == 0);
+ tb_assert(strcmp(v, "kanteel") == 0);
free(v);
r = macro_assign(store, "bla", "ww");
- log_assert(r);
+ tb_assert(r);
v = macro_lookup(store, "bla");
- log_assert(strcmp(v, "ww") == 0);
+ tb_assert(strcmp(v, "ww") == 0);
free(v);
- log_assert( macro_length("}") == 1);
- log_assert( macro_length("blabla}") == 7);
- log_assert( macro_length("bla${zoink}bla}") == 7+8);
- log_assert( macro_length("bla${zoink}${bla}bla}") == 7+8+6);
+ tb_assert( macro_length("}") == 1);
+ tb_assert( macro_length("blabla}") == 7);
+ tb_assert( macro_length("bla${zoink}bla}") == 7+8);
+ tb_assert( macro_length("bla${zoink}${bla}bla}") == 7+8+6);
v = macro_process(store, NULL, "");
- log_assert( v && strcmp(v, "") == 0);
+ tb_assert( v && strcmp(v, "") == 0);
free(v);
v = macro_process(store, NULL, "${}");
- log_assert( v && strcmp(v, "") == 0);
+ tb_assert( v && strcmp(v, "") == 0);
free(v);
v = macro_process(store, NULL, "blabla ${} dinges");
- log_assert( v && strcmp(v, "blabla dinges") == 0);
+ tb_assert( v && strcmp(v, "blabla dinges") == 0);
free(v);
v = macro_process(store, NULL, "1${$bla}2${$bla}3");
- log_assert( v && strcmp(v, "1ww2ww3") == 0);
+ tb_assert( v && strcmp(v, "1ww2ww3") == 0);
free(v);
v = macro_process(store, NULL, "it is ${ctime 123456}");
- log_assert( v && strcmp(v, "it is Fri Jan 2 10:17:36 1970") == 0);
+ tb_assert( v && strcmp(v, "it is Fri Jan 2 10:17:36 1970") == 0);
free(v);
r = macro_assign(store, "t1", "123456");
- log_assert(r);
+ tb_assert(r);
v = macro_process(store, NULL, "it is ${ctime ${$t1}}");
- log_assert( v && strcmp(v, "it is Fri Jan 2 10:17:36 1970") == 0);
+ tb_assert( v && strcmp(v, "it is Fri Jan 2 10:17:36 1970") == 0);
free(v);
v = macro_process(store, NULL, "it is ${ctime $t1}");
- log_assert( v && strcmp(v, "it is Fri Jan 2 10:17:36 1970") == 0);
+ tb_assert( v && strcmp(v, "it is Fri Jan 2 10:17:36 1970") == 0);
free(v);
r = macro_assign(store, "x", "1");
- log_assert(r);
+ tb_assert(r);
r = macro_assign(store, "y", "2");
- log_assert(r);
+ tb_assert(r);
v = macro_process(store, NULL, "${$x + $x}");
- log_assert( v && strcmp(v, "2") == 0);
+ tb_assert( v && strcmp(v, "2") == 0);
free(v);
v = macro_process(store, NULL, "${$x - $x}");
- log_assert( v && strcmp(v, "0") == 0);
+ tb_assert( v && strcmp(v, "0") == 0);
free(v);
v = macro_process(store, NULL, "${$y * $y}");
- log_assert( v && strcmp(v, "4") == 0);
+ tb_assert( v && strcmp(v, "4") == 0);
free(v);
v = macro_process(store, NULL, "${32 / $y + $x + $y}");
- log_assert( v && strcmp(v, "19") == 0);
+ tb_assert( v && strcmp(v, "19") == 0);
free(v);
v = macro_process(store, NULL, "${32 / ${$y+$y} + ${${100*3}/3}}");
- log_assert( v && strcmp(v, "108") == 0);
+ tb_assert( v && strcmp(v, "108") == 0);
free(v);
v = macro_process(store, NULL, "${1 2 33 2 1}");
- log_assert( v && strcmp(v, "1 2 33 2 1") == 0);
+ tb_assert( v && strcmp(v, "1 2 33 2 1") == 0);
free(v);
v = macro_process(store, NULL, "${123 3 + 5}");
- log_assert( v && strcmp(v, "123 8") == 0);
+ tb_assert( v && strcmp(v, "123 8") == 0);
free(v);
v = macro_process(store, NULL, "${123 glug 3 + 5}");
- log_assert( v && strcmp(v, "123 glug 8") == 0);
+ tb_assert( v && strcmp(v, "123 glug 8") == 0);
free(v);
macro_store_delete(store);
+ printf("selftest successful (%d checks).\n", num_asserts);
}
diff --git a/external/unbound/testcode/testbound.c b/external/unbound/testcode/testbound.c
index fa361c4ea..d908150a0 100644
--- a/external/unbound/testcode/testbound.c
+++ b/external/unbound/testcode/testbound.c
@@ -35,7 +35,7 @@
*/
/**
* \file
- * Exits with code 1 on a failure. 0 if all unit tests are successfull.
+ * Exits with code 1 on a failure. 0 if all unit tests are successful.
*/
#include "config.h"
@@ -284,10 +284,9 @@ main(int argc, char* argv[])
case 's':
free(pass_argv[1]);
testbound_selftest();
- printf("selftest successful\n");
exit(0);
case '2':
-#if (defined(HAVE_EVP_SHA256) || defined(HAVE_NSS)) && defined(USE_SHA2)
+#if (defined(HAVE_EVP_SHA256) || defined(HAVE_NSS) || defined(HAVE_NETTLE)) && defined(USE_SHA2)
printf("SHA256 supported\n");
exit(0);
#else
diff --git a/external/unbound/testcode/testpkts.h b/external/unbound/testcode/testpkts.h
index 864f33fee..5c000546f 100644
--- a/external/unbound/testcode/testpkts.h
+++ b/external/unbound/testcode/testpkts.h
@@ -214,7 +214,7 @@ void delete_entry(struct entry* list);
* @param in: file to read from. Filepos must be at the start of a new line.
* @param name: name of the file for prettier errors.
* @param pstate: file parse state with lineno, default_ttl,
- * oirigin and prev_rr name.
+ * origin and prev_rr name.
* @param skip_whitespace: skip leftside whitespace.
* @return: The entry read (malloced) or NULL if no entry could be read.
*/
diff --git a/external/unbound/testcode/unitlruhash.c b/external/unbound/testcode/unitlruhash.c
index 32d29d0af..28fc617f4 100644
--- a/external/unbound/testcode/unitlruhash.c
+++ b/external/unbound/testcode/unitlruhash.c
@@ -359,7 +359,7 @@ testlookup_unlim(struct lruhash* table, testdata_t** ref)
static void
test_long_table(struct lruhash* table)
{
- /* assuming it all fits in the hastable, this check will work */
+ /* assuming it all fits in the hashtable, this check will work */
testdata_t* ref[HASHTESTMAX * 100];
size_t i;
memset(ref, 0, sizeof(ref));
diff --git a/external/unbound/testcode/unitmain.c b/external/unbound/testcode/unitmain.c
index 09ebba329..0b32dcd86 100644
--- a/external/unbound/testcode/unitmain.c
+++ b/external/unbound/testcode/unitmain.c
@@ -36,7 +36,7 @@
/**
* \file
* Unit test main program. Calls all the other unit tests.
- * Exits with code 1 on a failure. 0 if all unit tests are successfull.
+ * Exits with code 1 on a failure. 0 if all unit tests are successful.
*/
#include "config.h"
diff --git a/external/unbound/testcode/unitslabhash.c b/external/unbound/testcode/unitslabhash.c
index b4a5048e6..783468883 100644
--- a/external/unbound/testcode/unitslabhash.c
+++ b/external/unbound/testcode/unitslabhash.c
@@ -242,7 +242,7 @@ testlookup_unlim(struct slabhash* table, testdata_t** ref)
static void
test_long_table(struct slabhash* table)
{
- /* assuming it all fits in the hastable, this check will work */
+ /* assuming it all fits in the hashtable, this check will work */
testdata_t* ref[HASHTESTMAX * 100];
size_t i;
memset(ref, 0, sizeof(ref));
diff --git a/external/unbound/testcode/unitverify.c b/external/unbound/testcode/unitverify.c
index 078af0a9c..9cb0eb99e 100644
--- a/external/unbound/testcode/unitverify.c
+++ b/external/unbound/testcode/unitverify.c
@@ -504,12 +504,12 @@ verify_test(void)
verifytest_file("testdata/test_signatures.6", "20080416005004");
verifytest_file("testdata/test_signatures.7", "20070829144150");
verifytest_file("testdata/test_signatures.8", "20070829144150");
-#if (defined(HAVE_EVP_SHA256) || defined(HAVE_NSS)) && defined(USE_SHA2)
+#if (defined(HAVE_EVP_SHA256) || defined(HAVE_NSS) || defined(HAVE_NETTLE)) && defined(USE_SHA2)
verifytest_file("testdata/test_sigs.rsasha256", "20070829144150");
verifytest_file("testdata/test_sigs.sha1_and_256", "20070829144150");
verifytest_file("testdata/test_sigs.rsasha256_draft", "20090101000000");
#endif
-#if (defined(HAVE_EVP_SHA512) || defined(HAVE_NSS)) && defined(USE_SHA2)
+#if (defined(HAVE_EVP_SHA512) || defined(HAVE_NSS) || defined(HAVE_NETTLE)) && defined(USE_SHA2)
verifytest_file("testdata/test_sigs.rsasha512_draft", "20070829144150");
#endif
verifytest_file("testdata/test_sigs.hinfo", "20090107100022");