5
5
* This library is free software; you can redistribute it and/or
6
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; version
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
10
* This library is distributed in the hope that it will be useful,
11
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
#ifndef _TESTS_SUPPORT_H
22
#define _TESTS_SUPPORT_H
22
25
#include <libsyncml/syncml.h>
23
26
#include <libsyncml/syncml_internals.h>
28
void configure_environment();
29
void cleanup_environment();
25
30
char *setup_testbed(char *fkt_name);
26
31
void destroy_testbed(char *path);
27
32
void create_case(Suite *s, const char *name, TFun function);
28
SmlParser *start_parser(const char *data);
33
SmlParser *start_parser(const char *data, SmlError **error);
34
int sml_sleep(int64_t nanoseconds);
36
#ifdef THREAD_SAFE_CHECK
38
#define sml_fail_unless(expr, ...);\
41
fail_unless(_result, ## __VA_ARGS__);\
42
if (!_result) smlAssertMsg(0, g_strdup_printf(__VA_ARGS__));\
47
/* If check is earlier than 0.9.7 then it is not thread safe. */
49
extern GStaticMutex __libsyncml_check_mutex;
51
#define sml_fail_unless(expr, ...);\
54
g_static_mutex_lock(&__libsyncml_check_mutex);\
55
fail_unless(_result, ## __VA_ARGS__);\
56
g_static_mutex_unlock(&__libsyncml_check_mutex);\
58
/* disabled to avoid unwanted aborts
59
* if (!_result) smlAssertMsg(0, g_strdup_printf(__VA_ARGS__));\
63
#endif /* THREAD_SAFE_CHECK */
65
/* setup test cases */
67
#define SML_TESTCASE_START(x) \
68
const char *_unittest = (#x); \
69
struct sml_testcase_s sml_testcase[] = {
71
#define SML_TESTCASE_ADD(x) { (#x), x },
73
#define SML_TESTCASE_END \
77
int main(int argc, char **argv) \
79
return sml_testsuite(argc, argv, _unittest, sml_testcase); \
82
struct sml_testcase_s {
92
struct sml_testcase_s *tc);
94
#endif // _TESTS_SUPPORT_H