summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/bin/CMakeLists.txt11
-rw-r--r--src/bin/edbg_checker.c191
3 files changed, 76 insertions, 130 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4b8866d..d850b25 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,10 @@ cmake_minimum_required(VERSION 2.8.1)
2 2
3project(EDBG_CHECKER) 3project(EDBG_CHECKER)
4 4
5find_package(Elementary REQUIRED)
5find_package(Eina REQUIRED) 6find_package(Eina REQUIRED)
6find_package(Eet REQUIRED) 7find_package(Eet REQUIRED)
7find_package(Edebug REQUIRED) 8find_package(Efreet REQUIRED)
9find_package(Ecore REQUIRED)
8 10
9add_subdirectory(src/bin) 11add_subdirectory(src/bin)
diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt
index 776f7af..6b4a19a 100644
--- a/src/bin/CMakeLists.txt
+++ b/src/bin/CMakeLists.txt
@@ -2,18 +2,25 @@ set(CMAKE_BUILD_TYPE Debug)
2 2
3LIST(APPEND SOURCES edbg_checker.c) 3LIST(APPEND SOURCES edbg_checker.c)
4 4
5link_directories (${PC_LIBELEMENTARY_LIBRARY_DIRS})
6
5include_directories( 7include_directories(
8 ${ELEMENTARY_INCLUDE_DIRS}
6 ${EINA_INCLUDE_DIRS} 9 ${EINA_INCLUDE_DIRS}
7 ${EET_INCLUDE_DIRS} 10 ${EET_INCLUDE_DIRS}
8 ${EDEBUG_INCLUDE_DIRS} 11 ${EFREET_INCLUDE_DIRS}
12 ${ECORE_INCLUDE_DIRS}
9 ) 13 )
10 14
11add_executable(edbg_checker ${SOURCES}) 15add_executable(edbg_checker ${SOURCES})
12 16
13target_link_libraries(edbg_checker 17target_link_libraries(edbg_checker
14 ${EINA_LIBRARIES} 18 ${EINA_LIBRARIES}
19 ${EFREET_LIBRARIES}
20 ${ECORE_LIBRARIES}
15 ${EET_LIBRARIES} 21 ${EET_LIBRARIES}
16 ${EDEBUG_LIBRARIES} 22 ${EFREET_LIBRARIES}
23 ecore_file
17 ) 24 )
18 25
19install(TARGETS edbg_checker DESTINATION bin) 26install(TARGETS edbg_checker DESTINATION bin)
diff --git a/src/bin/edbg_checker.c b/src/bin/edbg_checker.c
index 6a9f1b2..952ba07 100644
--- a/src/bin/edbg_checker.c
+++ b/src/bin/edbg_checker.c
@@ -1,73 +1,51 @@
1#define EFL_BETA_API_SUPPORT
2#include <getopt.h>
3
4#include <Efreet.h>
1#include <Eina.h> 5#include <Eina.h>
2#include <Eet.h> 6#include <Eet.h>
7#include <Ecore_File.h>
3 8
4#define _PROFILE_EET_ENTRY "config"
5#define BUFFER_SIZE 1000000 9#define BUFFER_SIZE 1000000
6 10
7typedef enum 11typedef enum
8{ 12{
9 CLOUSEAU_PROFILE_LOCAL = 1, 13 OFFLINE = 0,
10 CLOUSEAU_PROFILE_SHELL_REMOTE 14 LOCAL_CONNECTION,
11} Clouseau_Profile_Type; 15 REMOTE_CONNECTION,
12 16 LAST_CONNECTION
13typedef struct 17} Connection_Type;
14{
15 const char *name;
16 const char *command;
17 const char *script;
18 Clouseau_Profile_Type type;
19} Clouseau_Profile;
20static Eet_Data_Descriptor *_profile_edd = NULL;
21 18
22static Eina_Debug_Session *_session = NULL; 19static Eina_Debug_Session *_session = NULL;
23static Eina_Debug_Client *_client = NULL;
24 20
25static int _remaining_tests = 1000; 21static int _remaining_tests = 1000;
26static int _pattern_size; 22static int _pattern_size = 8000;
27static char _pattern_buf[BUFFER_SIZE]; 23static char _pattern_buf[BUFFER_SIZE];
28 24
29static uint32_t _data_test_opcode = EINA_DEBUG_OPCODE_INVALID; 25static int _data_test_opcode = EINA_DEBUG_OPCODE_INVALID;
30
31static void
32_profile_eet_load()
33{
34 if (_profile_edd) return;
35 Eet_Data_Descriptor_Class eddc;
36
37 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Clouseau_Profile);
38 _profile_edd = eet_data_descriptor_stream_new(&eddc);
39
40#define CFG_ADD_BASIC(member, eet_type)\
41 EET_DATA_DESCRIPTOR_ADD_BASIC\
42 (_profile_edd, Clouseau_Profile, # member, member, eet_type)
43
44 CFG_ADD_BASIC(name, EET_T_STRING);
45 CFG_ADD_BASIC(command, EET_T_STRING);
46 CFG_ADD_BASIC(script, EET_T_STRING);
47 CFG_ADD_BASIC(type, EET_T_INT);
48
49#undef CFG_ADD_BASIC
50}
51 26
52static void 27static void
53_pattern_generate() 28_pattern_generate()
54{ 29{
55 int i; 30 int i;
56 if (!_remaining_tests--) exit(0); 31 if (!_remaining_tests--) exit(0);
32#if 0
57 do 33 do
58 { 34 {
59 _pattern_size = rand() % BUFFER_SIZE; 35 _pattern_size = rand() % BUFFER_SIZE;
60 } while(!_pattern_size); 36 } while(!_pattern_size);
37#endif
38 _pattern_size += 1000;
61 printf("Generating pattern: size %d\n", _pattern_size); 39 printf("Generating pattern: size %d\n", _pattern_size);
62 for (i = 0; i < _pattern_size; i++) 40 for (i = 0; i < _pattern_size; i++)
63 { 41 {
64 _pattern_buf[i] = rand() % 256; 42 _pattern_buf[i] = rand() % 256;
65 } 43 }
66 eina_debug_session_send(_client, _data_test_opcode, _pattern_buf, _pattern_size); 44 eina_debug_session_send(_session, 0, _data_test_opcode, _pattern_buf, _pattern_size);
67} 45}
68 46
69static Eina_Bool 47static Eina_Bool
70_pattern_check_cb(Eina_Debug_Client *src EINA_UNUSED, void *buffer, int size) 48_pattern_check_cb(Eina_Debug_Session *session EINA_UNUSED, int cid EINA_UNUSED, void *buffer, int size)
71{ 49{
72 if (_pattern_size != size) 50 if (_pattern_size != size)
73 { 51 {
@@ -88,113 +66,72 @@ _pattern_check_cb(Eina_Debug_Client *src EINA_UNUSED, void *buffer, int size)
88} 66}
89 67
90static void 68static void
91_post_register_handle(Eina_Bool flag) 69_post_register_handle(void *data EINA_UNUSED, Eina_Bool flag)
92{ 70{
71 static Eina_Bool old = EINA_FALSE;
72 if (flag == old) return;
73 old = flag;
93 if(!flag) return; 74 if(!flag) return;
94 _client = eina_debug_client_new(_session, 0);
95 _pattern_generate(); 75 _pattern_generate();
96} 76}
97 77
98static Eina_List *
99_parse_script(const char *script)
100{
101 Eina_List *lines = NULL;
102 while (script && *script)
103 {
104 char *tmp = strchr(script, '\n');
105 Eina_Stringshare *line;
106 if (tmp)
107 {
108 line = eina_stringshare_add_length(script, tmp - script);
109 script = tmp + 1;
110 }
111 else
112 {
113 line = eina_stringshare_add(script);
114 script = NULL;
115 }
116 lines = eina_list_append(lines, line);
117 }
118 return lines;
119}
120
121static Clouseau_Profile *
122_config_load(const char *path)
123{
124 Eet_File *file = eet_open(path, EET_FILE_MODE_READ);
125 if (!file) return EINA_FALSE;
126 Clouseau_Profile *p = eet_data_read(file, _profile_edd, _PROFILE_EET_ENTRY);
127 eet_close(file);
128 return p;
129}
130
131static const Eina_Debug_Opcode ops[] = 78static const Eina_Debug_Opcode ops[] =
132{ 79{
133 {"daemon/data_test", &_data_test_opcode, _pattern_check_cb}, 80 {"Test/data_loop", &_data_test_opcode, _pattern_check_cb},
134 {NULL, NULL, NULL} 81 {NULL, NULL, NULL}
135}; 82};
136 83
137static Eina_Bool
138_profile_load(Clouseau_Profile *p)
139{
140 _session = eina_debug_session_new();
141
142 switch (p->type)
143 {
144 case CLOUSEAU_PROFILE_LOCAL:
145 if (!eina_debug_local_connect(_session))
146 {
147 fprintf(stderr, "ERROR: Cannot connect to debug daemon.\n");
148 return EINA_FALSE;
149 }
150 break;
151 case CLOUSEAU_PROFILE_SHELL_REMOTE:
152 eina_debug_session_basic_codec_add(_session, EINA_DEBUG_CODEC_BASE_16);
153 Eina_List *script_lines = _parse_script(p->script);
154 if (!eina_debug_shell_remote_connect(_session, p->command, script_lines))
155 {
156 fprintf(stderr, "ERROR: Cannot connect to shell remote debug daemon.\n");
157 return EINA_FALSE;
158 }
159 break;
160 default:
161 {
162 printf("Profile type %d not supported\n", p->type);
163 return EINA_FALSE;
164 }
165 }
166
167 eina_debug_opcodes_register(_session, ops, _post_register_handle);
168 return EINA_TRUE;
169}
170
171int main(int argc, char **argv) 84int main(int argc, char **argv)
172{ 85{
173 int error = 1; 86 int long_index = 0, opt;
174 eina_debug_reconnect_set(EINA_FALSE); /* No need to connect as an application*/ 87 Eina_Bool help = EINA_FALSE;
88
175 eina_init(); 89 eina_init();
176 eet_init(); 90 eet_init();
177 _profile_eet_load(); 91
178 if (argc < 2) 92 static struct option long_options[] =
179 { 93 {
180 fprintf(stderr, "Path to profile is required\n"); 94 /* These options set a flag. */
181 goto end; 95 {"help", no_argument, 0, 'h'},
96 {"local", no_argument, 0, 'l'},
97 {"remote", required_argument, 0, 'r'},
98 {0, 0, 0, 0}
99 };
100 while ((opt = getopt_long(argc, argv,"hlr:", long_options, &long_index )) != -1)
101 {
102 switch (opt) {
103 case 0: break;
104 case 'l':
105 {
106 _session = eina_debug_local_connect(EINA_TRUE);
107 break;
108 }
109 case 'r':
110 {
111 int port = atoi(optarg);
112 _session = eina_debug_remote_connect(port);
113 break;
114 }
115 case 'h': help = EINA_TRUE; break;
116 default: help = EINA_TRUE;
117 }
182 } 118 }
183 119 if (help || !_session)
184 const char *path = argv[1];
185
186 Clouseau_Profile *p = _config_load(path);
187 if (!p)
188 { 120 {
189 fprintf(stderr, "Incorrect path (%s) or bad contents\n", path); 121 printf("Usage: %s [-h/--help] [-v/--verbose] [options]\n", argv[0]);
190 goto end; 122 printf(" --help/-h Print that help\n");
123 printf(" --local/-l Create a local connection\n");
124 printf(" --remote/-r Create a remote connection by using the given profile name\n");
125 return 0;
191 } 126 }
192 _profile_load(p); 127
193 while(1) sleep(10); 128 eina_debug_opcodes_register(_session, ops, _post_register_handle, NULL);
194 error = 0; 129
195end: 130 while (1) sleep(10);
131
132 eina_debug_session_terminate(_session);
196 eet_shutdown(); 133 eet_shutdown();
197 eina_shutdown(); 134 eina_shutdown();
198 exit(error); 135 return 0;
199} 136}
200 137