95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang/*
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSD
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug-tests.c
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang Authors:
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang Pavel Březina <pbrezina@redhat.com>
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang Copyright (C) 2011 Red Hat
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
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
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
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 Jiang*/
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang#include <check.h>
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang#include <stdio.h>
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang#include <talloc.h>
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang#include <errno.h>
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang#include <string.h>
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang#include "util/util.h"
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang#include "tests/common.h"
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang#define DEBUG_TEST_ERROR -1
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang#define DEBUG_TEST_NOK 1
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang#define DEBUG_TEST_NOK_TS 2
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng JiangSTART_TEST(test_debug_convert_old_level_old_format)
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang{
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int expected_level = 0x0000;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int old_level;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int levels[] = {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_FATAL_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_CRIT_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_OP_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_MINOR_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_CONF_SETTINGS,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_FUNC_DATA,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_TRACE_FUNC,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_TRACE_LIBS,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_TRACE_INTERNAL,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_TRACE_ALL | SSSDBG_BE_FO
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang };
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang for (old_level = 0; old_level <= 9; old_level++) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang expected_level |= levels[old_level];
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang char *msg = NULL;
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);
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang talloc_free(msg);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang}
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng JiangEND_TEST
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng JiangSTART_TEST(test_debug_convert_old_level_new_format)
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang{
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang fail_unless(
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang debug_convert_old_level(SSSDBG_UNRESOLVED) == SSSDBG_FATAL_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_UNRESOLVED"
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang );
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fail_unless(
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_FATAL_FAILURE) == SSSDBG_FATAL_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_FATAL_FAILURE"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang );
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fail_unless(
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_CRIT_FAILURE) == SSSDBG_CRIT_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_CRIT_FAILURE"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang );
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fail_unless(
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_OP_FAILURE) == SSSDBG_OP_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_OP_FAILURE"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang );
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fail_unless(
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_MINOR_FAILURE) == SSSDBG_MINOR_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_MINOR_FAILURE"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang );
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fail_unless(
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_CONF_SETTINGS) == SSSDBG_CONF_SETTINGS,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_CONF_SETTINGS"
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang );
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fail_unless(
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_FUNC_DATA) == SSSDBG_FUNC_DATA,
f0a4ace924cef940ca4cc646fa180df70ef405d8Klaus Luettich "Invalid conversion of SSSDBG_FUNC_DATA"
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang );
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fail_unless(
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_TRACE_FUNC) == SSSDBG_TRACE_FUNC,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_TRACE_FUNC"
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang );
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang fail_unless(
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang debug_convert_old_level(SSSDBG_TRACE_LIBS) == SSSDBG_TRACE_LIBS,
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang "Invalid conversion of SSSDBG_TRACE_LIBS"
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang );
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang fail_unless(
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang debug_convert_old_level(SSSDBG_TRACE_INTERNAL) == SSSDBG_TRACE_INTERNAL,
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang "Invalid conversion of SSSDBG_TRACE_INTERNAL"
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang );
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fail_unless(
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_convert_old_level(SSSDBG_TRACE_ALL) == SSSDBG_TRACE_ALL,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_TRACE_ALL"
31ac08a9e5233b83a63fd5aaac494c32305c4c77Heng Jiang );
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fail_unless(
31ac08a9e5233b83a63fd5aaac494c32305c4c77Heng Jiang debug_convert_old_level(SSSDBG_MASK_ALL) == SSSDBG_MASK_ALL,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "Invalid conversion of SSSDBG_MASK_ALL"
f0a4ace924cef940ca4cc646fa180df70ef405d8Klaus Luettich );
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang}
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng JiangEND_TEST
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiangint test_helper_debug_check_message(int level)
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang{
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang TALLOC_CTX *ctx = talloc_new(NULL);
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang char filename[24] = {'\0'};
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang char *msg = NULL;
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang char *compare_to = NULL;
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang const char *function = __FUNCTION__;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang const char *body = "some error";
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int filesize;
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang int fsize;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int fd;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int ret;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int _errno = 0;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang mode_t old_umask;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang FILE *file = NULL;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang strncpy(filename, "sssd_debug_tests.XXXXXX", 24);
0b31ea5ec0e20f17d55845a5d803c48466e01ca3Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang old_umask = umask(SSS_DFL_UMASK);
31ac08a9e5233b83a63fd5aaac494c32305c4c77Heng Jiang fd = mkstemp(filename);
31ac08a9e5233b83a63fd5aaac494c32305c4c77Heng Jiang umask(old_umask);
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang if (fd == -1) {
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang _errno = errno;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang talloc_free(ctx);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang errno = _errno;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang return DEBUG_TEST_ERROR;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang file = fdopen(fd, "r");
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (file == NULL) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang _errno = errno;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = DEBUG_TEST_ERROR;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang goto done;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = set_debug_file_from_fd(fd);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (ret != EOK) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang _errno = ret;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = DEBUG_TEST_ERROR;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang goto done;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang DEBUG(level, "%s\n", body);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = fseek(file, 0, SEEK_END);
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang if (ret == -1) {
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang _errno = errno;
806bce66335c88260a63e7524b1efc68d8dfacc1Heng Jiang ret = DEBUG_TEST_ERROR;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang goto done;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang filesize = ftell(file);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (filesize == -1) {
f0a4ace924cef940ca4cc646fa180df70ef405d8Klaus Luettich _errno = errno;
f0a4ace924cef940ca4cc646fa180df70ef405d8Klaus Luettich ret = DEBUG_TEST_ERROR;
f0a4ace924cef940ca4cc646fa180df70ef405d8Klaus Luettich goto done;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang rewind(file);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang msg = talloc_array(ctx, char, filesize+1);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (msg == NULL) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang _errno = ENOMEM;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = DEBUG_TEST_ERROR;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang goto done;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fsize = fread(msg, sizeof(char), filesize, file);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (fsize != filesize) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang _errno = EIO;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = DEBUG_TEST_ERROR;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang goto done;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang msg[fsize] = '\0';
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (debug_timestamps == 1) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang char time_day[4] = {'\0', '\0', '\0', '\0'};
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang char time_month[4] = {'\0', '\0', '\0', '\0'};
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int time_day_num = 0;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int time_hour = 0;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int time_min = 0;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int time_sec = 0;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int time_usec = 0;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int time_year = 0;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int scan_return = 0;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (debug_microseconds == 0) {
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
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (scan_return != 7) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = DEBUG_TEST_NOK_TS;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang goto done;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang compare_to = talloc_asprintf(ctx,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang "(%s %s %2d %.2d:%.2d:%.2d %.4d) "
175c9e5fde43fc804a8d25198133288669b9d54cKlaus Luettich "[%s] [%s] (%#.4x): %s\n",
175c9e5fde43fc804a8d25198133288669b9d54cKlaus Luettich time_day, time_month, time_day_num,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang time_hour, time_min, time_sec, time_year,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_prg_name, function, level, body);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (compare_to == NULL) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang _errno = ENOMEM;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = DEBUG_TEST_ERROR;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang goto done;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang }
175c9e5fde43fc804a8d25198133288669b9d54cKlaus Luettich } else {
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang scan_return = sscanf(msg, "(%s %s %d %d:%d:%d:%d %d)", time_day, time_month,
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang &time_day_num, &time_hour, &time_min, &time_sec,
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang &time_usec, &time_year);
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang if (scan_return != 8) {
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang ret = DEBUG_TEST_NOK_TS;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang goto done;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang }
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang compare_to = talloc_asprintf(ctx,
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang "(%s %s %2d %.2d:%.2d:%.2d:%.6d %.4d) "
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang "[%s] [%s] (%#.4x): %s\n",
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang time_day, time_month, time_day_num,
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang time_hour, time_min, time_sec, time_usec,
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang time_year, debug_prg_name, function, level, body);
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang if (compare_to == NULL) {
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang _errno = ENOMEM;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang ret = DEBUG_TEST_ERROR;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang goto done;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang }
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang }
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang } else {
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang compare_to = talloc_asprintf(ctx, "[%s] [%s] (%#.4x): %s\n",
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang debug_prg_name, function, level, body);
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang if (compare_to == NULL) {
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang _errno = ENOMEM;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang ret = DEBUG_TEST_ERROR;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang goto done;
c51b5677113ce7260c44afb3c5932eea6c875e27Heng Jiang }
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang }
c51b5677113ce7260c44afb3c5932eea6c875e27Heng Jiang ret = strncmp(msg, compare_to, filesize) == 0 ? EOK : DEBUG_TEST_NOK;
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowskidone:
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski talloc_free(ctx);
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski if (file != NULL) {
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski fclose(file);
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski }
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski remove(filename);
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski errno = _errno;
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski return ret;
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski}
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowskiint test_helper_debug_is_empty_message(int level)
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski{
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski char filename[24] = {'\0'};
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski int fd;
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski int filesize;
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski int ret;
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski int _errno = 0;
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski mode_t old_umask;
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski FILE *file;
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski
67d5e49547d78aa56a8f9ba5e64a950b730eba66Till Mossakowski strncpy(filename, "sssd_debug_tests.XXXXXX", 24);
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang old_umask = umask(SSS_DFL_UMASK);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fd = mkstemp(filename);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang umask(old_umask);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (fd == -1) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang return DEBUG_TEST_ERROR;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang file = fdopen(fd, "r");
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (file == NULL) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang _errno = errno;
b3c65285705f6d184b5f8b00b1a328d96b6b19c5Heng Jiang ret = DEBUG_TEST_ERROR;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang goto done;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang }
c51b5677113ce7260c44afb3c5932eea6c875e27Heng Jiang
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang ret = set_debug_file_from_fd(fd);
b3c65285705f6d184b5f8b00b1a328d96b6b19c5Heng Jiang if (ret != EOK) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang _errno = ret;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = DEBUG_TEST_ERROR;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang goto done;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang }
b3c65285705f6d184b5f8b00b1a328d96b6b19c5Heng Jiang
c51b5677113ce7260c44afb3c5932eea6c875e27Heng Jiang DEBUG(level, "some error\n");
c51b5677113ce7260c44afb3c5932eea6c875e27Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = fseek(file, 0, SEEK_END);
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang if (ret == -1) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang _errno = errno;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = DEBUG_TEST_ERROR;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang goto done;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang filesize = ftell(file);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (filesize == -1) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang _errno = errno;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = DEBUG_TEST_ERROR;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang goto done;
b91c4dbd00294ce29ab1ae84ad4e8c93ca5ad943Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang ret = filesize == 0 ? EOK : DEBUG_TEST_NOK;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiangdone:
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (file != NULL) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fclose(file);
b3c65285705f6d184b5f8b00b1a328d96b6b19c5Heng Jiang }
c51b5677113ce7260c44afb3c5932eea6c875e27Heng Jiang remove(filename);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang errno = _errno;
b3c65285705f6d184b5f8b00b1a328d96b6b19c5Heng Jiang return ret;
b3c65285705f6d184b5f8b00b1a328d96b6b19c5Heng Jiang}
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng JiangSTART_TEST(test_debug_is_set_single_no_timestamp)
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang{
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int i;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int result;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang int levels[] = {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_FATAL_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_CRIT_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_OP_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_MINOR_FAILURE,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_CONF_SETTINGS,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_FUNC_DATA,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_TRACE_FUNC,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_TRACE_LIBS,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_TRACE_INTERNAL,
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang SSSDBG_TRACE_ALL
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang };
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang char *error_msg;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_timestamps = 0;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_microseconds = 0;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_to_file = 1;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_prg_name = "sssd";
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang for (i = 0; i <= 9; i++) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang debug_level = levels[i];
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang errno = 0;
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang result = test_helper_debug_check_message(levels[i]);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang if (result == DEBUG_TEST_ERROR) {
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang error_msg = strerror(errno);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang fail(error_msg);
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang }
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang
95242ab07e9aa13b37c16cac36a75d190e1766e4Heng Jiang char *msg = NULL;
msg = talloc_asprintf(NULL, "Test of level %#.4x failed - message don't match", levels[i]);
fail_unless(result == EOK, msg);
talloc_free(msg);
}
}
END_TEST
START_TEST(test_debug_is_set_single_timestamp)
{
int i;
int result;
int levels[] = {
SSSDBG_FATAL_FAILURE,
SSSDBG_CRIT_FAILURE,
SSSDBG_OP_FAILURE,
SSSDBG_MINOR_FAILURE,
SSSDBG_CONF_SETTINGS,
SSSDBG_FUNC_DATA,
SSSDBG_TRACE_FUNC,
SSSDBG_TRACE_LIBS,
SSSDBG_TRACE_INTERNAL,
SSSDBG_TRACE_ALL
};
char *error_msg;
debug_timestamps = 1;
debug_microseconds = 0;
debug_to_file = 1;
debug_prg_name = "sssd";
for (i = 0; i <= 9; i++) {
debug_level = levels[i];
errno = 0;
result = test_helper_debug_check_message(levels[i]);
if (result == DEBUG_TEST_ERROR) {
error_msg = strerror(errno);
fail(error_msg);
}
char *msg = NULL;
msg = talloc_asprintf(NULL, "Test of level %#.4x failed - invalid timestamp", levels[i]);
fail_if(result == DEBUG_TEST_NOK_TS, msg);
talloc_free(msg);
msg = talloc_asprintf(NULL, "Test of level %#.4x failed - message don't match", levels[i]);
fail_unless(result == EOK, msg);
talloc_free(msg);
}
}
END_TEST
START_TEST(test_debug_is_set_single_timestamp_microseconds)
{
int i;
int result;
int levels[] = {
SSSDBG_FATAL_FAILURE,
SSSDBG_CRIT_FAILURE,
SSSDBG_OP_FAILURE,
SSSDBG_MINOR_FAILURE,
SSSDBG_CONF_SETTINGS,
SSSDBG_FUNC_DATA,
SSSDBG_TRACE_FUNC,
SSSDBG_TRACE_LIBS,
SSSDBG_TRACE_INTERNAL,
SSSDBG_TRACE_ALL
};
char *error_msg;
debug_timestamps = 1;
debug_microseconds = 1;
debug_to_file = 1;
debug_prg_name = "sssd";
for (i = 0; i <= 9; i++) {
debug_level = levels[i];
errno = 0;
result = test_helper_debug_check_message(levels[i]);
if (result == DEBUG_TEST_ERROR) {
error_msg = strerror(errno);
fail(error_msg);
}
char *msg = NULL;
msg = talloc_asprintf(NULL, "Test of level %#.4x failed - invalid timestamp", levels[i]);
fail_if(result == DEBUG_TEST_NOK_TS, msg);
talloc_free(msg);
msg = talloc_asprintf(NULL, "Test of level %#.4x failed - message don't match", levels[i]);
fail_unless(result == EOK, msg);
talloc_free(msg);
}
}
END_TEST
START_TEST(test_debug_is_notset_no_timestamp)
{
int i;
int result;
int all_set = SSSDBG_MASK_ALL;
int levels[] = {
SSSDBG_FATAL_FAILURE,
SSSDBG_CRIT_FAILURE,
SSSDBG_OP_FAILURE,
SSSDBG_MINOR_FAILURE,
SSSDBG_CONF_SETTINGS,
SSSDBG_FUNC_DATA,
SSSDBG_TRACE_FUNC,
SSSDBG_TRACE_LIBS,
SSSDBG_TRACE_INTERNAL,
SSSDBG_TRACE_ALL
};
char *error_msg;
debug_timestamps = 0;
debug_microseconds = 0;
debug_to_file = 1;
debug_prg_name = "sssd";
for (i = 0; i <= 9; i++) {
debug_level = all_set & ~levels[i];
errno = 0;
result = test_helper_debug_is_empty_message(levels[i]);
if (result == DEBUG_TEST_ERROR) {
error_msg = strerror(errno);
fail(error_msg);
}
char *msg = NULL;
msg = talloc_asprintf(NULL,
"Test of level %#.4x failed - message has been written",
levels[i]);
fail_unless(result == EOK, msg);
talloc_free(msg);
}
}
END_TEST
START_TEST(test_debug_is_notset_timestamp)
{
int i;
int result;
int all_set = SSSDBG_MASK_ALL;
int levels[] = {
SSSDBG_FATAL_FAILURE,
SSSDBG_CRIT_FAILURE,
SSSDBG_OP_FAILURE,
SSSDBG_MINOR_FAILURE,
SSSDBG_CONF_SETTINGS,
SSSDBG_FUNC_DATA,
SSSDBG_TRACE_FUNC,
SSSDBG_TRACE_LIBS,
SSSDBG_TRACE_INTERNAL,
SSSDBG_TRACE_ALL
};
char *error_msg;
debug_timestamps = 0;
debug_microseconds = 0;
debug_to_file = 1;
debug_prg_name = "sssd";
for (i = 0; i <= 9; i++) {
debug_level = all_set & ~levels[i];
errno = 0;
result = test_helper_debug_is_empty_message(levels[i]);
if (result == DEBUG_TEST_ERROR) {
error_msg = strerror(errno);
fail(error_msg);
}
char *msg = NULL;
msg = talloc_asprintf(NULL,
"Test of level %#.4x failed - message has been written",
levels[i]);
fail_unless(result == EOK, msg);
talloc_free(msg);
}
}
END_TEST
START_TEST(test_debug_is_notset_timestamp_microseconds)
{
int i;
int result;
int all_set = SSSDBG_MASK_ALL;
int levels[] = {
SSSDBG_FATAL_FAILURE,
SSSDBG_CRIT_FAILURE,
SSSDBG_OP_FAILURE,
SSSDBG_MINOR_FAILURE,
SSSDBG_CONF_SETTINGS,
SSSDBG_FUNC_DATA,
SSSDBG_TRACE_FUNC,
SSSDBG_TRACE_LIBS,
SSSDBG_TRACE_INTERNAL,
SSSDBG_TRACE_ALL
};
char *error_msg;
debug_timestamps = 0;
debug_microseconds = 1;
debug_to_file = 1;
debug_prg_name = "sssd";
for (i = 0; i <= 9; i++) {
debug_level = all_set & ~levels[i];
errno = 0;
result = test_helper_debug_is_empty_message(levels[i]);
if (result == DEBUG_TEST_ERROR) {
error_msg = strerror(errno);
fail(error_msg);
}
char *msg = NULL;
msg = talloc_asprintf(NULL,
"Test of level %#.4x failed - message has been written",
levels[i]);
fail_unless(result == EOK, msg);
talloc_free(msg);
}
}
END_TEST
START_TEST(test_debug_is_set_true)
{
int i;
int result;
int levels[] = {
SSSDBG_FATAL_FAILURE,
SSSDBG_CRIT_FAILURE,
SSSDBG_OP_FAILURE,
SSSDBG_MINOR_FAILURE,
SSSDBG_CONF_SETTINGS,
SSSDBG_FUNC_DATA,
SSSDBG_TRACE_FUNC,
SSSDBG_TRACE_LIBS,
SSSDBG_TRACE_INTERNAL,
SSSDBG_TRACE_ALL
};
debug_level = SSSDBG_MASK_ALL;
for (i = 0; i <= 9; i++) {
result = DEBUG_IS_SET(levels[i]);
char *msg = NULL;
msg = talloc_asprintf(NULL, "Test of level %#.4x failed - result is 0x%.4x", levels[i], result);
fail_unless(result > 0, msg);
talloc_free(msg);
}
}
END_TEST
START_TEST(test_debug_is_set_false)
{
int i;
int result;
int all_set = SSSDBG_MASK_ALL;
int levels[] = {
SSSDBG_FATAL_FAILURE,
SSSDBG_CRIT_FAILURE,
SSSDBG_OP_FAILURE,
SSSDBG_MINOR_FAILURE,
SSSDBG_CONF_SETTINGS,
SSSDBG_FUNC_DATA,
SSSDBG_TRACE_FUNC,
SSSDBG_TRACE_LIBS,
SSSDBG_TRACE_INTERNAL,
SSSDBG_TRACE_ALL
};
for (i = 0; i <= 9; i++) {
debug_level = all_set & ~levels[i];
result = DEBUG_IS_SET(levels[i]);
char *msg = NULL;
msg = talloc_asprintf(NULL, "Test of level %#.4x failed - result is 0x%.4x", levels[i], result);
fail_unless(result == 0, msg);
talloc_free(msg);
}
}
END_TEST
Suite *debug_suite(void)
{
Suite *s = suite_create("debug");
TCase *tc_debug = tcase_create("debug");
tcase_add_test(tc_debug, test_debug_convert_old_level_old_format);
tcase_add_test(tc_debug, test_debug_convert_old_level_new_format);
tcase_add_test(tc_debug, test_debug_is_set_single_no_timestamp);
tcase_add_test(tc_debug, test_debug_is_set_single_timestamp);
tcase_add_test(tc_debug, test_debug_is_set_single_timestamp_microseconds);
tcase_add_test(tc_debug, test_debug_is_notset_no_timestamp);
tcase_add_test(tc_debug, test_debug_is_notset_timestamp);
tcase_add_test(tc_debug, test_debug_is_notset_timestamp_microseconds);
tcase_add_test(tc_debug, test_debug_is_set_true);
tcase_add_test(tc_debug, test_debug_is_set_false);
tcase_set_timeout(tc_debug, 60);
suite_add_tcase(s, tc_debug);
return s;
}
int main(int argc, const char *argv[])
{
int number_failed;
tests_set_cwd();
Suite *s = debug_suite();
SRunner *sr = srunner_create(s);
srunner_run_all(sr, CK_NORMAL);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
if (number_failed == 0)
return EXIT_SUCCESS;
return EXIT_FAILURE;
}