~ubuntu-branches/ubuntu/precise/libsyncml/precise

« back to all changes in this revision

Viewing changes to tests/support.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2010-01-24 21:29:53 UTC
  • mfrom: (1.1.3 upstream) (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100124212953-klvyvldqkp4px1j3
Tags: 0.5.4-2
* Upload to unstable.
* debian/control (Standards-Version): Bumped to 3.8.3.
* debian/control (Build-Depends): Bump required debhelper version to 7.0.0.
* debian/compat: Set to 7.
* debian/rules (install): Replace call to dh_clean -k with dh_prep.
* debian/control (libsyncml2-dbg): Set section to debug.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 *
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 
8
 
 * 2.1 of the License.
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
9
9
 *
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
18
18
 *
19
19
 */
20
20
 
 
21
#ifndef _TESTS_SUPPORT_H
 
22
#define _TESTS_SUPPORT_H
 
23
 
21
24
#include <check.h>
22
25
#include <libsyncml/syncml.h>
23
26
#include <libsyncml/syncml_internals.h>
24
27
 
 
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);
 
35
 
 
36
#ifdef THREAD_SAFE_CHECK
 
37
 
 
38
        #define sml_fail_unless(expr, ...);\
 
39
                {\
 
40
                        int _result = expr;\
 
41
                        fail_unless(_result, ## __VA_ARGS__);\
 
42
                        if (!_result) smlAssertMsg(0, g_strdup_printf(__VA_ARGS__));\
 
43
                }
 
44
 
 
45
#else
 
46
 
 
47
        /* If check is earlier than 0.9.7 then it is not thread safe. */
 
48
 
 
49
        extern GStaticMutex __libsyncml_check_mutex;
 
50
 
 
51
        #define sml_fail_unless(expr, ...);\
 
52
                {\
 
53
                        int _result = expr;\
 
54
                        g_static_mutex_lock(&__libsyncml_check_mutex);\
 
55
                        fail_unless(_result, ## __VA_ARGS__);\
 
56
                        g_static_mutex_unlock(&__libsyncml_check_mutex);\
 
57
                }
 
58
                        /* disabled to avoid unwanted aborts
 
59
                         * if (!_result) smlAssertMsg(0, g_strdup_printf(__VA_ARGS__));\
 
60
                         */
 
61
 
 
62
        
 
63
#endif /* THREAD_SAFE_CHECK */
 
64
 
 
65
/* setup test cases */
 
66
 
 
67
#define SML_TESTCASE_START(x)   \
 
68
        const char *_unittest = (#x);   \
 
69
        struct sml_testcase_s sml_testcase[] = {
 
70
 
 
71
#define SML_TESTCASE_ADD(x) { (#x), x },
 
72
 
 
73
#define SML_TESTCASE_END                        \
 
74
        { NULL, NULL }                          \
 
75
        };                                      \
 
76
                                                \
 
77
int main(int argc, char **argv)                 \
 
78
{                                               \
 
79
        return sml_testsuite(argc, argv, _unittest, sml_testcase);      \
 
80
}
 
81
 
 
82
struct sml_testcase_s {
 
83
        const char *name;
 
84
        void *func;
 
85
};
 
86
 
 
87
 
 
88
int sml_testsuite(
 
89
                int argc,
 
90
                char **argv,
 
91
                const char *unittest,
 
92
                struct sml_testcase_s *tc);
 
93
 
 
94
#endif // _TESTS_SUPPORT_H