2 * libusbx 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 LIBUSBX_TESTLIB_H
21 #define LIBUSBX_TESTLIB_H
35 /** Values returned from a test function to indicate test result */
37 /** Indicates that the test ran successfully. */
39 /** Indicates that the test failed one or more test. */
41 /** Indicates that an unexpected error occurred. */
43 /** Indicates that the test can't be run. For example this may be
44 * due to no suitable device being connected to perform the tests.*/
46 } libusbx_testlib_result
;
49 * Context for test library functions
59 } libusbx_testlib_ctx
;
62 * Logs some test information or state
64 void libusbx_testlib_logf(libusbx_testlib_ctx
* ctx
,
65 const char* fmt
, ...);
68 * Function pointer for a libusbx test function.
70 * Should return TEST_STATUS_SUCCESS on success or another TEST_STATUS value.
72 typedef libusbx_testlib_result
73 (*libusbx_testlib_test_function
)(libusbx_testlib_ctx
* ctx
);
76 * Structure holding a test description.
79 /** Human readable name of the test. */
81 /** The test library will call this function to run the test. */
82 libusbx_testlib_test_function function
;
83 } libusbx_testlib_test
;
86 * Value to use at the end of a test array to indicate the last
89 #define LIBUSBX_NULL_TEST {NULL, NULL}
92 * Runs the tests provided.
94 * Before running any tests argc and argv will be processed
95 * to determine the mode of operation.
97 * \param argc The argc from main
98 * \param argv The argv from main
99 * \param tests A NULL_TEST terminated array of tests
100 * \return 0 on success, non-zero on failure
102 int libusbx_testlib_run_tests(int argc
,
104 const libusbx_testlib_test
* tests
);
106 #endif //LIBUSBX_TESTLIB_H