mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-19 13:59:15 +00:00
all old tests have been ported to check
This commit is contained in:
parent
9ccbd4bc88
commit
dc34d6edee
|
@ -1,7 +1,7 @@
|
||||||
CC = gcc
|
CC = gcc
|
||||||
TEST = test
|
TEST = test
|
||||||
OBJS = test.o base32.o read.o
|
OBJS = test.o base32.o read.o dns.o encoding.o
|
||||||
SRCOBJS = ../src/base32.o ../src/read.o
|
SRCOBJS = ../src/base32.o ../src/read.o ../src/dns.o ../src/encoding.o
|
||||||
|
|
||||||
OS = `uname | tr "a-z" "A-Z"`
|
OS = `uname | tr "a-z" "A-Z"`
|
||||||
|
|
||||||
|
@ -22,5 +22,5 @@ $(TEST): $(OBJS) $(SRCOBJS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo "Cleaning..."
|
@echo "Cleaning..."
|
||||||
@rm -f *~ *.core $(TESTS) $(OBJS)
|
@rm -f *~ *.core $(TEST) $(OBJS)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
70
tests/dns.c
Normal file
70
tests/dns.c
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <arpa/nameser.h>
|
||||||
|
|
||||||
|
#include "structs.h"
|
||||||
|
#include "dns.h"
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
START_TEST(test_encode_hostname)
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
int len;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
len = 256;
|
||||||
|
|
||||||
|
memset(buf, 0, 256);
|
||||||
|
ret = dns_encode_hostname( // More than 63 chars between dots
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
, buf, len);
|
||||||
|
fail_unless(ret == -1, NULL);
|
||||||
|
|
||||||
|
memset(buf, 0, 256);
|
||||||
|
ret = dns_encode_hostname( // More chars than fits into array
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.ABCDEFGHIJKLMNOPQRSTUVWXYZ."
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.ABCDEFGHIJKLMNOPQRSTUVWXYZ."
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.ABCDEFGHIJKLMNOPQRSTUVWXYZ."
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.ABCDEFGHIJKLMNOPQRSTUVWXYZ."
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.ABCDEFGHIJKLMNOPQRSTUVWXYZ."
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.ABCDEFGHIJKLMNOPQRSTUVWXYZ."
|
||||||
|
, buf, len);
|
||||||
|
|
||||||
|
fail_unless(ret == -1, NULL);
|
||||||
|
fail_unless(strlen(buf) < len, NULL);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
TCase *
|
||||||
|
test_dns_create_tests()
|
||||||
|
{
|
||||||
|
TCase *tc;
|
||||||
|
|
||||||
|
tc = tcase_create("Dns");
|
||||||
|
tcase_add_test(tc, test_encode_hostname);
|
||||||
|
|
||||||
|
return tc;
|
||||||
|
}
|
57
tests/encoding.c
Normal file
57
tests/encoding.c
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "encoding.h"
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
START_TEST(test_encoding_base32)
|
||||||
|
{
|
||||||
|
char temp[256];
|
||||||
|
char *start = "HELLOTEST";
|
||||||
|
char *out = "1HELLOTEST";
|
||||||
|
char *end;
|
||||||
|
char *tempend;
|
||||||
|
int codedlength;
|
||||||
|
|
||||||
|
memset(temp, 0, sizeof(temp));
|
||||||
|
end = malloc(16);
|
||||||
|
memset(end, 0, 16);
|
||||||
|
|
||||||
|
codedlength = encode_data(start, 9, 256, temp, 0);
|
||||||
|
tempend = temp + strlen(temp);
|
||||||
|
decode_data(end, 16, temp, tempend);
|
||||||
|
|
||||||
|
fail_unless(strcmp(out, end) == 0, NULL);
|
||||||
|
|
||||||
|
free(end);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
TCase *
|
||||||
|
test_encoding_create_tests()
|
||||||
|
{
|
||||||
|
TCase *tc;
|
||||||
|
|
||||||
|
tc = tcase_create("Encoding");
|
||||||
|
tcase_add_test(tc, test_encoding_base32);
|
||||||
|
|
||||||
|
return tc;
|
||||||
|
}
|
22
tests/test.c
22
tests/test.c
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -31,6 +47,12 @@ main()
|
||||||
test = test_base32_create_tests();
|
test = test_base32_create_tests();
|
||||||
suite_add_tcase(iodine, test);
|
suite_add_tcase(iodine, test);
|
||||||
|
|
||||||
|
test = test_dns_create_tests();
|
||||||
|
suite_add_tcase(iodine, test);
|
||||||
|
|
||||||
|
test = test_encoding_create_tests();
|
||||||
|
suite_add_tcase(iodine, test);
|
||||||
|
|
||||||
test = test_read_create_tests();
|
test = test_read_create_tests();
|
||||||
suite_add_tcase(iodine, test);
|
suite_add_tcase(iodine, test);
|
||||||
|
|
||||||
|
|
18
tests/test.h
18
tests/test.h
|
@ -1,7 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __TEST_H__
|
#ifndef __TEST_H__
|
||||||
#define __TEST_H__
|
#define __TEST_H__
|
||||||
|
|
||||||
TCase *test_base32_create_tests();
|
TCase *test_base32_create_tests();
|
||||||
|
TCase *test_dns_create_tests();
|
||||||
|
TCase *test_encoding_create_tests();
|
||||||
TCase *test_read_create_tests();
|
TCase *test_read_create_tests();
|
||||||
|
|
||||||
char *va_str(const char *, ...);
|
char *va_str(const char *, ...);
|
||||||
|
|
Loading…
Reference in a new issue