tests: remove dependency on check package

Only check_parser depends on the check. Convert it. All tests will be
rewritten at once when new testsuite is implemented.
This commit is contained in:
Dmitry Podgorny
2016-09-15 12:42:45 +03:00
parent 4ef2740c36
commit f0706f56c4
3 changed files with 28 additions and 22 deletions

View File

@@ -81,9 +81,9 @@ TESTS = tests/check_parser tests/test_sha1 tests/test_md5 tests/test_rand \
check_PROGRAMS = $(TESTS)
tests_check_parser_SOURCES = tests/check_parser.c tests/test.h
tests_check_parser_CFLAGS = @check_CFLAGS@ $(PARSER_CFLAGS) $(STROPHE_FLAGS) \
tests_check_parser_CFLAGS = $(PARSER_CFLAGS) $(STROPHE_FLAGS) \
-I$(top_srcdir)/src
tests_check_parser_LDADD = @check_LIBS@ $(STROPHE_LIBS)
tests_check_parser_LDADD = $(STROPHE_LIBS)
tests_check_parser_LDFLAGS = -static
tests_test_ctx_SOURCES = tests/test_ctx.c

View File

@@ -22,9 +22,6 @@ AC_ARG_WITH([libxml2],
AC_ARG_ENABLE([tls],
[AS_HELP_STRING([--disable-tls], [disable TLS support])])
PKG_CHECK_MODULES([check], [check >= 0.9.4],
[], [AC_MSG_WARN([libcheck not found; unit tests will not be compilable])])
if test "x$enable_tls" != xno; then
PKG_CHECK_MODULES([openssl], [openssl],
[PC_REQUIRES="openssl ${PC_REQUIRES}"],

View File

@@ -10,27 +10,34 @@
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <check.h>
#include <strophe.h>
#include "strophe.h"
#include "parser.h"
#include "test.h"
START_TEST(create_destroy)
#define fail_unless(expr) do { \
int result = (expr); \
if (!result) { \
printf("%s:%d: Assertion failed: %s\n", \
__FILE__, __LINE__, #expr); \
exit(1); \
} \
} while (0)
static void create_destroy(void)
{
xmpp_ctx_t *ctx;
parser_t *parser;
ctx = xmpp_ctx_new(NULL, NULL);
parser = parser_new(ctx, NULL, NULL, NULL, NULL);
fail_unless(parser != NULL, "Parser creation failed.");
fail_unless(parser != NULL);
parser_free(parser);
xmpp_ctx_free(ctx);
}
END_TEST
int cbtest_got_start = 0;
void cbtest_handle_start(char *name, char **attrs, void *userdata)
@@ -53,7 +60,7 @@ void cbtest_handle_stanza(xmpp_stanza_t *stanza, void *userdata)
cbtest_got_stanza = 1;
}
START_TEST(callbacks)
static void callbacks(void)
{
xmpp_ctx_t *ctx;
parser_t *parser;
@@ -79,16 +86,18 @@ START_TEST(callbacks)
parser_free(parser);
xmpp_ctx_free(ctx);
}
END_TEST
Suite *parser_suite(void)
int main()
{
Suite *s = suite_create("Parser");
TCase *tc_core = tcase_create("Core");
tcase_add_test(tc_core, create_destroy);
tcase_add_test(tc_core, callbacks);
suite_add_tcase(s, tc_core);
return s;
}
printf("XML parser tests.\n");
TEST_MAIN
printf("create-destroy: ");
create_destroy();
printf("ok\n");
printf("callbacks: ");
callbacks();
printf("ok\n");
return 0;
}