MeshX 0.4
This repository provides an implementation for Bluetooth Low Energy (BLE) Mesh network nodes. The project allows you to create BLE mesh nodes that can communicate with each other, enabling the development of smart home solutions or other IoT-based applications.
Loading...
Searching...
No Matches
unit_test.h
Go to the documentation of this file.
1/**
2 * Copyright © 2024 - 2025 MeshX
3 *
4 * @file unit_test.h
5 * @brief Header file for the production console unit test functionality.
6 *
7 * This file contains the declarations and definitions for initializing the
8 * production console and registering unit test callbacks for different modules.
9 *
10 *
11 */
12#ifndef __MESHX_UNIT_TEST_H__
13#define __MESHX_UNIT_TEST_H__
14
15#include <stdio.h>
16#include <stdlib.h>
17#include <string.h>
19#include "argtable3/argtable3.h"
20#include "module_id.h"
21#include "meshx_err.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#if CONFIG_ENABLE_UNIT_TEST
28/**
29 * @brief Macro to extract an argument from the argument list.
30 */
31#define UT_GET_ARG(_x, _type, _argv) (_type) atoi( _argv [_x] )
32
33/**
34 * @brief Callback function for unit test modules.
35 *
36 * This function is used to define the callback function signature for unit test modules.
37 * The callback function is invoked when a unit test command is received by the production console.
38 *
39 * @param cmd_id The command ID to be processed.
40 * @param argc The number of arguments provided.
41 * @param argv The array of arguments.
42 *
43 * @return
44 * - MESHX_SUCCESS: Success
45 * - MESHX_INVALID_ARG: Invalid arguments
46 * - Other error codes depending on the implementation
47 */
48typedef meshx_err_t (*module_callback_t)(int cmd_id, int argc, char **argv);
49
50/**
51 * @brief Structure to hold the unit test callback function.
52 */
53typedef struct callback_node {
54 module_callback_t callback; /**< Callback function */
56
57/**
58 * @brief Registers the unit test (ut) command with the MeshX shell.
59 *
60 * This function creates a new shell command "ut" which is used for running unit tests.
61 *
62 * @return
63 * - MESHX_SUCCESS: Success
64 * - Other error codes: Failure
65 */
67
68/**
69 * @brief Initialize the unit test console.
70 *
71 * This function initializes the unit test console for the application using the underlying shell.
72 *
73 * @return
74 * - MESHX_SUCCESS: Success
75 * - MESHX_FAIL: Initialization failed
76 */
78
79/**
80 * @brief Register a unit test for a specific module.
81 *
82 * This function registers a unit test callback for the given module ID.
83 *
84 * @param[in] module_id The ID of the module for which the unit test is being registered.
85 * @param[in] callback The callback function to be called for the unit test.
86 *
87 * @return
88 * - MESHX_SUCCESS: Success
89 * - MESHX_INVALID_ARG: Invalid arguments
90 * - MESHX_FAIL: Failed to register the unit test
91 */
93
94#endif /* CONFIG_ENABLE_UNIT_TEST */
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif /* __MESHX_UNIT_TEST_H__ */
Internal configuration settings for MeshX.
MeshX Error Codes.
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:43
Defines module IDs for different elements in the BLE mesh node application.
module_id_t
Enumeration of module IDs.
Definition module_id.h:27
Structure to hold the unit test callback function.
Definition unit_test.h:53
module_callback_t callback
Definition unit_test.h:54
meshx_err_t register_ut_command()
Registers the unit test (ut) command with the MeshX shell.
Definition unit_test.c:84
meshx_err_t(* module_callback_t)(int cmd_id, int argc, char **argv)
Callback function for unit test modules.
Definition unit_test.h:48
meshx_err_t register_unit_test(module_id_t module_id, module_callback_t callback)
Register a unit test for a specific module.
Definition unit_test.c:137
struct callback_node unit_test_callback_t
Structure to hold the unit test callback function.
meshx_err_t init_unit_test_console(void)
Initialize the unit test console.
Definition unit_test.c:103