]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/commitdiff
Updated list of stations test
authorTuka Martin <tukamart@fel.cvut.cz>
Thu, 14 Apr 2011 23:52:48 +0000 (01:52 +0200)
committerTuka Martin <tukamart@fel.cvut.cz>
Thu, 14 Apr 2011 23:52:48 +0000 (01:52 +0200)
Changed structure so test program runs
as a client (fwp_mngr is a server)
Added function for list printing in forb_wifi_agent
interface

src/fwp/fwp/mngr/Makefile.omk
src/fwp/fwp/mngr/test/Makefile.omk
src/fwp/fwp/mngr/test/list_of_stations_test.c
src/fwp/fwp/mngr/test/list_of_stations_test.sh
src/fwp/fwp/mngr/wifi_agent.c
src/fwp/fwp/mngr/wifi_agent_idl.idl
src/fwp/fwp/wifi_agent/wifi_agent_idl.idl

index ce2bfe44a1890945a3fd7ff3926d93b2c907b15f..1470ee501fc72a48972784c2924de836fe0e955d 100644 (file)
@@ -1,6 +1,5 @@
-shared_LIBRARIES += wifi_agent_functions
-wifi_agent_functions_SOURCES = wifi_agent.c
-wifi_agent_functions_SERVER_IDL = wifi_agent_idl.idl
+shared_LIBRARIES += wifi_agent_client_functions
+wifi_agent_client_functions_CLIENT_IDL = wifi_agent_idl.idl
 include_HEADERS = wifi_agent.h
 include_GEN_HEADERS = wifi_agent_idl.h
 
@@ -9,10 +8,12 @@ fwp_admctrl_SOURCES = fwp_admctrl.c
 include_HEADERS = fwp_admctrl.h
 
 bin_PROGRAMS = frm_fwp
-frm_fwp_SOURCES = fwp_mngr.c
-frm_fwp_LIBS = frm forb contract fosa rt ulut wifi_agent_functions fwp_admctrl
-
+frm_fwp_SOURCES = fwp_mngr.c wifi_agent.c
 include_HEADERS = wifi_agent.h
+frm_fwp_SERVER_IDL = wifi_agent_idl.idl
+include_GEN_HEADERS = wifi_agent_idl.h
+frm_fwp_LIBS = frm forb contract fosa rt ulut fwp_admctrl fcb_client
+
 CFLAGS += -D_FWP_INTERNALS_
 lib_LOADLIBES+= frsh forb fosa pthread rt ulut
 
index 45af892e7fe4ab2d923d5ef6d3b04775a46c7839..2d783d2f72a42b16bdc8de5d0d634e91aa32f9f5 100644 (file)
@@ -8,5 +8,5 @@ fwp_adm_test_LIBS += frm forb frsh contract pthread fosa rt ulut fwp_admctrl wvt
 wvtest_SCRIPTS += list_of_stations_test.sh
 test_PROGRAMS += list_of_stations_test
 list_of_stations_test_SOURCES = list_of_stations_test.c
-list_of_stations_test_LIBS += wvtest forb ulut wifi_agent_functions
+list_of_stations_test_LIBS += wvtest forb ulut wifi_agent_client_functions
 
index b7e7cea8b6263ac20a78bbf597901d275cc69b11..e4efd1c7acbfa00b4bcd2ba87db07bc595d9233e 100644 (file)
 #include "wifi_agent.h"
 #include "wvtest.h"
 
-typedef struct fwp_sta {
-       long long client_mac_addr;
-       int rate;       //mbps
-       bool erp_ofdm;
-       bool short_preamble;
-       bool bypass;
-       ul_list_node_t sta_node;        
-} fwp_sta_t;
-
-typedef struct fwp_sta_list {
-       ul_list_head_t requests;
-} fwp_sta_list_t;
-
-struct frm_fwp_priv {
-       int rate_mbps;
-       bool erp_ofdm;
-       bool short_preamble;
-       bool bypass;
-       fwp_sta_list_t sta_list;
-};
-
-UL_LIST_CUST_DEC(sta_list, // cust_prefix
-                fwp_sta_list_t, // cust_head_t
-                fwp_sta_t, // cust_item_t
-                requests, // cust_head_field
-                sta_node); // cust_node_field
-
-struct forb_wifi_agent_idl_impl wifi_agent_impl;
-
-struct frm_fwp_priv priv = {
-       .rate_mbps = 1,
-       .erp_ofdm = false,
-       .short_preamble = false,
-//     .list_head = NULL,//head of linked list initialized in main function
-};
-
 //WVTEST_MAIN("list-of-stations-test")
 int main(void)
 {
-       forb_orb orb;
-       int ret;
-       bool opt_daemon = false;
-       char *opt_pidfile = NULL;
-
-       forb_executor_t executor;
-
-       wifi_agent_idl wai;     //wifi agent interface
-       struct fwp_sta intern_data;
-       CORBA_Environment env;
-
-       if (getenv("FWP_BYPASS"))
-               priv.bypass = true;
-
-       if (opt_daemon)
-               forb_daemon_prepare(opt_pidfile);
-
-       orb = forb_init(NULL, NULL, NULL);
-       if (!orb) return 1;
+       forb_orb fwp_orb;
+        wifi_agent_idl wai;
+        CORBA_Environment env;
        
-        wai = forb_wifi_agent_idl_new(orb, &wifi_agent_impl, &intern_data);
-        
-        forb_register_reference(wai, "net.sourceforge.frsh-forb.wai");
-
-       sta_list_init_head(&priv.sta_list);
-       
-       ret = forb_executor_init(&executor);
-       if (ret) return 1;
-       
-       ret = forb_executor_register_object(&executor, wai);
-       if (ret) return 1;
-
-       wifi_agent_idl_add(wai, 10, 120976291, &env);
-       wifi_agent_idl_add(wai, 12, 120976291, &env);
-       wifi_agent_idl_add(wai, 20, 80976291, &env);
-       //wifi_agent_idl_add(wai, 64, 80955472, &env);
-       //wifi_agent_idl_add(wai, 1, 80976291, &env);
-       //wifi_agent_idl_add(wai, 10, 120976291, &env);         
+       fwp_orb = forb_init(NULL, NULL, NULL); /* FORB initialization */
+
+       /* Find our implementation */
+        wai = forb_resolve_reference(fwp_orb, "net.sourceforge.frsh-forb.wai");
+       if(wai == NULL)
+               fprintf(stderr, "failed to create connection\n");       
+       if(wai != NULL)
+       {
+               wifi_agent_idl_add(wai, 10, 120976291, &env);   //new station
+               wifi_agent_idl_print_state(wai, &env);
+               wifi_agent_idl_add(wai, 12, 120976291, &env);   //changed rate
+               wifi_agent_idl_add(wai, 21, 80976291, &env);    //new station
+               wifi_agent_idl_print_state(wai, &env);
+               wifi_agent_idl_add(wai, 64, 80976291, &env);    //changed rate
+               wifi_agent_idl_add(wai, 64, 80945292, &env);    //new station
+               wifi_agent_idl_print_state(wai, &env);
+       }
        
        return 0;
 }
index 504569738468a8eccb4cfe43a1000e7cc4ef042c..9d2cd7c5f360aed951df267e4de37ba74c312a09 100755 (executable)
@@ -10,27 +10,26 @@ wvtest_cleanup() {
 WVPASS fcb -dfcb.pid
 
 cat > expected << EOF
-Added new station
-Actual list of all stations
-[mac address (dec) - rate]
+Actual list of stations
 120976291 - 10
 ------------
 
-Changed rate in a station 120976291
-Actual list of all stations
-[mac address (dec) - rate]
+Actual list of stations
 120976291 - 12
+80976291 - 21
 ------------
 
-Added new station
-Actual list of all stations
-[mac address (dec) - rate]
+Actual list of stations
 120976291 - 12
-80976291 - 20
+80976291 - 64
+80945292 - 64
 ------------
 
 EOF
 
-WVPASS sh -c "list_of_stations_test > actual"
+#TODO: Synchronize processes for correct output
+WVPASS sh -c "frm_fwp > actual"
+WVPASS list_of_stations_test
 WVPASS diff -u expected actual
 
+
index 69c9ed17b27f1eacaa11824b3afbc064023135dc..2e3ed27a714659101b9aae5f53bc9b2a5398c3bb 100644 (file)
@@ -1,4 +1,3 @@
-
 #include <frm_generic.h>
 #include <forb.h>
 #include <error.h>
 #include "fwp_admctrl.h"
 
 struct forb_wifi_agent_idl_impl wifi_agent_impl = {
-       .add = wifi_agent_idl_add, 
+       .add = wifi_agent_idl_add,
+       .print_state = wifi_agent_idl_print_state,
 };
 
-void print_list_of_stations(void)
+/**
+ *     Print list of stored stations
+ */
+void wifi_agent_idl_print_state(wifi_agent_idl _obj, CORBA_Environment *ev)
 {
        fwp_sta_t *sta2;
 
+       printf("Actual list of stations\n");
        ul_list_for_each(sta_list, &priv.sta_list, sta2){
                printf("%llu -", sta2->client_mac_addr);        
                printf(" %d\n", sta2->rate);
        }
        printf("------------\n\n");
-       
 }
 
 /**
@@ -54,10 +57,6 @@ CORBA_long wifi_agent_idl_add(wifi_agent_idl _obj, const CORBA_long rate, const
                if(sta->client_mac_addr == ed->client_mac_addr) {
                        //mac address is the same change only rate
                        sta->rate = ed->rate;
-       
-                       printf("Changed rate in a station %d\n", sta->client_mac_addr);
-                       printf("Actual list of all stations\n[mac address (dec) - rate]\n");
-                       print_list_of_stations();
 
                        return 0;
                }
@@ -68,10 +67,6 @@ CORBA_long wifi_agent_idl_add(wifi_agent_idl _obj, const CORBA_long rate, const
        
        sta_list_ins_tail(&priv.sta_list, new_to_add);
 
-       printf("Added new station\n");
-       printf("Actual list of all stations\n[mac address (dec) - rate]\n");
-       print_list_of_stations();
-
        return 0;
 }
 
index f4cb868b2f56fbc8124bbaae6c61f92b34293034..9838ab047bf67a0a723ceccff1dd9e01b8971126 100644 (file)
@@ -5,5 +5,6 @@ struct fwp_sta {
 
 interface wifi_agent_idl {
         long add(in long rate, in long long client_mac_addr);
+       void print_state();
         //void get_last(out long rate, out string client_mac_addr);
 };
index f4cb868b2f56fbc8124bbaae6c61f92b34293034..9838ab047bf67a0a723ceccff1dd9e01b8971126 100644 (file)
@@ -5,5 +5,6 @@ struct fwp_sta {
 
 interface wifi_agent_idl {
         long add(in long rate, in long long client_mac_addr);
+       void print_state();
         //void get_last(out long rate, out string client_mac_addr);
 };