]> git.sesse.net Git - vlc/blob - test/libvlc/test.h
Merge branch 'master' of git@git.videolan.org:vlc
[vlc] / test / libvlc / test.h
1 /*
2  * test.h - libvlc smoke test common definitions
3  *
4  * $Id$
5  */
6
7 /**********************************************************************
8  *  Copyright (C) 2007 RĂ©mi Denis-Courmont.                           *
9  *  Copyright (C) 2008 Pierre d'Herbemont.                            *
10  *  This program is free software; you can redistribute and/or modify *
11  *  it under the terms of the GNU General Public License as published *
12  *  by the Free Software Foundation; version 2 of the license, or (at *
13  *  your option) any later version.                                   *
14  *                                                                    *
15  *  This program is distributed in the hope that it will be useful,   *
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of    *
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.              *
18  *  See the GNU General Public License for more details.              *
19  *                                                                    *
20  *  You should have received a copy of the GNU General Public License *
21  *  along with this program; if not, you can get it from:             *
22  *  http://www.gnu.org/copyleft/gpl.html                              *
23  **********************************************************************/
24
25 #ifndef TEST_H
26 #define TEST_H
27
28 /*********************************************************************
29  * Some useful common headers
30  */
31
32 #ifdef HAVE_CONFIG_H
33 # include "config.h"
34 #endif
35 #include <vlc/libvlc.h>
36
37 #undef NDEBUG
38 #include <assert.h>
39
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <unistd.h>
43
44
45 /*********************************************************************
46  * Some useful global var
47  */
48 static libvlc_exception_t ex;
49
50 static const char * test_defaults_args[] = {
51     "-vvv",
52     "--ignore-config",
53     "-I",
54     "dummy",
55     "--plugin-path=../modules",
56     "--vout=dummy",
57     "--aout=dummy"
58 };
59
60 static const int test_defaults_nargs =
61     sizeof (test_defaults_args) / sizeof (test_defaults_args[0]);
62
63 static const char * test_default_sample = "samples/test.sample";
64
65
66 /*********************************************************************
67  * Some useful common functions
68  */
69
70 #define log( ... ) printf( "testapi: " __VA_ARGS__ );
71
72 /* test if we have exception */
73 static inline bool have_exception (void)
74 {
75     if (libvlc_exception_raised (&ex))
76     {
77         libvlc_exception_clear (&ex);
78         return true;
79     }
80     else
81         return false;
82 }
83
84 static inline void catch (void)
85 {
86     if (libvlc_exception_raised (&ex))
87     {
88          fprintf (stderr, "Exception: %s\n",
89                   libvlc_exception_get_message (&ex));
90          abort ();
91     }
92
93     assert (libvlc_exception_get_message (&ex) == NULL);
94     libvlc_exception_clear (&ex);
95 }
96
97 static inline void test_init (void)
98 {
99     (void)test_default_sample; /* This one may not be used */
100     alarm (50); /* Make sure "make check" does not get stuck */
101 }
102
103 #endif /* TEST_H */