Commit 0e36bd80 authored by Ondřej Surý's avatar Ondřej Surý

Get rid of commented out libtap functions, use is_int and is_hex where appropriate

parent a698ce64
......@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
// Test 2: Parse config
int ret = conf_parse_str(conf, sample_conf_rc);
ok(ret == 0, "parsing configuration file %s", config_fn);
is_int(0, ret, "parsing configuration file %s", config_fn);
if (ret != 0) {
skip_block(19, NULL);
goto skip_all;
......@@ -52,11 +52,11 @@ int main(int argc, char *argv[])
struct node *n = HEAD(conf->ifaces);
conf_iface_t *iface = (conf_iface_t*)n;
is_string("10.10.1.1", iface->address, "interface0 address check");
ok(iface->port == 53531, "interface0 port check");
is_int(53531, iface->port, "interface0 port check");
n = n->next;
iface = (conf_iface_t*)n;
is_string("::0", iface->address, "interface1 address check");
ok(iface->port == 53, "interface1 default port check");
is_int(53, iface->port, "interface1 default port check");
// Test 9,10: Check server key
if(conf->key_count <= 0) {
......
......@@ -33,13 +33,13 @@ int main(int argc, char *argv[])
// lengths of different hashes
ok(knot_nsec3_hash_length(1) == 20,
is_int(20, knot_nsec3_hash_length(1),
"raw hash length for SHA1");
ok(knot_nsec3_hash_length(42) == 0,
is_int(0, knot_nsec3_hash_length(42),
"raw hash length for unknown algorithm");
ok(knot_nsec3_hash_b32_length(1) == 32,
is_int(32, knot_nsec3_hash_b32_length(1),
"B32 hash length for SHA1");
ok(knot_nsec3_hash_b32_length(42) == 0,
is_int(0, knot_nsec3_hash_b32_length(42),
"B32 hash length for unknown algorithm");
// parsing NSEC3PARAMs from wire
......@@ -60,11 +60,11 @@ int main(int argc, char *argv[])
result = knot_nsec3_params_from_wire(&params, rrset);
}
ok(params.algorithm == 1, "parse algorithm from wire");
ok(params.flags == 0, "parse flags from wire");
ok(params.iterations == 10, "parse iterations from wire");
ok(params.salt_length == 4, "parse salt length from wire");
ok(memcmp(params.salt, "abcd", 4) == 0, "parse salt from wire");
is_int(1, params.algorithm, "parse algorithm from wire");
is_int(0, params.flags, "parse flags from wire");
is_int(10, params.iterations, "parse iterations from wire");
is_int(4, params.salt_length, "parse salt length from wire");
is_int(0, memcmp(params.salt, "abcd", 4), "parse salt from wire");
knot_rrset_deep_free(&rrset, 1);
knot_nsec3_params_free(&params);
......
......@@ -34,7 +34,7 @@ static void test_algorithm(const char *alg, const knot_key_params_t *kp)
knot_dnssec_key_t key = { 0 };
result = knot_dnssec_key_from_params(kp, &key);
ok(result == KNOT_EOK, "%s: create key from params", alg);
is_int(KNOT_EOK, result, "%s: create key from params", alg);
knot_dnssec_sign_context_t *ctx;
ctx = knot_dnssec_sign_init(&key);
......@@ -51,37 +51,37 @@ static void test_algorithm(const char *alg, const knot_key_params_t *kp)
assert(sig != NULL);
result = knot_dnssec_sign_add(ctx, (uint8_t *)"test", 4);
ok(result == KNOT_EOK, "%s: add data A", alg);
is_int(KNOT_EOK, result, "%s: add data A", alg);
result = knot_dnssec_sign_new(ctx);
ok(result == KNOT_EOK, "%s: restart context", alg);
is_int(KNOT_EOK, result, "%s: restart context", alg);
result = knot_dnssec_sign_add(ctx, (uint8_t *)"hello", 5);
ok(result == KNOT_EOK, "%s: add data B", alg);
is_int(KNOT_EOK, result, "%s: add data B", alg);
result = knot_dnssec_sign_add(ctx, (uint8_t *)"dns", 3);
ok(result == KNOT_EOK, "%s: add data C", alg);
is_int(KNOT_EOK, result, "%s: add data C", alg);
result = knot_dnssec_sign_write(ctx, sig);
ok(result == KNOT_EOK, "%s: write signature", alg);
is_int(KNOT_EOK, result, "%s: write signature", alg);
result = knot_dnssec_sign_new(ctx);
ok(result == KNOT_EOK, "%s: restart context", alg);
is_int(KNOT_EOK, result, "%s: restart context", alg);
result = knot_dnssec_sign_add(ctx, (uint8_t *)"wrong", 5);
ok(result == KNOT_EOK, "%s: add data D", alg);
is_int(KNOT_EOK, result, "%s: add data D", alg);
result = knot_dnssec_sign_verify(ctx, sig, sig_size);
ok(result == KNOT_DNSSEC_EINVALID_SIGNATURE, "%s: verify invalid signature", alg);
result = knot_dnssec_sign_new(ctx);
ok(result == KNOT_EOK, "%s: restart context", alg);
is_int(KNOT_EOK, result, "%s: restart context", alg);
result = knot_dnssec_sign_add(ctx, (uint8_t *)"hellodns", 8);
ok(result == KNOT_EOK, "%s: add data B + C", alg);
is_int(KNOT_EOK, result, "%s: add data B + C", alg);
result = knot_dnssec_sign_verify(ctx, sig, sig_size);
ok(result == KNOT_EOK, "%s: verify valid signature", alg);
is_int(KNOT_EOK, result, "%s: verify valid signature", alg);
}
knot_dnssec_sign_free(ctx);
......
......@@ -40,7 +40,7 @@ int main(int argc, char *argv[])
};
knot_dname_t *result = create_nsec3_owner(owner, apex, &params);
ok(knot_dname_cmp(result, expect) == 0, "create_nsec3_owner()");
is_int(0, knot_dname_cmp(result, expect), "create_nsec3_owner()");
knot_dname_free(&result);
knot_dname_free(&owner);
......
......@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
/* Test 5: Compare counter. */
int expected = _runnable_cycles * 1;
ok(_runnable_i == expected, "dthreads: result ok");
is_int(expected, _runnable_i, "dthreads: result ok");
/* Test 6: Repurpose threads. */
_runnable_i = 0;
......@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
tv.tv_sec = 0;
tv.tv_usec = 4000 + rand() % 1000; // 4-5ms
diag("waiting for %dus to let thread do some work ...",
tv.tv_usec);
(long)tv.tv_usec);
select(0, 0, 0, 0, &tv);
ok(dt_test_repurpose(unit, 0), "dthreads: repurpose on-the-fly");
......@@ -209,7 +209,7 @@ int main(int argc, char *argv[])
tv.tv_sec = 0;
tv.tv_usec = (250 + rand() % 500) * 1000; // 250-750ms
diag("waiting for %dms to let thread pretend blocking I/O ...",
tv.tv_usec / 1000);
(long)(tv.tv_usec / 1000));
select(0, 0, 0, 0, &tv);
ok(dt_test_cancel(unit, 0), "dthreads: cancel blocking thread");
......@@ -232,38 +232,36 @@ int main(int argc, char *argv[])
/* Test 14: Deinitialize */
dt_delete(&unit);
ok(unit == 0, "dthreads: delete unit");
ok(unit == NULL, "dthreads: delete unit");
/* Test 15: Wrong values. */
unit = dt_create(-1);
ok(unit == 0, "dthreads: create with negative count");
ok(unit == NULL, "dthreads: create with negative count");
unit = dt_create_coherent(dt_optimal_size(), 0, 0, 0);
/* Test 16: NULL runnable. */
ok(dt_start(unit) == 0, "dthreads: start with NULL runnable");
is_int(0, dt_start(unit), "dthreads: start with NULL runnable");
/* Test 17: NULL operations crashing. */
int op_count = 14;
int expected_min = op_count * -1;
// All functions must return -1 at least
int ret = 0;
/* lives_ok( { */
ret += dt_activate(0); // -1
ret += dt_cancel(0); // -1
ret += dt_compact(0); // -1
dt_delete(0); //
ret += dt_is_cancelled(0); // 0
ret += dt_join(0); // -1
ret += dt_repurpose(0, 0, 0); // -1
ret += dt_signalize(0, SIGALRM); // -1
ret += dt_start(0); // -1
ret += dt_start_id(0); // -1
ret += dt_stop(0); // -1
ret += dt_stop_id(0); // -1
ret += dt_unit_lock(0); // -1
ret += dt_unit_unlock(0); // -1
/* }, "dthreads: not crashed while executing functions on NULL context"); */
ok(1, "dthreads: not crashed while executing functions on NULL context");
ret += dt_activate(0); // -1
ret += dt_cancel(0); // -1
ret += dt_compact(0); // -1
dt_delete(0); //
ret += dt_is_cancelled(0); // 0
ret += dt_join(0); // -1
ret += dt_repurpose(0, 0, 0); // -1
ret += dt_signalize(0, SIGALRM); // -1
ret += dt_start(0); // -1
ret += dt_start_id(0); // -1
ret += dt_stop(0); // -1
ret += dt_stop_id(0); // -1
ret += dt_unit_lock(0); // -1
ret += dt_unit_unlock(0); // -1
is_int(-1464, ret, "dthreads: not crashed while executing functions on NULL context");
/* Test 18: expected results. */
ok(ret <= expected_min,
......
......@@ -54,11 +54,11 @@ int main(int argc, char *argv[])
int ret = 0;
uint8_t sent = 0xaf, rcvd = 0;
ret = evqueue_write(q, &sent, sizeof(uint8_t));
ok(ret == sizeof(uint8_t), "evqueue: send byte through");
is_int(sizeof(uint8_t), ret, "evqueue: send byte through");
// 3. Receive byte from event queue
ret = evqueue_read(q, &rcvd, sizeof(uint8_t));
ok(ret == sizeof(uint8_t), "evqueue: received byte");
is_int(sizeof(uint8_t), ret, "evqueue: received byte");
// 4. Received match
ok(sent == rcvd, "evqueue: received byte match");
......@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
ev.type = 0xfa11;
ev.data = (void*)0xceed;
ret = evqueue_add(q, &ev);
ok(ret == 0, "evqueue: sent event to queue");
is_int(0, ret, "evqueue: sent event to queue");
// 6. Poll for new events
struct timespec ts;
......@@ -85,22 +85,19 @@ int main(int argc, char *argv[])
if (ev.type == rev.type && ev.data == rev.data) {
ret = 0;
}
ok(ret == 0, "evqueue: received event matches sent");
is_int(0, ret, "evqueue: received event matches sent");
// 8. Invalid parameters
// lives_ok({
evqueue_free(0);
evqueue_poll(0,0,0);
evqueue_read(0, 0, 0);
evqueue_write(0, 0, 0);
evqueue_read(0, 0, 0);
evqueue_get(0, 0);
evqueue_add(0, 0);
// },
evqueue_free(0);
evqueue_poll(0,0,0);
evqueue_read(0, 0, 0);
evqueue_write(0, 0, 0);
evqueue_read(0, 0, 0);
evqueue_get(0, 0);
evqueue_add(0, 0);
ok(1, "evqueue: won't crash with NULL parameters");
// 9. Free event queue
// lives_ok({evqueue_free(&q);}, "evqueue: delete");
evqueue_free(&q);
ok(1, "evqueue: delete");
......@@ -143,7 +140,6 @@ int main(int argc, char *argv[])
ok(e->data == (void*)0xcafe, "evsched: received data is valid");
// 6. Delete event
// lives_ok({evsched_event_free(s, e);}, "evsched: deleted event");
evsched_event_free(s, e);
ok(1, "evsched: deleted event");
......@@ -168,21 +164,17 @@ int main(int argc, char *argv[])
pthread_join(t, 0);
// 10. Invalid parameters
// lives_ok({
evsched_delete(0);
evsched_event_new(0, 0);
evsched_event_free(0, 0);
evsched_next(0);
evsched_schedule(0, 0, 0);
evsched_schedule_cb(0, 0, 0, 0);
evsched_schedule_term(0, 0);
evsched_cancel(0, 0);
//},
evsched_delete(0);
evsched_event_new(0, 0);
evsched_event_free(0, 0);
evsched_next(0);
evsched_schedule(0, 0, 0);
evsched_schedule_cb(0, 0, 0, 0);
evsched_schedule_term(0, 0);
evsched_cancel(0, 0);
ok(1, "evsched: won't crash with NULL parameters");
// 11. Delete event scheduler
//lives_ok({evsched_delete(&s);}, "evsched: delete");
evsched_delete(&s);
ok(1, "evsched: delete");
......
......@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
/* 1. Create fdset. */
fdset_t set;
int ret = fdset_init(&set, 32);
ok(ret == 0, "fdset: init");
is_int(0, ret, "fdset: init");
/* 2. Create pipe. */
int fds[2], tmpfds[2];
......@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
/* 3. Add fd to set. */
ret = fdset_add(&set, fds[0], POLLIN, NULL);
ok(ret == 0, "fdset: add to set works");
is_int(0, ret, "fdset: add to set works");
fdset_add(&set, tmpfds[0], POLLIN, NULL);
/* Schedule write. */
......@@ -125,29 +125,27 @@ int main(int argc, char *argv[])
/* 7-9. Remove from event set. */
ret = fdset_remove(&set, 0);
ok(ret == 0, "fdset: remove from fdset works");
is_int(0, ret, "fdset: remove from fdset works");
close(fds[0]);
close(fds[1]);
ret = fdset_remove(&set, 0);
close(tmpfds[1]);
close(tmpfds[1]);
ok(ret == 0, "fdset: remove from fdset works (2)");
is_int(0, ret, "fdset: remove from fdset works (2)");
ret = fdset_remove(&set, 0);
ok(ret != 0, "fdset: removing nonexistent item");
/* 10. Crash test. */
// lives_ok({
fdset_init(0, 0);
fdset_add(0, 1, 1, 0);
fdset_add(0, 0, 1, 0);
fdset_remove(0, 1);
fdset_remove(0, 0);
// }, "fdset: crash test successful");
fdset_init(0, 0);
fdset_add(0, 1, 1, 0);
fdset_add(0, 0, 1, 0);
fdset_remove(0, 1);
fdset_remove(0, 0);
ok(1, "fdset: crash test successful");
/* 11. Destroy fdset. */
ret = fdset_clear(&set);
ok(ret == 0, "fdset: destroyed");
is_int(0, ret, "fdset: destroyed");
/* Cleanup. */
pthread_join(t, 0);
......
......@@ -52,7 +52,7 @@ static int walkchars(journal_t *j, journal_node_t *n) {
int main(int argc, char *argv[])
{
plan(21);
plan(24);
/* Create tmpdir */
int fsize = 8092;
......@@ -73,11 +73,11 @@ int main(int argc, char *argv[])
/* Test 2: Create journal. */
const char *jfilename = jfn_buf;
int ret = journal_create(jfilename, jsize);
ok(ret == KNOT_EOK, "journal: create journal '%s'", jfilename);
is_int(KNOT_EOK, ret, "journal: create journal '%s'", jfilename);
/* Test 3: Open journal. */
journal_t *journal = journal_open(jfilename, fsize, JOURNAL_LAZY, 0);
ok(journal != 0, "journal: open");
ok(journal, "journal: open journal '%s'", jfilename);
/* Retain journal. */
journal_t *j = journal_retain(journal);
......@@ -85,16 +85,16 @@ int main(int argc, char *argv[])
/* Test 4: Write entry to log. */
const char *sample = "deadbeef";
ret = journal_write(j, 0x0a, sample, strlen(sample));
ok(ret == KNOT_EOK, "journal: write");
is_int(KNOT_EOK, ret, "journal: write");
/* Test 5: Read entry from log. */
char tmpbuf[64] = {'\0'};
ret = journal_read(j, 0x0a, 0, tmpbuf);
ok(ret == KNOT_EOK, "journal: read entry");
is_int(KNOT_EOK, ret, "journal: read entry");
/* Test 6: Compare read data. */
ret = strncmp(sample, tmpbuf, strlen(sample));
ok(ret == 0, "journal: read data integrity check");
is_int(KNOT_EOK, ret, "journal: read data integrity check");
/* Append several characters. */
journal_write(j, 0, "X", 1); /* Dummy */
......@@ -108,7 +108,7 @@ int main(int argc, char *argv[])
journal_walk(j, walkchars);
_walkbuf[_wbi] = '\0';
ret = strcmp(word, _walkbuf);
ok(ret == 0, "journal: read data integrity check 2 '%s'", _walkbuf);
is_int(0, ret, "journal: read data integrity check 2 '%s'", _walkbuf);
_wbi = 0;
/* Test 8: Change single letter and compare. */
......@@ -117,7 +117,7 @@ int main(int argc, char *argv[])
journal_walk(j, walkchars);
_walkbuf[_wbi] = '\0';
ret = strcmp(word + 1, _walkbuf);
ok(ret == 0, "journal: read data integrity check 3 '%s'", _walkbuf);
is_int(0, ret, "journal: read data integrity check 3 '%s'", _walkbuf);
_wbi = 0;
/* Test 9: Attempt to retain and release. */
......@@ -138,7 +138,10 @@ int main(int argc, char *argv[])
fsize = 8092;
jsize = 512;
ret = journal_create(jfilename, jsize);
is_int(KNOT_EOK, ret, "journal: create journal '%s'", jfilename);
j = journal_open(jfilename, fsize, 0, 0);
ok(j, "journal: open journal '%s'", jfilename);
/* Test 10: Write random data. */
int chk_key = 0;
......@@ -159,27 +162,29 @@ int main(int argc, char *argv[])
memcpy(chk_buf, tmpbuf, sizeof(chk_buf));
}
}
ok(j && ret == 0, "journal: sustained looped writes");
is_int(0, ret, "journal: sustained looped writes");
/* Test 11: Check data integrity. */
memset(tmpbuf, 0, sizeof(tmpbuf));
journal_read(j, chk_key, 0, tmpbuf);
ret = strncmp(chk_buf, tmpbuf, sizeof(chk_buf));
ok(j && ret == 0, "journal: read data integrity check");
is_int(0, ret, "journal: read data integrity check");
/* Test 12: Reopen log and re-read value. */
memset(tmpbuf, 0, sizeof(tmpbuf));
journal_close(j);
j = journal_open(jfilename, fsize, 0, 0);
ok(j, "journal: open journal '%s'", jfilename);
journal_read(j, chk_key, 0, tmpbuf);
ret = strncmp(chk_buf, tmpbuf, sizeof(chk_buf));
ok(j && ret == 0, "journal: read data integrity check after close/open");
is_int(0, ret, "journal: read data integrity check after close/open");
/* Test 13: Map journal entry. */
char *mptr = NULL;
memset(chk_buf, 0xde, sizeof(chk_buf));
ret = journal_map(j, 0x12345, &mptr, sizeof(chk_buf));
ok(j && mptr && ret == 0, "journal: mapped journal entry");
ok(mptr && ret == 0, "journal: mapped journal entry");
if (ret != 0) {
skip_block(2, NULL);
} else {
......@@ -187,20 +192,20 @@ int main(int argc, char *argv[])
/* Test 14: Write to mmaped entry and unmap. */
memcpy(mptr, chk_buf, sizeof(chk_buf));
ret = journal_unmap(j, 0x12345, mptr, 1);
ok(j && mptr && ret == 0, "journal: written to mapped entry and finished");
ok(mptr && ret == 0, "journal: written to mapped entry and finished");
/* Test 15: Compare mmaped entry. */
memset(tmpbuf, 0, sizeof(tmpbuf));
journal_read(j, 0x12345, NULL, tmpbuf);
ret = strncmp(chk_buf, tmpbuf, sizeof(chk_buf));
ok(j && ret == 0, "journal: mapped entry data integrity check");
ok(ret == 0, "journal: mapped entry data integrity check");
} /* end skip */
/* Test 16: Make a transaction. */
uint64_t tskey = 0x75750000;
ret = journal_trans_begin(j);
ok(j && ret == 0, "journal: TRANS begin");
is_int(0, ret, "journal: TRANS begin");
for (int i = 0; i < 16; ++i) {
memset(tmpbuf, i, sizeof(tmpbuf));
journal_write(j, tskey + i, tmpbuf, sizeof(tmpbuf));
......@@ -208,12 +213,12 @@ int main(int argc, char *argv[])
/* Test 17: Check if uncommited node exists. */
ret = journal_read(j, tskey + rand() % 16, NULL, chk_buf);
ok(j && ret != 0, "journal: check for uncommited node");
ok(ret != 0, "journal: check for uncommited node");
/* Test 18: Commit transaction. */
ret = journal_trans_commit(j);
int read_ret = journal_read(j, tskey + rand() % 16, NULL, chk_buf);
ok(j && ret == 0 && read_ret == 0, "journal: transaction commit");
ok(ret == 0 && read_ret == 0, "journal: transaction commit");
/* Test 19: Rollback transaction. */
tskey = 0x6B6B0000;
......@@ -224,7 +229,7 @@ int main(int argc, char *argv[])
}
ret = journal_trans_rollback(j);
read_ret = journal_read(j, tskey + rand() % 16, NULL, chk_buf);
ok(j && ret == 0 && read_ret != 0, "journal: transaction rollback");
ok(ret == 0 && read_ret != 0, "journal: transaction rollback");
/* Test 20: Write random data. */
ret = 0;
......@@ -256,13 +261,13 @@ int main(int argc, char *argv[])
break;
}
}
ok(j && ret == 0, "journal: sustained mmap r/w");
is_int(0, ret, "journal: sustained mmap r/w");
/* Test 21: Open + create journal. */
journal_close(j);
remove(jfilename);
j = journal_open(jfilename, fsize, 0, 0);
ok(j != NULL, "journal: open+create from scratch");
ok(j, "journal: open+create from scratch '%s'", jfilename);
/* Close journal. */
journal_close(j);
......
......@@ -134,11 +134,11 @@ int main(int argc, char *argv[])
/* 2. set rate limit */
uint32_t rate = 10;
rrl_setrate(rrl, rate);
ok(rate == rrl_rate(rrl), "rrl: setrate");
is_int(rate, rrl_rate(rrl), "rrl: setrate");
/* 3. setlocks */
ret = rrl_setlocks(rrl, RRL_LOCKS);
ok(ret == KNOT_EOK, "rrl: setlocks");
is_int(KNOT_EOK, ret, "rrl: setlocks");
/* 4. N unlimited requests. */
knot_dname_t *apex = knot_dname_from_str("rrl.", 4);
......@@ -155,33 +155,31 @@ int main(int argc, char *argv[])
break;
}
}
ok(ret == 0, "rrl: unlimited IPv4/v6 requests");
is_int(0, ret, "rrl: unlimited IPv4/v6 requests");
#ifdef ENABLE_TIMED_TESTS
/* 5. limited request */
ret = rrl_query(rrl, &addr, &rq, zone);
ok(ret != 0, "rrl: throttled IPv4 request");
is_int(0, ret, "rrl: throttled IPv4 request");
/* 6. limited IPv6 request */
ret = rrl_query(rrl, &addr6, &rq, zone);
ok(ret != 0, "rrl: throttled IPv6 request");
is_int(0, ret, "rrl: throttled IPv6 request");
#else
skip_block(2, "Timed tests not enabled");
#endif
/* 7. invalid values. */
ret = 0;
// lives_ok( {
rrl_create(0); // NULL
ret += rrl_setrate(0, 0); // 0
ret += rrl_rate(0); // 0
ret += rrl_setlocks(0,0); // -1
ret += rrl_query(0, 0, 0, 0); // -1
ret += rrl_query(rrl, 0, 0, 0); // -1
ret += rrl_query(rrl, (void*)0x1, 0, 0); // -1
ret += rrl_destroy(0); // -1
// }, "rrl: not crashed while executing functions on NULL context");
ok(1, "rrl: not crashed while executing functions on NULL context");
rrl_create(0); // NULL
ret += rrl_setrate(0, 0); // 0
ret += rrl_rate(0); // 0
ret += rrl_setlocks(0,0); // -1
ret += rrl_query(0, 0, 0, 0); // -1
ret += rrl_query(rrl, 0, 0, 0); // -1
ret += rrl_query(rrl, (void*)0x1, 0, 0); // -1
ret += rrl_destroy(0); // -1
is_int(-488, ret, "rrl: not crashed while executing functions on NULL context");
#ifdef ENABLE_TIMED_TESTS
/* 8. hopscotch test */
......@@ -192,7 +190,7 @@ int main(int argc, char *argv[])
ok(rd.passed, "rrl: hashtable is ~ consistent");
/* 9. reseed */
ok(rrl_reseed(rrl) == 0, "rrl: reseed");
is_int(0, rrl_reseed(rrl), "rrl: reseed");
/* 10. hopscotch after reseed. */
rrl_hopscotch(&rd);
......
const unsigned sample_conf_rc_size = 872;
const char sample_conf_rc[] = {
0x23, 0x20, 0x63, 0x6F, 0x6E, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x66, 0x69, 0x6C, 0x65, 0x20, 0x77, 0x69, 0x6C, 0x6C, 0x20, 0x66, 0x6F, 0x6C, 0x6C, 0x6F, 0x77, 0x20, 0x62, 0x69, 0x72, 0x64, 0x20, 0x28, 0x61, 0x6E, 0x64, 0x20, 0x6A, 0x75, 0x6E, 0x69, 0x70, 0x65, 0x72, 0x29, 0x20, 0x74, 0x79, 0x70, 0x65, 0x20, 0x6F, 0x66, 0x20, 0x63, 0x6F, 0x6E, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x66, 0x69, 0x6C, 0x65, 0x0A, 0x23, 0x20, 0x69, 0x2E, 0x65, 0x2E, 0x20, 0x63, 0x75, 0x72, 0x6C, 0x79, 0x20, 0x62, 0x72, 0x61, 0x63, 0x6B, 0x65, 0x74, 0x73, 0x20, 0x77, 0x69, 0x6C, 0x6C, 0x20, 0x62, 0x65, 0x20, 0x75, 0x73, 0x65, 0x64, 0x3B, 0x0A, 0x0A, 0x23, 0x20, 0x77, 0x68, 0x61, 0x74, 0x20, 0x74, 0x6F, 0x20, 0x64, 0x6F, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x7D, 0x3B, 0x0A, 0x23, 0x20, 0x61, 0x29, 0x20, 0x69, 0x67, 0x6E, 0x6F, 0x72, 0x65, 0x20, 0x3B, 0x20, 0x69, 0x66, 0x20, 0x69, 0x74, 0x20, 0x66, 0x6F, 0x6C, 0x6C, 0x6F, 0x77, 0x73, 0x20, 0x7D, 0x0A, 0x0A, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x20, 0x7B, 0x0A, 0x0A, 0x20, 0x20, 0x69, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x74, 0x79, 0x20, 0x22, 0x49, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x6E, 0x6F, 0x20, 0x6D, 0x6F, 0x75, 0x74, 0x68, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x6D, 0x75, 0x73, 0x74, 0x20, 0x73, 0x63, 0x72, 0x65, 0x61, 0x6D, 0x22, 0x3B, 0x0A, 0x20, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x20, 0x22, 0x49, 0x6E, 0x66, 0x69, 0x6E, 0x69, 0x74, 0x65, 0x73, 0x69, 0x6D, 0x61, 0x6C, 0x22, 0x3B, 0x0A, 0x20, 0x20, 0x73, 0x74, 0x6F, 0x72, 0x61, 0x67, 0x65, 0x20, 0x22, 0x2E, 0x22, 0x3B, 0x0A, 0x7D, 0x0A, 0x0A, 0x6B, 0x65, 0x79, 0x73, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x6B, 0x65, 0x79, 0x30, 0x2E, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x6E, 0x65, 0x74, 0x20, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x6D, 0x64, 0x35, 0x20, 0x22, 0x57, 0x67, 0x3D, 0x3D, 0x22, 0x3B, 0x20, 0x23, 0x20, 0x6B, 0x65, 0x79, 0x20, 0x73, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6C, 0x20, 0x66, 0x6F, 0x72, 0x20, 0x6F, 0x6E, 0x65, 0x20, 0x72, 0x65, 0x6D, 0x6F, 0x74, 0x65, 0x0A, 0x20, 0x20, 0x6B, 0x65, 0x79, 0x31, 0x2E, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x6E, 0x65, 0x74, 0x20, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x6D, 0x64, 0x35, 0x20, 0x22, 0x5A, 0x47, 0x46, 0x75, 0x43, 0x67, 0x3D, 0x3D, 0x22, 0x3B, 0x20, 0x23, 0x20, 0x69, 0x6D, 0x70, 0x6C, 0x69, 0x63, 0x69, 0x74, 0x20, 0x6B, 0x65, 0x79, 0x20, 0x66, 0x6F, 0x72, 0x20, 0x77, 0x68, 0x6F, 0x6C, 0x65, 0x20, 0x7A, 0x6F, 0x6E, 0x65, 0x0A, 0x7D, 0x0A, 0x0A, 0x72, 0x65, 0x6D, 0x6F, 0x74, 0x65, 0x73, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x72, 0x65, 0x6D, 0x6F, 0x74, 0x65, 0x30, 0x20, 0x7B, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x20, 0x31, 0x2E, 0x32, 0x2E, 0x33, 0x2E, 0x34, 0x3B, 0x20, 0x7D, 0x0A, 0x7D, 0x0A, 0x0A, 0x7A, 0x6F, 0x6E, 0x65, 0x73, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x6E, 0x65, 0x74, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6C, 0x65, 0x20, 0x22, 0x2F, 0x76, 0x61, 0x72, 0x2F, 0x6C, 0x69, 0x62, 0x2F, 0x6B, 0x6E, 0x6F, 0x74, 0x2F, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x6E, 0x65, 0x74, 0x22, 0x3B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x78, 0x66, 0x72, 0x2D, 0x6F, 0x75, 0x74, 0x20, 0x72, 0x65, 0x6D, 0x6F, 0x74, 0x65, 0x30, 0x3B, 0x0A, 0x20, 0x20, 0x7D, 0x0A, 0x7D, 0x0A, 0x0A, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x30, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x20, 0x31, 0x30, 0x2E, 0x31, 0x30, 0x2E, 0x31, 0x2E, 0x31, 0x3B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x70, 0x6F, 0x72, 0x74, 0x20, 0x35, 0x33, 0x35, 0x33, 0x31, 0x3B, 0x0A, 0x20, 0x20, 0x7D, 0x0A, 0x0A, 0x20, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x31, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x20, 0x3A, 0x3A, 0x30, 0x3B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x23, 0x20, 0x70, 0x6F, 0x72, 0x74, 0x20, 0x35, 0x33, 0x3B, 0x0A, 0x20, 0x20, 0x7D, 0x0A, 0x7D, 0x0A, 0x0A, 0x6C, 0x6F, 0x67, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x73, 0x79, 0x73, 0x6C, 0x6F, 0x67, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x61, 0x6E, 0x79, 0x20, 0x6E, 0x6F, 0x74, 0x69, 0x63, 0x65, 0x2C, 0x20, 0x77, 0x61, 0x72, 0x6E, 0x69, 0x6E, 0x67, 0x2C, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0x3B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x7A, 0x6F, 0x6E, 0x65, 0x20, 0x61, 0x6C, 0x6C, 0x3B, 0x0A, 0x20, 0x20, 0x7D, 0x0A, 0x0A, 0x20, 0x20, 0x66, 0x69, 0x6C, 0x65, 0x20, 0x22, 0x2F, 0x76, 0x61, 0x72, 0x2F, 0x6C, 0x6F, 0x67, 0x2F, 0x6B, 0x6E, 0x6F, 0x74, 0x2F, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2E, 0x65, 0x72, 0x72, 0x22, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0x3B, 0x0A, 0x20, 0x20, 0x7D, 0x0A, 0x0A, 0x20, 0x20, 0x73, 0x74, 0x64, 0x65, 0x72, 0x72, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x61, 0x6E, 0x79, 0x20, 0x77, 0x61, 0x72, 0x6E, 0x69, 0x6E, 0x67, 0x2C, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0x3B, 0x0A, 0x20, 0x20, 0x7D, 0x0A, 0x0A, 0x20, 0x20, 0x73, 0x74, 0x64, 0x6F, 0x75, 0x74, 0x20, 0x7B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x61, 0x6E, 0x79, 0x20, 0x69, 0x6E, 0x66, 0x6F, 0x3B, 0x0A, 0x20, 0x20, 0x7D, 0x0A, 0x7D, 0x0A, 0x00 };
......@@ -51,7 +51,7 @@ static void interrupt_handle(int s)
/*! API: run tests. */
int main(int argc, char *argv[])
{
plan(5);
plan(4);
server_t *server = 0;
int ret = 0;
......@@ -68,14 +68,9 @@ int main(int argc, char *argv[])
ok(server != 0, "server: initialized");
//! Test server startup
ret = 0;
// lives_ok( {
ret = test_server_start(server);
// }, "server: not crashing on runtime");
ok(1, "server: not crashing on runtime");
//! Test server exit code
ret = test_server_start(server);
ok(ret, "server: started ok");
if (!ret) {
skip_block(2, "server crashed, skipping deinit and destroy tests");
} else {
......
......@@ -37,14 +37,14 @@ extern void slab_deinit();
int main(int argc, char *argv[])
{
plan(5);
plan(4);
// 1. Create slab cache
srand(time(0));
const unsigned pattern = 0xdeadbeef;
slab_cache_t cache;
int ret = slab_cache_init(&cache, sizeof(int));
ok(ret == 0, "slab: created empty cache");
is_int(0, ret, "slab: created empty cache");
// 2. Couple alloc/free
bool valid_free = true;
......@@ -55,7 +55,6 @@ int main(int argc, char *argv[])
if (*data == pattern)
valid_free = false;
}
ok(1, "slab: create and free memory 100 times");
// 5. Verify freed block
ok(valid_free, "slab: freed memory is correctly invalidated");
......@@ -72,7 +71,7 @@ int main(int argc, char *argv[])
}
int reaped = slab_cache_reap(&cache);
ok(reaped == free_count, "slab: cache reaping works");
is_int(reaped, free_count, "slab: cache reaping works");
// Stress cache
int alloc_count = 73521;
......@@ -96,7 +95,7 @@ int main(int argc, char *argv[])
// 5. Delete cache
slab_cache_destroy(&cache);
ok(cache.bufsize == 0, "slab: freed cache");
is_int(0, cache.bufsize, "slab: freed cache");
return 0;
}
......@@ -19,7 +19,6 @@
#include "libknot/util/utils.h"
#define write_test(size, value, ...) { \
const uint8_t expect[] = { __VA_ARGS__ }; \
uint8_t wdata[sizeof(expect)] = { 0x00 }; \
......@@ -33,10 +32,10 @@ int main(int argc, char *argv[])
const uint8_t rdata[] = { 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
ok(knot_wire_read_u16(rdata) == 0x8899, "16-bit read");
ok(knot_wire_read_u32(rdata) == 0x8899aabb, "32-bit read");
ok(knot_wire_read_u48(rdata) == 0x8899aabbccdd, "48-bit read");
ok(knot_wire_read_u64(rdata) == 0x8899aabbccddeeff, "64-bit read");
is_hex( 0x8899, knot_wire_read_u16(rdata), "16-bit read");
is_hex( 0x8899aabb, knot_wire_read_u32(rdata), "32-bit read");
is_hex( 0x8899aabbccdd, knot_wire_read_u48(rdata), "48-bit read");
is_hex(0x8899aabbccddeeff, knot_wire_read_u64(rdata), "64-bit read");
write_test(16, 0x1122, 0x11, 0x22);
write_test(32, 0x66778899, 0x66, 0x77, 0x88, 0x99);
......
......@@ -116,7 +116,7 @@ int main(int argc, char *argv[])