2 * basic test framework for echld
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * Copyright (c) 2013 by Luis Ontanon <luis@ontanon.org>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
49 #include <glib/gprintf.h>
51 #include "echld/echld.h"
52 #include "echld/echld-util.h"
54 #include "epan/epan.h"
55 #include "wsutil/str_util.h"
60 void ping_cb(long usec, void* data _U_) {
62 fprintf(stderr, "Ping ping=%d usec=%d\n", pings ,(int)usec );
73 void param_cb(const char* param, const char* value, const char* error, void* data _U_) {
75 fprintf(stderr, "Param Set Error msg=%s\n", error );
81 fprintf(stderr, "Param: param='%s' val='%s'\n", param, value );
85 int main(int argc _U_, char** argv _U_) {
95 echld_set_parent_dbg_level(5);
97 echld_initialize(ECHLD_ENCODING_JSON,argv[0],main);
100 if ( tot_cycles == 2 ) echld_ping(0,ping_cb,NULL);
102 if ( tot_cycles == 4 ) {
104 fprintf(stderr, "No Dispatcher PONG 0\n");
107 echld_ping(0,ping_cb,NULL);
110 if ( tot_cycles == 6 ) {
112 fprintf(stderr, "No Dispatcher PONG 1\n");
116 echld_set_param(0,"dbg_level","5",param_cb,NULL);
119 if ( tot_cycles == 8) {
121 fprintf(stderr, "Set Dispatcher Param Failed\n");
125 echld_get_param(0,"interfaces",param_cb,NULL);
128 if ( tot_cycles == 10) {
130 fprintf(stderr, "Set Dispatcher Param Failed\n");
134 child = echld_new(NULL);
136 fprintf(stderr, "New chld_id=%d\n",child);
139 fprintf(stderr, "No child\n");
145 if ( tot_cycles == 16 ) echld_ping(child,ping_cb,NULL);
147 if ( tot_cycles == 18 ) {
149 fprintf(stderr, "No Child PONG 0\n");
152 echld_ping(child,ping_cb,NULL);
157 if ( tot_cycles == 20 ) {
159 fprintf(stderr, "No Child PONG 1\n");
163 echld_set_param(child,"cookie","hello-hello",param_cb,NULL);
167 if ( tot_cycles == 22 ) {
169 fprintf(stderr, "Set Child Param Failed\n");
173 echld_get_param(child,"dbg_level",param_cb,NULL);
176 if ( tot_cycles == 24 ) {
178 fprintf(stderr, "Get Child Param Failed\n");
187 } while( keep_going && (tot_cycles < max_cycles));
189 fprintf(stderr, "Done: pings=%d errors=%d tot_cycles=%d\n", pings, errors ,tot_cycles );
196 void main_window_update(void) {}