k_test.h
Go to the documentation of this file.
1 /*
2  * KubOS Core Flight Services
3  * Copyright (C) 2016 Kubos Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef K_TEST_H
19 #define K_TEST_H
20 
21 #ifdef TARGET_LIKE_FREERTOS
22 #include "FreeRTOS.h"
23 #include "kubos-hal/uart.h"
24 
25 #define K_TEST_MAIN() \
26 static int __test_result = -1; \
27 static int __test_main (void); \
28 static void __test_task (void *p) { \
29  __test_result = __test_main(); \
30  vTaskDelete(NULL); \
31 } \
32 static int __test_main (void)
33 
34 #define K_TEST_RUN_MAIN() do { \
35  k_uart_console_init(); \
36  xTaskCreate(__test_task, "TESTS", configMINIMAL_STACK_SIZE * 4, NULL, 2, NULL); \
37  vTaskStartScheduler(); \
38  return __test_result; \
39 } while(0)
40 #else
41 #define K_TEST_MAIN() static int __test_main(void)
42 #define K_TEST_RUN_MAIN() return __test_main()
43 #endif
44 
45 #endif