Adjustments for testing

This commit is contained in:
John Jones 2017-09-25 15:11:44 -05:00
parent 8b8a2844bd
commit 630985c698
5 changed files with 28 additions and 13 deletions

View file

@ -123,6 +123,7 @@ struct Block* ipfs_block_new() {
return 0;
block->data = NULL;
block->data_length = 0;
block->cid = NULL;
return block;
}
@ -158,7 +159,8 @@ int ipfs_blocks_block_add_data(const unsigned char* data, size_t data_size, stru
*/
int ipfs_block_free(struct Block* block) {
if (block != NULL) {
ipfs_cid_free(block->cid);
if (block->cid != NULL)
ipfs_cid_free(block->cid);
if (block->data != NULL)
free(block->data);
free(block);

View file

@ -43,8 +43,17 @@ void* ipfs_bitswap_engine_wantlist_processor_start(void* ctx) {
while (!context->bitswap_engine->shutting_down) {
struct WantListQueueEntry* item = ipfs_bitswap_wantlist_queue_pop(context->localWantlist);
if (item != NULL) {
// if there is something on the queue process it.
ipfs_bitswap_wantlist_process_entry(context, item);
if (item->attempts > 10) {
// we have tried too many times
for (int i = 0; i < item->sessionsRequesting->total; i++) {
struct WantListSession* curr_session = (struct WantListSession*) libp2p_utils_vector_get(item->sessionsRequesting, i);
ipfs_bitswap_wantlist_queue_remove(context->localWantlist, item->cid, curr_session);
}
} else {
// if there is something on the queue process it.
ipfs_bitswap_wantlist_process_entry(context, item);
}
} else {
// if there is nothing on the queue, wait...
sleep(2);

View file

@ -189,10 +189,10 @@ int test_core_api_name_resolve() {
libp2p_logger_debug("test_api", "*** Firing up daemons ***\n");
pthread_create(&daemon_thread1, NULL, test_daemon_start, (void*)ipfs_path1);
thread_started1 = 1;
sleep(3);
sleep(5);
pthread_create(&daemon_thread2, NULL, test_daemon_start, (void*)ipfs_path2);
thread_started2 = 1;
sleep(3);
sleep(10);
// publish name on server 1
args = cli_arguments_new(6, publish_args);
@ -200,12 +200,16 @@ int test_core_api_name_resolve() {
cli_arguments_free(args);
args = NULL;
sleep(3);
// use a client of server2 to to ask for the "name resolve" on server 1
args = cli_arguments_new(6, resolve_args);
if (ipfs_name(args) == 0) {
goto exit;
}
sleep(5);
retVal = 1;
exit:
cli_arguments_free(args);

View file

@ -317,7 +317,7 @@ int test_bitswap_retrieve_file_known_remote() {
if (!ipfs_cid_decode_hash_from_base58((unsigned char*)hello_world_hash, strlen(hello_world_hash), &cid))
goto exit;
sleep(300);
sleep(3);
// this does the heavy lifting...
if (!ipfs_node2->exchange->GetBlock(ipfs_node2->exchange, cid, &result)) {

View file

@ -29,12 +29,12 @@
#include "namesys/test_namesys.h"
int testit(const char* name, int (*func)(void)) {
printf("TESTING %s...\n", name);
fprintf(stderr, "TESTING %s...\n", name);
int retVal = func();
if (retVal)
printf("%s success!\n", name);
fprintf(stderr, "%s success!\n", name);
else
printf("** Uh oh! %s failed.**\n", name);
fprintf(stderr, "** Uh oh! %s failed.**\n", name);
return retVal == 0;
}
@ -215,7 +215,7 @@ int main(int argc, char** argv) {
int array_length = sizeof(funcs) / sizeof(funcs[0]);
int array2_length = sizeof(names) / sizeof(names[0]);
if (array_length != array2_length) {
printf("Test arrays are not of the same length. Funcs: %d, Names: %d\n", array_length, array2_length);
fprintf(stderr, "Test arrays are not of the same length. Funcs: %d, Names: %d\n", array_length, array2_length);
}
test_wanted = get_test(argc, argv, current_test_arg);
while (!certain_tests || test_wanted != NULL) {
@ -240,12 +240,12 @@ int main(int argc, char** argv) {
test_wanted = get_test(argc, argv, ++current_test_arg);
}
if (tests_ran == 0)
printf("***** No tests found *****\n");
fprintf(stderr, "***** No tests found *****\n");
else {
if (counter > 0) {
printf("***** There were %d failed (out of %d) test(s) *****\n", counter, tests_ran);
fprintf(stderr, "***** There were %d failed (out of %d) test(s) *****\n", counter, tests_ran);
} else {
printf("All %d tests passed\n", tests_ran);
fprintf(stderr, "All %d tests passed\n", tests_ran);
}
}
libp2p_logger_free();