Update testit.c
This commit is contained in:
parent
0052ef8ca2
commit
53b893bda2
1 changed files with 84 additions and 54 deletions
138
test/testit.c
138
test/testit.c
|
@ -1,54 +1,84 @@
|
||||||
#include "repo/test_repo_config.h"
|
#include "storage/test_ds_helper.h" #include "storage/test_ds_helper.h"
|
||||||
#include "repo/test_repo_identity.h"
|
#include "storage/test_datastore.h" #include "storage/test_datastore.h"
|
||||||
#include "repo/test_repo_bootstrap_peers.h"
|
#include "storage/test_blocks.h" #include "storage/test_blocks.h"
|
||||||
#include "repo/test_repo_fsrepo.h"
|
+#include "ipfs/node/node.h"
|
||||||
#include "cmd/ipfs/test_init.h"
|
|
||||||
#include "cid/test_cid.h"
|
-int testit(const char* name, int (*func)(void)) { +int main(int argc, char** argv)
|
||||||
#include "flatfs/test_flatfs.h"
|
- printf("Testing %s...\n", name); +{
|
||||||
#include "storage/test_ds_helper.h"
|
- int retVal = func(); + printf("XETH TESTS\n");
|
||||||
#include "storage/test_datastore.h"
|
- if (retVal) + //Variables of link:
|
||||||
#include "storage/test_blocks.h"
|
- printf("%s success!\n", name); + char * name = "Alex";
|
||||||
#include "ipfs/node/node.h"
|
- else + char * ahash = "QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG";
|
||||||
|
- printf("** Uh oh! %s failed.**\n", name); + struct Link * mylink;
|
||||||
int main(int argc, char** argv)
|
- return retVal == 0; + mylink = Create_Link(name,ahash);
|
||||||
{
|
-} + printf("===================================\n" \
|
||||||
printf("XETH TESTS\n");
|
- + "Node Link:\n" \
|
||||||
//Variables of link:
|
-const char* names[] = { + " -Name: %s\n" \
|
||||||
char * name = "Alex";
|
- "test_cid_new_free", + " -Size: %lu\n" \
|
||||||
char * ahash = "QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG";
|
- "test_cid_cast_multihash", + "\n Cid Details:\n\n" \
|
||||||
struct Link * mylink;
|
- "test_cid_cast_non_multihash", + " -Version: %d\n" \
|
||||||
mylink = Create_Link(name,ahash);
|
- //"test_init_new_installation", + " -Codec: %c\n" \
|
||||||
printf("===================================\n" \
|
- "test_repo_config_new", + " -Hash: %s\n" \
|
||||||
"Node Link:\n" \
|
- "test_repo_config_init", + " -Hash Length: %lu\n" \
|
||||||
" -Name: %s\n" \
|
- "test_repo_config_write", + "====================================\n" \
|
||||||
" -Size: %lu\n" \
|
- "test_repo_config_identity_new", + , mylink->name, mylink->size, mylink->Lcid->version,mylink->Lcid->codec,mylink->Lcid->hash,mylink->Lcid->hash_length);
|
||||||
"\n Cid Details:\n\n" \
|
- "test_repo_config_identity_private_key", + //Link Two for testing purposes
|
||||||
" -Version: %d\n" \
|
- "test_get_init_command", + char * name2 = "Simo";
|
||||||
" -Codec: %c\n" \
|
- "test_repo_fsrepo_open_config", + char * ahash2 = "QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnSimo";
|
||||||
" -Hash: %s\n" \
|
- "test_flatfs_get_directory", + struct Link * mylink2;
|
||||||
" -Hash Length: %lu\n" \
|
- "test_flatfs_get_filename", + mylink2 = Create_Link(name2,ahash2);
|
||||||
"====================================\n" \
|
- "test_flatfs_get_full_filename", + //Nodes
|
||||||
, mylink->name, mylink->size, mylink->Lcid->version,mylink->Lcid->codec,mylink->Lcid->hash,mylink->Lcid->hash_length);
|
- "test_ds_key_from_binary", + struct Node * Mynode;
|
||||||
//Link Two for testing purposes
|
- "test_blocks_new", + Mynode = N_Create_From_Link(mylink,sizeof(mylink));
|
||||||
char * name2 = "Simo";
|
- "test_repo_bootstrap_peers_init", + mylink->name = "HAHA";//Testing for valid node creation
|
||||||
char * ahash2 = "QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnSimo";
|
- "test_ipfs_datastore_put" + printf("Node Link[0] Name: %s\nHash: %s\n",Mynode->links[0]->name, Mynode->links[0]->Lcid->hash);
|
||||||
struct Link * mylink2;
|
-}; + Mynode = N_Add_Link(&Mynode, mylink2, sizeof(mylink2));
|
||||||
mylink2 = Create_Link(name2,ahash2);
|
- + mylink2->name = "HAHA";//Testing for valid node creation
|
||||||
//Nodes
|
-int (*funcs[])(void) = { + printf("Node Link[1] Name: %s\nHash: %s\n",Mynode->links[1]->name,Mynode->links[1]->Lcid->hash);
|
||||||
struct Node * Mynode;
|
- test_cid_new_free, + struct Link * ResultLink = Node_Get_Link("Simo", Mynode);
|
||||||
Mynode = N_Create_From_Link(mylink,sizeof(mylink));
|
- test_cid_cast_multihash, + printf("\nResultLink: \nName: %s\nHash: %s\n", ResultLink->name, ResultLink->Lcid->hash);
|
||||||
mylink->name = "HAHA";//Testing for valid node creation
|
- test_cid_cast_non_multihash, + Node_Remove_Link("Simo", Mynode);
|
||||||
printf("Node Link[0] Name: %s\nHash: %s\n",Mynode->links[0]->name, Mynode->links[0]->Lcid->hash);
|
- //test_init_new_installation, + printf("Outlinkamt: %d\n", Mynode->link_ammount);
|
||||||
Mynode = N_Add_Link(&Mynode, mylink2, sizeof(mylink2));
|
- test_repo_config_new, + Free_Link(mylink);
|
||||||
mylink2->name = "HAHA";//Testing for valid node creation
|
- test_repo_config_init, + Free_Link(mylink2);
|
||||||
printf("Node Link[1] Name: %s\nHash: %s\n",Mynode->links[1]->name,Mynode->links[1]->Lcid->hash);
|
- test_repo_config_write, + Free_Link(ResultLink);
|
||||||
struct Link * ResultLink = Node_Get_Link("Simo", Mynode);
|
- test_repo_config_identity_new, + Node_Delete(Mynode);
|
||||||
printf("\nResultLink: \nName: %s\nHash: %s\n", ResultLink->name, ResultLink->Lcid->hash);
|
- test_repo_config_identity_private_key, + return 0;
|
||||||
Node_Remove_Link("Simo", Mynode);
|
- test_get_init_command,
|
||||||
printf("Outlinkamt: %d\n", Mynode->link_ammount);
|
- test_repo_fsrepo_open_config,
|
||||||
Free_Link(mylink);
|
- test_flatfs_get_directory,
|
||||||
Free_Link(mylink2);
|
- test_flatfs_get_filename,
|
||||||
Free_Link(ResultLink);
|
- test_flatfs_get_full_filename,
|
||||||
Node_Delete(Mynode);
|
- test_ds_key_from_binary,
|
||||||
return 0;
|
- test_blocks_new,
|
||||||
}
|
- test_repo_bootstrap_peers_init,
|
||||||
|
- test_ipfs_datastore_put
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- * run 1 test or run all
|
||||||
|
- */
|
||||||
|
-int main(int argc, char** argv) {
|
||||||
|
- int counter = 0;
|
||||||
|
- 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]);
|
||||||
|
-
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (counter > 0) {
|
||||||
|
- printf("***** There were %d failed test(s) *****\n", counter);
|
||||||
|
- } else {
|
||||||
|
- printf("All tests passed\n");
|
||||||
|
- }
|
||||||
|
- return 1;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue