debug-tests.c revision fb0332565892bc10998ca98b567d4dde2213844d
/*
SSSD
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2011 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <check.h>
#include <stdio.h>
#include <talloc.h>
#include <errno.h>
#include <string.h>
#define DEBUG_TEST_ERROR -1
#define DEBUG_TEST_NOK 1
#define DEBUG_TEST_NOK_TS 2
{
int expected_level = 0x0000;
int old_level;
int levels[] = {
};
}
}
{
"Invalid conversion of SSSDBG_UNRESOLVED"
);
"Invalid conversion of SSSDBG_FATAL_FAILURE"
);
"Invalid conversion of SSSDBG_CRIT_FAILURE"
);
"Invalid conversion of SSSDBG_OP_FAILURE"
);
"Invalid conversion of SSSDBG_MINOR_FAILURE"
);
"Invalid conversion of SSSDBG_CONF_SETTINGS"
);
"Invalid conversion of SSSDBG_FUNC_DATA"
);
"Invalid conversion of SSSDBG_TRACE_FUNC"
);
"Invalid conversion of SSSDBG_TRACE_LIBS"
);
"Invalid conversion of SSSDBG_TRACE_INTERNAL"
);
"Invalid conversion of SSSDBG_TRACE_ALL"
);
"Invalid conversion of SSSDBG_MASK_ALL"
);
}
{
}
{
"Invalid conversion of SSSDBG_UNRESOLVED"
);
"Invalid conversion of SSSDBG_FATAL_FAILURE"
);
"Invalid conversion of SSSDBG_CRIT_FAILURE"
);
"Invalid conversion of SSSDBG_OP_FAILURE"
);
"Invalid conversion of SSSDBG_MINOR_FAILURE"
);
"Invalid conversion of SSSDBG_CONF_SETTINGS"
);
"Invalid conversion of SSSDBG_FUNC_DATA"
);
"Invalid conversion of SSSDBG_TRACE_FUNC"
);
"Invalid conversion of SSSDBG_TRACE_LIBS"
);
"Invalid conversion of SSSDBG_TRACE_INTERNAL"
);
"Invalid conversion of SSSDBG_TRACE_ALL"
);
}
int test_helper_debug_check_message(int level)
{
char *compare_to = NULL;
const char *function = __FUNCTION__;
const char *body = "some error\n";
int filesize;
int fsize;
int fd;
int ret;
int _errno = 0;
if (fd == -1) {
return DEBUG_TEST_ERROR;
}
goto done;
}
goto done;
}
if (ret == -1) {
goto done;
}
if (filesize == -1) {
goto done;
}
goto done;
}
goto done;
}
if (debug_timestamps == 1) {
int time_day_num = 0;
int time_hour = 0;
int time_min = 0;
int time_sec = 0;
int time_usec = 0;
int time_year = 0;
int scan_return = 0;
if (debug_microseconds == 0) {
if (scan_return != 7) {
goto done;
}
"(%s %s %2d %.2d:%.2d:%.2d %.4d) "
"[%s] [%s] (%#.4x): %s",
if (compare_to == NULL) {
goto done;
}
} else {
if (scan_return != 8) {
goto done;
}
"(%s %s %2d %.2d:%.2d:%.2d:%.6d %.4d) "
"[%s] [%s] (%#.4x): %s",
if (compare_to == NULL) {
goto done;
}
}
} else {
if (compare_to == NULL) {
goto done;
}
}
done:
}
return ret;
}
int test_helper_debug_is_empty_message(int level)
{
int fd;
int filesize;
int ret;
int _errno = 0;
if (fd == -1) {
return DEBUG_TEST_ERROR;
}
goto done;
}
goto done;
}
if (ret == -1) {
goto done;
}
if (filesize == -1) {
goto done;
}
done:
}
return ret;
}
{
int i;
int result;
int levels[] = {
};
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 = levels[i];
errno = 0;
if (result == DEBUG_TEST_ERROR) {
}
}
}
{
int i;
int result;
int levels[] = {
};
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;
if (result == DEBUG_TEST_ERROR) {
}
}
}
{
int i;
int result;
int levels[] = {
};
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;
if (result == DEBUG_TEST_ERROR) {
}
}
}
{
int i;
int result;
int all_set = SSSDBG_MASK_ALL;
int levels[] = {
};
char *error_msg;
debug_timestamps = 0;
debug_microseconds = 0;
debug_to_file = 1;
debug_prg_name = "sssd";
for (i = 0; i <= 9; i++) {
errno = 0;
if (result == DEBUG_TEST_ERROR) {
}
"Test of level %#.4x failed - message has been written",
levels[i]);
}
}
{
int i;
int result;
int all_set = SSSDBG_MASK_ALL;
int levels[] = {
};
char *error_msg;
debug_timestamps = 0;
debug_microseconds = 0;
debug_to_file = 1;
debug_prg_name = "sssd";
for (i = 0; i <= 9; i++) {
errno = 0;
if (result == DEBUG_TEST_ERROR) {
}
"Test of level %#.4x failed - message has been written",
levels[i]);
}
}
{
int i;
int result;
int all_set = SSSDBG_MASK_ALL;
int levels[] = {
};
char *error_msg;
debug_timestamps = 0;
debug_microseconds = 1;
debug_to_file = 1;
debug_prg_name = "sssd";
for (i = 0; i <= 9; i++) {
errno = 0;
if (result == DEBUG_TEST_ERROR) {
}
"Test of level %#.4x failed - message has been written",
levels[i]);
}
}
{
int i;
int result;
int levels[] = {
};
for (i = 0; i <= 9; i++) {
}
}
{
int i;
int result;
int all_set = SSSDBG_MASK_ALL;
int levels[] = {
};
for (i = 0; i <= 9; i++) {
}
}
Suite *debug_suite(void)
{
suite_add_tcase(s, tc_debug);
return s;
}
{
int number_failed;
Suite *s = debug_suite();
if (number_failed == 0)
return EXIT_SUCCESS;
return EXIT_FAILURE;
}