Morse Micro IoT SDK  2.9.7
porting_assistant.h
1/*
2 * Copyright 2023 Morse Micro
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#pragma once
7
8#include <stdlib.h>
9#include <stdint.h>
10
11#include "mmosal.h"
12
13#include "config.h"
14#include "log.h"
15
16#ifndef PACKED
17#define PACKED __attribute__((packed))
18#endif
19
20/* Enumeration of result codes that can be returned by a test. */
21enum test_result
22{
23 TEST_NO_RESULT,
24 TEST_PASSED,
25 TEST_SKIPPED,
26 TEST_FAILED,
27 TEST_FAILED_NON_CRITICAL,
28};
29
32{
34 const char *description;
36 enum test_result (*exec)(char *log_buf, size_t log_buf_len);
37};
38
39#define TEST_STEP(name, description) \
40 static enum test_result name##_exec(char *log_buf, size_t log_buf_len); \
41 const struct test_step name = { description, name##_exec }; \
42 static enum test_result name##_exec(char *log_buf, size_t log_buf_len)
43
44#define TEST_LOG_APPEND(fstr, ...) \
45 do { \
46 int len = snprintf(log_buf, log_buf_len, fstr, ##__VA_ARGS__); \
47 if (len > 0 && (int)log_buf_len >= len) { \
48 log_buf += len; \
49 log_buf_len -= len; \
50 } \
51 } while (0)
Test step descriptor.
const char * description
Short, user friendly description of the test step.
enum test_result(* exec)(char *log_buf, size_t log_buf_len)
Test step execution function.