aboutsummaryrefslogtreecommitdiff
path: root/testcode
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2018-10-09 19:42:34 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2018-10-09 19:42:34 +0000
commit0a0da7ddd5c01b9259ddad3331e1629ee066505d (patch)
treefd129f43a9bc4160d8fd56f12f9bb76269bc632f /testcode
parentdcaa814d350c5ee7deb2164502a24f2f698b9799 (diff)
Vendor import of Unbound 1.8.1.vendor/unbound/1.8.1
Diffstat (limited to 'testcode')
-rw-r--r--testcode/asynclook.c22
-rw-r--r--testcode/delayer.c2
-rw-r--r--testcode/perf.c6
-rw-r--r--testcode/petal.c10
-rw-r--r--testcode/replay.c15
-rw-r--r--testcode/testbound.c6
-rw-r--r--testcode/testpkts.c1
-rw-r--r--testcode/unitneg.c2
8 files changed, 41 insertions, 23 deletions
diff --git a/testcode/asynclook.c b/testcode/asynclook.c
index 06bcf5ab862a..f82c6dcab71c 100644
--- a/testcode/asynclook.c
+++ b/testcode/asynclook.c
@@ -182,6 +182,8 @@ struct ext_thr_info {
char** argv;
/** number of queries to do */
int numq;
+ /** list of ids to free once threads are done */
+ struct track_id* id_list;
};
/** if true, we are testing against 'localhost' and extra checking is done */
@@ -309,6 +311,7 @@ ext_thread(void* arg)
for(i=0; i<inf->numq; i++) {
lock_basic_init(&async_ids[i].lock);
}
+ inf->id_list = async_ids;
}
for(i=0; i<inf->numq; i++) {
if(async_ids) {
@@ -347,14 +350,6 @@ ext_thread(void* arg)
/* if these locks are destroyed, or if the async_ids is freed, then
a use-after-free happens in another thread.
The allocation is only part of this test, though. */
- /*
- if(async_ids) {
- for(i=0; i<inf->numq; i++) {
- lock_basic_destroy(&async_ids[i].lock);
- }
- }
- free(async_ids);
- */
return NULL;
}
@@ -375,6 +370,7 @@ ext_test(struct ub_ctx* ctx, int argc, char** argv)
inf[i].argc = argc;
inf[i].argv = argv;
inf[i].numq = 100;
+ inf[i].id_list = NULL;
ub_thread_create(&inf[i].tid, ext_thread, &inf[i]);
}
/* the work happens here */
@@ -382,6 +378,16 @@ ext_test(struct ub_ctx* ctx, int argc, char** argv)
ub_thread_join(inf[i].tid);
}
printf("extended test end\n");
+ /* free the id lists */
+ for(i=0; i<NUMTHR; i++) {
+ if(inf[i].id_list) {
+ int j;
+ for(j=0; j<inf[i].numq; j++) {
+ lock_basic_destroy(&inf[i].id_list[j].lock);
+ }
+ free(inf[i].id_list);
+ }
+ }
ub_ctx_delete(ctx);
checklock_stop();
return 0;
diff --git a/testcode/delayer.c b/testcode/delayer.c
index 5489b591e337..4abcfc235dcd 100644
--- a/testcode/delayer.c
+++ b/testcode/delayer.c
@@ -788,7 +788,7 @@ service_tcp_relay(struct tcp_proxy** tcp_proxies, struct timeval* now,
if(!tcp_relay_write(p->server_s, &p->querylist,
&p->querylast, now))
delete_it = 1;
- if(p->querylist && p->server_s != -1 &&
+ if(p->querylist &&
dl_tv_smaller(&p->querylist->wait, now))
FD_SET(FD_SET_T p->server_s, worig);
else FD_CLR(FD_SET_T p->server_s, worig);
diff --git a/testcode/perf.c b/testcode/perf.c
index d11357c4acaa..32a5307edb15 100644
--- a/testcode/perf.c
+++ b/testcode/perf.c
@@ -610,7 +610,7 @@ int main(int argc, char* argv[])
case 'd':
if(atoi(optarg)==0 && strcmp(optarg, "0")!=0) {
printf("-d not a number %s", optarg);
- return 1;
+ exit(1);
}
info.duration = atoi(optarg);
break;
@@ -635,11 +635,11 @@ int main(int argc, char* argv[])
}
if(!extstrtoaddr(argv[0], &info.dest, &info.destlen)) {
printf("Could not parse ip: %s\n", argv[0]);
- return 1;
+ exit(1);
}
if(info.qlist_size == 0) {
printf("No queries to make, use -f or -a.\n");
- return 1;
+ exit(1);
}
/* do the performance test */
diff --git a/testcode/petal.c b/testcode/petal.c
index 1c26fa700346..e1f5f43417e3 100644
--- a/testcode/petal.c
+++ b/testcode/petal.c
@@ -417,7 +417,7 @@ provide_file_10(SSL* ssl, char* fname)
}
fclose(in);
at += len;
- avail -= len;
+ /* avail -= len; unused */
if(SSL_write(ssl, buf, at-buf) <= 0) {
/* write failure */
}
@@ -506,7 +506,7 @@ provide_file_chunked(SSL* ssl, char* fname)
snprintf(at, avail, "\r\n");
r = strlen(at);
at += r;
- avail -= r;
+ /* avail -= r; unused */
}
/* send chunk */
if(SSL_write(ssl, buf, at-buf) <= 0) {
@@ -569,7 +569,9 @@ do_service(char* addr, int port, char* key, char* cert)
while(go) {
struct sockaddr_storage from;
socklen_t flen = (socklen_t)sizeof(from);
- int s = accept(fd, (struct sockaddr*)&from, &flen);
+ int s;
+ memset(&from, 0, sizeof(from));
+ s = accept(fd, (struct sockaddr*)&from, &flen);
if(verb) fflush(stdout);
if(s != -1) {
SSL* ssl = setup_ssl(s, sslctx);
@@ -633,7 +635,7 @@ int main(int argc, char* argv[])
}
}
argc -= optind;
- argv += optind;
+ /* argv += optind; not using further arguments */
if(argc != 0)
usage();
diff --git a/testcode/replay.c b/testcode/replay.c
index 08d87470bd00..93a600425ca1 100644
--- a/testcode/replay.c
+++ b/testcode/replay.c
@@ -458,6 +458,8 @@ replay_scenario_read(FILE* in, const char* name, int* lineno)
if(parse_keyword(&parse, ";"))
continue; /* comment */
if(parse_keyword(&parse, "SCENARIO_BEGIN")) {
+ if(scen)
+ fatal_exit("%d: double SCENARIO_BEGIN", *lineno);
scen = make_scenario(parse);
if(!scen)
fatal_exit("%d: could not make scen", *lineno);
@@ -801,14 +803,19 @@ macro_expand(rbtree_type* store, struct replay_runtime* runtime, char** text)
/* check for functions */
if(strcmp(buf, "time") == 0) {
- snprintf(buf, sizeof(buf), ARG_LL "d", (long long)runtime->now_secs);
+ if(runtime)
+ snprintf(buf, sizeof(buf), ARG_LL "d", (long long)runtime->now_secs);
+ else
+ snprintf(buf, sizeof(buf), ARG_LL "d", (long long)0);
*text += len;
return strdup(buf);
} else if(strcmp(buf, "timeout") == 0) {
time_t res = 0;
- struct fake_timer* t = first_timer(runtime);
- if(t && (time_t)t->tv.tv_sec >= runtime->now_secs)
- res = (time_t)t->tv.tv_sec - runtime->now_secs;
+ if(runtime) {
+ struct fake_timer* t = first_timer(runtime);
+ if(t && (time_t)t->tv.tv_sec >= runtime->now_secs)
+ res = (time_t)t->tv.tv_sec - runtime->now_secs;
+ }
snprintf(buf, sizeof(buf), ARG_LL "d", (long long)res);
*text += len;
return strdup(buf);
diff --git a/testcode/testbound.c b/testcode/testbound.c
index 071ac9c2a5b4..cea74c593540 100644
--- a/testcode/testbound.c
+++ b/testcode/testbound.c
@@ -429,14 +429,14 @@ main(int argc, char* argv[])
case 'h':
default:
testbound_usage();
- return 1;
+ exit(1);
}
}
argc -= optind;
- argv += optind;
+ /* argv += optind; not using further arguments */
if(argc != 0) {
testbound_usage();
- return 1;
+ exit(1);
}
log_info("Start of %s testbound program.", PACKAGE_STRING);
if(atexit(&remove_configfile) != 0)
diff --git a/testcode/testpkts.c b/testcode/testpkts.c
index ec0f7fe2449a..01f23e48ed2e 100644
--- a/testcode/testpkts.c
+++ b/testcode/testpkts.c
@@ -46,6 +46,7 @@ enum verbosity_value { NO_VERBOSE=0 };
#endif
/** logging routine, provided by caller */
void verbose(enum verbosity_value lvl, const char* msg, ...) ATTR_FORMAT(printf, 2, 3);
+static void error(const char* msg, ...) ATTR_NORETURN;
/** print error and exit */
static void error(const char* msg, ...)
diff --git a/testcode/unitneg.c b/testcode/unitneg.c
index 4cd9b306c72e..59c4e8dcc643 100644
--- a/testcode/unitneg.c
+++ b/testcode/unitneg.c
@@ -118,6 +118,8 @@ static void get_random_data(char** fromp, char** top, char* zname)
int labnum1[10], labnum2[10];
int i;
char* p;
+ memset(labnum1, 0, sizeof(int)*10);
+ memset(labnum2, 0, sizeof(int)*10);
*fromp = buf1;
*top = buf2;