Valgrind integration, refactor build process
[platform/upstream/libsecret.git] / egg / egg-testing.h
1 /*
2  * gnome-keyring
3  *
4  * Copyright (C) 2011 Stefan Walter
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General  License as
8  * published by the Free Software Foundation; either version 2.1 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General  License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General
17  * License along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19  * 02111-1307, USA.
20  *
21  * Author: Stef Walter <stefw@collabora.co.uk>
22  */
23
24 #ifndef EGG_TESTING_H_
25 #define EGG_TESTING_H_
26
27 #include <glib.h>
28 #include <string.h>
29
30 #define egg_assert_cmpsize(a, o, b) \
31         g_assert_cmpuint ((guint)(a), o, (guint)(b))
32
33 #define egg_assert_cmpmem(a, na, cmp, b, nb) \
34         do { gconstpointer __p1 = (a), __p2 = (b); gsize __n1 = (na), __n2 = (nb); \
35              if (__n1 cmp __n2 && memcmp (__p1, __p2, __n1) cmp 0) ; else \
36                 egg_assertion_message_cmpmem (G_LOG_DOMAIN, __FILE__, __LINE__, \
37                     G_STRFUNC, #a "[" #na"] " #cmp " " #b "[" #nb "]", \
38                     __p1, __n1, #cmp, __p2, __n2); } while (0)
39
40 #define egg_assert_not_object(p) \
41         (egg_assertion_not_object (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, #p, (p)))
42
43 void       egg_assertion_not_object          (const char *domain,
44                                               const char *file,
45                                               int         line,
46                                               const char *func,
47                                               const char *expr,
48                                               gpointer was_object);
49
50 void       egg_assertion_message_cmpmem        (const char *domain, const char *file,
51                                                 int line, const char *func,
52                                                 const char *expr, gconstpointer arg1,
53                                                 gsize n_arg1, const char *cmp,
54                                                 gconstpointer arg2, gsize n_arg2);
55
56 void       egg_test_wait_stop                  (void);
57
58 #define    egg_test_wait()                     g_assert (egg_test_wait_until (20000) != FALSE)
59
60 gboolean   egg_test_wait_until                 (int timeout);
61
62 gint       egg_tests_run_with_loop             (void);
63
64 #endif /* EGG_DH_H_ */