diff --git a/t/CMakeLists.txt b/t/CMakeLists.txt index 8b418b7..5f50208 100644 --- a/t/CMakeLists.txt +++ b/t/CMakeLists.txt @@ -2,6 +2,7 @@ enable_testing() set(SRC_DIR "../src") +add_executable("t_md5" "t_md5.c" "${SRC_DIR}/md5.c") add_executable("t_buf" "t_buf.c" "${SRC_DIR}/strlcpy.c" "${SRC_DIR}/buf.c") add_executable("t_cmd" "t_cmd.c" "${SRC_DIR}/strlcpy.c" "${SRC_DIR}/buf.c" "${SRC_DIR}/commands.c") add_executable("t_matches" "t_matches.c" "${SRC_DIR}/strlcpy.c" "${SRC_DIR}/matches.c") @@ -11,6 +12,7 @@ add_executable("t_config_param" "t_config_param.c" "${SRC_DIR}/strlcpy.c" "${SRC add_test("tests/f2b_buf_*" "t_buf") add_test("tests/f2b_cmd_*" "t_cmd") +add_test("tests/f2b_md5_*" "t_md5") add_test("tests/f2b_matches_*" "t_matches") add_test("tests/f2b_ipaddr_*" "t_ipaddr") add_test("tests/f2b_statefile_*" "t_statefile") diff --git a/t/t_md5.c b/t/t_md5.c new file mode 100644 index 0000000..0be25fa --- /dev/null +++ b/t/t_md5.c @@ -0,0 +1,16 @@ +#include "../src/common.h" +#include "../src/md5.h" + +int main() { + MD5_CTX md5; + char *sample = "098f6bcd4621d373cade4e832627b4f6"; // md5_hex("test") + + memset(&md5, 0x0, sizeof(md5)); + + MD5Init(&md5); + MD5Update(&md5, (unsigned char *) "test", 4); + MD5Final(&md5); + + assert(strcmp(md5.hexdigest, sample) == 0); + return 0; +}