]> git.sesse.net Git - vlc/blob - src/control/testapi.c
21d28692f83fd2a5b502290636660b54f08b9996
[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     int id;
53
54     alarm (30); /* Make sure "make check" does not get stuck */
55
56     args[0] = "-vvv";
57     args[1] = "-I";
58     args[2] = "-dummy";
59     args[3] = "--plugin-path=../modules";
60     for (int i = 1; i < argc; i++)
61         args[i + 3] = argv[i];
62
63     libvlc_exception_init (&ex);
64     vlc = libvlc_new (sizeof (args) / sizeof (args[0]), args, &ex);
65     catch ();
66
67     libvlc_playlist_clear (vlc, &ex);
68     catch ();
69
70     id = libvlc_playlist_add_extended (vlc, "/dev/null", "Test", 0, NULL,
71                                        &ex);
72     catch ();
73
74     libvlc_playlist_clear (vlc, &ex);
75     catch ();
76
77     libvlc_destroy (vlc, &ex);
78     catch ();
79     return 0;
80 }