This commit is contained in:
Nils O. Selåsdal
2025-07-16 00:10:44 +02:00
39 changed files with 773 additions and 91 deletions
+13 -6
View File
@@ -1,20 +1,27 @@
import platform
import platform
Import('env', 'build_type', 'prefix', 'lib_suffix', 'version_info', 'test_xml')
test_env = env.Clone()
test_env.Append(LIBPATH = ['#build/src']);
test_env.Append(LIBS = ['ucore' + lib_suffix, 'check','m','rt'])
test_env.Append(LIBS = ['ucore' + lib_suffix, 'check','m'])
system = platform.system()
#NetBSD needs /usr/pkg/...
#NetBSD needs /usr/pkg/...
if 'netbsd' in system.lower():
test_env.Append(LIBPATH = ['/usr/pkg/lib'])
test_env.Append(LINKFLAGS = ['-Wl,-rpath,/usr/pkg/lib'])
test_env.Append(CPPPATH = ['/usr/pkg/include'])
if 'darwin' in system.lower():
test_env.Append(LIBPATH = ['/opt/homebrew/lib'])
test_env.Append(LINKFLAGS = ['-Wl,-rpath,/opt/homebrew/lib'])
test_env.Append(CPPPATH = ['/opt/homebrew/include'])
if 'darwin' not in system.lower():
test_env.Append(LIBS = ['rt'])
tests = test_env.Glob('test_*.c')
@@ -27,8 +34,8 @@ if test_xml:
test_env.Append(LINKFLAGS = ['-Wl,-rpath,\\$$ORIGIN/../src'])
prog = test_env.Program('test_runner', tests)
cmd = test_env.Command(target='test_phony' ,
source = None,
cmd = test_env.Command(target='test_phony' ,
source = None,
action= test_env.Dir('.').abspath + '/' + test_executable)
test_env.Depends(cmd, prog)
test_env.AlwaysBuild(cmd)
+22
View File
@@ -3,6 +3,7 @@
START_TEST (test_2bcd_1234567890)
{
char ascii[] = "1234567890";
unsigned char bcd[5];
size_t len = uc_ascii2bcd(ascii, bcd, 0);
@@ -13,26 +14,32 @@ START_TEST (test_2bcd_1234567890)
fail_if(bcd[2] != 0x65,"was 0x%x",bcd[2]);
fail_if(bcd[3] != 0x87,"was 0x%x",bcd[3]);
fail_if(bcd[4] != 0x09,"was 0x%x",bcd[4]);
}
END_TEST
START_TEST (test_2bcd_empty)
{
char ascii[] = "";
unsigned char bcd[1];
size_t len = uc_ascii2bcd(ascii, bcd, 3);
fail_if(len != 0, "len is %zu", len);
}
END_TEST
START_TEST (test_2bcd_1_filler)
{
char ascii[] = "1";
unsigned char bcd[1];
size_t len = uc_ascii2bcd(ascii, bcd, 0xa);
fail_if(len != 1, "len is %zu", len);
fail_if(bcd[0] != 0xa1,"was 0x%x",bcd[0]);
}
END_TEST
START_TEST (test_2bcd_2_filler)
{
char ascii[] = "123";
unsigned char bcd[2];
size_t len = uc_ascii2bcd(ascii, bcd, 0xf);
@@ -41,9 +48,11 @@ START_TEST (test_2bcd_2_filler)
fail_if(bcd[0] != 0x21,"was 0x%x",bcd[0]);
fail_if(bcd[1] != 0xf3,"was 0x%x",bcd[1]);
fail_if(UC_BCD_LEN(strlen(ascii)) != len);
}
END_TEST
START_TEST (test_2bcd_3_filler)
{
char ascii[] = "123";
unsigned char bcd[2];
@@ -52,18 +61,22 @@ START_TEST (test_2bcd_3_filler)
fail_if(len != 2, "len is %zu", len);
fail_if(bcd[0] != 0x21,"was 0x%x",bcd[0]);
fail_if(bcd[1] != 0x03,"was 0x%x",bcd[1]);
}
END_TEST
START_TEST (test_2bcd_non_digits)
{
char ascii[] = "a,b{ }=";
unsigned char bcd[10];
size_t len = uc_ascii2bcd(ascii, bcd, 0x0);
fail_if(len != 0, "len is %zu", len);
}
END_TEST
START_TEST (test_2bcd_phoneno)
{
char ascii[] = "0047-3233-4";
unsigned char bcd[24];
@@ -75,9 +88,11 @@ START_TEST (test_2bcd_phoneno)
fail_if(bcd[2] != 0x23,"was 0x%x",bcd[1]);
fail_if(bcd[3] != 0x33,"was 0x%x",bcd[1]);
fail_if(bcd[4] != 0xf4,"was 0x%x",bcd[1]);
}
END_TEST
START_TEST (test_2bcd_binary)
{
char ascii[] = {0x32,0x01,0xAF,0xFF,0x00};
unsigned char bcd[24];
@@ -85,9 +100,11 @@ START_TEST (test_2bcd_binary)
fail_if(len != 1, "len is %zu", len);
fail_if(bcd[0] != 0xf2,"0 was 0x%x",bcd[0]);
}
END_TEST
START_TEST (test_2hex_1)
{
unsigned char bcd[] = {0x21, 0x43 };
char ascii[sizeof bcd * 2 + 1];
@@ -100,9 +117,11 @@ START_TEST (test_2hex_1)
fail_if(ascii[3] != '4',"3 was %c",ascii[3]);
fail_if(ascii[4] != 0, "4 was %c",ascii[4]);
fail_if(UC_ASCII_LEN(sizeof bcd) != len);
}
END_TEST
START_TEST (test_2hex_2)
{
unsigned char bcd[] = {0xF0, 0xFF, 0x00};
char ascii[sizeof bcd * 2 + 1];
@@ -116,9 +135,11 @@ START_TEST (test_2hex_2)
fail_if(ascii[4] != '0', "4 was %c",ascii[4]);
fail_if(ascii[5] != '0', "5 was %c",ascii[5]);
fail_if(ascii[6] != 0, "6 was %c",ascii[6]);
}
END_TEST
START_TEST (test_2hex_empty)
{
unsigned char bcd[] = {0xF0, 0xFF, 0x00};
char ascii[sizeof bcd * 2 + 1];
@@ -127,6 +148,7 @@ START_TEST (test_2hex_empty)
fail_if(len != 0, "len is %zu", len);
fail_if(ascii[0] != 0, "0 was %c",ascii[0]);
}
END_TEST
Suite *bcd_suite(void)
+10
View File
@@ -3,15 +3,18 @@
START_TEST (test_bitvec_1)
{
uc_bv_integer s[3] = {0};
struct UCBitVec v = UC_BV_STATIC_INIT(s);
size_t i;
for (i = 0; i < sizeof s * 8; i++)
fail_if(uc_bv_get_bit(&v, i), "bit %zu is not 0", i);
}
END_TEST
START_TEST (test_bitvec_2)
{
uc_bv_integer s[3] = {0};
struct UCBitVec v = UC_BV_STATIC_INIT(s);
size_t i;
@@ -21,9 +24,11 @@ START_TEST (test_bitvec_2)
for (i = 0; i < sizeof s * 8; i++)
fail_if(uc_bv_get_bit(&v, i) != 1 , "bit %zu is not 1", i);
}
END_TEST
START_TEST (test_bitvec_clearbit)
{
uc_bv_integer s[3] = {-1, -1, -1};
struct UCBitVec v = UC_BV_STATIC_INIT(s);
size_t i;
@@ -37,9 +42,11 @@ START_TEST (test_bitvec_clearbit)
for (i = 0; i < sizeof(uc_bv_integer) * 8; i++)
fail_if(uc_bv_get_bit(&v, i) != 0 , "bit %zu is not 0", i);
}
END_TEST
START_TEST (test_bitvec_set_bits_from_array)
{
struct UCBitVec *v = uc_bv_new(5);
char a[] = {1, 0,1 ,0, 1};
@@ -51,10 +58,12 @@ START_TEST (test_bitvec_set_bits_from_array)
fail_if(uc_bv_get_bit(v, 4) != 1 , "bit 4 is wrong");
uc_bv_free(v);
}
END_TEST
START_TEST (test_bitvec_setall_clearall)
{
struct UCBitVec *v = uc_bv_new(511);
size_t i;
@@ -70,6 +79,7 @@ START_TEST (test_bitvec_setall_clearall)
uc_bv_free(v);
}
END_TEST
Suite *bitvec_suite(void)
+14
View File
@@ -4,6 +4,7 @@
START_TEST (test_new_gbuf)
{
GBuf *buf = uc_new_gbuf(11);
fail_if(buf == NULL);
@@ -13,9 +14,11 @@ START_TEST (test_new_gbuf)
fail_if(buf->used != 0);
uc_gbuf_unref(buf);
}
END_TEST
START_TEST (test_gbuf_grow)
{
GBuf *buf = uc_new_gbuf(33);
int rc;
@@ -29,9 +32,11 @@ START_TEST (test_gbuf_grow)
fail_if(buf->used != 0);
uc_gbuf_unref(buf);
}
END_TEST
START_TEST (test_gbuf_append1)
{
const char *data = "lorum_ ipson 1234567890";
int rc;
GBuf *buf = uc_new_gbuf(11);
@@ -44,9 +49,11 @@ START_TEST (test_gbuf_append1)
fail_if(strcmp(data, buf->buf) != 0);
uc_gbuf_unref(buf);
}
END_TEST
START_TEST (test_gbuf_printf1)
{
int rc;
GBuf *buf = uc_new_gbuf(10);
@@ -58,9 +65,11 @@ START_TEST (test_gbuf_printf1)
fail_if(strcmp("test 1", buf->buf) != 0);
uc_gbuf_unref(buf);
}
END_TEST
START_TEST (test_gbuf_printf2)
{
int rc;
GBuf *buf = uc_new_gbuf(8);
@@ -72,9 +81,11 @@ START_TEST (test_gbuf_printf2)
fail_if(strcmp("test 1 test 2 test 3", buf->buf) != 0);
uc_gbuf_unref(buf);
}
END_TEST
START_TEST (test_gbuf_printf3)
{
int rc;
GBuf *buf = uc_new_gbuf(8);
@@ -92,9 +103,11 @@ START_TEST (test_gbuf_printf3)
fail_if(strcmp("test 1 test 2 test 3 test 4 test 5", buf->buf) != 0);
uc_gbuf_unref(buf);
}
END_TEST
START_TEST (test_gbuf_printf_empty_string)
{
int rc;
GBuf *buf = uc_new_gbuf(1);
const char *fmt = ""; //tricks gcc to not warn about empty format string
@@ -106,6 +119,7 @@ START_TEST (test_gbuf_printf_empty_string)
fail_if(buf->used != 0);
uc_gbuf_unref(buf);
}
END_TEST
+4
View File
@@ -4,6 +4,7 @@
START_TEST (test_settable_clock)
{
struct UCoreSettableClock my_clock;
struct timeval tv;
struct timeval tv_tmp;
@@ -34,9 +35,11 @@ START_TEST (test_settable_clock)
fail_if(tv.tv_sec != 123456789);
fail_if(tv.tv_usec != 44);
}
END_TEST
START_TEST (test_cached_clock)
{
struct UCoreCachedClock my_clock;
struct timeval tv1,tv2;
@@ -60,6 +63,7 @@ START_TEST (test_cached_clock)
fail_if(!timercmp(&tv1, &tv2, !=));
}
END_TEST
+2
View File
@@ -15,6 +15,7 @@ struct Outer {
};
START_TEST (test_container_of)
{
struct Outer outer = {
.tag1 = 1,
.tag2 = 2,
@@ -29,6 +30,7 @@ START_TEST (test_container_of)
fail_if(outerp != &outer);
}
END_TEST
Suite *container_of_suite(void)
+8
View File
@@ -5,6 +5,7 @@
START_TEST (test_dbuf)
{
DBuf buf;
int rc;
@@ -59,9 +60,11 @@ START_TEST (test_dbuf)
uc_dbuf_free(&buf);
}
END_TEST
START_TEST (test_dbuf_take_fail)
{
DBuf buf;
int rc;
@@ -80,10 +83,12 @@ START_TEST (test_dbuf_take_fail)
fail_if(rc == 0);
uc_dbuf_free(&buf);
}
END_TEST
START_TEST (test_dbuf_take_all)
{
DBuf buf;
int rc;
@@ -104,9 +109,11 @@ START_TEST (test_dbuf_take_all)
fail_if(uc_dbuf_remaining(&buf) != 10);
uc_dbuf_free(&buf);
}
END_TEST
START_TEST (test_dbuf_add_ensure_take)
{
DBuf *buf;
int rc;
@@ -155,6 +162,7 @@ START_TEST (test_dbuf_add_ensure_take)
uc_dbuf_free(buf);
free(buf);
}
END_TEST
+18
View File
@@ -6,6 +6,7 @@
START_TEST (test_dstr_basics)
{
struct DStr str;
int rc;
@@ -46,9 +47,11 @@ START_TEST (test_dstr_basics)
//just test that this doesn't crash:
uc_dstr_init(&str);
uc_dstr_destroy(&str);
}
END_TEST
START_TEST (test_dstr_init)
{
struct DStr str;
int rc;
@@ -65,9 +68,11 @@ START_TEST (test_dstr_init)
ck_assert_str_eq(uc_dstr_str(&str), "He");
uc_dstr_destroy(&str);
}
END_TEST
START_TEST (test_dstr_own)
{
struct DStr str;
uc_dstr_init_str(&str, "init");
@@ -76,8 +81,10 @@ START_TEST (test_dstr_own)
ck_assert_str_eq(uc_dstr_str(&str), "Hello !");
uc_dstr_destroy(&str);
}
END_TEST
START_TEST (test_dstr_own_steal)
{
struct DStr str;
char *s;
@@ -93,9 +100,11 @@ START_TEST (test_dstr_own_steal)
free(s);
uc_dstr_destroy(&str);
}
END_TEST
START_TEST (test_dstr_trim)
{
struct DStr str = UC_DSTR_INITIALIZER;
uc_dstr_append_str(&str, " \t \nHello !\r\n");
@@ -118,9 +127,11 @@ START_TEST (test_dstr_trim)
uc_dstr_destroy(&str);
}
END_TEST
START_TEST (test_dstr_replace)
{
struct DStr str;
size_t rc;
@@ -136,9 +147,11 @@ START_TEST (test_dstr_replace)
uc_dstr_destroy(&str);
}
END_TEST
START_TEST (test_dstr_filter)
{
struct DStr str;
size_t rc;
@@ -151,9 +164,11 @@ START_TEST (test_dstr_filter)
uc_dstr_destroy(&str);
}
END_TEST
START_TEST (test_dstr_sprintf)
{
struct DStr str;
size_t rc;
@@ -168,9 +183,11 @@ START_TEST (test_dstr_sprintf)
uc_dstr_destroy(&str);
}
END_TEST
START_TEST (test_dstr_copy)
{
struct DStr str;
struct DStr copy;
size_t rc;
@@ -195,6 +212,7 @@ START_TEST (test_dstr_copy)
uc_dstr_destroy(&str);
uc_dstr_destroy(&copy);
}
END_TEST
Suite *dstr_suite(void)
+6
View File
@@ -52,6 +52,7 @@ static int cmp_stuff_array(const struct Stuff *a, const struct Stuff *b, size_t
}
START_TEST (test_heapsort_odd)
{
struct Stuff unordered[] = {
{"2", 2},
{"1", 1},
@@ -72,9 +73,11 @@ START_TEST (test_heapsort_odd)
cmp_stuff, swap_stuff, NULL);
print_stuff(unordered, ARRAY_SIZE(unordered));
fail_if(cmp_stuff_array(unordered, ordered, ARRAY_SIZE(unordered)) != 0);
}
END_TEST
START_TEST (test_heapsort_even)
{
struct Stuff unordered[] = {
{"1", 1},
{"7", 7},
@@ -96,9 +99,11 @@ START_TEST (test_heapsort_even)
uc_heapsort(unordered, ARRAY_SIZE(unordered), sizeof(struct Stuff),
cmp_stuff, swap_stuff, NULL);
fail_if(cmp_stuff_array(unordered, ordered, ARRAY_SIZE(unordered)) != 0);
}
END_TEST
START_TEST (test_heapsort_zero_one)
{
struct Stuff unordered[] = {
{"1", 1},
{"7", 7},
@@ -128,6 +133,7 @@ START_TEST (test_heapsort_zero_one)
uc_heapsort(unordered, 1, sizeof(struct Stuff),
cmp_stuff, swap_stuff, NULL);
fail_if(cmp_stuff_array(unordered, same, ARRAY_SIZE(unordered)) != 0);
}
END_TEST
Suite *heapsort_suite(void)
+34
View File
@@ -4,6 +4,7 @@
START_TEST (test_uc_hex_encode_1)
{
uint8_t binary[] = {0xff};
char hex[3] = "";
@@ -11,9 +12,11 @@ START_TEST (test_uc_hex_encode_1)
fail_if(strcmp(hex,"FF") != 0);
}
END_TEST
START_TEST (test_uc_hex_encode_2)
{
uint8_t binary[] = {127, 128, 129};
char hex[sizeof binary * 2 + 1] = "";
@@ -21,9 +24,11 @@ START_TEST (test_uc_hex_encode_2)
fail_if(strcmp(hex,"7F8081") != 0, "was %s", hex);
}
END_TEST
START_TEST (test_uc_hex_encode_3)
{
uint8_t binary[] = {0, 1, 9, 11};
char hex[sizeof binary * 2 + 1] = "";
@@ -31,9 +36,11 @@ START_TEST (test_uc_hex_encode_3)
fail_if(strcmp(hex,"0001090B") != 0, "was %s", hex);
}
END_TEST
START_TEST (test_uc_hex_encode_zero_len)
{
uint8_t binary[1] = {0xff};
char hex[3] = "aa";
@@ -42,9 +49,11 @@ START_TEST (test_uc_hex_encode_zero_len)
fail_if(hex[0] != 0);
fail_if(hex[1] != 'a');
}
END_TEST
START_TEST (test_uc_hex_decode_1)
{
char hex[] = "1F";
uint8_t binary[2] = {0x11,0x22};
uint8_t *res;
@@ -55,9 +64,11 @@ START_TEST (test_uc_hex_decode_1)
fail_if(binary[1] != 0x22);
fail_if(res != binary + 1, "binary %p, res %p", &binary[0], res);
}
END_TEST
START_TEST (test_uc_hex_decode_2)
{
char hex[] = "00FF80";
uint8_t binary[4] = {0x11, 0x11, 0x11};
uint8_t *res;
@@ -69,9 +80,11 @@ START_TEST (test_uc_hex_decode_2)
fail_if(binary[2] != 0x80);
fail_if(res != binary + 3, "binary %p, res %p", &binary[0], res);
}
END_TEST
START_TEST (test_uc_hex_decode_zero_length)
{
char hex[] = "00FF80";
uint8_t binary[4] = {0x11, 0x11, 0x11};
uint8_t *res;
@@ -83,9 +96,11 @@ START_TEST (test_uc_hex_decode_zero_length)
fail_if(binary[2] != 0x11);
fail_if(res != binary);
}
END_TEST
START_TEST (test_uc_hex_decode_empty_string)
{
char hex[] = "";
uint8_t binary[] = {0x11, 0x11, 0x11};
uint8_t *res;
@@ -97,8 +112,10 @@ START_TEST (test_uc_hex_decode_empty_string)
fail_if(binary[2] != 0x11);
fail_if(res != binary, "length %zu\n", res - binary);
}
END_TEST
START_TEST (test_uc_hex_decode_spaces)
{
char hex[] = " 11 1213";
uint8_t binary[3];
uint8_t *res;
@@ -110,9 +127,11 @@ START_TEST (test_uc_hex_decode_spaces)
fail_if(binary[2] != 0x13);
fail_if(res != binary+3, "length %zu\n", res - binary);
}
END_TEST
START_TEST (test_uc_hex_decode_spaces2)
{
char hex[] = "1112 13\r\n";
uint8_t binary[3];
uint8_t *res;
@@ -124,9 +143,11 @@ START_TEST (test_uc_hex_decode_spaces2)
fail_if(binary[2] != 0x13);
fail_if(res != binary+3, "length %zu\n", res - binary);
}
END_TEST
START_TEST (test_uc_hex_decode_spaces_empty)
{
char hex[] = " \r\n ";
uint8_t binary[] = {0x11,0x12};
uint8_t *res;
@@ -137,9 +158,11 @@ START_TEST (test_uc_hex_decode_spaces_empty)
fail_if(binary[1] != 0x12);
fail_if(res != binary, "length %zu\n", res - binary);
}
END_TEST
START_TEST (test_uc_hex_decode_odd_length)
{
char hex[] = "33FF80";
uint8_t binary[4] = {0x11, 0x11, 0x11};
uint8_t *res;
@@ -151,9 +174,11 @@ START_TEST (test_uc_hex_decode_odd_length)
fail_if(binary[2] != 0x11);
fail_if(res != &binary[1]);
}
END_TEST
START_TEST (test_uc_hex_decode_invalid)
{
char hex[] = "TEST ";
uint8_t binary[4] = {0x11, 0x11, 0x11};
uint8_t *res;
@@ -165,9 +190,11 @@ START_TEST (test_uc_hex_decode_invalid)
fail_if(binary[2] != 0x11);
fail_if(res != NULL);
}
END_TEST
START_TEST (test_uc_hex_encode_delim_1)
{
uint8_t binary[4] = {0xFF, 0x00, 0x7F, 0x0A};
char hex[17] = "";
char *res;
@@ -178,9 +205,11 @@ START_TEST (test_uc_hex_encode_delim_1)
*res = 0;
fail_if(res != hex + 12);
}
END_TEST
START_TEST (test_uc_hex_encode_delim_2)
{
uint8_t binary[] = {0xFF, 0x00};
char hex[8] = "";
char *res;
@@ -190,9 +219,11 @@ START_TEST (test_uc_hex_encode_delim_2)
fail_if(strcmp(hex, "FF \n00 ") != 0, "hex was '%s'", hex);
fail_if(res != hex + 7, "sz was %zu", res - hex);
}
END_TEST
START_TEST (test_uc_hex_encode_delim_zero_len)
{
uint8_t binary[] = {0xFF, 0x00};
char hex[8] = "......";
char *res;
@@ -202,10 +233,12 @@ START_TEST (test_uc_hex_encode_delim_zero_len)
fail_if(strcmp(hex, "") != 0, "hex was '%s'", hex);
fail_if(res != hex);
}
END_TEST
START_TEST (test_uc_hex_decode_lowercase)
{
char hex[] = "1f";
uint8_t binary[2] = {0x11,0x22};
uint8_t *res;
@@ -216,6 +249,7 @@ START_TEST (test_uc_hex_decode_lowercase)
fail_if(binary[1] != 0x22);
fail_if(res != binary + 1, "binary %p, res %p", &binary[0], res);
}
END_TEST
Suite *hex_suite(void)
{
+20
View File
@@ -40,6 +40,7 @@ struct MyString *my_find(struct UHTable *table, const char *str, size_t hash)
START_TEST (test_htable1)
{
struct MyString str[5] = {
{"One", {0,NULL}},
{"Two", {0,NULL}},
@@ -67,9 +68,11 @@ START_TEST (test_htable1)
uc_htable_destroy(&table);
}
END_TEST
START_TEST (test_htable_hash_collision)
{
//same as test1 but with a bad hash to force equal hash
struct MyString str[5] = {
{"...", {0,NULL}},
@@ -97,9 +100,11 @@ START_TEST (test_htable_hash_collision)
uc_htable_destroy(&table);
}
END_TEST
START_TEST (test_htable_resize)
{
struct MyString str[5] = {
{"One", {0,NULL}},
{"Two", {0,NULL}},
@@ -132,9 +137,11 @@ START_TEST (test_htable_resize)
uc_htable_destroy(&table);
}
END_TEST
START_TEST (test_htable_fail_init_resize)
{
int rc;
struct UHTable table;
rc = uc_htable_init(&table, 0);
@@ -148,9 +155,11 @@ START_TEST (test_htable_fail_init_resize)
uc_htable_destroy(&table);
}
END_TEST
START_TEST (test_htable_has_node)
{
struct MyString str1 = {"One", {0,NULL}};
struct MyString str2 = {"Two", {0,NULL}};
@@ -171,9 +180,11 @@ START_TEST (test_htable_has_node)
uc_htable_destroy(&table);
}
END_TEST
START_TEST (test_htable_remove)
{
struct MyString str1 = {"One", {0,NULL}};
struct MyString str2 = {"One", {0,NULL}};
struct MyString str3 = {"Other", {0,NULL}};
@@ -216,9 +227,11 @@ START_TEST (test_htable_remove)
uc_htable_destroy(&table);
}
END_TEST
START_TEST (test_htable_remove_foreach)
{
struct MyString str1 = {"One", {0,NULL}};
struct MyString str2 = {"One", {0,NULL}};
struct MyString str3 = {"Other", {0,NULL}};
@@ -254,9 +267,11 @@ START_TEST (test_htable_remove_foreach)
uc_htable_destroy(&table);
}
END_TEST
START_TEST (test_htable_clear)
{
struct MyString str1 = {"One", {0,NULL}};
struct UHTable table;
@@ -276,9 +291,11 @@ START_TEST (test_htable_clear)
uc_htable_destroy(&table);
}
END_TEST
START_TEST (test_htable_foreach)
{
struct MyString str1 = {"One", {0,NULL}};
struct MyString str2 = {"One", {0,NULL}};
struct MyString str3 = {"Other",{0,NULL}};
@@ -318,9 +335,11 @@ START_TEST (test_htable_foreach)
uc_htable_destroy(&table);
}
END_TEST
START_TEST (test_htable_foreach_safe)
{
struct MyString str1 = {"One", {0,NULL}};
struct MyString str2 = {"One", {0,NULL}};
struct MyString str3 = {"Other",{0,NULL}};
@@ -353,6 +372,7 @@ START_TEST (test_htable_foreach_safe)
uc_htable_destroy(&table);
}
END_TEST
Suite *htable_suite(void)
+14
View File
@@ -3,6 +3,7 @@
START_TEST (test_human_bytesz_bytes)
{
char result[128];
char *rc;
@@ -13,9 +14,11 @@ START_TEST (test_human_bytesz_bytes)
rc = uc_human_bytesz_bin(999, result, sizeof result);
fail_if(rc == NULL);
ck_assert_str_eq(result, "999 b");
}
END_TEST
START_TEST (test_human_bytesz_bytes_0)
{
char result[128];
char *rc;
@@ -26,9 +29,11 @@ START_TEST (test_human_bytesz_bytes_0)
rc = uc_human_bytesz_bin(0, result, sizeof result);
fail_if(rc == NULL);
ck_assert_str_eq(result, "0 b");
}
END_TEST
START_TEST (test_human_bytesz_kilobytes)
{
char result[128];
char *rc;
@@ -39,9 +44,11 @@ START_TEST (test_human_bytesz_kilobytes)
rc = uc_human_bytesz_bin(64000, result, sizeof result);
fail_if(rc == NULL);
ck_assert_str_eq(result, "62.50 KiB");
}
END_TEST
START_TEST (test_human_bytesz_megabytes)
{
char result[128];
char *rc;
@@ -52,9 +59,11 @@ START_TEST (test_human_bytesz_megabytes)
rc = uc_human_bytesz_bin(6409000, result, sizeof result);
fail_if(rc == NULL);
ck_assert_str_eq(result, "6.11 MiB");
}
END_TEST
START_TEST (test_human_bytesz_gigabytes)
{
char result[128];
char *rc;
@@ -65,9 +74,11 @@ START_TEST (test_human_bytesz_gigabytes)
rc = uc_human_bytesz_bin(126999400000, result, sizeof result);
fail_if(rc == NULL);
ck_assert_str_eq(result, "118.28 GiB");
}
END_TEST
START_TEST (test_human_bytesz_terrabytes)
{
char result[128];
char *rc;
@@ -78,9 +89,11 @@ START_TEST (test_human_bytesz_terrabytes)
rc = uc_human_bytesz_bin(12453400030000, result, sizeof result);
fail_if(rc == NULL);
ck_assert_str_eq(result, "11.33 TiB");
}
END_TEST
START_TEST (test_human_bytesz_petabytes)
{
char result[128];
char *rc;
@@ -91,6 +104,7 @@ START_TEST (test_human_bytesz_petabytes)
rc = uc_human_bytesz_bin(~0ULL, result, sizeof result);
fail_if(rc == NULL);
ck_assert_str_eq(result, "16384.00 PiB");
}
END_TEST
+2
View File
@@ -67,6 +67,7 @@ static void simple_wcb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event
START_TEST (test_iomux_pipe_simple)
{
struct IOMux *mux;
struct IOMuxFD rfd;
struct IOMuxFD wfd;
@@ -106,6 +107,7 @@ START_TEST (test_iomux_pipe_simple)
iomux_delete(mux);
}
END_TEST
+2
View File
@@ -46,6 +46,7 @@ static void usr2_handler(struct IOMux *mux, int signo, void *cookie)
}
START_TEST (test_iomux_signal_simple)
{
struct IOMux *mux = iomux_create(g_iomux_type);
@@ -87,6 +88,7 @@ START_TEST (test_iomux_signal_simple)
ck_assert_int_eq(g_usr1_seen, 1);
ck_assert_int_eq(g_usr2_seen, 1);
}
END_TEST
+28
View File
@@ -31,6 +31,7 @@ static void logging_rm_subdir(void)
}
START_TEST (test_logfile_location)
{
struct UCLogModule m = {
.id = 0,
@@ -62,9 +63,11 @@ START_TEST (test_logfile_location)
rc = stat(FILE_NAME, &st);
fail_if(rc != 0, "stat failed: %s", strerror(errno));
fail_if(st.st_size != 380, "was %ld", (long)st.st_size);
}
END_TEST
START_TEST (test_logfile_delete_destination)
{
struct UCLogModule m = {
.id = 0,
@@ -110,9 +113,11 @@ START_TEST (test_logfile_delete_destination)
fail_if(rc != 0, "stat failed: %s", strerror(errno));
fail_if(st.st_size != 380, "was %ld", (long)st.st_size);
}
END_TEST
START_TEST (test_logfile_no_location)
{
struct UCLogModule m = {
.id = 0,
@@ -140,9 +145,11 @@ START_TEST (test_logfile_no_location)
rc = stat(FILE_NAME, &st);
fail_if(rc != 0, "stat failed: %s", strerror(errno));
fail_if(st.st_size != 52*2, "was %ld", (long)st.st_size);
}
END_TEST
START_TEST (test_logfile_loglevel_surpressed_dest)
{
struct UCLogModule m = {
.id = 0,
@@ -172,9 +179,11 @@ START_TEST (test_logfile_loglevel_surpressed_dest)
fail_if(rc != 0, "stat failed: %s", strerror(errno));
fail_if(st.st_size != 0, "was %ld", (long)st.st_size);
}
END_TEST
START_TEST (test_logfile_loglevel_surpressed_module)
{
struct UCLogModule m = {
.id = 0,
@@ -204,9 +213,11 @@ START_TEST (test_logfile_loglevel_surpressed_module)
fail_if(rc != 0, "stat failed: %s", strerror(errno));
fail_if(st.st_size != 0, "was %ld", (long)st.st_size);
}
END_TEST
START_TEST (test_logfile_reopen_files)
{
struct UCLogModule m = {
.id = 0,
@@ -247,9 +258,11 @@ START_TEST (test_logfile_reopen_files)
fail_if(rc != 0, "2. stat failed: %s", strerror(errno));
fail_if(st.st_size != 77, "was %ld", (long)st.st_size);//should only one line there now
}
END_TEST
START_TEST (test_logfile_remove_dest)
{
struct UCLogModule m = {
.id = 0,
@@ -301,9 +314,11 @@ START_TEST (test_logfile_remove_dest)
fail_if(rc != 0, "2. stat failed: %s", strerror(errno));
fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size);//should be same size
}
END_TEST
START_TEST (test_logfile_full_filesystem)
{
//logging to a full filesystem shouldn't crash
struct UCLogModule m = {
.id = 0,
@@ -331,9 +346,11 @@ START_TEST (test_logfile_full_filesystem)
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d", 1);
}
}
END_TEST
START_TEST (test_logfile_invalid_file)
{
//check behavior when a log file cannot be opened
struct UCLogModule m = {
.id = 0,
@@ -352,9 +369,11 @@ START_TEST (test_logfile_invalid_file)
dest = uc_log_new_file("PATH/to/nonexisting.log", UC_LL_DEBUG, 1);
fail_if(dest != NULL);
}
END_TEST
START_TEST (test_logfile_invalid_file_after_reopen)
{
//check behavior when a log file cannot be re-opened
struct UCLogModule m = {
.id = 0,
@@ -391,9 +410,11 @@ START_TEST (test_logfile_invalid_file_after_reopen)
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d", 1);
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d", 1);
}
END_TEST
START_TEST (test_logfile_raw)
{
struct UCLogModule m = {
.id = 0,
@@ -421,9 +442,11 @@ START_TEST (test_logfile_raw)
rc = stat(FILE_NAME, &st);
fail_if(rc != 0, "stat failed: %s", strerror(errno));
fail_if(st.st_size != 14*2, "was %ld", (long)st.st_size);
}
END_TEST
START_TEST (test_logfile_dest_mask)
{
struct UCLogModule m[] = {
{
@@ -467,9 +490,11 @@ START_TEST (test_logfile_dest_mask)
rc = stat(FILE_NAME, &st);
fail_if(rc != 0, "stat failed: %s", strerror(errno));
fail_if(st.st_size != 14*2, "was %ld", (long)st.st_size);
}
END_TEST
START_TEST (test_loglevel_module_none)
{
struct UCLogModule m = {
.id = 0,
@@ -496,9 +521,11 @@ START_TEST (test_loglevel_module_none)
rc = stat(FILE_NAME, &st);
fail_if(rc != 0, "stat failed: %s", strerror(errno));
fail_if(st.st_size != 0, "was %ld", (long)st.st_size);
}
END_TEST
START_TEST (test_loglevel_dest_none)
{
struct UCLogModule m = {
.id = 0,
@@ -525,6 +552,7 @@ START_TEST (test_loglevel_dest_none)
rc = stat(FILE_NAME, &st);
fail_if(rc != 0, "stat failed: %s", strerror(errno));
fail_if(st.st_size != 0, "was %ld", (long)st.st_size);
}
END_TEST
+30
View File
@@ -5,6 +5,7 @@
START_TEST (test_mbuf_new)
{
struct MBuf *mbuf;
mbuf = uc_mbuf_new(110);
@@ -22,9 +23,11 @@ START_TEST (test_mbuf_new)
uc_mbuf_free(mbuf);
}
END_TEST
START_TEST (test_mbuf_new_inline)
{
struct MBuf *mbuf;
mbuf = uc_mbuf_new_inline(110);
@@ -44,9 +47,11 @@ START_TEST (test_mbuf_new_inline)
uc_mbuf_free(mbuf);
}
END_TEST
START_TEST (test_mbuf_new_headroom)
{
struct MBuf *mbuf;
mbuf = uc_mbuf_new_hr(110,20);
@@ -64,9 +69,11 @@ START_TEST (test_mbuf_new_headroom)
uc_mbuf_free(mbuf);
}
END_TEST
START_TEST (test_mbuf_put)
{
struct MBuf *mbuf;
uint8_t *data;
@@ -82,9 +89,11 @@ START_TEST (test_mbuf_put)
uc_mbuf_free(mbuf);
}
END_TEST
START_TEST (test_mbuf_put_fail)
{
struct MBuf *mbuf;
uint8_t *data;
@@ -96,9 +105,11 @@ START_TEST (test_mbuf_put_fail)
uc_mbuf_free(mbuf);
}
END_TEST
START_TEST (test_mbuf_push)
{
struct MBuf *mbuf;
uint8_t *data;
@@ -114,10 +125,12 @@ START_TEST (test_mbuf_push)
uc_mbuf_free(mbuf);
}
END_TEST
START_TEST (test_mbuf_push_fail)
{
struct MBuf *mbuf;
uint8_t *data;
@@ -129,9 +142,11 @@ START_TEST (test_mbuf_push_fail)
uc_mbuf_free(mbuf);
}
END_TEST
START_TEST (test_mbuf_pull)
{
struct MBuf *mbuf;
uint8_t *data1;
uint8_t *data2;
@@ -151,9 +166,11 @@ START_TEST (test_mbuf_pull)
uc_mbuf_free(mbuf);
}
END_TEST
START_TEST (test_mbuf_pull_fail)
{
struct MBuf *mbuf;
uint8_t *data1;
uint8_t *data2;
@@ -172,9 +189,11 @@ START_TEST (test_mbuf_pull_fail)
uc_mbuf_free(mbuf);
}
END_TEST
START_TEST (test_mbuf_copy)
{
struct MBuf *mbuf;
uint8_t *data1;
struct MBuf *copy;
@@ -196,9 +215,11 @@ START_TEST (test_mbuf_copy)
uc_mbuf_free(mbuf);
uc_mbuf_free(copy);
}
END_TEST
START_TEST (test_mbuf_zero)
{
struct MBuf *mbuf;
uint8_t *data1;
@@ -215,9 +236,11 @@ START_TEST (test_mbuf_zero)
uc_mbuf_free(mbuf);
}
END_TEST
START_TEST (test_mbuf_static)
{
uint8_t data[1024];
struct MBuf mbuf;
@@ -245,9 +268,11 @@ START_TEST (test_mbuf_static)
uc_mbuf_free(&mbuf);
}
END_TEST
START_TEST (test_mbuf_extend_tailroom)
{
struct MBuf *mbuf;
uint8_t *data;
void *filler;
@@ -281,9 +306,11 @@ START_TEST (test_mbuf_extend_tailroom)
uc_mbuf_free(mbuf);
free(filler);
}
END_TEST
START_TEST (test_mbuf_extend_tailroom_wrong_type)
{
struct MBuf *mbuf;
int rc;
@@ -295,9 +322,11 @@ START_TEST (test_mbuf_extend_tailroom_wrong_type)
uc_mbuf_free(mbuf);
}
END_TEST
START_TEST (test_mbuf_queue)
{
struct MBuf *m1;
struct MBuf *m2;
struct MBuf *q;
@@ -337,6 +366,7 @@ START_TEST (test_mbuf_queue)
uc_mbuf_free(m1);
uc_mbuf_free(m2);
}
END_TEST
Suite *mbuf_suite(void)
+64
View File
@@ -3,6 +3,7 @@
START_TEST (test_pack16_le_1)
{
uint16_t v = 0x1234;
uint8_t r[2];
@@ -10,9 +11,11 @@ START_TEST (test_pack16_le_1)
fail_if(r[0] != 0x34,"was 0x%x",r[0]);
fail_if(r[1] != 0x12,"was 0x%x",r[1]);
}
END_TEST
START_TEST (test_pack16_le_2)
{
uint16_t v = 0xFEEF;
uint8_t r[2];
@@ -20,9 +23,11 @@ START_TEST (test_pack16_le_2)
fail_if(r[0] != 0xEF,"was 0x%x",r[0]);
fail_if(r[1] != 0xFE,"was 0x%x",r[1]);
}
END_TEST
START_TEST (test_pack16_be_1)
{
uint16_t v = 0x1234;
uint8_t r[2];
@@ -30,9 +35,11 @@ START_TEST (test_pack16_be_1)
fail_if(r[0] != 0x12,"was 0x%x",r[0]);
fail_if(r[1] != 0x34,"was 0x%x",r[1]);
}
END_TEST
START_TEST (test_pack16_be_2)
{
uint16_t v = 0xFEEF;
uint8_t r[2];
@@ -40,45 +47,55 @@ START_TEST (test_pack16_be_2)
fail_if(r[0] != 0xFE,"was 0x%x",r[0]);
fail_if(r[1] != 0xEF,"was 0x%x",r[1]);
}
END_TEST
START_TEST (test_unpack16_le_1)
{
uint16_t v;
uint8_t r[2] = {0x12, 0x34};
v = uc_unpack_16_le(r);
fail_if(v != 0x3412,"was 0x%x",v);
}
END_TEST
START_TEST (test_unpack16_le_2)
{
uint16_t v;
uint8_t r[2] = {0xFE, 0xEF};
v = uc_unpack_16_le(r);
fail_if(v != 0xEFFE,"was 0x%x",v);
}
END_TEST
START_TEST (test_unpack16_be_1)
{
uint16_t v;
uint8_t r[2] = {0x12, 0x34};
v = uc_unpack_16_be(r);
fail_if(v != 0x1234,"was 0x%x",v);
}
END_TEST
START_TEST (test_unpack16_be_2)
{
uint16_t v;
uint8_t r[2] = {0xFE, 0xEF};
v = uc_unpack_16_be(r);
fail_if(v != 0xFEEF,"was 0x%x",v);
}
END_TEST
START_TEST (test_pack24_le_1)
{
uint32_t v = 0x123456;
uint8_t r[3];
@@ -87,9 +104,11 @@ START_TEST (test_pack24_le_1)
fail_if(r[0] != 0x56,"was 0x%x",r[0]);
fail_if(r[1] != 0x34,"was 0x%x",r[1]);
fail_if(r[2] != 0x12,"was 0x%x",r[2]);
}
END_TEST
START_TEST (test_pack24_le_2)
{
uint32_t v = 0xF8F7F6;
uint8_t r[3];
@@ -98,9 +117,11 @@ START_TEST (test_pack24_le_2)
fail_if(r[0] != 0xF6,"was 0x%x",r[0]);
fail_if(r[1] != 0xF7,"was 0x%x",r[1]);
fail_if(r[2] != 0xF8,"was 0x%x",r[2]);
}
END_TEST
START_TEST (test_pack24_be_1)
{
uint32_t v = 0x123456;
uint8_t r[3];
@@ -109,9 +130,11 @@ START_TEST (test_pack24_be_1)
fail_if(r[0] != 0x12,"was 0x%x",r[0]);
fail_if(r[1] != 0x34,"was 0x%x",r[1]);
fail_if(r[2] != 0x56,"was 0x%x",r[2]);
}
END_TEST
START_TEST (test_pack24_be_2)
{
uint32_t v = 0xF8F7F6;
uint8_t r[3];
@@ -120,9 +143,11 @@ START_TEST (test_pack24_be_2)
fail_if(r[0] != 0xF8,"was 0x%x",r[0]);
fail_if(r[1] != 0xF7,"was 0x%x",r[1]);
fail_if(r[2] != 0xF6,"was 0x%x",r[2]);
}
END_TEST
START_TEST (test_pack32_le_1)
{
uint32_t v = 0x12345678;
uint8_t r[4];
@@ -132,9 +157,11 @@ START_TEST (test_pack32_le_1)
fail_if(r[1] != 0x56,"was 0x%x",r[1]);
fail_if(r[2] != 0x34,"was 0x%x",r[2]);
fail_if(r[3] != 0x12,"was 0x%x",r[3]);
}
END_TEST
START_TEST (test_pack32_le_2)
{
uint32_t v = 0xF8F7F6F4;
uint8_t r[4];
@@ -144,9 +171,11 @@ START_TEST (test_pack32_le_2)
fail_if(r[1] != 0xF6,"was 0x%x",r[1]);
fail_if(r[2] != 0xF7,"was 0x%x",r[2]);
fail_if(r[3] != 0xF8,"was 0x%x",r[3]);
}
END_TEST
START_TEST (test_pack32_be_1)
{
uint32_t v = 0x12345678;
uint8_t r[4];
@@ -156,9 +185,11 @@ START_TEST (test_pack32_be_1)
fail_if(r[2] != 0x56,"was 0x%x",r[2]);
fail_if(r[1] != 0x34,"was 0x%x",r[1]);
fail_if(r[0] != 0x12,"was 0x%x",r[0]);
}
END_TEST
START_TEST (test_pack32_be_2)
{
uint32_t v = 0xF8F7F6F4;
uint8_t r[4];
@@ -168,81 +199,99 @@ START_TEST (test_pack32_be_2)
fail_if(r[2] != 0xF6,"was 0x%x",r[2]);
fail_if(r[1] != 0xF7,"was 0x%x",r[1]);
fail_if(r[0] != 0xF8,"was 0x%x",r[0]);
}
END_TEST
START_TEST (test_unpack24_le_1)
{
uint32_t v;
uint8_t r[3] = {0x12, 0x34, 0x56 };
v = uc_unpack_24_le(r);
fail_if(v != 0x563412,"was 0x%x",v);
}
END_TEST
START_TEST (test_unpack24_le_2)
{
uint32_t v;
uint8_t r[4] = {0xF8, 0xF7, 0xF6};
v = uc_unpack_24_le(r);
fail_if(v != 0xF6F7F8,"was 0x%x",v);
}
END_TEST
START_TEST (test_unpack24_be_1)
{
uint32_t v;
uint8_t r[3] = {0x12, 0x34, 0x56 };
v = uc_unpack_24_be(r);
fail_if(v != 0x123456,"was 0x%x",v);
}
END_TEST
START_TEST (test_unpack24_be_2)
{
uint32_t v;
uint8_t r[4] = {0xF8, 0xF7, 0xF6};
v = uc_unpack_24_be(r);
fail_if(v != 0xF8F7F6,"was 0x%x",v);
}
END_TEST
START_TEST (test_unpack32_le_1)
{
uint32_t v;
uint8_t r[4] = {0x12, 0x34, 0x56, 0x78};
v = uc_unpack_32_le(r);
fail_if(v != 0x78563412,"was 0x%x",v);
}
END_TEST
START_TEST (test_unpack32_le_2)
{
uint32_t v;
uint8_t r[4] = {0xF8, 0xF7, 0xF6, 0xF4 };
v = uc_unpack_32_le(r);
fail_if(v != 0xF4F6F7F8,"was 0x%x",v);
}
END_TEST
START_TEST (test_unpack32_be_1)
{
uint32_t v;
uint8_t r[4] = {0x12, 0x34, 0x56, 0x78};
v = uc_unpack_32_be(r);
fail_if(v != 0x12345678,"was 0x%x",v);
}
END_TEST
START_TEST (test_unpack32_be_2)
{
uint32_t v;
uint8_t r[4] = {0xF8, 0xF7, 0xF6, 0xF4 };
v = uc_unpack_32_be(r);
fail_if(v != 0xF8F7F6F4,"was 0x%x",v);
}
END_TEST
START_TEST (test_pack64_le_1)
{
uint64_t v = 0x1122334455667788ULL;
uint8_t r[8] = {};
@@ -256,9 +305,11 @@ START_TEST (test_pack64_le_1)
fail_if(r[5] != 0x33,"was 0x%x",r[5]);
fail_if(r[6] != 0x22,"was 0x%x",r[6]);
fail_if(r[7] != 0x11,"was 0x%x",r[7]);
}
END_TEST
START_TEST (test_pack64_le_2)
{
uint64_t v = 0xFFFEFDFCFBFAF9F8ULL;
uint8_t r[8] = {};
@@ -272,28 +323,34 @@ START_TEST (test_pack64_le_2)
fail_if(r[5] != 0xFD,"was 0x%x",r[5]);
fail_if(r[6] != 0xFE,"was 0x%x",r[6]);
fail_if(r[7] != 0xFF,"was 0x%x",r[7]);
}
END_TEST
START_TEST (test_unpack64_le_1)
{
uint64_t v;
uint8_t r[8] = {0x11 ,0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
v = uc_unpack_64_le(r);
fail_if(v != 0x8877665544332211ULL,"was 0x%llx",v);
}
END_TEST
START_TEST (test_unpack64_le_2)
{
uint64_t v;
uint8_t r[8] = {0xFF ,0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8};
v = uc_unpack_64_le(r);
fail_if(v != 0xF8F9FAFBFCFDFEFFULL,"was 0x%llx",v);
}
END_TEST
START_TEST (test_pack64_be_1)
{
uint64_t v = 0x1122334455667788ULL;
uint8_t r[8] = {};
@@ -307,9 +364,11 @@ START_TEST (test_pack64_be_1)
fail_if(r[5] != 0x66,"was 0x%x",r[5]);
fail_if(r[6] != 0x77,"was 0x%x",r[6]);
fail_if(r[7] != 0x88,"was 0x%x",r[7]);
}
END_TEST
START_TEST (test_pack64_be_2)
{
uint64_t v = 0xFFFEFDFCFBFAF9F8ULL;
uint8_t r[8] = {};
@@ -323,24 +382,29 @@ START_TEST (test_pack64_be_2)
fail_if(r[5] != 0xFA,"was 0x%x",r[5]);
fail_if(r[6] != 0xF9,"was 0x%x",r[6]);
fail_if(r[7] != 0xF8,"was 0x%x",r[7]);
}
END_TEST
START_TEST (test_unpack64_be_1)
{
uint64_t v;
uint8_t r[8] = {0x11 ,0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
v = uc_unpack_64_be(r);
fail_if(v != 0x1122334455667788ULL,"was 0x%llx",v);
}
END_TEST
START_TEST (test_unpack64_be_2)
{
uint64_t v;
uint8_t r[8] = {0xFF ,0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8};
v = uc_unpack_64_be(r);
fail_if(v != 0xFFFEFDFCFBFAF9F8ULL,"was 0x%llx",v);
}
END_TEST
Suite *pack_suite(void)
+12
View File
@@ -3,6 +3,7 @@
START_TEST (test_ratelimit_1)
{
struct RateLimit r;
long now = 10;
int i;
@@ -12,9 +13,11 @@ START_TEST (test_ratelimit_1)
fail_if(!uc_ratelimit_allow(&r, now), "i = %d", i);
}
fail_if(uc_ratelimit_allow(&r, now));
}
END_TEST
START_TEST (test_ratelimit_2)
{
struct RateLimit r;
long now = 10;
@@ -27,9 +30,11 @@ START_TEST (test_ratelimit_2)
fail_if(!uc_ratelimit_allow(&r, now));
fail_if(uc_ratelimit_allow(&r, now));
}
END_TEST
START_TEST (test_ratelimit_3)
{
struct RateLimit r;
long now = 10;
int i;
@@ -63,9 +68,11 @@ START_TEST (test_ratelimit_3)
fail_if(uc_ratelimit_allow(&r, now));
}
END_TEST
START_TEST (test_ratelimit_4)
{
struct RateLimit r;
long now = 10;
int i;
@@ -86,9 +93,11 @@ START_TEST (test_ratelimit_4)
}
fail_if(uc_ratelimit_allow(&r, now));
}
END_TEST
START_TEST (test_ratelimit_5)
{
struct RateLimit r;
long now = 1400000000;
@@ -111,9 +120,11 @@ START_TEST (test_ratelimit_5)
fail_if(!uc_ratelimit_allow(&r, now));
fail_if(uc_ratelimit_allow(&r, now));
}
END_TEST
START_TEST (test_ratelimit_time_backward)
{
struct RateLimit r;
long now = 1400000000;
@@ -126,6 +137,7 @@ START_TEST (test_ratelimit_time_backward)
fail_if(uc_ratelimit_allow(&r, now));
}
END_TEST
+14
View File
@@ -9,6 +9,7 @@
START_TEST (test_read_file_non_existing_file)
{
char *content;
size_t len;
int saved_errno;
@@ -19,9 +20,11 @@ START_TEST (test_read_file_non_existing_file)
fail_if(content != NULL);
fail_if(saved_errno == 0);
}
END_TEST
START_TEST (test_read_file_simple)
{
char *content;
const char *filename = "test_read_file_simple";
size_t len;
@@ -43,9 +46,11 @@ START_TEST (test_read_file_simple)
fail_if(strlen(content) != 5);
fail_if(strcmp("hello", content) != 0);
free(content);
}
END_TEST
START_TEST (test_read_file_greater_than_max)
{
char *content;
const char *filename = "test_read_file_simple";
size_t len;
@@ -66,9 +71,11 @@ START_TEST (test_read_file_greater_than_max)
fail_if(content != NULL);
fail_if(saved_errno != EMSGSIZE, "was %d", saved_errno);
}
END_TEST
START_TEST (test_read_file_boundary)
{
char *content;
const char *filename = "test_read_file_boundary";
size_t len;
@@ -91,9 +98,11 @@ START_TEST (test_read_file_boundary)
fail_if(len != sizeof buf);
fail_if(strcmp("foobar", &content[1022]) != 0);
free(content);
}
END_TEST
START_TEST (test_read_file_devnull)
{
char *content;
size_t len = 123;
@@ -102,9 +111,11 @@ START_TEST (test_read_file_devnull)
fail_if(len != 0);
free(content);
}
END_TEST
START_TEST (test_read_file_too_big)
{
char *content;
const char *filename = "test_read_file_too_big";
size_t len;
@@ -124,9 +135,11 @@ START_TEST (test_read_file_too_big)
fail_if(content != NULL);
unlink(filename);
}
END_TEST
START_TEST (test_read_file_big)
{
char *content;
const char *filename = "test_read_file_big";
char buf[4096 * 16];
@@ -150,6 +163,7 @@ START_TEST (test_read_file_big)
free(content);
unlink(filename);
}
END_TEST
Suite *read_file_suite(void)
+17 -4
View File
@@ -10,7 +10,7 @@
#include "ucore/restart_counter.h"
#define FILE_NAME "restart_counter_test"
//Note that these tests are comewhat fragile as they depend on the
//Note that these tests are comewhat fragile as they depend on the
//file sizes that are created, which depends on the (relative)paths of this file.
//for cleaning the created log files..
static void logging_rm_files(void)
@@ -20,6 +20,7 @@ static void logging_rm_files(void)
START_TEST (test_restart_counter)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -33,9 +34,11 @@ START_TEST (test_restart_counter)
ck_assert_int_eq(1, uc_restart_counter_get(&cnt));
}
END_TEST
START_TEST (test_restart_counter_existing)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -50,9 +53,11 @@ START_TEST (test_restart_counter_existing)
fail_if(rc != UC_RC_OK);
ck_assert_int_eq(100000, uc_restart_counter_get(&cnt));
}
END_TEST
START_TEST (test_restart_counter_inaccessible_file)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -60,8 +65,10 @@ START_TEST (test_restart_counter_inaccessible_file)
rc = uc_restart_counter_init(&cnt, "/should/not/exist/abc", 0);
fail_if(rc != UC_RC_ERR_FILE_ACCESS_ERROR);
}
END_TEST
START_TEST (test_restart_counter_garble)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -78,9 +85,11 @@ START_TEST (test_restart_counter_garble)
fail_if(rc != UC_RC_OK, "%d", rc);
ck_assert_int_eq(1, uc_restart_counter_get(&cnt));
}
END_TEST
START_TEST (test_restart_counter_full_filesystem)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -88,9 +97,11 @@ START_TEST (test_restart_counter_full_filesystem)
rc = uc_restart_counter_init(&cnt, "/dev/full", 0);
fail_if(rc != UC_RC_ERR_UNSPECIFIED);
}
END_TEST
#ifndef __APPLE__
START_TEST (test_restart_counter_lock_file)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -126,8 +137,9 @@ START_TEST (test_restart_counter_lock_file)
_exit(0);
}
}
END_TEST
#endif
Suite *restart_counter_suite(void)
{
@@ -143,8 +155,9 @@ Suite *restart_counter_suite(void)
} else {
puts("Cannot access /dev/full. Not testing test_logfile_full_filesystem");
}
#ifndef __APPLE__
tcase_add_test(tc1, test_restart_counter_lock_file);
#endif
tcase_add_checked_fixture(tc1, logging_rm_files, logging_rm_files);
suite_add_tcase(s, tc1);
+48
View File
@@ -0,0 +1,48 @@
#include <check.h>
#include <unistd.h>
#include "ucore/ringbuf.h"
START_TEST (test_ringbuf)
{
UCRingBuf rb;
int rc;
int pgsize = getpagesize();
rc = uc_ringbuf_init(&rb, pgsize);
ck_assert_int_eq(rc, 0);
ck_assert_int_eq(uc_ringbuf_available(&rb), pgsize);
for (int i = 0 ; i < pgsize; i++) {
unsigned char data = i % 256;
rc = uc_ringbuf_write(&rb, &data, 1);
ck_assert_int_eq(rc, 0);
}
ck_assert_int_eq(uc_ringbuf_available(&rb), 0);
for (int i = 0; i < pgsize; i++) {
unsigned char data = 0;
rc = uc_ringbuf_read(&rb, &data, 1);
ck_assert_int_eq(rc, 0);
ck_assert_int_eq(data, i % 256);
}
ck_assert_int_eq(uc_ringbuf_available(&rb), pgsize);
}
Suite *ringbuf_suite(void)
{
Suite *s = suite_create("ringbuf");
TCase *tc1 = tcase_create("ringbuf");
tcase_add_test(tc1, test_ringbuf);
#ifndef __APPLE__
#endif
suite_add_tcase(s, tc1);
return s;
}
+5 -3
View File
@@ -35,6 +35,7 @@ extern Suite *restart_counter_suite(void);
extern Suite *iomux_suite(void);
extern Suite *iomux_signal_suite(void);
extern Suite *string_suite(void);
extern Suite *ringbuf_suite(void);
static suite_func suites[] = {
bitvec_suite,
@@ -65,6 +66,7 @@ static suite_func suites[] = {
iomux_suite,
iomux_signal_suite,
string_suite
ringbuf_suite
};
@@ -107,7 +109,7 @@ main (int argc, char *argv[])
size_t i;
SRunner *sr = srunner_create (NULL);
if (xml_output)
if (xml_output)
srunner_set_xml(sr, "result.xml");
//set the environment variable CK_FORK=no which means don't fork().
@@ -133,10 +135,10 @@ main (int argc, char *argv[])
number_run = srunner_ntests_run(sr);
number_failed = srunner_ntests_failed (sr);
srunner_free (sr);
if (!number_run)
puts("ERROR: no tests were run");
if (number_failed)
if (number_failed)
printf("ERROR: %d tests failed\n", number_failed);
return (number_failed != 0) ;
+24
View File
@@ -3,6 +3,7 @@
START_TEST (test_sat_uc_addu8)
{
uint8_t a;
uint8_t b;
@@ -49,9 +50,11 @@ START_TEST (test_sat_uc_addu8)
a = 100;
b = 100;
fail_if(uc_sat_addu8(a,b) != 200);
}
END_TEST
START_TEST (test_sat_uc_subu8)
{
uint8_t a;
uint8_t b;
@@ -82,9 +85,11 @@ START_TEST (test_sat_uc_subu8)
a = 100;
b = 100;
fail_if(uc_sat_subu8(a,b) != 0);
}
END_TEST
START_TEST (test_sat_uc_multu8)
{
uint8_t a;
uint8_t b;
@@ -120,10 +125,12 @@ START_TEST (test_sat_uc_multu8)
b = 10;
fail_if(uc_sat_multu8(a,b) != 100);
}
END_TEST
START_TEST (test_sat_uc_addu16)
{
uint16_t a;
uint16_t b;
@@ -170,9 +177,11 @@ START_TEST (test_sat_uc_addu16)
a = 100;
b = 100;
fail_if(uc_sat_addu16(a,b) != 200);
}
END_TEST
START_TEST (test_sat_uc_subu16)
{
uint16_t a;
uint16_t b;
@@ -203,9 +212,11 @@ START_TEST (test_sat_uc_subu16)
a = 100;
b = 100;
fail_if(uc_sat_subu16(a,b) != 0);
}
END_TEST
START_TEST (test_sat_uc_multu16)
{
uint16_t a;
uint16_t b;
@@ -241,9 +252,11 @@ START_TEST (test_sat_uc_multu16)
b = 10;
fail_if(uc_sat_multu16(a,b) != 100);
}
END_TEST
START_TEST (test_sat_uc_addu32)
{
uint32_t a;
uint32_t b;
@@ -290,9 +303,11 @@ START_TEST (test_sat_uc_addu32)
a = 0x1fffffff;
b = 0x80000000;
fail_if(uc_sat_addu32(a,b) != 0x9fffffff);
}
END_TEST
START_TEST (test_sat_uc_subu32)
{
uint32_t a;
uint32_t b;
@@ -323,9 +338,11 @@ START_TEST (test_sat_uc_subu32)
a = 100;
b = 100;
fail_if(uc_sat_subu32(a,b) != 0);
}
END_TEST
START_TEST (test_sat_uc_multu32)
{
uint32_t a;
uint32_t b;
@@ -361,8 +378,10 @@ START_TEST (test_sat_uc_multu32)
b = 10;
fail_if(uc_sat_multu32(a,b) != 100);
}
END_TEST
START_TEST (test_sat_uc_addu64)
{
uint64_t a;
uint64_t b;
@@ -409,9 +428,11 @@ START_TEST (test_sat_uc_addu64)
a = 0x1fffffffffffffffULL;
b = 0x8000000000000000ULL;
fail_if(uc_sat_addu64(a,b) != 0x9fffffffffffffffULL);
}
END_TEST
START_TEST (test_sat_uc_subu64)
{
uint64_t a;
uint64_t b;
@@ -442,9 +463,11 @@ START_TEST (test_sat_uc_subu64)
a = 100;
b = 100;
fail_if(uc_sat_subu64(a,b) != 0);
}
END_TEST
START_TEST (test_sat_uc_multu64)
{
uint64_t a;
uint64_t b;
@@ -480,6 +503,7 @@ START_TEST (test_sat_uc_multu64)
b = 10;
fail_if(uc_sat_multu64(a,b) != 100);
}
END_TEST
Suite *sat_math_suite(void)
{
+8
View File
@@ -3,6 +3,7 @@
START_TEST (test_uc_seq_lt)
{
fail_if(uc_seq_lt(0, 1) != 1);
fail_if(uc_seq_lt(0x7fffffffU, 0x80000000U) != 1);
fail_if(uc_seq_lt(0xfffffffeU, 2) != 1);
@@ -15,9 +16,11 @@ START_TEST (test_uc_seq_lt)
fail_if(uc_seq_lt(0, 0) != 0);
fail_if(uc_seq_lt(1, 1) != 0);
fail_if(uc_seq_lt(0xffffffffU, 0xffffffffU) != 0);
}
END_TEST
START_TEST (test_uc_seq_gt)
{
fail_if(uc_seq_gt(1, 0) != 1);
fail_if(uc_seq_gt(0x80000000U,0x7fffffffU) != 1);
fail_if(uc_seq_gt(2, 0xfffffffeU) != 1);
@@ -30,9 +33,11 @@ START_TEST (test_uc_seq_gt)
fail_if(uc_seq_gt(0, 0) != 0);
fail_if(uc_seq_gt(1, 1) != 0);
fail_if(uc_seq_gt(0xffffffffU, 0xffffffffU) != 0);
}
END_TEST
START_TEST (test_uc_seq_leq)
{
fail_if(uc_seq_leq(0, 1) != 1);
fail_if(uc_seq_leq(0x7fffffffU, 0x80000000U) != 1);
fail_if(uc_seq_leq(0xfffffffeU, 2) != 1);
@@ -47,9 +52,11 @@ START_TEST (test_uc_seq_leq)
fail_if(uc_seq_leq(0x80000000U,0x7fffffffU) != 0);
fail_if(uc_seq_leq(2, 0xfffffffeU) != 0);
fail_if(uc_seq_leq(0, 0xffffffffU) != 0);
}
END_TEST
START_TEST (test_uc_seq_geq)
{
fail_if(uc_seq_geq(1, 0) != 1);
fail_if(uc_seq_geq(0x80000000U,0x7fffffffU) != 1);
fail_if(uc_seq_geq(2, 0xfffffffeU) != 1);
@@ -65,6 +72,7 @@ START_TEST (test_uc_seq_geq)
fail_if(uc_seq_geq(0xfffffffeU, 2) != 0);
fail_if(uc_seq_geq(0xffffffffU, 0) != 0);
}
END_TEST
+8
View File
@@ -9,6 +9,7 @@
// long long 64 bit
START_TEST (test_sprintb)
{
char result[128];
char *rc;
@@ -24,9 +25,11 @@ START_TEST (test_sprintb)
rc = uc_sprintb(result, 1);
ck_assert_str_eq(rc, "00000000000000000000000000000001");
}
END_TEST
START_TEST (test_sprintbc)
{
char result[128];
char *rc;
@@ -42,9 +45,11 @@ START_TEST (test_sprintbc)
rc = uc_sprintbc(result, 1);
ck_assert_str_eq(rc, "00000001");
}
END_TEST
START_TEST (test_sprintbs)
{
char result[128];
char *rc;
@@ -60,9 +65,11 @@ START_TEST (test_sprintbs)
rc = uc_sprintbs(result, 1);
ck_assert_str_eq(rc, "0000000000000001");
}
END_TEST
START_TEST (test_sprintbll)
{
char result[128];
char *rc;
@@ -78,6 +85,7 @@ START_TEST (test_sprintbll)
rc = uc_sprintbll(result, 1);
ck_assert_str_eq(rc, "0000000000000000000000000000000000000000000000000000000000000001");
}
END_TEST
Suite *sprintb_suite(void)
+12
View File
@@ -5,6 +5,7 @@
START_TEST (test_strv_append)
{
struct UCStrv strv;
int rc;
@@ -22,9 +23,11 @@ START_TEST (test_strv_append)
uc_strv_destroy(&strv);
}
END_TEST
START_TEST (test_strv_clear)
{
struct UCStrv strv;
int rc;
@@ -38,9 +41,11 @@ START_TEST (test_strv_clear)
fail_if(strv.cnt != 0);
uc_strv_destroy(&strv);
}
END_TEST
START_TEST (test_strv_nocopy)
{
struct UCStrv strv;
char *str = strdup("string");
int rc;
@@ -54,9 +59,11 @@ START_TEST (test_strv_nocopy)
uc_strv_destroy(&strv);
}
END_TEST
START_TEST (test_strv_null_terminate)
{
struct UCStrv strv;
int rc;
@@ -73,9 +80,11 @@ START_TEST (test_strv_null_terminate)
uc_strv_destroy(&strv);
}
END_TEST
START_TEST (test_strv_append_all_copy)
{
struct UCStrv src;
struct UCStrv dst;
int rc;
@@ -97,9 +106,11 @@ START_TEST (test_strv_append_all_copy)
uc_strv_destroy(&src);
uc_strv_destroy(&dst);
}
END_TEST
START_TEST (test_strv_append_all_nocopy)
{
struct UCStrv src;
struct UCStrv dst;
int rc;
@@ -121,6 +132,7 @@ START_TEST (test_strv_append_all_nocopy)
uc_strv_destroy(&dst);
free(src.strings);
}
END_TEST
START_TEST (test_strv_reverse)
+30 -4
View File
@@ -12,6 +12,7 @@ struct thr_msg {
};
START_TEST (test_thread_queue_length)
{
struct uc_threadqueue queue;
int i;
@@ -26,9 +27,11 @@ START_TEST (test_thread_queue_length)
fail_if(uc_thread_queue_length(&queue) != 51);
}
END_TEST
START_TEST (test_thread_queue_one_thread)
{
struct uc_threadqueue queue;
int i;
@@ -52,9 +55,11 @@ START_TEST (test_thread_queue_one_thread)
}
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
}
END_TEST
START_TEST (test_thread_queue_priority_msg)
{
struct uc_threadqueue queue;
int i;
@@ -79,6 +84,7 @@ START_TEST (test_thread_queue_priority_msg)
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
}
END_TEST
@@ -94,6 +100,7 @@ static void test_thread_queue_walk_func(struct uc_threadmsg *msg, void *cookie)
}
START_TEST (test_thread_queue_walk)
{
struct uc_threadqueue queue;
int i;
@@ -111,6 +118,7 @@ START_TEST (test_thread_queue_walk)
uc_thread_queue_walk(&queue, test_thread_queue_walk_func, NULL);
}
END_TEST
#define READER_WRITER_NUM_MSG 20000
@@ -133,6 +141,7 @@ static void *test_thread_queue_reader_writer_func(void *arg)
}
START_TEST (test_thread_queue_reader_writer)
{
struct uc_threadqueue queue;
int i;
@@ -154,9 +163,11 @@ START_TEST (test_thread_queue_reader_writer)
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
}
END_TEST
START_TEST (test_thread_queue_reader_writer_len_1)
{
struct uc_threadqueue queue;
int i;
@@ -176,14 +187,16 @@ START_TEST (test_thread_queue_reader_writer_len_1)
pthread_join(tid, NULL);
}
END_TEST
START_TEST (test_thread_queue_zero_len)
{
struct uc_threadqueue queue;
fail_if(uc_thread_queue_init(&queue, 0) == 0); //thread_queue_init should fail
}
END_TEST
void *test_thread_queue_multiple_writers_func(void *arg)
@@ -203,6 +216,7 @@ void *test_thread_queue_multiple_writers_func(void *arg)
}
START_TEST (test_thread_queue_multiple_writers)
{
struct uc_threadqueue queue;
int i;
@@ -232,9 +246,11 @@ START_TEST (test_thread_queue_multiple_writers)
fail_if(count_max != 3);
}
END_TEST
START_TEST (test_thread_queue_timeout1)
{
struct uc_threadqueue queue;
struct timespec timeout = {0, 1000};
@@ -245,6 +261,7 @@ START_TEST (test_thread_queue_timeout1)
fail_if(uc_thread_queue_tryget(&queue, &timeout, &msg) != ETIMEDOUT);
uc_thread_queue_destroy(&queue, NULL, NULL);
}
END_TEST
void *thread_test_thread_queue_timeout2(void *arg)
@@ -264,6 +281,7 @@ void *thread_test_thread_queue_timeout2(void *arg)
return NULL;
}
START_TEST (test_thread_queue_timeout2)
{
struct uc_threadqueue queue;
pthread_t tid1;
@@ -280,9 +298,12 @@ START_TEST (test_thread_queue_timeout2)
uc_thread_queue_destroy(&queue, NULL, NULL);
}
END_TEST
START_TEST (test_thread_queue_tryadd_timeout_0_0)
{
struct uc_threadqueue queue;
int i;
@@ -298,10 +319,12 @@ START_TEST (test_thread_queue_tryadd_timeout_0_0)
fail_if(uc_thread_queue_tryadd(&queue, &timeout, &msg[2].msg) != ETIMEDOUT);
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
}
END_TEST
START_TEST (test_thread_queue_tryadd_timeout_0_100)
{
struct uc_threadqueue queue;
int i;
@@ -318,9 +341,11 @@ START_TEST (test_thread_queue_tryadd_timeout_0_100)
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
}
END_TEST
START_TEST (test_thread_queue_tryadd_no_timeout_0_100)
{
struct uc_threadqueue queue;
int i;
@@ -336,7 +361,7 @@ START_TEST (test_thread_queue_tryadd_no_timeout_0_100)
fail_if(uc_thread_queue_tryadd(&queue, &timeout, &msg[2].msg) != 0);
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
}
END_TEST
void clear_cb(struct uc_threadmsg *msg, void *cookie)
@@ -347,6 +372,7 @@ void clear_cb(struct uc_threadmsg *msg, void *cookie)
}
START_TEST (test_thread_queue_clear)
{
struct uc_threadqueue queue;
int i;
@@ -365,7 +391,7 @@ START_TEST (test_thread_queue_clear)
fail_if(uc_thread_queue_length(&queue) != 0);
fail_if(uc_thread_queue_destroy(&queue, NULL, NULL) != 0);
}
END_TEST
+2
View File
@@ -29,6 +29,7 @@ static void *update_thread(void *arg)
#define NR_THREADS 5
START_TEST(test_ticket_lock1)
{
struct ThreadArg threads[NR_THREADS];
int i;
int lrc;
@@ -53,6 +54,7 @@ START_TEST(test_ticket_lock1)
ck_assert_int_eq((NR_THREADS * (NR_THREADS + 1)) / 2, g_counter);
}
END_TEST
Suite *ticket_lock_suite(void)
+8
View File
@@ -43,6 +43,7 @@ static void common_init(struct UCoreSettableClock *clk,
}
START_TEST (test_timers_simple)
{
struct UCoreSettableClock clk;
struct TimerTest tt;
struct UCTimers timers;
@@ -80,9 +81,11 @@ START_TEST (test_timers_simple)
ck_assert_int_eq(uc_timers_count(&timers), 0);
fail_if(uc_timer_running(&timer) != 0);
}
END_TEST
START_TEST (test_timers_add_from_callback)
{
struct UCoreSettableClock clk;
struct TimerTest tt;
struct UCTimers timers;
@@ -114,9 +117,11 @@ START_TEST (test_timers_add_from_callback)
fail_if(uc_timer_running(&timer) == 0);
ck_assert_int_eq(uc_timers_count(&timers), 1);
}
END_TEST
START_TEST (test_timers_remove_from_callback)
{
struct UCoreSettableClock clk;
struct TimerTest tt;
struct UCTimers timers;
@@ -158,9 +163,11 @@ START_TEST (test_timers_remove_from_callback)
rc = uc_timers_first(&timers, &tv);
fail_if(rc == 0);
}
END_TEST
START_TEST (test_timers_add_remove)
{
struct UCoreSettableClock clk;
struct TimerTest tt;
struct UCTimers timers;
@@ -193,6 +200,7 @@ START_TEST (test_timers_add_remove)
ck_assert_int_eq(uc_timers_count(&timers), 0);
fail_if(uc_timers_first(&timers, &first) == 0);
}
END_TEST
+12
View File
@@ -3,6 +3,7 @@
START_TEST (test_val_str_search)
{
struct UCValStr vals[] = {
UC_VS_ENTRY(1),
UC_VS_ENTRY(5),
@@ -14,9 +15,11 @@ START_TEST (test_val_str_search)
ck_assert_str_eq(uc_val_2_str(5 , vals) , "5");
fail_if(uc_val_2_str(10, vals) != NULL);
}
END_TEST
START_TEST (test_val_str_vs_search)
{
struct UCValStr vals[] = {
UC_VS_ENTRY(1),
UC_VS_ENTRY(5),
@@ -28,9 +31,11 @@ START_TEST (test_val_str_vs_search)
ck_assert_str_eq(uc_val_2_str_vs(5 , vals)->str , "5");
fail_if(uc_val_2_str(10, vals) != NULL);
}
END_TEST
START_TEST (test_val_str_bsearch_odd)
{
struct UCValStr vals[] = {
UC_VS_ENTRY(1),
UC_VS_ENTRY(2),
@@ -49,9 +54,11 @@ START_TEST (test_val_str_bsearch_odd)
fail_if(uc_val_2_str_bs(0 , vals , len) != NULL);
fail_if(uc_val_2_str_bs(55 , vals , len) != NULL);
fail_if(uc_val_2_str_bs(999 , vals , len) != NULL);
}
END_TEST
START_TEST (test_val_str_bsearch_even)
{
struct UCValStr vals[] = {
UC_VS_ENTRY(1),
UC_VS_ENTRY(2),
@@ -68,9 +75,11 @@ START_TEST (test_val_str_bsearch_even)
fail_if(uc_val_2_str_bs(0 , vals , len) != NULL);
fail_if(uc_val_2_str_bs(55 , vals , len) != NULL);
fail_if(uc_val_2_str_bs(999 , vals , len) != NULL);
}
END_TEST
START_TEST (test_str_str_search)
{
struct UCStrStr vals[] = {
{"1", "A"},
{"2", "B"},
@@ -82,9 +91,11 @@ START_TEST (test_str_str_search)
ck_assert_str_eq(uc_str_2_str("3" , vals) , "C");
fail_if(uc_str_2_str("10", vals) != NULL);
}
END_TEST
START_TEST (test_str_str_ci_search)
{
struct UCStrStr vals[] = {
{"A", "1"},
{"az","2"},
@@ -96,6 +107,7 @@ START_TEST (test_str_str_ci_search)
ck_assert_str_eq(uc_str_2_str_ci("C" , vals) , "3");
fail_if(uc_str_2_str_ci("aza", vals) != NULL);
}
END_TEST
Suite *val_str_suite(void)
{