]> git.sesse.net Git - vlc/blob - src/control/testapi.c
96887baab39762cb5f163a026e981c6872bbdfca
[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
32 static libvlc_exception_t ex;
33
34 static void catch (void)
35 {
36     if (libvlc_exception_raised (&ex))
37     {
38          fprintf (stderr, "Exception: %s\n",
39                   libvlc_exception_get_message (&ex));
40          abort ();
41     }
42
43     assert (libvlc_exception_get_message (&ex) == NULL);
44     libvlc_exception_clear (&ex);
45 }
46
47 int main (int argc, char *argv[])
48 {
49     libvlc_instance_t *vlc;
50     const char *args[argc + 3];
51
52     args[0] = "-I";
53     args[1] = "dummy";
54     args[2] = "-vvv";
55     args[3] = "--plugin-path=..";
56     for (int i = 1; i < argc; i++)
57         args[i + 3] = argv[i];
58
59     libvlc_exception_init (&ex);
60     vlc = libvlc_new (sizeof (args) / sizeof (args[0]), args, &ex);
61     catch ();
62
63     libvlc_destroy (vlc, &ex);
64     catch ();
65     return 0;
66 }