mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-16 12:53:17 +00:00
Use -pedantic in tests, fixed all warnings
This commit is contained in:
parent
ad07e40988
commit
7ea80349f5
|
@ -6,7 +6,7 @@ SRCOBJS = ../src/base32.o ../src/read.o ../src/dns.o ../src/encoding.o ../src/lo
|
|||
OS = `uname | tr "a-z" "A-Z"`
|
||||
|
||||
LDFLAGS = -L/usr/local/lib -lcheck
|
||||
CFLAGS = -g -Wall -D$(OS) -I../src -I/usr/local/include
|
||||
CFLAGS = -g -Wall -D$(OS) -I../src -I/usr/local/include -pedantic
|
||||
|
||||
all: $(TEST)
|
||||
@./$(TEST)
|
||||
|
|
|
@ -52,7 +52,7 @@ static char *msgData = "this is the message to be delivered";
|
|||
static char *topdomain = "kryo.se";
|
||||
|
||||
static char *queryData = "HELLO this is the test data";
|
||||
static char *recData = "AHELLO this is the test data"; // The A flag is added
|
||||
static char *recData = "AHELLO this is the test data"; /* The A flag is added */
|
||||
|
||||
START_TEST(test_encode_query)
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ START_TEST(test_encode_query)
|
|||
}
|
||||
strcpy(d, topdomain);
|
||||
ret = dns_encode(buf, len, &q, QR_QUERY, resolv, strlen(resolv));
|
||||
len = sizeof(queryPacket) - 1; // Skip extra null character
|
||||
len = sizeof(queryPacket) - 1; /* Skip extra null character */
|
||||
|
||||
if (strncmp(queryPacket, buf, sizeof(queryPacket)) || ret != len) {
|
||||
printf("\n");
|
||||
|
@ -129,7 +129,7 @@ START_TEST(test_encode_response)
|
|||
q.id = 1337;
|
||||
|
||||
ret = dns_encode(buf, len, &q, QR_ANSWER, msgData, strlen(msgData));
|
||||
len = sizeof(answerPacket) - 1; // Skip extra null character
|
||||
len = sizeof(answerPacket) - 1; /* Skip extra null character */
|
||||
|
||||
fail_unless(strncmp(answerPacket, buf, sizeof(answerPacket)) == 0, "Did not compile expected packet");
|
||||
fail_unless(ret == len, va_str("Bad packet length: %d, expected %d", ret, len));
|
||||
|
|
40
tests/read.c
40
tests/read.c
|
@ -85,13 +85,13 @@ END_TEST
|
|||
|
||||
START_TEST(test_read_name)
|
||||
{
|
||||
char emptyloop[] = {
|
||||
unsigned char emptyloop[] = {
|
||||
'A', 'A', 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01 };
|
||||
char infloop[] = {
|
||||
unsigned char infloop[] = {
|
||||
'A', 'A', 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 'A', 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01 };
|
||||
char longname[] =
|
||||
unsigned char longname[] =
|
||||
"AA\x81\x80\x00\x01\x00\x00\x00\x00\x00\x00"
|
||||
"\x3FzBCDEFGHIJKLMNOPQURSTUVXYZ0123456789abcdefghijklmnopqrstuvxyzAA"
|
||||
"\x3FzBCDEFGHIJKLMNOPQURSTUVXYZ0123456789abcdefghijklmnopqrstuvxyzAA"
|
||||
|
@ -100,50 +100,50 @@ START_TEST(test_read_name)
|
|||
"\x3FzBCDEFGHIJKLMNOPQURSTUVXYZ0123456789abcdefghijklmnopqrstuvxyzAA"
|
||||
"\x3FzBCDEFGHIJKLMNOPQURSTUVXYZ0123456789abcdefghijklmnopqrstuvxyzAA"
|
||||
"\x00\x00\x01\x00\x01";
|
||||
char onejump[] =
|
||||
unsigned char onejump[] =
|
||||
"AA\x81\x80\x00\x01\x00\x00\x00\x00\x00\x00"
|
||||
"\x02hh\xc0\x15\x00\x01\x00\x01\x05zBCDE\x00";
|
||||
char badjump[] = {
|
||||
unsigned char badjump[] = {
|
||||
'A', 'A', 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xfe, 0xcc, 0x00, 0x01, 0x00, 0x01 };
|
||||
char badjump2[] = {
|
||||
unsigned char badjump2[] = {
|
||||
'A', 'A', 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x02, 'B', 'A', 0xfe, 0xcc, 0x00, 0x01, 0x00, 0x01 };
|
||||
char *jumper;
|
||||
unsigned char *jumper;
|
||||
char buf[1024];
|
||||
char *data;
|
||||
int rv;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
data = emptyloop + sizeof(HEADER);
|
||||
data = (char*) emptyloop + sizeof(HEADER);
|
||||
buf[1023] = 'A';
|
||||
rv = readname(emptyloop, sizeof(emptyloop), &data, buf, 1023);
|
||||
rv = readname((char *) emptyloop, sizeof(emptyloop), &data, buf, 1023);
|
||||
fail_unless(buf[1023] == 'A', NULL);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
data = infloop + sizeof(HEADER);
|
||||
data = (char*) infloop + sizeof(HEADER);
|
||||
buf[4] = '\a';
|
||||
rv = readname(infloop, sizeof(infloop), &data, buf, 4);
|
||||
rv = readname((char*) infloop, sizeof(infloop), &data, buf, 4);
|
||||
fail_unless(buf[4] == '\a', NULL);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
data = longname + sizeof(HEADER);
|
||||
data = (char*) longname + sizeof(HEADER);
|
||||
buf[256] = '\a';
|
||||
rv = readname(longname, sizeof(longname), &data, buf, 256);
|
||||
rv = readname((char*) longname, sizeof(longname), &data, buf, 256);
|
||||
fail_unless(buf[256] == '\a', NULL);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
data = onejump + sizeof(HEADER);
|
||||
rv = readname(onejump, sizeof(onejump), &data, buf, 256);
|
||||
data = (char*) onejump + sizeof(HEADER);
|
||||
rv = readname((char*) onejump, sizeof(onejump), &data, buf, 256);
|
||||
fail_unless(rv == 9, NULL);
|
||||
|
||||
// These two tests use malloc to cause segfault if jump is executed
|
||||
/* These two tests use malloc to cause segfault if jump is executed */
|
||||
memset(buf, 0, sizeof(buf));
|
||||
jumper = malloc(sizeof(badjump));
|
||||
if (jumper) {
|
||||
memcpy(jumper, badjump, sizeof(badjump));
|
||||
data = jumper + sizeof(HEADER);
|
||||
rv = readname(jumper, sizeof(badjump), &data, buf, 256);
|
||||
data = (char*) jumper + sizeof(HEADER);
|
||||
rv = readname((char*) jumper, sizeof(badjump), &data, buf, 256);
|
||||
|
||||
fail_unless(rv == 0, NULL);
|
||||
fail_unless(buf[0] == 0, NULL);
|
||||
|
@ -154,8 +154,8 @@ START_TEST(test_read_name)
|
|||
jumper = malloc(sizeof(badjump2));
|
||||
if (jumper) {
|
||||
memcpy(jumper, badjump2, sizeof(badjump2));
|
||||
data = jumper + sizeof(HEADER);
|
||||
rv = readname(jumper, sizeof(badjump2), &data, buf, 256);
|
||||
data = (char*) jumper + sizeof(HEADER);
|
||||
rv = readname((char*) jumper, sizeof(badjump2), &data, buf, 256);
|
||||
|
||||
fail_unless(rv == 4, NULL);
|
||||
fail_unless(strcmp("BA.", buf) == 0,
|
||||
|
|
Loading…
Reference in a new issue