root/test/libvlc/test.h
| Revision eb5e7fb48e14a138a4e05c3672626995d58a90d0, 2.9 kB (checked in by Rémi Denis-Courmont <rdenis@simphalempin.com>, 4 months ago) | |
|---|---|
| |
| Line | |
|---|---|
| 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/vlc.h> |
| 36 | |
| 37 | #undef NDEBUG |
| 38 | #include <assert.h> |
| 39 | |
| 40 | #include <stdio.h> |
| 41 | #include <stdlib.h> |
| 42 | #include <stdbool.h> |
| 43 | #include <unistd.h> |
| 44 | |
| 45 | |
| 46 | /********************************************************************* |
| 47 | * Some useful global var |
| 48 | */ |
| 49 | static libvlc_exception_t ex; |
| 50 | |
| 51 | static const char * test_defaults_args[] = { |
| 52 | "-vvv", |
| 53 | "--ignore-config", |
| 54 | "-I", |
| 55 | "dummy", |
| 56 | "--no-media-library", |
| 57 | "--plugin-path=../modules", |
| 58 | "--vout=dummy", |
| 59 | "--aout=dummy" |
| 60 | }; |
| 61 | |
| 62 | static const int test_defaults_nargs = |
| 63 | sizeof (test_defaults_args) / sizeof (test_defaults_args[0]); |
| 64 | |
| 65 | static const char * test_default_sample = "samples/test.sample"; |
| 66 | |
| 67 | |
| 68 | /********************************************************************* |
| 69 | * Some useful common functions |
| 70 | */ |
| 71 | |
| 72 | #define log( ... ) printf( "testapi: " __VA_ARGS__ ); |
| 73 | |
| 74 | /* test if we have exception */ |
| 75 | static inline bool have_exception (void) |
| 76 | { |
| 77 | if (libvlc_exception_raised (&ex)) |
| 78 | { |
| 79 | libvlc_exception_clear (&ex); |
| 80 | return true; |
| 81 | } |
| 82 | else |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | static inline void catch (void) |
| 87 | { |
| 88 | if (libvlc_exception_raised (&ex)) |
| 89 | { |
| 90 | fprintf (stderr, "Exception: %s\n", |
| 91 | libvlc_exception_get_message (&ex)); |
| 92 | abort (); |
| 93 | } |
| 94 | |
| 95 | assert (libvlc_exception_get_message (&ex) == NULL); |
| 96 | libvlc_exception_clear (&ex); |
| 97 | } |
| 98 | |
| 99 | static inline void test_init (void) |
| 100 | { |
| 101 | (void)test_default_sample; /* This one may not be used */ |
| 102 | alarm (50); /* Make sure "make check" does not get stuck */ |
| 103 | } |
| 104 | |
| 105 | #endif /* TEST_H */ |
Note: See TracBrowser for help on using the browser.
