2 * libusb test library helper functions
3 * Copyright © 2012 Toby Gray <toby.gray@realvnc.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef LIBUSB_TESTLIB_H
21 #define LIBUSB_TESTLIB_H
25 /** Values returned from a test function to indicate test result */
27 /** Indicates that the test ran successfully. */
29 /** Indicates that the test failed one or more test. */
31 /** Indicates that an unexpected error occurred. */
33 /** Indicates that the test can't be run. For example this may be
34 * due to no suitable device being connected to perform the tests. */
36 } libusb_testlib_result;
39 * Logs some test information or state
41 void libusb_testlib_logf(const char *fmt, ...) PRINTF_FORMAT(1, 2);
44 * Structure holding a test description.
47 /** Human readable name of the test. */
49 /** The test library will call this function to run the test.
51 * Should return TEST_STATUS_SUCCESS on success or another TEST_STATUS value.
53 libusb_testlib_result (*function)(void);
54 } libusb_testlib_test;
57 * Value to use at the end of a test array to indicate the last
60 #define LIBUSB_NULL_TEST { NULL, NULL }
63 * Runs the tests provided.
65 * Before running any tests argc and argv will be processed
66 * to determine the mode of operation.
68 * \param argc The argc from main
69 * \param argv The argv from main
70 * \param tests A NULL_TEST terminated array of tests
71 * \return 0 on success, non-zero on failure
73 int libusb_testlib_run_tests(int argc, char *argv[],
74 const libusb_testlib_test *tests);
76 #endif //LIBUSB_TESTLIB_H