2017-09-20 17:39:26 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
|
2016-12-05 11:13:20 +00:00
|
|
|
#include "cid/test_cid.h"
|
|
|
|
#include "cmd/ipfs/test_init.h"
|
2017-09-13 10:02:59 +00:00
|
|
|
#include "core/test_api.h"
|
|
|
|
#include "core/test_ping.h"
|
|
|
|
#include "core/test_null.h"
|
|
|
|
#include "core/test_daemon.h"
|
|
|
|
#include "core/test_node.h"
|
2017-07-20 20:16:59 +00:00
|
|
|
#include "exchange/test_bitswap.h"
|
2017-07-24 14:09:22 +00:00
|
|
|
#include "exchange/test_bitswap_request_queue.h"
|
2016-12-05 11:13:20 +00:00
|
|
|
#include "flatfs/test_flatfs.h"
|
2017-08-24 15:08:27 +00:00
|
|
|
#include "journal/test_journal.h"
|
2016-12-05 15:50:17 +00:00
|
|
|
#include "merkledag/test_merkledag.h"
|
2016-12-05 11:13:20 +00:00
|
|
|
#include "node/test_node.h"
|
2016-12-14 17:07:43 +00:00
|
|
|
#include "node/test_importer.h"
|
2016-12-30 00:05:44 +00:00
|
|
|
#include "node/test_resolver.h"
|
2016-12-05 11:13:20 +00:00
|
|
|
#include "repo/test_repo_bootstrap_peers.h"
|
|
|
|
#include "repo/test_repo_config.h"
|
|
|
|
#include "repo/test_repo_fsrepo.h"
|
|
|
|
#include "repo/test_repo_identity.h"
|
2017-04-13 14:31:58 +00:00
|
|
|
#include "routing/test_routing.h"
|
2017-03-19 12:47:19 +00:00
|
|
|
#include "routing/test_supernode.h"
|
2016-12-05 11:13:20 +00:00
|
|
|
#include "storage/test_ds_helper.h"
|
|
|
|
#include "storage/test_datastore.h"
|
|
|
|
#include "storage/test_blocks.h"
|
2016-12-19 19:19:43 +00:00
|
|
|
#include "storage/test_unixfs.h"
|
2017-04-27 05:10:25 +00:00
|
|
|
#include "libp2p/utils/logger.h"
|
2017-09-21 18:59:06 +00:00
|
|
|
#include "namesys/test_namesys.h"
|
2017-10-09 14:00:48 +00:00
|
|
|
|
|
|
|
struct test {
|
|
|
|
int index;
|
|
|
|
const char* name;
|
|
|
|
int (*func)(void);
|
|
|
|
int part_of_suite;
|
|
|
|
struct test* next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct test* first_test = NULL;
|
|
|
|
struct test* last_test = NULL;
|
|
|
|
|
2016-12-05 11:13:20 +00:00
|
|
|
int testit(const char* name, int (*func)(void)) {
|
2017-09-25 20:11:44 +00:00
|
|
|
fprintf(stderr, "TESTING %s...\n", name);
|
2016-12-05 11:13:20 +00:00
|
|
|
int retVal = func();
|
|
|
|
if (retVal)
|
2017-09-25 20:11:44 +00:00
|
|
|
fprintf(stderr, "%s success!\n", name);
|
2016-12-05 11:13:20 +00:00
|
|
|
else
|
2017-09-25 20:11:44 +00:00
|
|
|
fprintf(stderr, "** Uh oh! %s failed.**\n", name);
|
2016-12-05 11:13:20 +00:00
|
|
|
return retVal == 0;
|
|
|
|
}
|
|
|
|
|
2017-10-09 14:12:14 +00:00
|
|
|
<<<<<<< HEAD
|
2017-10-09 14:00:48 +00:00
|
|
|
int add_test(const char* name, int (*func)(void), int part_of_suite) {
|
|
|
|
// create a new test
|
|
|
|
struct test* t = (struct test*) malloc(sizeof(struct test));
|
|
|
|
t->name = name;
|
|
|
|
t->func = func;
|
|
|
|
t->part_of_suite = part_of_suite;
|
|
|
|
t->next = NULL;
|
|
|
|
if (last_test == NULL)
|
|
|
|
t->index = 0;
|
|
|
|
else
|
|
|
|
t->index = last_test->index + 1;
|
|
|
|
// place it in the collection
|
|
|
|
if (first_test == NULL) {
|
|
|
|
first_test = t;
|
|
|
|
} else {
|
|
|
|
last_test->next = t;
|
|
|
|
}
|
|
|
|
last_test = t;
|
2017-10-09 14:12:14 +00:00
|
|
|
=======
|
2016-12-05 11:13:20 +00:00
|
|
|
const char* names[] = {
|
2017-07-20 20:16:59 +00:00
|
|
|
"test_bitswap_new_free",
|
2017-07-24 14:09:22 +00:00
|
|
|
"test_bitswap_peer_request_queue_new",
|
2017-07-26 14:48:04 +00:00
|
|
|
"test_bitswap_retrieve_file",
|
2017-10-04 11:34:37 +00:00
|
|
|
"test_bitswap_retrieve_file_go_remote",
|
2017-07-31 15:01:06 +00:00
|
|
|
"test_bitswap_retrieve_file_known_remote",
|
|
|
|
"test_bitswap_retrieve_file_remote",
|
2017-07-27 17:05:41 +00:00
|
|
|
"test_bitswap_retrieve_file_third_party",
|
2017-10-04 11:34:37 +00:00
|
|
|
"test_bitswap_serve_file_go_remote",
|
2016-12-05 11:13:20 +00:00
|
|
|
"test_cid_new_free",
|
|
|
|
"test_cid_cast_multihash",
|
|
|
|
"test_cid_cast_non_multihash",
|
2016-12-12 20:06:17 +00:00
|
|
|
"test_cid_protobuf_encode_decode",
|
2017-09-13 10:02:59 +00:00
|
|
|
"test_core_api_startup_shutdown",
|
2017-09-20 15:50:32 +00:00
|
|
|
"test_core_api_object_cat",
|
2017-10-04 11:34:37 +00:00
|
|
|
"test_core_api_object_cat_binary",
|
2017-10-05 18:08:36 +00:00
|
|
|
"test_core_api_object_cat_large_binary",
|
2017-09-25 11:57:17 +00:00
|
|
|
"test_core_api_name_resolve",
|
2017-09-25 16:25:34 +00:00
|
|
|
"test_core_api_name_resolve_1",
|
|
|
|
"test_core_api_name_resolve_2",
|
|
|
|
"test_core_api_name_resolve_3",
|
2017-04-17 16:58:47 +00:00
|
|
|
"test_daemon_startup_shutdown",
|
2017-08-21 19:49:21 +00:00
|
|
|
"test_datastore_list_journal",
|
2017-09-07 19:58:02 +00:00
|
|
|
"test_journal_db",
|
2017-08-24 15:08:27 +00:00
|
|
|
"test_journal_encode_decode",
|
2017-08-28 18:04:27 +00:00
|
|
|
"test_journal_server_1",
|
|
|
|
"test_journal_server_2",
|
2016-12-05 11:13:20 +00:00
|
|
|
"test_repo_config_new",
|
|
|
|
"test_repo_config_init",
|
|
|
|
"test_repo_config_write",
|
|
|
|
"test_repo_config_identity_new",
|
|
|
|
"test_repo_config_identity_private_key",
|
2016-12-14 17:07:43 +00:00
|
|
|
"test_repo_fsrepo_write_read_block",
|
2017-04-17 16:58:47 +00:00
|
|
|
"test_repo_fsrepo_build",
|
2017-03-19 12:47:19 +00:00
|
|
|
"test_routing_supernode_start",
|
2016-12-05 11:13:20 +00:00
|
|
|
"test_get_init_command",
|
2016-12-14 17:07:43 +00:00
|
|
|
"test_import_small_file",
|
2016-12-15 10:40:24 +00:00
|
|
|
"test_import_large_file",
|
2016-12-05 11:13:20 +00:00
|
|
|
"test_repo_fsrepo_open_config",
|
|
|
|
"test_flatfs_get_directory",
|
|
|
|
"test_flatfs_get_filename",
|
|
|
|
"test_flatfs_get_full_filename",
|
|
|
|
"test_ds_key_from_binary",
|
|
|
|
"test_blocks_new",
|
|
|
|
"test_repo_bootstrap_peers_init",
|
|
|
|
"test_ipfs_datastore_put",
|
2016-12-05 15:50:17 +00:00
|
|
|
"test_node",
|
2016-12-12 20:06:17 +00:00
|
|
|
"test_node_link_encode_decode",
|
|
|
|
"test_node_encode_decode",
|
2017-04-20 22:56:03 +00:00
|
|
|
"test_node_peerstore",
|
2016-12-05 22:23:58 +00:00
|
|
|
"test_merkledag_add_data",
|
2016-12-12 11:27:06 +00:00
|
|
|
"test_merkledag_get_data",
|
2016-12-15 10:40:24 +00:00
|
|
|
"test_merkledag_add_node",
|
2016-12-19 19:19:43 +00:00
|
|
|
"test_merkledag_add_node_with_links",
|
2017-09-27 15:05:17 +00:00
|
|
|
// 50 below
|
2017-09-14 21:49:19 +00:00
|
|
|
"test_namesys_publisher_publish",
|
2017-09-21 18:59:06 +00:00
|
|
|
"test_namesys_resolver_resolve",
|
2017-05-11 18:53:52 +00:00
|
|
|
"test_resolver_get",
|
2017-07-27 19:33:19 +00:00
|
|
|
"test_routing_find_peer",
|
2017-09-27 15:05:17 +00:00
|
|
|
"test_routing_provide",
|
2017-04-17 04:47:53 +00:00
|
|
|
"test_routing_find_providers",
|
2017-09-28 18:21:34 +00:00
|
|
|
"test_routing_put_value",
|
2017-03-19 19:40:16 +00:00
|
|
|
"test_routing_supernode_get_value",
|
2017-03-23 13:28:35 +00:00
|
|
|
"test_routing_supernode_get_remote_value",
|
2017-04-20 22:56:03 +00:00
|
|
|
"test_routing_retrieve_file_third_party",
|
2017-04-24 21:33:59 +00:00
|
|
|
"test_routing_retrieve_large_file",
|
2016-12-19 22:21:21 +00:00
|
|
|
"test_unixfs_encode_decode",
|
2017-02-23 16:16:23 +00:00
|
|
|
"test_unixfs_encode_smallfile",
|
2017-02-27 17:27:40 +00:00
|
|
|
"test_ping",
|
2017-04-03 16:55:36 +00:00
|
|
|
"test_ping_remote",
|
2017-04-17 04:47:53 +00:00
|
|
|
"test_null_add_provider",
|
2017-02-27 17:27:40 +00:00
|
|
|
"test_resolver_remote_get"
|
2016-12-05 11:13:20 +00:00
|
|
|
};
|
2017-10-09 14:12:14 +00:00
|
|
|
>>>>>>> branch 'master' of https://github.com/Agorise/c-ipfs
|
2016-12-05 11:13:20 +00:00
|
|
|
|
2017-10-09 14:12:14 +00:00
|
|
|
<<<<<<< HEAD
|
2017-10-09 14:00:48 +00:00
|
|
|
if (last_test == NULL)
|
|
|
|
return 0;
|
|
|
|
return last_test->index;
|
|
|
|
}
|
|
|
|
|
|
|
|
int build_test_collection() {
|
|
|
|
add_test("test_bitswap_new_free", test_bitswap_new_free, 1);
|
|
|
|
add_test("test_bitswap_peer_request_queue_new", test_bitswap_peer_request_queue_new, 1);
|
|
|
|
add_test("test_bitswap_retrieve_file", test_bitswap_retrieve_file, 1);
|
|
|
|
add_test("test_bitswap_retrieve_file_known_remote", test_bitswap_retrieve_file_known_remote, 0);
|
|
|
|
add_test("test_bitswap_retrieve_file_remote", test_bitswap_retrieve_file_remote, 1);
|
|
|
|
add_test("test_bitswap_retrieve_file_third_party", test_bitswap_retrieve_file_third_party, 1);
|
|
|
|
add_test("test_cid_new_free", test_cid_new_free, 1);
|
|
|
|
add_test("test_cid_cast_multihash", test_cid_cast_multihash, 1);
|
|
|
|
add_test("test_cid_cast_non_multihash", test_cid_cast_non_multihash, 1);
|
|
|
|
add_test("test_cid_protobuf_encode_decode", test_cid_protobuf_encode_decode, 1);
|
|
|
|
add_test("test_core_api_startup_shutdown", test_core_api_startup_shutdown, 1);
|
|
|
|
add_test("test_core_api_object_cat", test_core_api_object_cat, 1);
|
|
|
|
add_test("test_core_api_name_resolve", test_core_api_name_resolve, 1);
|
|
|
|
add_test("test_core_api_name_resolve_1", test_core_api_name_resolve_1, 1);
|
|
|
|
add_test("test_core_api_name_resolve_2", test_core_api_name_resolve_2, 1);
|
|
|
|
add_test("test_core_api_name_resolve_3", test_core_api_name_resolve_3, 1);
|
|
|
|
add_test("test_daemon_startup_shutdown", test_daemon_startup_shutdown, 1);
|
|
|
|
add_test("test_datastore_list_journal", test_datastore_list_journal, 1);
|
|
|
|
add_test("test_journal_db", test_journal_db, 1);
|
|
|
|
add_test("test_journal_encode_decode", test_journal_encode_decode, 1);
|
|
|
|
add_test("test_journal_server_1", test_journal_server_1, 1);
|
|
|
|
add_test("test_journal_server_2", test_journal_server_2, 1);
|
|
|
|
add_test("test_repo_config_new", test_repo_config_new, 1);
|
|
|
|
add_test("test_repo_config_init", test_repo_config_init, 1);
|
|
|
|
add_test("test_repo_config_write", test_repo_config_write, 1);
|
|
|
|
add_test("test_repo_config_identity_new", test_repo_config_identity_new, 1);
|
|
|
|
add_test("test_repo_config_identity_private_key", test_repo_config_identity_private_key, 1);
|
|
|
|
add_test("test_repo_fsrepo_write_read_block", test_repo_fsrepo_write_read_block, 1);
|
|
|
|
add_test("test_repo_fsrepo_build", test_repo_fsrepo_build, 1);
|
|
|
|
add_test("test_routing_supernode_start", test_routing_supernode_start, 1);
|
|
|
|
add_test("test_get_init_command", test_get_init_command, 1);
|
|
|
|
add_test("test_import_small_file", test_import_small_file, 1);
|
|
|
|
add_test("test_import_large_file", test_import_large_file, 1);
|
|
|
|
add_test("test_repo_fsrepo_open_config", test_repo_fsrepo_open_config, 1);
|
|
|
|
add_test("test_flatfs_get_directory", test_flatfs_get_directory, 1);
|
|
|
|
add_test("test_flatfs_get_filename", test_flatfs_get_filename, 1);
|
|
|
|
add_test("test_flatfs_get_full_filename", test_flatfs_get_full_filename, 1);
|
|
|
|
add_test("test_ds_key_from_binary", test_ds_key_from_binary, 1);
|
|
|
|
add_test("test_blocks_new", test_blocks_new, 1);
|
|
|
|
add_test("test_repo_bootstrap_peers_init", test_repo_bootstrap_peers_init, 1);
|
|
|
|
add_test("test_ipfs_datastore_put", test_ipfs_datastore_put, 1);
|
|
|
|
add_test("test_node", test_node, 1);
|
|
|
|
add_test("test_node_link_encode_decode", test_node_link_encode_decode, 1);
|
|
|
|
add_test("test_node_encode_decode", test_node_encode_decode, 1);
|
|
|
|
add_test("test_node_peerstore", test_node_peerstore, 1);
|
|
|
|
add_test("test_merkledag_add_data", test_merkledag_add_data, 1);
|
|
|
|
add_test("test_merkledag_get_data", test_merkledag_get_data, 1);
|
|
|
|
add_test("test_merkledag_add_node", test_merkledag_add_node, 1);
|
|
|
|
add_test("test_merkledag_add_node_with_links", test_merkledag_add_node_with_links, 1);
|
|
|
|
// 50 below
|
|
|
|
add_test("test_namesys_publisher_publish", test_namesys_publisher_publish, 1);
|
|
|
|
add_test("test_namesys_resolver_resolve", test_namesys_resolver_resolve, 1);
|
|
|
|
add_test("test_resolver_get", test_resolver_get, 1);
|
|
|
|
add_test("test_routing_find_peer", test_routing_find_peer, 1);
|
|
|
|
add_test("test_routing_provide", test_routing_provide, 1);
|
|
|
|
add_test("test_routing_find_providers", test_routing_find_providers, 1);
|
|
|
|
add_test("test_routing_put_value", test_routing_put_value, 1);
|
|
|
|
add_test("test_routing_supernode_get_value", test_routing_supernode_get_value, 1);
|
|
|
|
add_test("test_routing_supernode_get_remote_value", test_routing_supernode_get_remote_value, 1);
|
|
|
|
add_test("test_routing_retrieve_file_third_party", test_routing_retrieve_file_third_party, 1);
|
|
|
|
add_test("test_routing_retrieve_large_file", test_routing_retrieve_large_file, 1);
|
|
|
|
add_test("test_unixfs_encode_decode", test_unixfs_encode_decode, 1);
|
|
|
|
add_test("test_unixfs_encode_smallfile", test_unixfs_encode_smallfile, 1);
|
|
|
|
add_test("test_ping", test_ping, 1);
|
|
|
|
add_test("test_ping_remote", test_ping_remote, 1);
|
|
|
|
add_test("test_null_add_provider", test_null_add_provider, 1);
|
|
|
|
return add_test("test_resolver_remote_get", test_resolver_remote_get, 1);
|
|
|
|
}
|
2017-10-09 14:12:14 +00:00
|
|
|
=======
|
2016-12-05 11:13:20 +00:00
|
|
|
int (*funcs[])(void) = {
|
2017-07-20 20:16:59 +00:00
|
|
|
test_bitswap_new_free,
|
2017-07-24 14:09:22 +00:00
|
|
|
test_bitswap_peer_request_queue_new,
|
2017-07-26 14:48:04 +00:00
|
|
|
test_bitswap_retrieve_file,
|
2017-10-04 11:34:37 +00:00
|
|
|
test_bitswap_retrieve_file_go_remote,
|
2017-07-31 15:01:06 +00:00
|
|
|
test_bitswap_retrieve_file_known_remote,
|
|
|
|
test_bitswap_retrieve_file_remote,
|
2017-07-27 17:05:41 +00:00
|
|
|
test_bitswap_retrieve_file_third_party,
|
2017-10-04 11:34:37 +00:00
|
|
|
test_bitswap_serve_file_go_remote,
|
2016-12-05 11:13:20 +00:00
|
|
|
test_cid_new_free,
|
|
|
|
test_cid_cast_multihash,
|
|
|
|
test_cid_cast_non_multihash,
|
2016-12-12 20:06:17 +00:00
|
|
|
test_cid_protobuf_encode_decode,
|
2017-09-13 10:02:59 +00:00
|
|
|
test_core_api_startup_shutdown,
|
2017-09-20 15:50:32 +00:00
|
|
|
test_core_api_object_cat,
|
2017-10-04 11:34:37 +00:00
|
|
|
test_core_api_object_cat_binary,
|
2017-10-05 18:08:36 +00:00
|
|
|
test_core_api_object_cat_large_binary,
|
2017-09-25 11:57:17 +00:00
|
|
|
test_core_api_name_resolve,
|
2017-09-25 16:25:34 +00:00
|
|
|
test_core_api_name_resolve_1,
|
|
|
|
test_core_api_name_resolve_2,
|
|
|
|
test_core_api_name_resolve_3,
|
2017-04-17 16:58:47 +00:00
|
|
|
test_daemon_startup_shutdown,
|
2017-08-21 19:49:21 +00:00
|
|
|
test_datastore_list_journal,
|
2017-09-07 19:58:02 +00:00
|
|
|
test_journal_db,
|
2017-08-24 15:08:27 +00:00
|
|
|
test_journal_encode_decode,
|
2017-08-28 18:04:27 +00:00
|
|
|
test_journal_server_1,
|
|
|
|
test_journal_server_2,
|
2016-12-05 11:13:20 +00:00
|
|
|
test_repo_config_new,
|
|
|
|
test_repo_config_init,
|
|
|
|
test_repo_config_write,
|
|
|
|
test_repo_config_identity_new,
|
|
|
|
test_repo_config_identity_private_key,
|
2016-12-14 17:07:43 +00:00
|
|
|
test_repo_fsrepo_write_read_block,
|
2017-04-17 16:58:47 +00:00
|
|
|
test_repo_fsrepo_build,
|
2017-03-19 12:47:19 +00:00
|
|
|
test_routing_supernode_start,
|
2016-12-05 11:13:20 +00:00
|
|
|
test_get_init_command,
|
2016-12-14 17:07:43 +00:00
|
|
|
test_import_small_file,
|
2016-12-15 10:40:24 +00:00
|
|
|
test_import_large_file,
|
2016-12-05 11:13:20 +00:00
|
|
|
test_repo_fsrepo_open_config,
|
|
|
|
test_flatfs_get_directory,
|
|
|
|
test_flatfs_get_filename,
|
|
|
|
test_flatfs_get_full_filename,
|
|
|
|
test_ds_key_from_binary,
|
|
|
|
test_blocks_new,
|
|
|
|
test_repo_bootstrap_peers_init,
|
|
|
|
test_ipfs_datastore_put,
|
2016-12-05 15:50:17 +00:00
|
|
|
test_node,
|
2016-12-12 20:06:17 +00:00
|
|
|
test_node_link_encode_decode,
|
|
|
|
test_node_encode_decode,
|
2017-04-20 22:56:03 +00:00
|
|
|
test_node_peerstore,
|
2016-12-05 22:23:58 +00:00
|
|
|
test_merkledag_add_data,
|
2016-12-12 11:27:06 +00:00
|
|
|
test_merkledag_get_data,
|
2016-12-15 10:40:24 +00:00
|
|
|
test_merkledag_add_node,
|
2016-12-19 19:19:43 +00:00
|
|
|
test_merkledag_add_node_with_links,
|
2017-09-27 15:05:17 +00:00
|
|
|
// 50 below
|
2017-09-14 21:49:19 +00:00
|
|
|
test_namesys_publisher_publish,
|
2017-09-21 18:59:06 +00:00
|
|
|
test_namesys_resolver_resolve,
|
2017-05-11 18:53:52 +00:00
|
|
|
test_resolver_get,
|
2017-07-27 19:33:19 +00:00
|
|
|
test_routing_find_peer,
|
2017-04-17 19:02:33 +00:00
|
|
|
test_routing_provide,
|
2017-09-27 15:05:17 +00:00
|
|
|
test_routing_find_providers,
|
2017-09-28 18:21:34 +00:00
|
|
|
test_routing_put_value,
|
2017-03-19 19:40:16 +00:00
|
|
|
test_routing_supernode_get_value,
|
2017-03-23 13:28:35 +00:00
|
|
|
test_routing_supernode_get_remote_value,
|
2017-04-20 22:56:03 +00:00
|
|
|
test_routing_retrieve_file_third_party,
|
2017-04-24 21:33:59 +00:00
|
|
|
test_routing_retrieve_large_file,
|
2016-12-19 22:21:21 +00:00
|
|
|
test_unixfs_encode_decode,
|
2017-02-23 16:16:23 +00:00
|
|
|
test_unixfs_encode_smallfile,
|
2017-02-27 17:27:40 +00:00
|
|
|
test_ping,
|
2017-04-03 16:55:36 +00:00
|
|
|
test_ping_remote,
|
2017-04-17 04:47:53 +00:00
|
|
|
test_null_add_provider,
|
2017-05-11 18:53:52 +00:00
|
|
|
test_resolver_remote_get
|
2016-12-05 11:13:20 +00:00
|
|
|
};
|
2017-10-09 14:12:14 +00:00
|
|
|
>>>>>>> branch 'master' of https://github.com/Agorise/c-ipfs
|
2016-12-05 11:13:20 +00:00
|
|
|
|
|
|
|
/**
|
2017-05-11 18:53:52 +00:00
|
|
|
* Pull the next test name from the command line
|
|
|
|
* @param the count of arguments on the command line
|
|
|
|
* @param argv the command line arguments
|
|
|
|
* @param arg_number the current argument we want
|
|
|
|
* @returns a null terminated string of the next test or NULL
|
|
|
|
*/
|
|
|
|
char* get_test(int argc, char** argv, int arg_number) {
|
|
|
|
char* retVal = NULL;
|
|
|
|
char* ptr = NULL;
|
|
|
|
if (argc > arg_number) {
|
|
|
|
ptr = argv[arg_number];
|
|
|
|
if (ptr[0] == '\'')
|
|
|
|
ptr++;
|
2017-10-09 14:00:48 +00:00
|
|
|
retVal = ptr;
|
2017-08-03 19:35:06 +00:00
|
|
|
ptr = strchr(retVal, '\'');
|
2017-05-11 18:53:52 +00:00
|
|
|
if (ptr != NULL)
|
|
|
|
ptr[0] = 0;
|
|
|
|
}
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2017-10-09 14:00:48 +00:00
|
|
|
struct test* get_test_by_index(int index) {
|
|
|
|
struct test* current = first_test;
|
|
|
|
while (current != NULL && current->index != index) {
|
|
|
|
current = current->next;
|
|
|
|
}
|
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct test* get_test_by_name(const char* name) {
|
|
|
|
struct test* current = first_test;
|
|
|
|
while (current != NULL && strcmp(current->name, name) != 0) {
|
|
|
|
current = current->next;
|
|
|
|
}
|
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
2017-05-11 18:53:52 +00:00
|
|
|
/**
|
|
|
|
* run certain tests or run all
|
2016-12-05 11:13:20 +00:00
|
|
|
*/
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
int counter = 0;
|
2016-12-05 18:11:22 +00:00
|
|
|
int tests_ran = 0;
|
2017-10-09 14:00:48 +00:00
|
|
|
char* test_name_wanted = NULL;
|
2017-05-11 18:53:52 +00:00
|
|
|
int certain_tests = 0;
|
|
|
|
int current_test_arg = 1;
|
2016-12-05 11:13:20 +00:00
|
|
|
if(argc > 1) {
|
2017-05-11 18:53:52 +00:00
|
|
|
certain_tests = 1;
|
2016-12-05 11:13:20 +00:00
|
|
|
}
|
2017-10-09 14:00:48 +00:00
|
|
|
build_test_collection();
|
|
|
|
if (certain_tests) {
|
|
|
|
// certain tests were passed on the command line
|
|
|
|
test_name_wanted = get_test(argc, argv, current_test_arg);
|
|
|
|
while (test_name_wanted != NULL) {
|
|
|
|
struct test* t = get_test_by_name(test_name_wanted);
|
|
|
|
if (t != NULL) {
|
|
|
|
tests_ran++;
|
|
|
|
counter += testit(t->name, t->func);
|
|
|
|
}
|
|
|
|
test_name_wanted = get_test(argc, argv, ++current_test_arg);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// run all tests that are part of this test suite
|
|
|
|
struct test* current = first_test;
|
|
|
|
while (current != NULL) {
|
|
|
|
if (current->part_of_suite) {
|
|
|
|
tests_ran++;
|
|
|
|
counter += testit(current->name, current->func);
|
2016-12-12 20:06:17 +00:00
|
|
|
}
|
2017-10-09 14:00:48 +00:00
|
|
|
current = current->next;
|
2016-12-05 18:11:22 +00:00
|
|
|
}
|
2016-12-05 11:13:20 +00:00
|
|
|
}
|
2016-12-05 18:11:22 +00:00
|
|
|
if (tests_ran == 0)
|
2017-09-25 20:11:44 +00:00
|
|
|
fprintf(stderr, "***** No tests found *****\n");
|
2016-12-05 18:11:22 +00:00
|
|
|
else {
|
|
|
|
if (counter > 0) {
|
2017-09-25 20:11:44 +00:00
|
|
|
fprintf(stderr, "***** There were %d failed (out of %d) test(s) *****\n", counter, tests_ran);
|
2016-12-05 18:11:22 +00:00
|
|
|
} else {
|
2017-09-25 20:11:44 +00:00
|
|
|
fprintf(stderr, "All %d tests passed\n", tests_ran);
|
2016-12-05 18:11:22 +00:00
|
|
|
}
|
2016-12-05 11:13:20 +00:00
|
|
|
}
|
2017-04-27 05:10:25 +00:00
|
|
|
libp2p_logger_free();
|
2017-05-11 19:30:52 +00:00
|
|
|
fclose(stdin);
|
|
|
|
fclose(stdout);
|
|
|
|
fclose(stderr);
|
2016-12-05 11:13:20 +00:00
|
|
|
return 1;
|
|
|
|
}
|