[netperf-dev] netperf4 commit notice r214 -
branches/gobject_migration/src
raj at netperf.org
raj at netperf.org
Tue Mar 13 17:04:04 PST 2007
Author: raj
Date: 2007-03-13 17:04:03 -0800 (Tue, 13 Mar 2007)
New Revision: 214
Modified:
branches/gobject_migration/src/netperf-test.c
branches/gobject_migration/src/netperf4.c
Log:
more baby steps, still wondering about the control connection
Modified: branches/gobject_migration/src/netperf-test.c
===================================================================
--- branches/gobject_migration/src/netperf-test.c 2007-03-13 22:07:41 UTC (rev 213)
+++ branches/gobject_migration/src/netperf-test.c 2007-03-14 01:04:03 UTC (rev 214)
@@ -42,11 +42,17 @@
#include <stdlib.h>
#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <glib-object.h>
+#include <glib.h>
+#include <gmodule.h>
#include "netperf.h"
#include "netperf-test.h"
@@ -473,14 +479,169 @@
failure etc. */
}
+static int get_test_function(NetperfTest *test, const xmlChar *func)
+{
+ GModule *lib_handle = test->library_handle;
+ gboolean ret;
+ xmlChar *fname;
+ void *fptr = NULL;
+ int fnlen = 0;
+ int rc = NPE_FUNC_NAME_TOO_LONG;
+ char func_name[NETPERF_MAX_TEST_FUNCTION_NAME];
+ xmlChar *la_file;
+
+ /* should this be global debug, or test->debug? */
+ if (test->debug) {
+ g_fprintf(test->where,
+ "%s enter test %p func %s\n",
+ __func__,
+ test,
+ func);
+ fflush(test->where);
+ }
+
+ if (lib_handle == NULL) {
+ /* load the library for the test */
+ la_file = xmlGetProp(test->node,(const xmlChar *)"library");
+ if (test->debug) {
+ g_fprintf(test->where,
+ "%s looking to open library %p\n",
+ __func__,
+ la_file);
+ fflush(test->where);
+ }
+
+ lib_handle = open_library(la_file);
+ free(la_file);
+ test->library_handle = lib_handle;
+ }
+
+ fname = xmlGetProp(test->node,func);
+ if (!fname) {
+ fnlen = 0;
+ }
+ else {
+ fnlen = strlen((char *)fname);
+ }
+ if (test->debug) {
+ if (fname) {
+ g_fprintf(test->where,"func = '%s' fname = '%s' fname[0] = %c fnlen = %d\n",
+ (char *)func, fname, fname[0], fnlen);
+ }
+ else {
+ g_fprintf(test->where,"func = '%s' fname = '' fname[0] = '' fnlen = %d\n",
+ (char *)func, fnlen);
+ }
+ fflush(test->where);
+ }
+
+ if (fnlen < NETPERF_MAX_TEST_FUNCTION_NAME) {
+ if (fnlen) {
+ strcpy(func_name,(char *)fname);
+ rc = NPE_SUCCESS;
+ } else {
+ xmlChar *tname = test->test_name;
+ int tnlen = strlen((char *)tname);
+
+ strcpy(func_name,(char *)tname);
+ if (test->debug) {
+ g_fprintf(test->where,"func_name = '%s' tnlen = %d\n",
+ (char *)func_name, tnlen);
+ fflush(test->where);
+ }
+
+ if (!xmlStrcmp(func,(const xmlChar *)"test_clear")) {
+ if (strlen("_clear_stats") < (size_t)(NETPERF_MAX_TEST_FUNCTION_NAME-tnlen)) {
+ strcat(func_name,"_clear_stats");
+ rc = NPE_SUCCESS;
+ } else {
+ rc = NPE_FUNC_NAME_TOO_LONG;
+ }
+ } else if (!xmlStrcmp(func,(const xmlChar *)"test_stats")) {
+ if (strlen("_get_stats") < (size_t)(NETPERF_MAX_TEST_FUNCTION_NAME-tnlen)) {
+ strcat(func_name,"_get_stats");
+ rc = NPE_SUCCESS;
+ } else {
+ rc = NPE_FUNC_NAME_TOO_LONG;
+ }
+ } else if (!xmlStrcmp(func,(const xmlChar *)"test_decode")) {
+ if (strlen("_decode_stats") < (size_t)(NETPERF_MAX_TEST_FUNCTION_NAME-tnlen)) {
+ strcat(func_name,"_decode_stats");
+ rc = NPE_SUCCESS;
+ } else {
+ rc = NPE_FUNC_NAME_TOO_LONG;
+ }
+ } else {
+ rc = NPE_UNKNOWN_FUNCTION_TYPE;
+ }
+ }
+ if (test->debug) {
+ g_fprintf(test->where,"func_name = '%s'\n", (char *)func_name);
+ fflush(test->where);
+ }
+ if (rc == NPE_SUCCESS) {
+ ret = g_module_symbol(lib_handle,func_name,&fptr);
+ if (test->debug) {
+ g_fprintf(test->where,"symbol lookup of func_name '%s' returned %p\n",
+ func_name, fptr);
+ if (fptr == NULL) {
+ g_fprintf(test->where,"g_module_symbol error '%s'\n",g_module_error());
+ }
+ fflush(test->where);
+ }
+ if (fptr == NULL) {
+ if (lib_handle) {
+ rc = NPE_FUNC_NOT_FOUND;
+ } else {
+ rc = NPE_LIBRARY_NOT_LOADED;
+ }
+ }
+ }
+ } else {
+ rc = NPE_FUNC_NAME_TOO_LONG;
+ }
+
+ if (!xmlStrcmp(func,(const xmlChar *)"test_name")) {
+ test->test_name = fname;
+ test->test_func = (NetperfTestFunc)fptr;
+ } else if (!xmlStrcmp(func,(const xmlChar *)"test_clear")) {
+ test->test_clear = (NetperfTestClear)fptr;
+ xmlFree(fname);
+ } else if (!xmlStrcmp(func,(const xmlChar *)"test_stats")) {
+ test->test_stats = (NetperfTestStats)fptr;
+ xmlFree(fname);
+ } else if (!xmlStrcmp(func,(const xmlChar *)"test_decode")) {
+ test->test_decode = (NetperfTestDecode)fptr;
+ xmlFree(fname);
+ } else {
+ rc = NPE_UNKNOWN_FUNCTION_TYPE;
+ xmlFree(fname);
+ }
+
+ if (rc != NPE_SUCCESS) {
+ if (test->debug) {
+ g_fprintf(test->where,
+ "get_test_function: error %d occured getting function %s\n",
+ rc,func_name);
+ fflush(test->where);
+ }
+ }
+
+ return(rc);
+}
+
/* get and set property routines */
static void netperf_test_set_property(GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec) {
NetperfTest *test;
+ NetperfTest *dependent;
+
+ GList *item;
guint req_state;
+ xmlChar *test_func;
test = NETPERF_TEST(object);
@@ -526,10 +687,14 @@
break;
case TEST_PROP_TEST_ADD_DEPENDANT:
- g_print("Yo, add the code to add a dependant!\n");
+ dependent = g_value_get_pointer(value);
+ item = g_list_append(NULL, dependent);
+ g_object_add_weak_pointer(dependent, &item->data);
+ test->dependent_tests = g_list_concat(item, test->dependent_tests);
break;
case TEST_PROP_TEST_DEL_DEPENDANT:
+ dependent = g_value_get_pointer(value);
g_print("Yo, add the code to delete a dependant!\n");
break;
@@ -565,14 +730,14 @@
g_value_set_string(value, test->server_id);
break;
+ case TEST_PROP_NODE:
+ g_value_set_pointer(value, test->node);
+ break;
+
case TEST_PROP_TEST_FUNC:
g_value_set_pointer(value, test->test_func);
break;
- case TEST_PROP_NODE:
- g_value_set_pointer(value, test->node);
- break;
-
case TEST_PROP_TEST_CLEAR:
g_value_set_pointer(value, test->test_clear);
break;
Modified: branches/gobject_migration/src/netperf4.c
===================================================================
--- branches/gobject_migration/src/netperf4.c 2007-03-13 22:07:41 UTC (rev 213)
+++ branches/gobject_migration/src/netperf4.c 2007-03-14 01:04:03 UTC (rev 214)
@@ -592,8 +592,6 @@
gpointer data)
{
gboolean return_value = TRUE;
- g_print("the arguments to the NEW command were %s\n",
- arguments);
return return_value;
}
@@ -611,8 +609,6 @@
{
gboolean return_value = TRUE;
- g_print("the arguments to the SET command were %s\n",
- arguments);
return return_value;
}
@@ -700,8 +696,7 @@
gchar **split;
NETPERF_DEBUG_ENTRY(debug,where);
- g_print("the arguments to the SHOW command were %s\n",
- arguments);
+
split = g_strsplit_set(arguments,
" \r\n",
2);
@@ -724,8 +719,7 @@
gpointer data)
{
gboolean return_value = TRUE;
- g_print("the arguments to the READ command were %s\n",
- arguments);
+
return return_value;
}
@@ -733,8 +727,7 @@
gpointer data)
{
gboolean return_value = TRUE;
- g_print("the arguments to the LOAD command were %s\n",
- arguments);
+
return return_value;
}
@@ -742,8 +735,7 @@
gpointer data)
{
gboolean return_value = TRUE;
- g_print("the arguments to the MEASURE command were %s\n",
- arguments);
+
return return_value;
}
@@ -751,8 +743,7 @@
gpointer data)
{
gboolean return_value = TRUE;
- g_print("the arguments to the INIT command were %s\n",
- arguments);
+
return return_value;
}
@@ -760,8 +751,7 @@
gpointer data)
{
gboolean return_value = TRUE;
- g_print("the arguments to the IDLE command were %s\n",
- arguments);
+
return return_value;
}
@@ -769,8 +759,7 @@
gpointer data)
{
gboolean return_value = TRUE;
- g_print("the arguments to the stats command were %s\n",
- arguments);
+
return return_value;
}
@@ -778,8 +767,7 @@
gpointer data)
{
gboolean return_value = TRUE;
- g_print("the arguments to the DIE command were %s\n",
- arguments);
+
return return_value;
}
@@ -902,7 +890,12 @@
"node", this_test,
NULL);
if (new_test != NULL) { /* we have a new NetperfTest object */
- /* REVISIT - extract the relevant functions please
+ /* REVISIT - extract the relevant functions please. the netperf
+ side probably doesn't need anything but the decode? and even
+ that shouldn't be necessary once we have the generic
+ formatter. i'm not sure why we bothered extracting the
+ function for test_name from the XML on the netperf side in
+ the first place?
rc = get_test_function(new_test,(const xmlChar *)"test_name");
rc = get_test_function(new_test,(const xmlChar *)"test_decode"); */
g_hash_table_replace(test_hash,
@@ -946,20 +939,28 @@
continue;
}
netserverid = xmlGetProp(this_netserver,(const xmlChar *)"nid");
- /* REVISIT - make sure the node property gets set */
new_server = g_object_new(TYPE_NETPERF_NETSERVER,
"id", netserverid,
"node", this_netserver,
NULL);
if (new_server != NULL) { /* we have a new netserver object,
lets add it to the server_hash */
+ /* you know.... we should probably check if that netserverid
+ is already in the hash, particularly once we have
+ interactive addition of netservers and not just netservers
+ from a validated XML config file. raj 2007-03-13 */
g_hash_table_replace(server_hash,
netserverid,
new_server);
- /* REVISIT must set the node property, and decide what to do
- about the control connection/object. must also see about
- adding the tests to the test_hash and the like */
+ /* REVISIT must decide what to do about the control
+ connection/object. should we create it explicitly here, or
+ should it be done when the "node" property is set as that
+ is, presumably, where the addressing info happens to be? it
+ should probably be after the netserver has been added to the
+ server_hash on the off chance that messages start arriving */
}
+ /* lets go ahead and add the tests associated with this
+ netserver */
add_netservers_tests(this_netserver,new_server);
/* see about the next netserver */
this_netserver = this_netserver->next;
More information about the netperf-dev
mailing list