aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_akfs.c205
-rw-r--r--src/tests/test_akfs_mkdir.c38
-rw-r--r--src/tests/test_aklog.c72
-rw-r--r--src/tests/test_aklogcatter.c7
-rw-r--r--src/tests/test_aklogwrite.c13
-rw-r--r--src/tests/test_aksettings.c7
6 files changed, 0 insertions, 342 deletions
diff --git a/src/tests/test_akfs.c b/src/tests/test_akfs.c
deleted file mode 100644
index 079c00c..0000000
--- a/src/tests/test_akfs.c
+++ /dev/null
@@ -1,205 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <akfs.h>
-
-void correct_string_correct_length()
-{
- printf("%s\t", __func__);
- char queried_string[] = "921618bc6d9f8059437c5e0397b13f973ab7c7a7b81f0ca31b70bf448fd800a460b67efda0020088bc97bf7d9da97a9e2ce7b20d46e066462ec44cf60284f9a7";
- // printf("Hash given:\t%s\n", queried_string);
- // printf("Is a hash: %s\n", ak_fs_verify_input_is_hash(queried_string) ? "true": "false");
- sha512sum resulted_hash = ak_fs_sha512sum_string_to_struct(queried_string);
- char resulted_string[129] = {0};
- ak_fs_sha512sum_struct_to_string(resulted_hash, resulted_string);
- // printf("Hash returned:\t%s\n", resulted_string);
- if ( strcmp(queried_string, resulted_string) == 0 )
- {
- printf("PASS!\n");
- }
- else
- {
- printf("NO PASS :(\n");
- }
-}
-
-void bad_string_correct_length()
-{
- printf("%s\t", __func__);
- char queried_string[] = "921618bc6d9f8059437c5e0397b13f973ab7c7a7b81f0ca31b70bf448fd800a460b67efda0020088bc97bf7d9da97a9e2ce7b20d46e066462ec44cf60284f9az";
- // printf("Hash given:\t%s\n", queried_string);
- // printf("Is a hash: %s\n", ak_fs_verify_input_is_hash(queried_string) ? "true": "false");
- sha512sum resulted_hash = ak_fs_sha512sum_string_to_struct(queried_string);
- char resulted_string[129] = {0};
- ak_fs_sha512sum_struct_to_string(resulted_hash, resulted_string);
- // printf("Hash returned:\t%s\n", resulted_string);
- if ( strcmp(queried_string, resulted_string) != 0 )
- {
- printf("PASS!\n");
- }
- else
- {
- printf("NO PASS :(\n");
- }
-}
-
-void less_than_length()
-{
- printf("%s\t", __func__);
- char queried_string[] = "921618bc6d9f8059437c5e0397b13f973ab7c7a7b81f0ca31b70bf";
- // printf("Hash given:\t%s\n", queried_string);
- // printf("Is a hash: %s\n", ak_fs_verify_input_is_hash(queried_string) ? "true": "false");
- sha512sum resulted_hash = ak_fs_sha512sum_string_to_struct(queried_string);
- char resulted_string[129] = {0};
- ak_fs_sha512sum_struct_to_string(resulted_hash, resulted_string);
- // printf("Hash returned:\t%s\n", resulted_string);
- if ( strcmp(queried_string, resulted_string) != 0 )
- {
- printf("\tPASS!\n");
- }
- else
- {
- printf("\tNO PASS :(\n");
- }
-}
-
-void more_than_length()
-{
- printf("%s\t", __func__);
- char queried_string[] = "921618bc6d9f8059437c5e0397b13f973ab7c7a7b81f0ca31b70bf448fd800a460b67efda0020088bc97bf7d9da97a9e2ce7b20d46e066462ec44cf60284f9a7aaa";
- // printf("Hash given:\t%s\n", queried_string);
- // printf("Is a hash: %s\n", ak_fs_verify_input_is_hash(queried_string) ? "true": "false");
- sha512sum resulted_hash = ak_fs_sha512sum_string_to_struct(queried_string);
- char resulted_string[129] = {0};
- ak_fs_sha512sum_struct_to_string(resulted_hash, resulted_string);
- // printf("Hash returned:\t%s\n", resulted_string);
- if ( strcmp(queried_string, resulted_string) != 0 )
- {
- printf("\tPASS!\n");
- }
- else
- {
- printf("\tNO PASS :(\n");
- }
-}
-
-void string_is_empty()
-{
- printf("%s\t", __func__);
- char queried_string[128] = "";
- // printf("Hash given:\t%s\n", queried_string);
- //printf("Is a hash: %s\n", ak_fs_verify_input_is_hash(queried_string) ? "true": "false");
- sha512sum resulted_hash = ak_fs_sha512sum_string_to_struct(queried_string);
- char resulted_string[129] = {0};
- ak_fs_sha512sum_struct_to_string(resulted_hash, resulted_string);
- // printf("Hash returned:\t%s\n", resulted_string);
- if ( strcmp(queried_string, resulted_string) != 0 )
- {
- printf("\t\tPASS!\n");
- }
- else
- {
- printf("\t\tNO PASS :(\n");
- }
-}
-
-void hash_path_test()
-{
- printf("%s\t", __func__);
- char queried_string[] = "921618bc6d9f8059437c5e0397b13f973ab7c7a7b81f0ca31b70bf448fd800a460b67efda0020088bc97bf7d9da97a9e2ce7b20d46e066462ec44cf60284f9a7";
- // printf("Hash given:\t%s\n", queried_string);
- // printf("Is a hash: %s\n", ak_fs_verify_input_is_hash(queried_string) ? "true": "false");
- char* resulted_string = ak_fs_return_hash_path(queried_string);
- // printf("Path returned:\t%s\n", resulted_string);
- if ( strcmp(queried_string, resulted_string) != 0 )
- {
- printf("\t\tPASS!\n");
- }
- else
- {
- printf("\t\tNO PASS :(\n");
- }
-}
-
-void hash_dir_test()
-{
- printf("%s\t", __func__);
- char queried_string[] = "921618bc6d9f8059437c5e0397b13f973ab7c7a7b81f0ca31b70bf448fd800a460b67efda0020088bc97bf7d9da97a9e2ce7b20d46e066462ec44cf60284f9a7";
- // printf("Hash given:\t%s\n", queried_string);
- // printf("Is a hash: %s\n", ak_fs_verify_input_is_hash(queried_string) ? "true": "false");
- char* resulted_string = ak_fs_return_hash_dir(queried_string);
- // printf("Path returned:\t%s\n", resulted_string);
- if ( strcmp(queried_string, resulted_string) != 0 )
- {
- printf("\t\tPASS!\n");
- }
- else
- {
- printf("\t\tNO PASS :(\n");
- }
-}
-
-void hash_save_to_file()
-{
- printf("%s\t", __func__);
- char queried_string[] = "921618bc6d9f8059437c5e0397b13f973ab7c7a7b81f0ca31b70bf448fd800a460b67efda0020088bc97bf7d9da97a9e2ce7b20d46e066462ec44cf60284f9a7";
- // printf("Hash given:\t%s\n", queried_string);
- // printf("Is a hash: %s\n", ak_fs_verify_input_is_hash(queried_string) ? "true": "false");
- sha512sum resulted_hash = ak_fs_sha512sum_string_to_struct(queried_string);
- FILE* fd = fopen("tmpfile", "wb");
- if ( fd == NULL )
- {
- printf("Some error occured");
- exit(1);
- }
- fwrite(&resulted_hash, sizeof(sha512sum),1,fd);
- fclose(fd);
- sha512sum readone = {0};
- fd = fopen("tmpfile", "rb");
- if ( fd == NULL )
- {
- printf("Some error occured");
- exit(1);
- }
- fread (&readone, sizeof(sha512sum),1,fd);
- char resulted_string[129] = {0};
- ak_fs_sha512sum_struct_to_string(resulted_hash, resulted_string);
- if ( strcmp(queried_string, resulted_string) == 0 )
- {
- printf("\tPASS!\n");
- }
- else
- {
- printf("\tNO PASS :(\n");
- }
- fclose(fd);
- free(resulted_string);
-}
-
-int main(void)
-{
- // Correct one
- correct_string_correct_length();
-
- // Supposingly a bad string but in correct length
- bad_string_correct_length();
-
- // Less than must be length
- less_than_length();
-
- // More than must be length
- more_than_length();
-
- // Empty string
- string_is_empty();
-
- // Hash path
- hash_path_test();
-
- // Hash dir
- hash_dir_test();
-
- // Tempfile test read-write
- hash_save_to_file();
- return 0;
-}
diff --git a/src/tests/test_akfs_mkdir.c b/src/tests/test_akfs_mkdir.c
deleted file mode 100644
index 2ef86b3..0000000
--- a/src/tests/test_akfs_mkdir.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <stdio.h>
-#include <akfs.h>
-
-void test_non_hash_string(){
- char *path = "tes";
- int ec = ak_fs_create_dir_for_hash(path);
- printf("mkdir return code: %d\n", ec);
- path = "tes/t";
- ec = ak_fs_create_dir_for_hash(path);
- printf("mkdir return code: %d\n", ec);
-}
-
-void test_hash_string(){
- char *path = "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff";
- int ec = ak_fs_create_dir_for_hash(path);
- printf("mkdir return code: %d\n", ec);
-}
-
-void test_hash_string2(){
- char *path = "ee2ab0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff";
- int ec = ak_fs_create_dir_for_hash(path);
- printf("mkdir return code: %d\n", ec);
-}
-
-void test_hash_string3(){
- char *path = "ee2ab0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a800";
- int ec = ak_fs_create_dir_for_hash(path);
- printf("mkdir return code: %d\n", ec);
-}
-
-int main()
-{
- test_non_hash_string();
- test_hash_string();
- test_hash_string2();
- test_hash_string3();
- return 0;
-}
diff --git a/src/tests/test_aklog.c b/src/tests/test_aklog.c
deleted file mode 100644
index dad065f..0000000
--- a/src/tests/test_aklog.c
+++ /dev/null
@@ -1,72 +0,0 @@
-#include <aklog.h>
-
-void test_message_output()
-{
- ak_log_print_log_line("1731664790 <TEST> [INFO] test message info");
-}
-
-void test_follow()
-{
- ak_log_follow();
-}
-
-void test_grep()
-{
- ak_log_grep("-h");
-}
-
-void test_rotate()
-{
- ak_log_rotate();
-}
-
-void test_log_message()
-{
- ak_log_message(__func__, "TEST", "test message info");
-}
-
-void test_exit()
-{
- ak_log_exit(__func__, "test message info");
-}
-
-void test_warning()
-{
- ak_log_warning(__func__, "test message info");
-}
-
-void test_debug()
-{
- ak_log_debug(__func__, "test message info");
-}
-
-void test_error()
-{
- ak_log_error(__func__, "test message info");
-}
-
-void test_info()
-{
- ak_log_info(__func__, "test message info");
-}
-
-void test_write()
-{
- ak_log_info(__func__, "test message info");
-}
-
-int main (void)
-{
- test_follow();
- test_message_output();
- test_info();
- test_exit();
- test_error();
- test_debug();
- test_warning();
- test_log_message();
- test_rotate();
- test_grep();
- test_write();
- return 0;
-}
diff --git a/src/tests/test_aklogcatter.c b/src/tests/test_aklogcatter.c
deleted file mode 100644
index bc45063..0000000
--- a/src/tests/test_aklogcatter.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <aklogcatter.h>
-
-int main()
-{
- ak_logcatter();
- return 0;
-}
diff --git a/src/tests/test_aklogwrite.c b/src/tests/test_aklogwrite.c
deleted file mode 100644
index a6267b0..0000000
--- a/src/tests/test_aklogwrite.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <aklog.h>
-
-void test_write()
-{
- ak_log_info(__func__, "test message info");
-}
-
-int main (void)
-{
- test_write();
- return 0;
-}
-
diff --git a/src/tests/test_aksettings.c b/src/tests/test_aksettings.c
deleted file mode 100644
index 5b7d71e..0000000
--- a/src/tests/test_aksettings.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <aksettings.h>
-
-int main()
-{
- ak_settings();
- return 0;
-}