Imported Upstream version 3.2.0
[platform/upstream/libwebsockets.git] / include / libwebsockets / lws-test-sequencer.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010-2019 Andy Green <andy@warmcat.com>
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Lesser General Public
8  *  License as published by the Free Software Foundation:
9  *  version 2.1 of the License.
10  *
11  *  This library is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *  Lesser General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Lesser General Public
17  *  License along with this library; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  *  MA  02110-1301  USA
20  *
21  * included from libwebsockets.h
22  *
23  * lws_test_sequencer manages running an array of unit tests.
24  */
25
26 typedef void (*lws_test_sequence_cb)(const void *cb_user);
27
28 typedef struct lws_test_sequencer_args {
29         lws_abs_t               *abs; /* abstract protocol + unit test txport */
30         lws_unit_test_t *tests; /* array of lws_unit_test_t */
31         int                     *results; /* takes result dispositions */
32         int                     results_max; /* max space usable in results */
33         int                     *count_tests; /* count of done tests */
34         int                     *count_passes; /* count of passed tests */
35         lws_test_sequence_cb    cb; /* completion callback */
36         void                    *cb_user; /* opaque user ptr given to cb */
37 } lws_test_sequencer_args_t;
38
39 /**
40  * lws_abs_unit_test_sequencer() - helper to sequence multiple unit tests
41  *
42  * \param args: lws_test_sequencer_args_t prepared with arguments for the tests
43  *
44  * This helper sequences one or more unit tests to run and collects the results.
45  *
46  * The incoming abs should be set up for the abstract protocol you want to test
47  * and the lws unit-test transport.
48  *
49  * Results are one of
50  *
51  *      LPE_SUCCEEDED
52  *      LPE_FAILED
53  *      LPE_FAILED_UNEXPECTED_TIMEOUT
54  *      LPE_FAILED_UNEXPECTED_PASS
55  *      LPE_FAILED_UNEXPECTED_CLOSE
56  *
57  * The callback args->cb is called when the tests have been done.
58  */
59 LWS_VISIBLE LWS_EXTERN int
60 lws_abs_unit_test_sequencer(const lws_test_sequencer_args_t *args);