]> git.sesse.net Git - vlc/blob - src/control/testapi.c
Put timeout to the testsuite
[vlc] / src / control / testapi.c
1 /*
2  * testapi.c - libvlc smoke test
3  *
4  * $Id$
5  */
6
7 /**********************************************************************
8  *  Copyright (C) 2007 RĂ©mi Denis-Courmont.                           *
9  *  This program is free software; you can redistribute and/or modify *
10  *  it under the terms of the GNU General Public License as published *
11  *  by the Free Software Foundation; version 2 of the license, or (at *
12  *  your option) any later version.                                   *
13  *                                                                    *
14  *  This program is distributed in the hope that it will be useful,   *
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of    *
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.              *
17  *  See the GNU General Public License for more details.              *
18  *                                                                    *
19  *  You should have received a copy of the GNU General Public License *
20  *  along with this program; if not, you can get it from:             *
21  *  http://www.gnu.org/copyleft/gpl.html                              *
22  **********************************************************************/
23
24 #include <vlc/libvlc.h>
25
26 #undef NDEBUG
27 #include <assert.h>
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <unistd.h>
32
33 static libvlc_exception_t ex;
34
35 static void catch (void)
36 {
37     if (libvlc_exception_raised (&ex))
38     {
39          fprintf (stderr, "Exception: %s\n",
40                   libvlc_exception_get_message (&ex));
41          abort ();
42     }
43
44     assert (libvlc_exception_get_message (&ex) == NULL);
45     libvlc_exception_clear (&ex);
46 }
47
48 int main (int argc, char *argv[])
49 {
50     libvlc_instance_t *vlc;
51     const char *args[argc + 3];
52
53     alarm (30); /* Make sure "make check" does not get stuck */
54
55     args[0] = "-vvv";
56     args[1] = "-I";
57     args[2] = "-dummy";
58     args[3] = "--plugin-path=..";
59     for (int i = 1; i < argc; i++)
60         args[i + 3] = argv[i];
61
62     libvlc_exception_init (&ex);
63     vlc = libvlc_new (sizeof (args) / sizeof (args[0]), args, &ex);
64     catch ();
65
66     libvlc_destroy (vlc, &ex);
67     catch ();
68     return 0;
69 }