xrdp/tests/common/test_common_main.c

77 lines
1.7 KiB
C
Raw Normal View History

2021-03-29 00:55:19 +03:00
#if defined(HAVE_CONFIG_H)
#include "config_ac.h"
#endif
#include <stdio.h>
2021-03-29 00:55:19 +03:00
#include <stdlib.h>
2022-01-20 19:44:49 +03:00
#include "log.h"
#include "ssl_calls.h"
2021-03-29 00:55:19 +03:00
#include "test_common.h"
2022-01-27 19:23:51 +03:00
/**
* Converts a binary buffer to a hexadecimal representation
*
* Result must be free'd after use
*/
char *
bin_to_hex(const char *input, int length)
{
int i;
char *result = (char *)malloc(length * 2 + 1);
if (result != NULL)
{
char *p = result;
const char *hexdigit = "0123456789abcdef";
for (i = 0 ; i < length ; ++i)
{
int c = input[i];
if (c < 0)
{
c += 256;
}
*p++ = hexdigit[ c / 16];
*p++ = hexdigit[ c % 16];
}
*p = '\0';
}
return result;
}
2021-03-29 00:55:19 +03:00
int main (void)
{
int number_failed;
SRunner *sr;
2023-02-09 19:16:04 +03:00
sr = srunner_create (make_suite_test_list());
srunner_add_suite(sr, make_suite_test_string());
2021-09-06 07:41:49 +03:00
srunner_add_suite(sr, make_suite_test_os_calls());
2022-01-20 19:44:49 +03:00
srunner_add_suite(sr, make_suite_test_ssl_calls());
2022-01-27 19:23:51 +03:00
srunner_add_suite(sr, make_suite_test_base64());
srunner_add_suite(sr, make_suite_test_guid());
2021-03-29 00:55:19 +03:00
srunner_set_tap(sr, "-");
2022-01-20 19:44:49 +03:00
/*
* Set up console logging */
struct log_config *lc = log_config_init_for_console(LOG_LEVEL_INFO, NULL);
log_start_from_param(lc);
log_config_free(lc);
/* Disable stdout buffering, as this can confuse the error
* reporting when running in libcheck fork mode */
setvbuf(stdout, NULL, _IONBF, 0);
2022-01-20 19:44:49 +03:00
/* Initialise the ssl module */
ssl_init();
2021-03-29 00:55:19 +03:00
srunner_run_all (sr, CK_ENV);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
2022-01-20 19:44:49 +03:00
ssl_finish();
log_end();
2021-03-29 00:55:19 +03:00
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}