diff options
Diffstat (limited to 'test_commands.h')
-rw-r--r-- | test_commands.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test_commands.h b/test_commands.h new file mode 100644 index 0000000..e7498d0 --- /dev/null +++ b/test_commands.h @@ -0,0 +1,72 @@ +/* ------------------------------------------------------------------ + * test_commands.h + * Defines commands and structures of testing. + * ----------------------------------------------------------------*/ + +#ifndef STM_TEST_COMMANDS_H +#define STM_TEST_COMMANDS_H + +#include <stdio.h> +#include <stdbool.h> + +#define STM_TEST_DEBUG +#ifdef STM_TEST_DEBUG +#define TDBG printf +#else +#define TDBG +#endif + +#define MAX_COMMAND_NAME_LENGTH (16) +#define MAX_SHELL_COMMAND_LINE_SIZE (100) +#define MAX_CONFIG_NAME_LENGTH (100) +#define MAX_SIZE_STM_REQUEST (4096) /* maximum 4k for a read of <debugfs>/stm/request + * should be enough, and is double checked in code + * as well. */ + +/* external functions */ +extern int stm_create_channel(); +extern int stm_create_channel_sync_verify(); +extern int stm_info(); +extern int stm_info_sync_verify(); +extern int search_file(const char* path, const char* name); + +typedef struct command_list { + char command_name[MAX_COMMAND_NAME_LENGTH]; + int (*command_consumer_callback) (); + bool is_sync; + bool is_async; + int (*sync_verification_callback) (); + int (*async_verification_callback) (); +} command_list; + +typedef struct command_result_type { + command_list* current_command; /* pointer to current command in command_list */ + int sequencial_id; /* command sequencial id */ + int command_execution_result; /* this is direct result returned by command execution */ + int sync_veri_result; /* this is result returned by sync verificaiton callback */ + int async_veri_result; /* this is result returned by async verification callback */ + void* private_data; /* this is private data, which is meaningful to specific command */ +} command_result_type; + +#define COMMAND_EXEC_SUCCESS (0) +#define COMMAND_EXEC_FAILURE (-1) +#define VERIFICATION_FAILURE (-100) +#define VERIFICATION_SUCCESS (0) +#define SYNC_VERIFICATION_SUCCESS VERIFICATION_SUCCESS +#define ASYNC_VERIFICATION_SUCCESS VERIFICATION_SUCCESS +#define SYNC_VERIFICATION_FAILURE VERIFICATION_FAILURE +#define ASYNC_VERIFICATION_FAILURE VERIFICATION_FAILURE + + +static inline void INIT_COMMAND_RESULT(command_result_type *ptr_command_result) +{ + ptr_command_result->current_command = NULL; + ptr_command_result->sequencial_id = -1; + ptr_command_result->command_execution_result = COMMAND_EXEC_FAILURE; + ptr_command_result->sync_veri_result = SYNC_VERIFICATION_FAILURE; + ptr_command_result->async_veri_result = ASYNC_VERIFICATION_FAILURE; + ptr_command_result->private_data = NULL; +} + + +#endif /* STM_TEST_COMMANDS_H */ |