summaryrefslogtreecommitdiff
path: root/testcode
diff options
context:
space:
mode:
Diffstat (limited to 'testcode')
-rw-r--r--testcode/petal.c18
-rw-r--r--testcode/replay.c75
-rw-r--r--testcode/testbound.c1
3 files changed, 59 insertions, 35 deletions
diff --git a/testcode/petal.c b/testcode/petal.c
index 964735b39ddc8..a54181c372f19 100644
--- a/testcode/petal.c
+++ b/testcode/petal.c
@@ -236,12 +236,28 @@ setup_ctx(char* key, char* cert)
if(!ctx) print_exit("out of memory");
(void)SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2);
(void)SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv3);
- if(!SSL_CTX_use_certificate_file(ctx, cert, SSL_FILETYPE_PEM))
+ if(!SSL_CTX_use_certificate_chain_file(ctx, cert))
print_exit("cannot read cert");
if(!SSL_CTX_use_PrivateKey_file(ctx, key, SSL_FILETYPE_PEM))
print_exit("cannot read key");
if(!SSL_CTX_check_private_key(ctx))
print_exit("private key is not correct");
+#if HAVE_DECL_SSL_CTX_SET_ECDH_AUTO
+ if (!SSL_CTX_set_ecdh_auto(ctx,1))
+ if(verb>=1) printf("failed to set_ecdh_auto, not enabling ECDHE\n");
+#elif defined(USE_ECDSA)
+ if(1) {
+ EC_KEY *ecdh = EC_KEY_new_by_curve_name (NID_X9_62_prime256v1);
+ if (!ecdh) {
+ if(verb>=1) printf("could not find p256, not enabling ECDHE\n");
+ } else {
+ if (1 != SSL_CTX_set_tmp_ecdh (ctx, ecdh)) {
+ if(verb>=1) printf("Error in SSL_CTX_set_tmp_ecdh, not enabling ECDHE\n");
+ }
+ EC_KEY_free(ecdh);
+ }
+ }
+#endif
if(!SSL_CTX_load_verify_locations(ctx, cert, NULL))
print_exit("cannot load cert verify locations");
return ctx;
diff --git a/testcode/replay.c b/testcode/replay.c
index 01b17a7f7d0cc..8a88814e765ad 100644
--- a/testcode/replay.c
+++ b/testcode/replay.c
@@ -909,118 +909,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/testcode/testbound.c b/testcode/testbound.c
index fa361c4ead641..b297f477476e8 100644
--- a/testcode/testbound.c
+++ b/testcode/testbound.c
@@ -284,7 +284,6 @@ 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)