95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang Pavel Březina <pbrezina@redhat.com>
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang Copyright (C) 2011 Red Hat
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang This program is free software; you can redistribute it and/or modify
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang it under the terms of the GNU General Public License as published by
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang the Free Software Foundation; either version 3 of the License, or
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang (at your option) any later version.
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang This program is distributed in the hope that it will be useful,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang but WITHOUT ANY WARRANTY; without even the implied warranty of
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang GNU General Public License for more details.
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang You should have received a copy of the GNU General Public License
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang along with this program. If not, see <http://www.gnu.org/licenses/>.
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng JiangSTART_TEST(test_debug_convert_old_level_old_format)
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang for (old_level = 0; old_level <= 9; old_level++) {
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang msg = talloc_asprintf(NULL, "Invalid conversion of %d", old_level);
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang fail_unless(debug_convert_old_level(old_level) == expected_level, msg);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng JiangSTART_TEST(test_debug_convert_old_level_new_format)
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang debug_convert_old_level(SSSDBG_UNRESOLVED) == SSSDBG_FATAL_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_UNRESOLVED"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_FATAL_FAILURE) == SSSDBG_FATAL_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_FATAL_FAILURE"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_CRIT_FAILURE) == SSSDBG_CRIT_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_CRIT_FAILURE"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_OP_FAILURE) == SSSDBG_OP_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_OP_FAILURE"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_MINOR_FAILURE) == SSSDBG_MINOR_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_MINOR_FAILURE"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_CONF_SETTINGS) == SSSDBG_CONF_SETTINGS,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_CONF_SETTINGS"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_FUNC_DATA) == SSSDBG_FUNC_DATA,
f0a4ace924cef940ca4cc646fa180df70ef405d8Klaus Luettich "Invalid conversion of SSSDBG_FUNC_DATA"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_TRACE_FUNC) == SSSDBG_TRACE_FUNC,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_TRACE_FUNC"
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang debug_convert_old_level(SSSDBG_TRACE_LIBS) == SSSDBG_TRACE_LIBS,
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang "Invalid conversion of SSSDBG_TRACE_LIBS"
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang debug_convert_old_level(SSSDBG_TRACE_INTERNAL) == SSSDBG_TRACE_INTERNAL,
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang "Invalid conversion of SSSDBG_TRACE_INTERNAL"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_TRACE_ALL) == SSSDBG_TRACE_ALL,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_TRACE_ALL"
31ac08a9e5233b83a63fd5aaac494c32305c4c77Heng Jiang debug_convert_old_level(SSSDBG_MASK_ALL) == SSSDBG_MASK_ALL,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_MASK_ALL"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang strncpy(filename, "sssd_debug_tests.XXXXXX", 24);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fsize = fread(msg, sizeof(char), filesize, file);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang scan_return = sscanf(msg, "(%s %s %d %d:%d:%d %d)", time_day, time_month,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang &time_day_num, &time_hour, &time_min, &time_sec, &time_year);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "(%s %s %2d %.2d:%.2d:%.2d %.4d) "
175c9e5fde43fc804a8d25198133288669b9d54cKlaus Luettich "[%s] [%s] (%#.4x): %s\n",
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang scan_return = sscanf(msg, "(%s %s %d %d:%d:%d:%d %d)", time_day, time_month,
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang "(%s %s %2d %.2d:%.2d:%.2d:%.6d %.4d) "
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang "[%s] [%s] (%#.4x): %s\n",
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang time_year, debug_prg_name, function, level, body);
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang compare_to = talloc_asprintf(ctx, "[%s] [%s] (%#.4x): %s\n",
c51b5677113ce7260c44afb3c5932eea6c875e27Heng Jiang ret = strncmp(msg, compare_to, filesize) == 0 ? EOK : DEBUG_TEST_NOK;
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowskiint test_helper_debug_is_empty_message(int level)
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski strncpy(filename, "sssd_debug_tests.XXXXXX", 24);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang for (i = 0; i <= 9; i++) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang result = test_helper_debug_check_message(levels[i]);
debug_microseconds = 0;
errno = 0;
errno = 0;
debug_timestamps = 0;
debug_microseconds = 0;
errno = 0;
levels[i]);
debug_timestamps = 0;
debug_microseconds = 0;
errno = 0;
levels[i]);
debug_timestamps = 0;
errno = 0;
levels[i]);
if (number_failed == 0)
return EXIT_SUCCESS;
return EXIT_FAILURE;