summaryrefslogtreecommitdiff
path: root/test_commands.h
blob: e7498d0d6216945a925194a1f0e92a2dda729e13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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 */