int main(int argc, char **argv) { SilcBool success = FALSE; SilcTimeStruct curtime; if (argc > 1 && !strcmp(argv[1], "-d")) { silc_log_debug(TRUE); silc_log_quick(TRUE); silc_log_debug_hexdump(TRUE); silc_log_set_debug_string("*time*"); } SILC_LOG_DEBUG(("Get current time")); if (!silc_time_value(0, &curtime)) goto err; SILC_LOG_DEBUG(("year : %d", curtime.year)); SILC_LOG_DEBUG(("month : %d", curtime.month)); SILC_LOG_DEBUG(("day : %d", curtime.day)); SILC_LOG_DEBUG(("hour : %d", curtime.hour)); SILC_LOG_DEBUG(("minute : %d", curtime.minute)); SILC_LOG_DEBUG(("second : %d", curtime.second)); SILC_LOG_DEBUG(("msecond : %d", curtime.msecond)); SILC_LOG_DEBUG(("utc_hour : %d", curtime.utc_hour)); SILC_LOG_DEBUG(("utc_min : %d", curtime.utc_minute)); SILC_LOG_DEBUG(("utc_east : %d", curtime.utc_east)); SILC_LOG_DEBUG(("dst : %d", curtime.dst)); success = TRUE; err: SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); return success; }
int main(int argc, char **argv) { SilcBool success = FALSE; SilcSchedule schedule; SilcFSM fsm; Foo f; if (argc > 1 && !strcmp(argv[1], "-d")) { silc_log_debug(TRUE); silc_log_debug_hexdump(TRUE); silc_log_quick(TRUE); silc_log_set_debug_string("*fsm*,*async*"); } SILC_LOG_DEBUG(("Allocating scheduler")); schedule = silc_schedule_init(0, NULL); f = silc_calloc(1, sizeof(*f)); if (!f) goto err; f->schedule = schedule; SILC_LOG_DEBUG(("Allocating FSM context")); f->fsm = fsm = silc_fsm_alloc(f, destructor, f, schedule); if (!fsm) goto err; silc_fsm_start(fsm, test_st_start); SILC_LOG_DEBUG(("Running scheduler")); silc_schedule(schedule); if (f->error) goto err; silc_schedule_uninit(schedule); silc_free(f); success = TRUE; err: SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); return success; }
int main(int argc, char **argv) { SilcBool success = FALSE; SilcStack stack, child, child2; void *ptr, *ptr2; int i; if (argc > 1 && !strcmp(argv[1], "-d")) { silc_log_debug(TRUE); silc_log_debug_hexdump(TRUE); silc_log_quick(TRUE); silc_log_set_debug_string("*stack*,*errno*"); } SILC_LOG_DEBUG(("Allocating stack of default size (1024 bytes)")); stack = silc_stack_alloc(0, NULL); if (!stack) goto err; #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Allocating 2048 bytes from stack")); ptr = silc_smalloc(stack, 2048); if (!ptr) goto err; #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Freeing the stack")); silc_stack_free(stack); SILC_LOG_DEBUG(("Allocating stack of default size (1024 bytes)")); stack = silc_stack_alloc(0, NULL); if (!stack) goto err; #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and allocating %d times", NUM_ALLS)); if (!silc_stack_push(stack, NULL)) goto err; for (i = 0; i < NUM_ALLS; i++) { ptr2 = silc_smalloc(stack, (i + 1) * 7); if (!ptr2) goto err; } #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ silc_stack_pop(stack); SILC_LOG_DEBUG(("Popping")); #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and allocating %d times", NUM_ALLS)); if (!silc_stack_push(stack, NULL)) goto err; for (i = 0; i < NUM_ALLS; i++) { ptr2 = silc_smalloc(stack, (i + 1) * 7); if (!ptr2) goto err; } #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ silc_stack_pop(stack); SILC_LOG_DEBUG(("Popping")); #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing %d times", NUM_ALLS / 2)); for (i = 0; i < NUM_ALLS / 2; i++) { if (!silc_stack_push(stack, NULL)) goto err; ptr2 = silc_smalloc(stack, (i + 1) * 7); if (!ptr2) goto err; } #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Popping %d times", NUM_ALLS / 2)); for (i = 0; i < NUM_ALLS / 2; i++) silc_stack_pop(stack); #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and reallocating %d times", NUM_ALLS / 10)); ptr2 = NULL; if (!silc_stack_push(stack, NULL)) goto err; for (i = 0; i < NUM_ALLS / 10; i++) { ptr2 = silc_srealloc(stack, (i * 7), ptr2, (i + 1) * 7); if (!ptr2) goto err; } #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ silc_stack_pop(stack); SILC_LOG_DEBUG(("Popping")); #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Creating child stack")); child = silc_stack_alloc(8190, stack); if (!child) goto err; SILC_LOG_DEBUG(("Pushing %d times", NUM_ALLS / 2)); for (i = 0; i < NUM_ALLS / 2; i++) { if (!silc_stack_push(child, NULL)) goto err; ptr2 = silc_smalloc(child, (i + 1) * 7); if (!ptr2) goto err; } #ifdef SILC_DIST_INPLACE silc_stack_stats(child); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Popping %d times", NUM_ALLS / 2)); for (i = 0; i < NUM_ALLS / 2; i++) silc_stack_pop(child); #ifdef SILC_DIST_INPLACE silc_stack_stats(child); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and reallocating %d times", NUM_ALLS / 10)); ptr2 = NULL; if (!silc_stack_push(child, NULL)) goto err; for (i = 0; i < NUM_ALLS / 10; i++) { ptr2 = silc_srealloc(child, (i * 7), ptr2, (i + 1) * 7); if (!ptr2) goto err; } ptr = silc_smalloc(child, 100000); #ifdef SILC_DIST_INPLACE silc_stack_stats(child); #endif /* SILC_DIST_INPLACE */ silc_stack_pop(child); SILC_LOG_DEBUG(("Popping")); #ifdef SILC_DIST_INPLACE silc_stack_stats(child); #endif /* SILC_DIST_INPLACE */ #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ silc_stack_free(child); #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Creating child stack")); child = silc_stack_alloc(8192, stack); if (!child) goto err; SILC_LOG_DEBUG(("Pushing %d times", NUM_ALLS / 10)); for (i = 0; i < NUM_ALLS / 10; i++) { if (!silc_stack_push(child, NULL)) goto err; ptr2 = silc_smalloc(child, (i + 1) * 7); if (!ptr2) goto err; } #ifdef SILC_DIST_INPLACE silc_stack_stats(child); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Popping %d times", NUM_ALLS / 10)); for (i = 0; i < NUM_ALLS / 10; i++) silc_stack_pop(child); #ifdef SILC_DIST_INPLACE silc_stack_stats(child); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and reallocating %d times", NUM_ALLS / 10)); ptr2 = NULL; if (!silc_stack_push(child, NULL)) goto err; for (i = 0; i < NUM_ALLS / 10; i++) { ptr2 = silc_srealloc(child, (i * 7), ptr2, (i + 1) * 7); if (!ptr2) goto err; } SILC_LOG_DEBUG(("Allocate child from child")); child2 = silc_stack_alloc(0, child); ptr = silc_smalloc(child2, 500000); #ifdef SILC_DIST_INPLACE silc_stack_stats(child2); #endif /* SILC_DIST_INPLACE */ silc_stack_free(child2); #ifdef SILC_DIST_INPLACE silc_stack_stats(child2); #endif /* SILC_DIST_INPLACE */ silc_stack_pop(child); SILC_LOG_DEBUG(("Popping")); #ifdef SILC_DIST_INPLACE silc_stack_stats(child); #endif /* SILC_DIST_INPLACE */ #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ silc_stack_free(child); #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Purge stack")); silc_stack_purge(stack); #ifdef SILC_DIST_INPLACE silc_stack_stats(stack); #endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Current alignment: %d", silc_stack_get_alignment(stack))); SILC_LOG_DEBUG(("Set alignemtn to 16")); silc_stack_set_alignment(stack, 16); SILC_LOG_DEBUG(("Current alignment: %d", silc_stack_get_alignment(stack))); SILC_LOG_DEBUG(("Allocate 1 byte")); ptr = silc_smalloc(stack, 1); SILC_LOG_DEBUG(("Allocate 1 byte, check alignment")); ptr2 = silc_smalloc(stack, 1); if (ptr2 - ptr < 16) { SILC_LOG_DEBUG(("Bad alignment")); goto err; } SILC_LOG_DEBUG(("Alignment (ptr, ptr2) is %d", ptr2 - ptr)); SILC_LOG_DEBUG(("Allocate 1 byte, check alignment")); ptr2 = silc_smalloc(stack, 1); if (ptr2 - ptr < 32) { SILC_LOG_DEBUG(("Bad alignment")); goto err; } SILC_LOG_DEBUG(("Alignment (ptr, ptr2) is %d", ptr2 - ptr)); SILC_LOG_DEBUG(("Freeing the stack")); silc_stack_free(stack); success = TRUE; err: SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); return !success; }
int main(int argc, char **argv) { SilcUInt64 sec; SilcUInt32 usec; double totsec; unsigned char *data; SilcUInt32 rounds; SilcUInt32 i, k; silc_runtime_init(); silc_crypto_init(NULL); #if 0 silc_log_debug(TRUE); silc_log_quick(TRUE); silc_log_debug_hexdump(TRUE); silc_log_set_debug_string("*acc*,*thread*"); #endif if (!silc_acc_init(SILC_SOFTACC, (void *)0x01, "min_threads", 2, "max_threads", 8, NULL)) exit(1); data = malloc(ENC_LEN * sizeof(*data)); if (!data) exit(1); for (i = 0; i < ENC_LEN; i++) data[i] = i % 255; silc_timer_synchronize(&timer); for (i = 0; silc_default_ciphers[i].name; i++) { if (!silc_cipher_alloc(silc_default_ciphers[i].name, &cipher)) { fprintf(stderr, "Error allocating %s\n", silc_default_ciphers[i].name); exit(1); } acc_cipher = silc_acc_cipher(SILC_SOFTACC, cipher); if (!acc_cipher) continue; silc_cipher_set_iv(acc_cipher, data); silc_cipher_set_key(acc_cipher, data, silc_cipher_get_key_len(cipher), TRUE); sleep(1); rounds = ENC_ROUND; retry: silc_timer_start(&timer); for (k = 0; k < rounds; k++) silc_cipher_encrypt(acc_cipher, data, data, ENC_LEN, NULL); silc_timer_stop(&timer); silc_timer_value(&timer, &sec, &usec); totsec = (double)sec; totsec += ((double)usec / (double)((double)1000 * (double)1000)); if (totsec < ENC_MIN_TIME) { rounds += rounds; goto retry; } silc_cipher_free(acc_cipher); silc_cipher_free(cipher); sleep(1); printf("%s:\t%.2f KB (%.2f MB, %.2f Mbit) / sec (total %.3f secs)\n", silc_default_ciphers[i].name, (((double)((double)ENC_LEN * (double)rounds) / 1024.0) / totsec), (((double)((double)ENC_LEN * (double)rounds) / (1024.0 * 1024.0)) / totsec), ((((double)((double)ENC_LEN * (double)rounds) / 1024.0) / 128.0) / totsec), totsec); } silc_acc_uninit(SILC_SOFTACC); silc_crypto_uninit(); silc_runtime_uninit(); return 0; }
int main(int argc, char **argv) { SilcBool success = FALSE; int i; silc_runtime_init(); if (argc > 1 && !strcmp(argv[1], "-d")) { silc_log_debug(TRUE); silc_log_quick(TRUE); silc_log_debug_hexdump(TRUE); silc_log_set_debug_string("*tree*"); } for (i = 0; i < NUM; i++) { foo[i].id = i + 1; foo[i].od = i + 10; } for (i = 0; i < NUM; i++) { foo2[i].id = (i + 1) % (NUM / 4); foo2[i].od = (i + 10) % (NUM / 4); } /* AVL */ SILC_LOG_DEBUG(("Create AVL tree")); if (!silc_tree_init(tree, SILC_TREE_AVL, compare, NULL, silc_offsetof(Foo, header), TRUE)) goto err; /* Populate tree */ SILC_LOG_DEBUG(("Populate tree, %d entries", NUM)); for (i = 0; i < NUM; i++) if (!silc_tree_add(tree, &foo[i])) goto err; /* Add duplicates */ SILC_LOG_DEBUG(("Add duplicates")); for (i = 0; i < NUM; i++) if (!silc_tree_add(tree, &foo2[i])) goto err; SILC_LOG_DEBUG(("Tree has %d entries", silc_tree_count(tree))); if (silc_tree_count(tree) != NUM + NUM) goto err; /* Find random */ for (i = 0; i < NUM; i++) { tmp.id = (silc_rand() % NUM) + 1; SILC_LOG_DEBUG(("Find entry %d", tmp.id)); if ((entry = silc_tree_find(tree, &tmp)) == NULL) goto err; SILC_LOG_DEBUG(("Found entry %p %d", entry, entry->id)); } /* Find non-existing */ for (i = 0; i < 5; i++) { tmp.id = (silc_rand() % NUM) + (i % 2 ? -NUM - 1 : NUM + 1); SILC_LOG_DEBUG(("Find entry %d", tmp.id)); if (silc_tree_find(tree, &tmp)) goto err; } /* Enumerate in order */ for (entry = silc_tree_enumerate(tree, NULL); entry; entry = silc_tree_enumerate(tree, entry)) { SILC_LOG_DEBUG(("Enum entry %d, %p", entry->id, entry)); } /* Delete all */ for (i = 0; i < NUM; i++) { memset(&tmp, 0, sizeof(tmp)); tmp.id = i + 1; SILC_LOG_DEBUG(("Delete entry %d", tmp.id)); if (!silc_tree_del(tree, &tmp)) goto err; } /* Delete remaining duplicates in loop */ while ((entry = silc_tree_enumerate(tree, NULL))) { if (!silc_tree_del(tree, entry)) goto err; } SILC_LOG_DEBUG(("Tree has %d entries", silc_tree_count(tree))); if (silc_tree_count(tree) != 0) goto err; success = TRUE; err: SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); silc_runtime_uninit(); return !success; }
int main(int argc, char **argv) { SilcBool success = FALSE; unsigned char *vbuf, *vbuf2; unsigned char init[20]; SilcUInt32 gint, *gintptr; if (argc > 1 && !strcmp(argv[1], "-d")) { silc_log_debug(TRUE); silc_log_quick(TRUE); silc_log_debug_hexdump(TRUE); silc_log_set_debug_string("*global*"); } SILC_LOG_DEBUG(("Set global var")); gint = 100; if (!silc_global_set_var("gint", 4, &gint, FALSE)) goto err; SILC_LOG_DEBUG(("Retrieve var")); gintptr = silc_global_get_var("gint", FALSE); if (!gintptr) goto err; if (*gintptr != 100) goto err; SILC_LOG_DEBUG(("Set global var")); if (!silc_global_set_var("vbuf", 10, NULL, FALSE)) goto err; SILC_LOG_DEBUG(("Retrieve var")); vbuf = silc_global_get_var("vbuf", FALSE); if (!vbuf) goto err; SILC_LOG_DEBUG(("Change value")); memset(vbuf, 'F', 10); SILC_LOG_DEBUG(("Retrieve var")); vbuf = silc_global_get_var("vbuf", FALSE); if (!vbuf) goto err; if (vbuf[0] != 'F') goto err; SILC_LOG_DEBUG(("Retrieve var (must not find)")); vbuf = silc_global_get_var("vbuf2", FALSE); if (vbuf) goto err; SILC_LOG_DEBUG(("Retrieve var (must not find)")); vbuf = silc_global_get_var("VBUF", FALSE); if (vbuf) goto err; SILC_LOG_DEBUG(("Retrieve var (must not find)")); vbuf = silc_global_get_var("vbuf", TRUE); if (vbuf) goto err; SILC_LOG_DEBUG(("Reset same var")); if (!silc_global_set_var("vbuf", 20, NULL, FALSE)) goto err; SILC_LOG_DEBUG(("Retrieve var")); vbuf = silc_global_get_var("vbuf", FALSE); if (!vbuf) goto err; SILC_LOG_DEBUG(("Change value")); memset(vbuf, 'F', 20); SILC_LOG_DEBUG(("Retrieve var")); vbuf = silc_global_get_var("vbuf", FALSE); if (!vbuf) goto err; if (vbuf[19] != 'F') goto err; SILC_LOG_DEBUG(("Reset Tls var with initial value")); memset(init, 'D', 20); if (!silc_global_set_var("vbuf", 20, init, TRUE)) goto err; SILC_LOG_DEBUG(("Retrieve var")); vbuf2 = silc_global_get_var("vbuf", TRUE); if (vbuf == vbuf2) goto err; if (!vbuf2) goto err; if (vbuf2[19] != 'D') goto err; SILC_LOG_DEBUG(("Change value")); memset(vbuf2, 'T', 20); SILC_LOG_DEBUG(("Retrieve Tls var")); vbuf = silc_global_get_var("vbuf", TRUE); if (!vbuf) goto err; if (vbuf[0] != 'T') goto err; SILC_LOG_DEBUG(("Retrieve global var")); vbuf = silc_global_get_var("vbuf", FALSE); if (!vbuf) goto err; if (vbuf[19] != 'F') goto err; SILC_LOG_DEBUG(("Delete global var")); silc_global_del_var("vbuf", FALSE); SILC_LOG_DEBUG(("Retrieve var (must not find)")); vbuf = silc_global_get_var("vbuf", FALSE); if (vbuf) goto err; SILC_LOG_DEBUG(("Delete Tls var")); silc_global_del_var("vbuf", TRUE); SILC_LOG_DEBUG(("Retrieve var (must not find)")); vbuf = silc_global_get_var("vbuf", TRUE); if (vbuf) goto err; success = TRUE; err: SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); return !success; }
int main(int argc, char **argv) { SilcBool success = FALSE; unsigned char *s1, *s2, *s3, *s4; unsigned char t[16]; char h[32 + 1], str[40]; int l, opt, i; SilcUInt32 len; while ((opt = getopt(argc, argv, "hVd:")) != EOF) { switch(opt) { case 'h': printf("usage: test_silcstrutil\n"); exit(0); break; case 'V': printf("Secure Internet Live Conferencing\n"); exit(0); break; case 'd': silc_log_debug(TRUE); silc_log_debug_hexdump(TRUE); silc_log_quick(TRUE); if (optarg) silc_log_set_debug_string(optarg); else silc_log_set_debug_string("*strutil*,*errno*"); break; default: exit(1); break; } } /* Failure tests */ utf8failc(1); utf8failc(2); utf8failc(3); utf8failc(4); utf8failc(5); utf8failc(6); utf8failc(7); utf8failc(8); utf8failc(9); utf8failc(10); utf8failc(11); utf8failc(12); utf8failc(13); utf8failc(14); utf8failc(15); utf8failc(16); utf8failc(17); utf8failc(18); utf8failc(19); utf8failc(20); utf8failc(21); utf8failc(22); utf8failc(23); utf8failc(24); utf8failc(25); utf8failc(26); utf8failc(27); utf8failc(28); utf8failc(29); utf8failc(30); /* LDAP DN simple test */ s1 = "#&?*Pekka, \\Riikonen, <*****@*****.**>\xc4\x8d\\ "; SILC_LOG_DEBUG(("s1 = %s", s1)); /* To LDAP DN */ l = silc_utf8_decoded_len(s1, strlen(s1), SILC_STRING_LDAP_DN); if (!l) goto err; s3 = silc_calloc(l + 1, sizeof(*s3)); silc_utf8_decode(s1, strlen(s1), SILC_STRING_LDAP_DN, s3, l); SILC_LOG_DEBUG(("ldapdn = %s", s3)); /* To UTF-8 */ l = silc_utf8_encoded_len(s3, strlen(s3), SILC_STRING_LDAP_DN); if (!l) goto err; s4 = silc_calloc(l + 1, sizeof(*s4)); silc_utf8_encode(s3, strlen(s3), SILC_STRING_LDAP_DN, s4, l); SILC_LOG_DEBUG(("utf8 = %s", s4)); if (memcmp(s4, s1, strlen(s4))) { SILC_LOG_DEBUG(("UTF-8 mismatch")); goto err; } silc_free(s3); silc_free(s4); /* UTF-8 strcasecmp test */ SILC_LOG_DEBUG(("silc_utf8_strcasecmp test")); s1 = "Päivää vuan Yrjö"; s2 = "PÄIVÄÄ VUAN YRJÖ"; l = silc_utf8_encoded_len(s1, strlen(s1), SILC_STRING_LOCALE); if (!l) goto err; s3 = silc_calloc(l + 1, sizeof(*s3)); silc_utf8_encode(s1, strlen(s1), SILC_STRING_LOCALE, s3, l); l = silc_utf8_encoded_len(s2, strlen(s2), SILC_STRING_LOCALE); if (!l) goto err; s4 = silc_calloc(l + 1, sizeof(*s4)); silc_utf8_encode(s2, strlen(s2), SILC_STRING_LOCALE, s4, l); SILC_LOG_DEBUG(("%s == %s", s3, s4)); if (!silc_utf8_strcasecmp(s3, s4)) { SILC_LOG_DEBUG(("mismatch")); goto err; } SILC_LOG_DEBUG(("match")); silc_free(s3); silc_free(s4); /* Regex test */ SILC_LOG_DEBUG(("Simple regex test")); s1 = "foo,bar,silc,com"; SILC_LOG_DEBUG(("Find 'silc' from %s", s1)); if (!silc_string_match(s1, "silc")) goto err; SILC_LOG_DEBUG(("Regex match")); SILC_LOG_DEBUG(("Find 'foobar' from %s", s1)); if (silc_string_match(s1, "foobar")) goto err; SILC_LOG_DEBUG(("Regex not found (Ok)")); /* HEX to data, data to HEX tests */ for (i = 0; i < sizeof(t); i++) t[i] = i; silc_data2hex(t, sizeof(t), h, sizeof(h)); silc_hex2data(h, t, sizeof(t), &len); silc_snprintf(h, sizeof(h), "010203ffabdef9ab"); silc_hex2data(h, t, sizeof(t), &len); silc_data2hex(t, sizeof(t), h, sizeof(h)); /* snprintf test */ silc_snprintf(str, sizeof(str), "This is %@ rendered\n", render, "automatically"); SILC_LOG_DEBUG((str)); SILC_LOG_DEBUG(("This too %@ rendered", render, "is automatically")); success = TRUE; err: SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); return !success; }