2016-11-02 18:09:38 +00:00
|
|
|
#include "repo/test_repo_config.h"
|
2016-10-31 22:19:27 +00:00
|
|
|
#include "repo/test_repo_identity.h"
|
2016-11-02 18:09:38 +00:00
|
|
|
#include "repo/test_repo_bootstrap_peers.h"
|
2016-11-17 20:07:59 +00:00
|
|
|
#include "repo/test_repo_fsrepo.h"
|
2016-10-27 01:14:07 +00:00
|
|
|
#include "cmd/ipfs/test_init.h"
|
2016-11-14 02:01:51 +00:00
|
|
|
#include "cid/test_cid.h"
|
2016-11-28 13:09:00 +00:00
|
|
|
#include "flatfs/test_flatfs.h"
|
2016-11-28 21:13:46 +00:00
|
|
|
#include "storage/test_ds_helper.h"
|
2016-11-30 16:46:41 +00:00
|
|
|
#include "storage/test_datastore.h"
|
|
|
|
#include "storage/test_blocks.h"
|
2016-10-27 01:14:07 +00:00
|
|
|
|
|
|
|
int testit(const char* name, int (*func)(void)) {
|
|
|
|
printf("Testing %s...\n", name);
|
|
|
|
int retVal = func();
|
|
|
|
if (retVal)
|
|
|
|
printf("%s success!\n", name);
|
|
|
|
else
|
|
|
|
printf("** Uh oh! %s failed.**\n", name);
|
2016-11-17 20:07:59 +00:00
|
|
|
return retVal == 0;
|
2016-10-27 01:14:07 +00:00
|
|
|
}
|
|
|
|
|
2016-12-01 18:08:30 +00:00
|
|
|
const char* names[] = {
|
|
|
|
"test_cid_new_free",
|
|
|
|
"test_cid_cast_multihash",
|
|
|
|
"test_cid_cast_non_multihash",
|
|
|
|
//"test_init_new_installation",
|
|
|
|
"test_repo_config_new",
|
|
|
|
"test_repo_config_init",
|
|
|
|
"test_repo_config_write",
|
|
|
|
"test_repo_config_identity_new",
|
|
|
|
"test_repo_config_identity_private_key",
|
|
|
|
"test_get_init_command",
|
|
|
|
"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"
|
|
|
|
};
|
|
|
|
|
|
|
|
int (*funcs[])(void) = {
|
|
|
|
test_cid_new_free,
|
|
|
|
test_cid_cast_multihash,
|
|
|
|
test_cid_cast_non_multihash,
|
|
|
|
//test_init_new_installation,
|
|
|
|
test_repo_config_new,
|
|
|
|
test_repo_config_init,
|
|
|
|
test_repo_config_write,
|
|
|
|
test_repo_config_identity_new,
|
|
|
|
test_repo_config_identity_private_key,
|
|
|
|
test_get_init_command,
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* run 1 test or run all
|
|
|
|
*/
|
2016-10-27 01:14:07 +00:00
|
|
|
int main(int argc, char** argv) {
|
2016-11-17 20:07:59 +00:00
|
|
|
int counter = 0;
|
2016-12-01 18:08:30 +00:00
|
|
|
char* test_wanted;
|
|
|
|
int only_one = 0;
|
|
|
|
if(argc > 1) {
|
|
|
|
only_one = 1;
|
|
|
|
test_wanted = argv[1];
|
|
|
|
}
|
|
|
|
for (int i = 0; i < sizeof(funcs) / sizeof(funcs[0]); i++) {
|
|
|
|
if (only_one && strcmp(names[i], test_wanted) == 0)
|
|
|
|
counter += testit(names[i], funcs[i]);
|
|
|
|
else
|
|
|
|
if (!only_one)
|
|
|
|
counter += testit(names[i], funcs[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-11-17 20:07:59 +00:00
|
|
|
if (counter > 0) {
|
|
|
|
printf("***** There were %d failed test(s) *****\n", counter);
|
|
|
|
} else {
|
|
|
|
printf("All tests passed\n");
|
|
|
|
}
|
2016-10-27 01:14:07 +00:00
|
|
|
return 1;
|
|
|
|
}
|