testapi.c 2.11 KB
Newer Older
1
/*
2
 * testapi.c - libvlc smoke test
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *
 * $Id$
 */

/**********************************************************************
 *  Copyright (C) 2007 Rémi Denis-Courmont.                           *
 *  This program is free software; you can redistribute and/or modify *
 *  it under the terms of the GNU General Public License as published *
 *  by the Free Software Foundation; version 2 of the license, or (at *
 *  your option) any later version.                                   *
 *                                                                    *
 *  This program is distributed in the hope that it will be useful,   *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of    *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.              *
 *  See the GNU General Public License for more details.              *
 *                                                                    *
 *  You should have received a copy of the GNU General Public License *
 *  along with this program; if not, you can get it from:             *
 *  http://www.gnu.org/copyleft/gpl.html                              *
 **********************************************************************/

24
#include <vlc/libvlc.h>
25
26

#undef NDEBUG
27
28
#include <assert.h>

29
30
#include <stdio.h>
#include <stdlib.h>
31
#include <unistd.h>
32

33
static libvlc_exception_t ex;
34

35
36
37
38
39
40
41
42
static void catch (void)
{
    if (libvlc_exception_raised (&ex))
    {
         fprintf (stderr, "Exception: %s\n",
                  libvlc_exception_get_message (&ex));
         abort ();
    }
43

44
45
46
    assert (libvlc_exception_get_message (&ex) == NULL);
    libvlc_exception_clear (&ex);
}
47

48
49
50
51
int main (int argc, char *argv[])
{
    libvlc_instance_t *vlc;
    const char *args[argc + 3];
52

53
54
55
56
57
    alarm (30); /* Make sure "make check" does not get stuck */

    args[0] = "-vvv";
    args[1] = "-I";
    args[2] = "-dummy";
58
59
60
    args[3] = "--plugin-path=..";
    for (int i = 1; i < argc; i++)
        args[i + 3] = argv[i];
61

62
63
64
    libvlc_exception_init (&ex);
    vlc = libvlc_new (sizeof (args) / sizeof (args[0]), args, &ex);
    catch ();
65

66
67
    libvlc_destroy (vlc, &ex);
    catch ();
68
69
    return 0;
}