1/* 2 * Copyright 2017, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12 13#pragma once 14 15/* Include Kconfig variables. */ 16#include <autoconf.h> 17#include <sel4test/gen_config.h> 18#include <sel4test/testutil.h> 19 20#define SEL4TEST_PRINT_BUFFER 200 21 22/** 23 * When running a test suite, we want to output any output from the suite in a 24 * <stdout></stdout> section. But for debugging we do not want this. Therefore 25 * you should *disable* CONFIG_PRINT_XML while debugging tests. 26 */ 27#ifdef CONFIG_PRINT_XML 28#include <stdio.h> 29#define printf(x, ...) do {\ 30 char buffer[SEL4TEST_PRINT_BUFFER];\ 31 snprintf(buffer, SEL4TEST_PRINT_BUFFER, x, ##__VA_ARGS__);\ 32 sel4test_printf(buffer);\ 33} while(0) 34#endif /* CONFIG_PRINT_XML */ 35 36#define sel4test_case_with_message(condition, message) do {\ 37 if(!(condition)) {\ 38 sel4test_report_error(message);\ 39 }\ 40} while(0) 41/** 42 * Like an assert but does not crash the build. 43 */ 44#define sel4test_case(condition) do {\ 45 if(!(condition)) {\ 46 sel4test_report_error("");\ 47 }\ 48} while(0) 49 50/** 51 * Report an error in the test 52 */ 53#define sel4test_report_error(x) _sel4test_report_error(x, __FILE__, __LINE__) 54 55/** 56 * Report a failure in the test 57 */ 58#define sel4test_failure(x) _sel4test_failure(x, __FILE__, __LINE__) 59