summaryrefslogtreecommitdiff
path: root/unsorted/ecore/efl_net_dialer_websocket_autobahntestee.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-08-09 16:21:58 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-08-09 16:21:58 -0400
commitd9bc92888a11c400320c2058b3500a248e220363 (patch)
tree223be84ba5f8c1c7a725c4cca7c96488090d29bd /unsorted/ecore/efl_net_dialer_websocket_autobahntestee.c
parent471e5a2e5ce40d56d4989a9f0d6b78e5a3df71f0 (diff)
examples
Diffstat (limited to 'unsorted/ecore/efl_net_dialer_websocket_autobahntestee.c')
-rw-r--r--unsorted/ecore/efl_net_dialer_websocket_autobahntestee.c709
1 files changed, 0 insertions, 709 deletions
diff --git a/unsorted/ecore/efl_net_dialer_websocket_autobahntestee.c b/unsorted/ecore/efl_net_dialer_websocket_autobahntestee.c
deleted file mode 100644
index fd0c098..0000000
--- a/unsorted/ecore/efl_net_dialer_websocket_autobahntestee.c
+++ /dev/null
@@ -1,709 +0,0 @@
1#include <Efl_Net.h>
2#include <Ecore_Getopt.h>
3#include <fcntl.h>
4#include <ctype.h>
5
6static char *address = NULL;
7static char *agent = "efl_net_dialer_websocket";
8static unsigned int start_index = 0;
9static unsigned int end_index = UINT32_MAX;
10static unsigned int current_index = 0;
11static Eina_Bool no_report_update = EINA_FALSE;
12static Eina_List *case_tuples = NULL;
13static Eina_Bool verbose = 0;
14
15static Eo *pending = NULL;
16
17/* https://www.w3.org/International/questions/qa-forms-utf-8 */
18static Eina_Bool
19_utf8_check(const char *text)
20{
21 const unsigned char * bytes = (const unsigned char *)text;
22 while (*bytes)
23 {
24 const unsigned char c = bytes[0];
25
26 /* ascii: [\x09\x0A\x0D\x20-\x7E] */
27 if (((c >= 0x20) && (c <= 0x7e)) ||
28 (c == 0x09) || (c == 0x0a) || (c == 0x0d))
29 {
30 bytes += 1;
31 continue;
32 }
33
34 /* autobahnsuite says 0x7f is valid */
35 if (c == 0x7f)
36 {
37 bytes += 1;
38 continue;
39 }
40
41#define VALUE_BYTE_CHECK(x) ((x >= 0x80) && (x <= 0xbf))
42
43 /* non-overlong 2-byte: [\xC2-\xDF][\x80-\xBF] */
44 if ((c >= 0xc2) && (c <= 0xdf))
45 {
46 if (VALUE_BYTE_CHECK(bytes[1]))
47 {
48 bytes += 2;
49 continue;
50 }
51 }
52
53 /* excluding overlongs: \xE0[\xA0-\xBF][\x80-\xBF] */
54 if (c == 0xe0)
55 {
56 const unsigned char d = bytes[1];
57 if ((d >= 0xa0) && (d <= 0xbf))
58 {
59 if (VALUE_BYTE_CHECK(bytes[2]))
60 {
61 bytes += 3;
62 continue;
63 }
64 }
65 }
66
67 /* straight 3-byte: [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} */
68 if (((c >= 0xe1) && (c <= 0xec)) ||
69 (c == 0xee) || (c == 0xef))
70 {
71 if (VALUE_BYTE_CHECK(bytes[1]) && VALUE_BYTE_CHECK(bytes[2]))
72 {
73 bytes += 3;
74 continue;
75 }
76 }
77
78 /* excluding surrogates: \xED[\x80-\x9F][\x80-\xBF] */
79 if (c == 0xed)
80 {
81 const unsigned char d = bytes[1];
82 if ((d >= 0x80) && (d <= 0x9f))
83 {
84 if (VALUE_BYTE_CHECK(bytes[2]))
85 {
86 bytes += 3;
87 continue;
88 }
89 }
90 }
91
92 /* planes 1-3: \xF0[\x90-\xBF][\x80-\xBF]{2} */
93 if (c == 0xf0)
94 {
95 const unsigned char d = bytes[1];
96 if ((d >= 0x90) && (d <= 0xbf))
97 {
98 if (VALUE_BYTE_CHECK(bytes[2]) && VALUE_BYTE_CHECK(bytes[3]))
99 {
100 bytes += 4;
101 continue;
102 }
103 }
104 }
105 /* planes 4-15: [\xF1-\xF3][\x80-\xBF]{3} */
106 if ((c >= 0xf1) && (c <= 0xf3))
107 {
108 if (VALUE_BYTE_CHECK(bytes[1]) && VALUE_BYTE_CHECK(bytes[2]) && VALUE_BYTE_CHECK(bytes[3]))
109 {
110 bytes += 4;
111 continue;
112 }
113 }
114
115 /* plane 16: \xF4[\x80-\x8F][\x80-\xBF]{2} */
116 if (c == 0xf4)
117 {
118 const unsigned char d = bytes[1];
119 if ((d >= 0x80) && (d <= 0x8f))
120 {
121 if (VALUE_BYTE_CHECK(bytes[2]) && VALUE_BYTE_CHECK(bytes[3]))
122 {
123 bytes += 4;
124 continue;
125 }
126 }
127 }
128
129 if (verbose) fprintf(stderr, "INFO: failed unicode byte #%zd '%s'\n", (const char*)bytes - text, text);
130 return EINA_FALSE;
131 }
132
133 return EINA_TRUE;
134}
135
136static void
137_ws_pong(void *data EINA_UNUSED, const Efl_Event *event)
138{
139 Eo *dialer = event->object;
140 const char *text = event->info;
141 if (!verbose) return;
142 fprintf(stderr, "INFO: %s got PONG: %s\n",
143 efl_name_get(dialer), text);
144}
145
146static void
147_ws_closed_reason(void *data EINA_UNUSED, const Efl_Event *event)
148{
149 Eo *dialer = event->object;
150 Efl_Net_Dialer_Websocket_Closed_Reason *reason = event->info;
151
152 if (!_utf8_check(reason->message))
153 {
154 efl_net_dialer_websocket_close_request(dialer, EFL_NET_DIALER_WEBSOCKET_CLOSE_REASON_PROTOCOL_ERROR, "invalid UTF-8");
155 if (verbose) fprintf(stderr, "INFO: %s got CLOSE with invalid UTF-8\n", efl_name_get(dialer));
156 }
157
158 if (!verbose) return;
159 fprintf(stderr, "INFO: %s got CLOSE: %4d '%s'\n",
160 efl_name_get(dialer), reason->reason, reason->message);
161}
162
163static void
164_ws_message_text(void *data EINA_UNUSED, const Efl_Event *event)
165{
166 Eo *dialer = event->object;
167 const char *text = event->info;
168
169 if (!verbose) return;
170 fprintf(stderr, "INFO: %s got TEXT %zd bytes:\n%s\n",
171 efl_name_get(dialer), strlen(text), text);
172}
173
174static void
175_ws_message_binary(void *data EINA_UNUSED, const Efl_Event *event)
176{
177 Eo *dialer = event->object;
178 const Eina_Slice *slice = event->info;
179 size_t i;
180
181 if (!verbose) return;
182 fprintf(stderr, "INFO: %s got BINARY %zd bytes\n",
183 efl_name_get(dialer), slice->len);
184
185 for (i = 0; i < slice->len; i++)
186 {
187 const int c = slice->bytes[i];
188 if (isprint(c))
189 fprintf(stderr, " %#4x(%c)", c, c);
190 else
191 fprintf(stderr, " %#4x", c);
192 }
193
194 fprintf(stderr, "\n");
195}
196
197static void
198_closed(void *data EINA_UNUSED, const Efl_Event *event)
199{
200 Eo *dialer = event->object;
201
202 if (!verbose) return;
203 fprintf(stderr, "INFO: %s closed\n", efl_name_get(dialer));
204}
205
206static void
207_eos(void *data EINA_UNUSED, const Efl_Event *event)
208{
209 Eo *dialer = event->object;
210
211 if (!verbose) return;
212 fprintf(stderr, "INFO: %s eos\n", efl_name_get(dialer));
213}
214
215static void
216_connected(void *data EINA_UNUSED, const Efl_Event *event)
217{
218 Eo *dialer = event->object;
219
220 if (!verbose) return;
221 fprintf(stderr, "INFO: %s connected %s\n",
222 efl_name_get(dialer),
223 efl_net_dialer_address_dial_get(dialer));
224}
225
226static void
227_error(void *data EINA_UNUSED, const Efl_Event *event)
228{
229 Eo *dialer = event->object;
230 const Eina_Error *perr = event->info;
231 fprintf(stderr, "ERROR: %s error: %d '%s'\n",
232 efl_name_get(dialer), *perr, eina_error_msg_get(*perr));
233 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
234}
235
236static void
237_del(void *data EINA_UNUSED, const Efl_Event *event)
238{
239 Eo *dialer = event->object;
240 if (pending == dialer)
241 pending = NULL;
242}
243
244EFL_CALLBACKS_ARRAY_DEFINE(dialer_cbs,
245 { EFL_NET_DIALER_WEBSOCKET_EVENT_PONG, _ws_pong },
246 { EFL_NET_DIALER_WEBSOCKET_EVENT_CLOSED_REASON, _ws_closed_reason },
247 { EFL_NET_DIALER_WEBSOCKET_EVENT_MESSAGE_TEXT, _ws_message_text },
248 { EFL_NET_DIALER_WEBSOCKET_EVENT_MESSAGE_BINARY, _ws_message_binary },
249 { EFL_NET_DIALER_EVENT_CONNECTED, _connected },
250 { EFL_NET_DIALER_EVENT_ERROR, _error },
251 { EFL_IO_CLOSER_EVENT_CLOSED, _closed },
252 { EFL_IO_READER_EVENT_EOS, _eos },
253 { EFL_EVENT_DEL, _del });
254
255static Eo *
256_websocket_new(const char *name, Eo *loop)
257{
258 Eo *dialer;
259
260 dialer = efl_add(EFL_NET_DIALER_WEBSOCKET_CLASS, loop,
261 efl_name_set(efl_added, name),
262 efl_event_callback_array_add(efl_added, dialer_cbs(), NULL));
263 if (!dialer)
264 {
265 efl_loop_quit(loop, eina_value_int_init(EXIT_FAILURE));
266 fprintf(stderr, "ERROR: could not create WebSockets dialer '%s'\n", name);
267 return NULL;
268 }
269
270 pending = dialer;
271
272 return dialer;
273}
274
275static void
276_closed_quit(void *data EINA_UNUSED, const Efl_Event *event)
277{
278 Eo *dialer = event->object;
279 efl_del(dialer);
280 ecore_main_loop_quit();
281}
282
283static void
284_tests_finished(Eo *loop)
285{
286 Eo *dialer;
287 char url[4096];
288 int len;
289 Eina_Error err;
290
291 if (no_report_update)
292 {
293 if (verbose)
294 fprintf(stderr, "INFO: tests finished, user required to not update the reports\n");
295 ecore_main_loop_quit();
296 return;
297 }
298
299 case_tuples = eina_list_remove(case_tuples, case_tuples);
300 len = snprintf(url, sizeof(url), "%s/updateReports?agent=%s",
301 address, agent);
302 if (len < 0)
303 {
304 fprintf(stderr, "ERROR: could not create URL "
305 "'%s/updateReports?agent=%s': %s",
306 address, agent, strerror(errno));
307 ecore_main_loop_quit();
308 return;
309 }
310 else if ((size_t)len > sizeof(url))
311 {
312 fprintf(stderr, "ERROR: could not create URL "
313 "'%s/updateReports?agent=%s': no space.",
314 address, agent);
315 ecore_main_loop_quit();
316 return;
317 }
318
319 dialer = _websocket_new("update-reports", loop);
320 if (!dialer)
321 {
322 ecore_main_loop_quit();
323 return;
324 }
325
326 efl_event_callback_add(dialer, EFL_IO_CLOSER_EVENT_CLOSED, _closed_quit, NULL);
327
328 err = efl_net_dialer_dial(dialer, url);
329 if (err != 0)
330 {
331 fprintf(stderr, "ERROR: could not dial '%s': %s",
332 url, eina_error_msg_get(err));
333 efl_del(dialer);
334 efl_loop_quit(loop, eina_value_int_init(EXIT_FAILURE));
335 return;
336 }
337
338 if (!verbose) return;
339 fprintf(stderr, "INFO: %s '%s'\n",
340 efl_name_get(dialer), efl_net_dialer_address_dial_get(dialer));
341}
342
343static void
344_echo_text(void *data EINA_UNUSED, const Efl_Event *event)
345{
346 Eo *dialer = event->object;
347 const char *text = event->info;
348
349 if (!_utf8_check(text))
350 {
351 if (verbose) fprintf(stderr, "INFO: invalid UTF-8 sequence '%s'. Close the connection.\n", text);
352 efl_net_dialer_websocket_close_request(dialer, EFL_NET_DIALER_WEBSOCKET_CLOSE_REASON_INCONSISTENT_DATA, "invalid UTF-8");
353 return;
354 }
355
356 efl_net_dialer_websocket_text_send(dialer, text);
357}
358
359static void
360_echo_binary(void *data EINA_UNUSED, const Efl_Event *event)
361{
362 Eo *dialer = event->object;
363 const Eina_Slice *slice = event->info;
364 efl_net_dialer_websocket_binary_send(dialer, *slice);
365}
366
367static Eina_Bool _websocket_test_next_case_tuple(Eo *loop);
368
369static void
370_test_next_case_closed(void *data EINA_UNUSED, const Efl_Event *event)
371{
372 Eo *dialer = event->object;
373 efl_del(dialer);
374
375 if (!_websocket_test_next_case_tuple(efl_loop_get(event->object)))
376 _tests_finished(efl_loop_get(event->object));
377}
378
379EFL_CALLBACKS_ARRAY_DEFINE(_test_next_case_tuple_cbs,
380 { EFL_NET_DIALER_WEBSOCKET_EVENT_MESSAGE_TEXT, _echo_text },
381 { EFL_NET_DIALER_WEBSOCKET_EVENT_MESSAGE_BINARY, _echo_binary },
382 { EFL_IO_CLOSER_EVENT_CLOSED, _test_next_case_closed });
383
384static Eina_Bool
385_websocket_test_next_case_tuple(Eo *loop)
386{
387 Eo *dialer;
388 char url[4096];
389 char name[256];
390 char *str;
391 int len;
392 Eina_Error err;
393
394 if (!case_tuples)
395 return EINA_FALSE;
396
397 str = case_tuples->data;
398 case_tuples = eina_list_remove_list(case_tuples, case_tuples);
399 len = snprintf(url, sizeof(url), "%s/runCase?casetuple=%s&agent=%s",
400 address, str, agent);
401 if (len < 0)
402 {
403 fprintf(stderr, "ERROR: could not create URL "
404 "'%s/runCase?casetuple=%s&agent=%s': %s",
405 address, str, agent, strerror(errno));
406 free(str);
407 return EINA_FALSE;
408 }
409 else if ((size_t)len > sizeof(url))
410 {
411 fprintf(stderr, "ERROR: could not create URL "
412 "'%s/runCase?casetuple=%s&agent=%s': no space.",
413 address, str, agent);
414 free(str);
415 return EINA_FALSE;
416 }
417
418 snprintf(name, sizeof(name), "test_case=%s", str);
419 free(str);
420
421 dialer = _websocket_new(name, loop);
422 if (!dialer) return EINA_FALSE;
423
424 efl_event_callback_array_add(dialer, _test_next_case_tuple_cbs(), NULL);
425
426 err = efl_net_dialer_dial(dialer, url);
427 if (err != 0)
428 {
429 fprintf(stderr, "ERROR: could not dial '%s': %s",
430 url, eina_error_msg_get(err));
431 efl_del(dialer);
432 efl_loop_quit(loop, eina_value_int_init(EXIT_FAILURE));
433 return EINA_FALSE;
434 }
435
436 fprintf(stderr, "TEST: %s '%s'\n", efl_name_get(dialer), efl_net_dialer_address_dial_get(dialer));
437
438 return EINA_TRUE;
439}
440
441static Eina_Bool _websocket_test_index(unsigned int idx, Eo *loop);
442
443static void
444_test_index_closed(void *data EINA_UNUSED, const Efl_Event *event)
445{
446 Eo *dialer = event->object;
447 efl_del(dialer);
448
449 if (!_websocket_test_index(current_index + 1, efl_loop_get(event->object)))
450 _tests_finished(efl_loop_get(event->object));
451}
452
453EFL_CALLBACKS_ARRAY_DEFINE(_test_index_cbs,
454 { EFL_NET_DIALER_WEBSOCKET_EVENT_MESSAGE_TEXT, _echo_text },
455 { EFL_NET_DIALER_WEBSOCKET_EVENT_MESSAGE_BINARY, _echo_binary },
456 { EFL_IO_CLOSER_EVENT_CLOSED, _test_index_closed });
457
458static Eina_Bool
459_websocket_test_index(unsigned int idx, Eo *loop)
460{
461 Eo *dialer;
462 char url[4096];
463 char name[64];
464 int len;
465 Eina_Error err;
466
467 if (idx > end_index)
468 return EINA_FALSE;
469
470 len = snprintf(url, sizeof(url), "%s/runCase?case=%u&agent=%s",
471 address, idx, agent);
472 if (len < 0)
473 {
474 fprintf(stderr, "ERROR: could not create URL "
475 "'%s/runCase?case=%u&agent=%s': %s",
476 address, idx, agent, strerror(errno));
477 return EINA_FALSE;
478 }
479 else if ((size_t)len > sizeof(url))
480 {
481 fprintf(stderr, "ERROR: could not create URL "
482 "'%s/runCase?case=%u&agent=%s': no space.",
483 address, idx, agent);
484 return EINA_FALSE;
485 }
486
487 snprintf(name, sizeof(name), "test_case=%u", idx);
488
489 dialer = _websocket_new(name, loop);
490 if (!dialer) return EINA_FALSE;
491
492 efl_event_callback_array_add(dialer, _test_index_cbs(), NULL);
493
494 err = efl_net_dialer_dial(dialer, url);
495 if (err != 0)
496 {
497 fprintf(stderr, "ERROR: could not dial '%s': %s",
498 url, eina_error_msg_get(err));
499 efl_del(dialer);
500 efl_loop_quit(loop, eina_value_int_init(EXIT_FAILURE));
501 return EINA_FALSE;
502 }
503
504 current_index = idx;
505
506 fprintf(stderr, "TEST: %s '%s'\n", efl_name_get(dialer), efl_net_dialer_address_dial_get(dialer));
507
508 return EINA_TRUE;
509}
510
511static void
512_load_tests_text(void *data EINA_UNUSED, const Efl_Event *event)
513{
514 const char *text = event->info;
515 unsigned int n = strtoul(text, NULL, 10);
516
517 if (start_index == 0)
518 start_index = 1;
519 else if (start_index > n)
520 start_index = n;
521
522 if (end_index == 0 || end_index > n)
523 end_index = n;
524
525 if (!verbose) return;
526 fprintf(stderr, "INFO: test count: %u, start_index=%u, end_index=%u\n",
527 n, start_index, end_index);
528}
529
530static void
531_load_tests_closed(void *data EINA_UNUSED, const Efl_Event *event)
532{
533 Eo *dialer = event->object;
534 efl_del(dialer);
535
536 if (!_websocket_test_index(start_index, efl_loop_get(event->object)))
537 _tests_finished(efl_loop_get(event->object));
538}
539
540EFL_CALLBACKS_ARRAY_DEFINE(_load_tests_cbs,
541 { EFL_NET_DIALER_WEBSOCKET_EVENT_MESSAGE_TEXT, _load_tests_text },
542 { EFL_IO_CLOSER_EVENT_CLOSED, _load_tests_closed });
543
544static Eina_Bool
545_websocket_load_tests(Eo *loop)
546{
547 Eo *dialer;
548 char url[4096];
549 int len;
550 Eina_Error err;
551
552 len = snprintf(url, sizeof(url), "%s/getCaseCount", address);
553 if (len < 0)
554 {
555 fprintf(stderr, "ERROR: could not create URL '%s/getCaseCount': %s",
556 address, strerror(errno));
557 return EINA_FALSE;
558 }
559 else if ((size_t)len > sizeof(url))
560 {
561 fprintf(stderr, "ERROR: could not create URL '%s/getCaseCount': no space.",
562 address);
563 return EINA_FALSE;
564 }
565
566 dialer = _websocket_new("get-case-count", loop);
567 if (!dialer) return EINA_FALSE;
568
569 efl_event_callback_array_add(dialer, _load_tests_cbs(), NULL);
570
571 err = efl_net_dialer_dial(dialer, url);
572 if (err != 0)
573 {
574 fprintf(stderr, "ERROR: could not dial '%s': %s",
575 url, eina_error_msg_get(err));
576 efl_del(dialer);
577 efl_loop_quit(loop, eina_value_int_init(EXIT_FAILURE));
578 return EINA_FALSE;
579 }
580
581 if (verbose) fprintf(stderr, "INFO: %s '%s'\n", efl_name_get(dialer), efl_net_dialer_address_dial_get(dialer));
582
583 return EINA_TRUE;
584}
585
586static const Ecore_Getopt options = {
587 "efl_net_dialer_websocket_autobahntestee", /* program name */
588 NULL, /* usage line */
589 "1", /* version */
590 "(C) 2016 Enlightenment Project", /* copyright */
591 "BSD 2-Clause", /* license */
592 /* long description, may be multiline and contain \n */
593 "Use Efl_Net_Dialer_Websocket to implement a testee client for the Autobahn Test Suite."
594 "\n"
595 "Autobahn Test Suite http://autobahn.ws/testsuite provides a fully automated test suite to verify client and server implementations of the WebSocket Protocol for specification conformance and implementation robustness."
596 "\n"
597 "This is a client to talk to their test server, that should be executed as:\n"
598 " wstest -m fuzzingserver\n"
599 "\n",
600 EINA_FALSE,
601 {
602 ECORE_GETOPT_STORE_UINT('s', "start-index", "when running batch, specifies the start (first) index"),
603 ECORE_GETOPT_STORE_UINT('e', "end-index", "when running batch, specifies the end (last) index"),
604 ECORE_GETOPT_STORE_TRUE('n', "no-report-update", "do not trigger autobahn to update report"),
605 ECORE_GETOPT_STORE_TRUE('v', "verbose", "print messages"),
606 ECORE_GETOPT_APPEND('t', "test-case", "the test-case tuple such as '1.2.8'", ECORE_GETOPT_TYPE_STR),
607 ECORE_GETOPT_STORE_STR('a', "agent", "the agent identifier"),
608 ECORE_GETOPT_VERSION('V', "version"),
609 ECORE_GETOPT_COPYRIGHT('C', "copyright"),
610 ECORE_GETOPT_LICENSE('L', "license"),
611 ECORE_GETOPT_HELP('h', "help"),
612 ECORE_GETOPT_STORE_METAVAR_STR(0, NULL,
613 "The address (URL) to dial, such as ws://127.0.0.1:9001", "address"),
614 ECORE_GETOPT_SENTINEL
615 }
616};
617
618EAPI_MAIN void
619efl_pause(void *data EINA_UNUSED,
620 const Efl_Event *ev EINA_UNUSED)
621{
622}
623
624EAPI_MAIN void
625efl_resume(void *data EINA_UNUSED,
626 const Efl_Event *ev EINA_UNUSED)
627{
628}
629
630EAPI_MAIN void
631efl_terminate(void *data EINA_UNUSED,
632 const Efl_Event *ev EINA_UNUSED)
633{
634 /* FIXME: For the moment the main loop doesn't get
635 properly destroyed on shutdown which disallow
636 relying on parent destroying their children */
637 if (pending)
638 {
639 efl_del(pending);
640 pending = NULL;
641 }
642 if (verbose) fprintf(stderr, "INFO: main loop finished.\n");
643}
644
645EAPI_MAIN void
646efl_main(void *data EINA_UNUSED,
647 const Efl_Event *ev)
648{
649 Eina_Bool quit_option = EINA_FALSE;
650 Ecore_Getopt_Value values[] = {
651 ECORE_GETOPT_VALUE_UINT(start_index),
652 ECORE_GETOPT_VALUE_UINT(end_index),
653 ECORE_GETOPT_VALUE_BOOL(no_report_update),
654 ECORE_GETOPT_VALUE_BOOL(verbose),
655 ECORE_GETOPT_VALUE_LIST(case_tuples),
656 ECORE_GETOPT_VALUE_STR(agent),
657
658 /* standard block to provide version, copyright, license and help */
659 ECORE_GETOPT_VALUE_BOOL(quit_option), /* -V/--version quits */
660 ECORE_GETOPT_VALUE_BOOL(quit_option), /* -C/--copyright quits */
661 ECORE_GETOPT_VALUE_BOOL(quit_option), /* -L/--license quits */
662 ECORE_GETOPT_VALUE_BOOL(quit_option), /* -h/--help quits */
663
664 /* positional argument */
665 ECORE_GETOPT_VALUE_STR(address),
666
667 ECORE_GETOPT_VALUE_NONE /* sentinel */
668 };
669 int args;
670 Eina_Bool r;
671
672 args = ecore_getopt_parse(&options, values, 0, NULL);
673 if (args < 0)
674 {
675 fputs("ERROR: Could not parse command line options.\n", stderr);
676 goto end;
677 }
678
679 if (quit_option) goto end;
680
681 args = ecore_getopt_parse_positional(&options, values, 0, NULL, args);
682 if (args < 0)
683 {
684 fputs("ERROR: Could not parse positional arguments.\n", stderr);
685 goto end;
686 }
687
688 if (case_tuples)
689 r = _websocket_test_next_case_tuple(ev->object);
690 else if (start_index == end_index)
691 r = _websocket_test_index(start_index, ev->object);
692 else
693 r = _websocket_load_tests(ev->object);
694
695 if (r)
696 {
697 ecore_main_loop_begin();
698 }
699
700 if (pending)
701 efl_del(pending);
702
703 return ;
704
705 end:
706 efl_loop_quit(efl_loop_get(ev->object), eina_value_int_init(EXIT_FAILURE));
707}
708
709EFL_MAIN_EX();