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:
@@ -81,9 +81,9 @@ TESTS = tests/check_parser tests/test_sha1 tests/test_md5 tests/test_rand \
|
|||||||
check_PROGRAMS = $(TESTS)
|
check_PROGRAMS = $(TESTS)
|
||||||
|
|
||||||
tests_check_parser_SOURCES = tests/check_parser.c tests/test.h
|
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
|
-I$(top_srcdir)/src
|
||||||
tests_check_parser_LDADD = @check_LIBS@ $(STROPHE_LIBS)
|
tests_check_parser_LDADD = $(STROPHE_LIBS)
|
||||||
tests_check_parser_LDFLAGS = -static
|
tests_check_parser_LDFLAGS = -static
|
||||||
|
|
||||||
tests_test_ctx_SOURCES = tests/test_ctx.c
|
tests_test_ctx_SOURCES = tests/test_ctx.c
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ AC_ARG_WITH([libxml2],
|
|||||||
AC_ARG_ENABLE([tls],
|
AC_ARG_ENABLE([tls],
|
||||||
[AS_HELP_STRING([--disable-tls], [disable TLS support])])
|
[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
|
if test "x$enable_tls" != xno; then
|
||||||
PKG_CHECK_MODULES([openssl], [openssl],
|
PKG_CHECK_MODULES([openssl], [openssl],
|
||||||
[PC_REQUIRES="openssl ${PC_REQUIRES}"],
|
[PC_REQUIRES="openssl ${PC_REQUIRES}"],
|
||||||
|
|||||||
@@ -10,27 +10,34 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <check.h>
|
#include "strophe.h"
|
||||||
|
|
||||||
#include <strophe.h>
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
#include "test.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;
|
xmpp_ctx_t *ctx;
|
||||||
parser_t *parser;
|
parser_t *parser;
|
||||||
|
|
||||||
ctx = xmpp_ctx_new(NULL, NULL);
|
ctx = xmpp_ctx_new(NULL, NULL);
|
||||||
parser = parser_new(ctx, NULL, NULL, NULL, NULL);
|
parser = parser_new(ctx, NULL, NULL, NULL, NULL);
|
||||||
fail_unless(parser != NULL, "Parser creation failed.");
|
fail_unless(parser != NULL);
|
||||||
parser_free(parser);
|
parser_free(parser);
|
||||||
xmpp_ctx_free(ctx);
|
xmpp_ctx_free(ctx);
|
||||||
}
|
}
|
||||||
END_TEST
|
|
||||||
|
|
||||||
int cbtest_got_start = 0;
|
int cbtest_got_start = 0;
|
||||||
void cbtest_handle_start(char *name, char **attrs, void *userdata)
|
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;
|
cbtest_got_stanza = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(callbacks)
|
static void callbacks(void)
|
||||||
{
|
{
|
||||||
xmpp_ctx_t *ctx;
|
xmpp_ctx_t *ctx;
|
||||||
parser_t *parser;
|
parser_t *parser;
|
||||||
@@ -79,16 +86,18 @@ START_TEST(callbacks)
|
|||||||
parser_free(parser);
|
parser_free(parser);
|
||||||
xmpp_ctx_free(ctx);
|
xmpp_ctx_free(ctx);
|
||||||
}
|
}
|
||||||
END_TEST
|
|
||||||
|
|
||||||
Suite *parser_suite(void)
|
int main()
|
||||||
{
|
{
|
||||||
Suite *s = suite_create("Parser");
|
printf("XML parser tests.\n");
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_MAIN
|
printf("create-destroy: ");
|
||||||
|
create_destroy();
|
||||||
|
printf("ok\n");
|
||||||
|
|
||||||
|
printf("callbacks: ");
|
||||||
|
callbacks();
|
||||||
|
printf("ok\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user