1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <inttypes.h>
20 #include <lk/compiler.h>
21 #include <stdbool.h>
22 #include <trusty_ipc.h>
23 
24 #define PORT_TEST(suite_name, port_name_string)           \
25     __BEGIN_CDECLS                                        \
26     static bool run_##suite_name(struct unittest* test) { \
27         return RUN_ALL_TESTS();                           \
28     }                                                     \
29                                                           \
30     int main(void) {                                      \
31         static struct unittest test = {                   \
32                 .port_name = port_name_string,            \
33                 .run_test = run_##suite_name,             \
34         };                                                \
35         struct unittest* tests = &test;                   \
36         return unittest_main(&tests, 1);                  \
37     }                                                     \
38     __END_CDECLS
39 
40 __BEGIN_CDECLS
41 
42 struct unittest {
43     const char* port_name;
44     bool (*run_test)(struct unittest* test);
45     handle_t _port_handle;
46 };
47 
48 int unittest_main(struct unittest** tests, size_t test_count);
49 
50 __END_CDECLS
51