2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2010, Digium, Inc.
6 * Russell Bryant <russell@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
23 * \author Russell Bryant <russell@digium.com>
29 <depend>TEST_FRAMEWORK</depend>
34 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
36 #include "asterisk/utils.h"
37 #include "asterisk/module.h"
38 #include "asterisk/test.h"
39 #include "asterisk/md5.h"
41 AST_TEST_DEFINE(md5_test)
45 const char *expected_output;
47 { "apples", "daeccf0ad3c1fc8c8015205c332f5b42" },
48 { "bananas", "ec121ff80513ae58ed478d5c5787075b" },
49 { "reallylongstringaboutgoatcheese", "0a2d9280d37e2e37545cfef6e7e4e890" },
51 enum ast_test_result_state res = AST_TEST_PASS;
56 info->name = "md5_test";
57 info->category = "main/";
58 info->summary = "MD5 test";
60 "This test exercises MD5 calculations.\n"
62 return AST_TEST_NOT_RUN;
67 ast_test_status_update(&args->status_update, "Testing MD5 ...\n");
69 for (i = 0; i < ARRAY_LEN(tests); i++) {
71 ast_md5_hash(md5_hash, tests[i].input);
72 if (strcasecmp(md5_hash, tests[i].expected_output)) {
73 ast_test_status_update(&args->status_update,
74 "input: '%s' hash: '%s' expected hash: '%s'\n",
75 tests[i].input, md5_hash, tests[i].expected_output);
76 ast_str_append(&args->ast_test_error_str, 0,
77 "input: '%s' hash: '%s' expected hash: '%s'\n",
78 tests[i].input, md5_hash, tests[i].expected_output);
86 static int unload_module(void)
88 AST_TEST_UNREGISTER(md5_test);
92 static int load_module(void)
94 AST_TEST_REGISTER(md5_test);
95 return AST_MODULE_LOAD_SUCCESS;
98 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "MD5 Test");