[netperf-dev] netperf4 commit notice r9 - in trunk: . src
raj at netperf.org
raj at netperf.org
Thu Oct 27 14:30:44 PDT 2005
Author: raj
Date: 2005-10-27 14:30:24 -0700 (Thu, 27 Oct 2005)
New Revision: 9
Modified:
trunk/config.h.in
trunk/configure
trunk/configure.ac
trunk/src/netconfidence.c
trunk/src/netlib.c
trunk/src/netmsg.c
trunk/src/netperf.h
trunk/src/netsysstats_common.c
trunk/src/netsysstats_hpux.c
trunk/src/netsysstats_linux.c
trunk/src/nettest_bsd.c
Log:
all sorts of cleanup - missing includes, make debug and where part of test_t
and the like.
Modified: trunk/config.h.in
===================================================================
--- trunk/config.h.in 2005-10-27 00:56:05 UTC (rev 8)
+++ trunk/config.h.in 2005-10-27 21:30:24 UTC (rev 9)
@@ -93,6 +93,9 @@
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
+/* Define to 1 if you have the <math.h> header file. */
+#undef HAVE_MATH_H
+
/* Define to 1 if you have the `memcpy' function. */
#undef HAVE_MEMCPY
Modified: trunk/configure
===================================================================
--- trunk/configure 2005-10-27 00:56:05 UTC (rev 8)
+++ trunk/configure 2005-10-27 21:30:24 UTC (rev 9)
@@ -20921,7 +20921,8 @@
-for ac_header in arpa/inet.h fcntl.h limits.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h
+
+for ac_header in arpa/inet.h fcntl.h limits.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h math.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2005-10-27 00:56:05 UTC (rev 8)
+++ trunk/configure.ac 2005-10-27 21:30:24 UTC (rev 9)
@@ -31,7 +31,7 @@
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h])
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h math.h])
# Some platforms require these. There may be a better way.
AC_HAVE_LIBRARY(socket)
Modified: trunk/src/netconfidence.c
===================================================================
--- trunk/src/netconfidence.c 2005-10-27 00:56:05 UTC (rev 8)
+++ trunk/src/netconfidence.c 2005-10-27 21:30:24 UTC (rev 9)
@@ -1,4 +1,48 @@
+char netconfidence_id[]="\
+@(#)netconfidence.c (c) Copyright 2005, Hewlett-Packard Company, $Id$";
+
+/*
+
+This file is part of netperf4.
+
+Netperf4 is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+Netperf4 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+USA.
+
+In addition, as a special exception, the copyright holders give
+permission to link the code of netperf4 with the OpenSSL project's
+"OpenSSL" library (or with modified versions of it that use the same
+license as the "OpenSSL" library), and distribute the linked
+executables. You must obey the GNU General Public License in all
+respects for all of the code used other than "OpenSSL". If you modify
+this file, you may extend this exception to your version of the file,
+but you are not obligated to do so. If you do not wish to do so,
+delete this exception statement from your version.
+
+*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
+
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+
#include "netperf.h"
extern int debug;
Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c 2005-10-27 00:56:05 UTC (rev 8)
+++ trunk/src/netlib.c 2005-10-27 21:30:24 UTC (rev 9)
@@ -102,6 +102,7 @@
{
char *ns;
+
ns = strchr(s,',');
if (ns) {
/* there was a comma arg2 should be the second arg*/
@@ -128,6 +129,7 @@
{
char *ns;
+
ns = strchr(s,',');
if (ns) {
/* there was a comma arg2 should be the second arg*/
@@ -154,6 +156,7 @@
char temp[10]; /* gotta love magic constants :) */
+
strncpy(temp,family_string,10);
if (debug) {
@@ -279,6 +282,7 @@
{
int i;
test_t * test;
+
if (debug) {
for (i=0;i < TEST_HASH_BUCKETS; i++) {
test = test_hash[i].test;
@@ -298,6 +302,7 @@
{
int hash_value;
+
hash_value = TEST_HASH_VALUE(new_test->id);
/* don't forget to add error checking one day */
@@ -320,6 +325,7 @@
int hash_value;
test_t *test_pointer;
+
hash_value = TEST_HASH_VALUE(id);
/* don't forget to add error checking one day */
@@ -538,6 +544,7 @@
xmlChar *fname;
GenReport func;
+
la_file = xmlGetProp(cmd, (const xmlChar *)"library");
map_la_to_lib(la_file,lib_file);
if (debug) {
@@ -581,6 +588,7 @@
int rc = NPE_FUNC_NAME_TOO_LONG;
char func_name[NETPERF_MAX_TEST_FUNCTION_NAME];
+
if (debug) {
fprintf(where,"get_test_func enter test %p func %s\n",test, func);
fflush(where);
@@ -732,6 +740,7 @@
int rc;
pthread_t temp_tid;
+
rc = pthread_create(&temp_tid, (pthread_attr_t *)NULL, start_routine, data);
if (rc != 0) {
if (debug) {
@@ -769,6 +778,7 @@
int
strtofam(xmlChar *familystr)
{
+
if (debug) {
fprintf(where, "strtofam called with %s\n", familystr);
fflush(where);
@@ -1141,6 +1151,7 @@
struct timeval timeout;
+
/* one of these days, we probably aught to make sure that what
message points to is NULL... but only as a debug assert... raj
2003-03-05 */
@@ -1333,6 +1344,7 @@
char *control_message;
int control_message_len;
+
if (debug) {
fprintf(where,
"send_control_message: called with sock %d and message node at %p",
@@ -1426,6 +1438,8 @@
report_server_error(server_t *server)
{
int i;
+
+
i = server->err_rc - NPE_MIN_ERROR_NUM;
fprintf(where,
"server %s entered error state %d from %s error code %d %s\n",
Modified: trunk/src/netmsg.c
===================================================================
--- trunk/src/netmsg.c 2005-10-27 00:56:05 UTC (rev 8)
+++ trunk/src/netmsg.c 2005-10-27 21:30:24 UTC (rev 9)
@@ -132,10 +132,6 @@
xmlNodePtr cur;
struct msgs *which_msg;
- if (debug) {
- fprintf(where,"process_message: entered\n");
- fflush(where);
- }
msg = xmlDocGetRootElement(doc);
if (msg == NULL) {
@@ -269,6 +265,7 @@
int rc = NPE_SUCCESS;
xmlNodePtr message;
+
if ((message = xmlNewNode(NULL,(xmlChar *)"version")) != NULL) {
/* set the properties of the version message -
the version, update, and fix levels sgb 2003-02-27 */
@@ -322,6 +319,7 @@
xmlChar *testid;
test_t *test;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -355,6 +353,7 @@
test_t *test;
xmlNodePtr stats;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -383,6 +382,7 @@
test_t *test;
xmlNodePtr stats;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -411,6 +411,7 @@
test_t *test;
xmlNodePtr stats;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -443,6 +444,7 @@
test_t *test;
xmlNodePtr sys_stats;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -475,6 +477,7 @@
test_t *test;
int hash_value;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
hash_value = TEST_HASH_VALUE(testid);
@@ -522,6 +525,7 @@
xmlChar *testid;
test_t *test;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -546,6 +550,7 @@
xmlChar *testid;
test_t *test;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -573,6 +578,7 @@
test_t *test;
int hash_value;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
dependency_data = msg->xmlChildrenNode;
@@ -631,6 +637,7 @@
xmlChar *testid;
test_t *test;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -655,6 +662,7 @@
xmlChar *testid;
test_t *test;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -679,6 +687,7 @@
xmlChar *testid;
test_t *test;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -702,6 +711,7 @@
xmlChar *testid;
test_t *test;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -730,10 +740,7 @@
xmlChar *test_name;
xmlChar *testid;
- if (debug) {
- fprintf(where,"entering test_message\n");
- fflush(where);
- }
+
if (server->state != server->state_req) {
/* set netserver state to NSRV_WORK because receiving a test message
shows that netperf accepted our version message */
@@ -743,7 +750,8 @@
while (test_node != NULL && rc == NPE_SUCCESS) {
if (xmlStrcmp(test_node->name,(const xmlChar *)"test")) {
if (debug) {
- printf("test_message: skipped a non-test node\n");
+ fprintf(where,"test_message: skipped a non-test node\n");
+ fflush(where);
}
test_node = test_node->next;
continue;
@@ -758,7 +766,8 @@
new_test->state = TEST_PREINIT;
new_test->new_state = TEST_PREINIT;
new_test->state_req = TEST_IDLE;
-
+ new_test->debug = debug;
+ new_test->where = where;
rc = get_test_function(new_test,(const xmlChar *)"test_name");
if (rc == NPE_SUCCESS) {
rc = get_test_function(new_test,(const xmlChar *)"test_clear");
@@ -779,8 +788,9 @@
if (rc == NPE_SUCCESS) {
if (debug) {
fprintf(where,
- "test_message: about to launch thread for test %d\n",
- new_test->tid);
+ "test_message: about to launch thread for test %d using func %p\n",
+ new_test->tid,
+ new_test->test_func);
fflush(where);
}
rc = launch_thread(&new_test->tid,new_test->test_func,new_test);
@@ -805,7 +815,7 @@
} /* end wait */
if (debug) {
fprintf(where,
- "test_message: test has started initialization on thread %d\n",
+ "test_message: test has finished initialization on thread %d\n",
new_test->tid);
fflush(where);
}
@@ -837,6 +847,7 @@
test_t *test;
xmlNodePtr stats;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (debug || loc_debug) {
@@ -878,6 +889,7 @@
test_t *test;
xmlNodePtr stats;
+
testid = xmlGetProp(msg,(const xmlChar *)"tid");
test = find_test_in_hash(testid);
if (test != NULL) {
@@ -906,6 +918,8 @@
unknown_message(xmlNodePtr msg, xmlDocPtr doc, server_t *server)
{
int rc = NPE_SUCCESS;
+
+
fprintf(where,"Server %s sent a %s message which is unknown by netperf4\n",
server->id, msg->name);
fflush(where);
Modified: trunk/src/netperf.h
===================================================================
--- trunk/src/netperf.h 2005-10-27 00:56:05 UTC (rev 8)
+++ trunk/src/netperf.h 2005-10-27 21:30:24 UTC (rev 9)
@@ -14,6 +14,12 @@
#define NETPERF_UPDATE (const xmlChar *)"0"
#define NETPERF_FIX (const xmlChar *)"999"
+#define NETPERF_DEBUG_ENTRY(d,w) \
+ if (d) { \
+ fprintf(w,"DEBUG entering function %s\n",__func__); \
+ fflush(w); \
+ }
+
#ifndef WIN32
#define NETPERF_PATH_SEP "/"
#else
@@ -119,8 +125,13 @@
to reach the test instance */
xmlNodePtr node; /* the xml document node containing the
- tests configuration data */
+ test's configuration data */
+ uint32_t debug; /* should the test routine generate
+ debug output */
+
+ FILE *where; /* where that debug output should go */
+
uint32_t state; /* the state netperf or netserver believes the
test instance to be in at the moment.
only changed by netperf or netserver */
Modified: trunk/src/netsysstats_common.c
===================================================================
--- trunk/src/netsysstats_common.c 2005-10-27 00:56:05 UTC (rev 8)
+++ trunk/src/netsysstats_common.c 2005-10-27 21:30:24 UTC (rev 9)
@@ -48,6 +48,10 @@
# endif
#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
#include <errno.h>
#include "netperf.h"
@@ -70,15 +74,13 @@
SYS_STATS_SUCCESS = 0
};
-int debug;
-extern FILE *where;
-
static void
-update_sys_stats(netsysstat_data_t *tsd)
+update_sys_stats(test_t *test)
{
- int loc_debug = 0;
+ netsysstat_data_t *tsd = GET_TEST_DATA(test);
+
int i;
uint64_t subtotal;
@@ -96,12 +98,14 @@
dtime->tv_usec = curr->tv_usec - prev->tv_usec;
dtime->tv_sec = curr->tv_sec - prev->tv_sec;
- if (loc_debug) {
- fprintf(where,"\tdelta_sec = %d\t%d\t%d\n",
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
+ if (test->debug) {
+ fprintf(test->where,"\tdelta_sec = %d\t%d\t%d\n",
dtime->tv_sec,curr->tv_sec,prev->tv_sec);
- fprintf(where,"\tdelta_usec = %d\t%d\t%d\n",
+ fprintf(test->where,"\tdelta_usec = %d\t%d\t%d\n",
dtime->tv_usec,curr->tv_usec,prev->tv_usec);
- fflush(where);
+ fflush(test->where);
}
if (curr->tv_usec < prev->tv_usec) {
@@ -114,17 +118,17 @@
dtime->tv_sec++;
}
- if (loc_debug) {
- fprintf(where,"\tdelta_sec = %d\t%d\t%d\n",
+ if (test->debug) {
+ fprintf(test->where,"\tdelta_sec = %d\t%d\t%d\n",
dtime->tv_sec,curr->tv_sec,prev->tv_sec);
- fprintf(where,"\tdelta_usec = %d\t%d\t%d\n",
+ fprintf(test->where,"\tdelta_usec = %d\t%d\t%d\n",
dtime->tv_usec,curr->tv_usec,prev->tv_usec);
- fflush(where);
+ fflush(test->where);
}
- if (loc_debug) {
- fprintf(where,"\tttime = %d.%d\n",ttime->tv_sec,ttime->tv_usec);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"\tttime = %d.%d\n",ttime->tv_sec,ttime->tv_usec);
+ fflush(test->where);
}
ttime->tv_sec += dtime->tv_sec;
@@ -135,9 +139,9 @@
ttime->tv_sec++;
}
- if (loc_debug) {
- fprintf(where,"\tttime = %d.%d\n",ttime->tv_sec,ttime->tv_usec);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"\tttime = %d.%d\n",ttime->tv_sec,ttime->tv_usec);
+ fflush(test->where);
}
for (i = 0; i < tsd->num_cpus; i++) {
@@ -190,11 +194,14 @@
int err_code;
char *err_string;
{
+
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
test->err_no = GET_ERRNO;
- if (debug) {
- fprintf(where,"%s: called report_test_failure:\n",function);
- fprintf(where,"\nreporting %s errno = %d\n",err_string,test->err_no);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"%s: called report_test_failure:\n",function);
+ fprintf(test->where,"\nreporting %s errno = %d\n",err_string,test->err_no);
+ fflush(test->where);
}
test->err_rc = err_code;
test->err_fn = function;
@@ -205,6 +212,7 @@
static void
clear_cpu_time_counters(cpu_time_counters_t *counters, int count) {
int i;
+
/* lets be paranoid */
if (NULL != counters) {
for (i=0;i<count;i++) {
@@ -226,6 +234,8 @@
{
netsysstat_data_t *tsd = GET_TEST_DATA(test);
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
tsd->total_elapsed_time.tv_usec = 0;
tsd->total_elapsed_time.tv_sec = 0;
tsd->delta_elapsed_time.tv_usec = 0;
@@ -243,67 +253,74 @@
}
static xmlAttrPtr
-set_stat_attribute(xmlNodePtr stats,char *name, uint32_t value)
+set_stat_attribute(test_t *test, xmlNodePtr stats,char *name, uint32_t value)
{
xmlAttrPtr ap = NULL;
char value_str[32];
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
sprintf(value_str,"%#ld",value);
ap = xmlSetProp(stats,(xmlChar *)name,(xmlChar *)value_str);
- if (debug) {
- fprintf(where,"%s=%s\n",name,value_str);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"%s=%s\n",name,value_str);
+ fflush(test->where);
}
return(ap);
}
static xmlAttrPtr
-set_counter_attribute(xmlNodePtr stats,char *name, uint64_t value)
+set_counter_attribute(test_t *test, xmlNodePtr stats,char *name, uint64_t value)
{
xmlAttrPtr ap = NULL;
char value_str[32];
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
sprintf(value_str,"%#llx",value);
ap = xmlSetProp(stats,(xmlChar *)name,(xmlChar *)value_str);
- if (debug) {
- fprintf(where,"%s=%s\n",name,value_str);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"%s=%s\n",name,value_str);
+ fflush(test->where);
}
return(ap);
}
static xmlAttrPtr
-add_per_cpu_attributes(xmlNodePtr stats,
+add_per_cpu_attributes(test_t *test,
+ xmlNodePtr stats,
cpu_time_counters_t *cpu,
uint32_t num_cpus)
{
int i;
xmlNodePtr cpu_stats = NULL;
xmlAttrPtr ap = NULL;
+
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
for (i=0;i<num_cpus;i++) {
if ((cpu_stats = xmlNewNode(NULL,(xmlChar *)"per_cpu_stats")) != NULL) {
/* set the properites of the per_cpu_stats -
the cpu_id counter values sgb 2005-10-17 */
- ap = set_stat_attribute(cpu_stats,"cpu_id",i);
+ ap = set_stat_attribute(test, cpu_stats,"cpu_id",i);
if (ap != NULL) {
- ap = set_counter_attribute(cpu_stats, "calibration", cpu[i].calibrate);
+ ap = set_counter_attribute(test, cpu_stats, "calibration", cpu[i].calibrate);
}
if (ap != NULL) {
- ap = set_counter_attribute(cpu_stats, "idle_count", cpu[i].idle);
+ ap = set_counter_attribute(test, cpu_stats, "idle_count", cpu[i].idle);
}
#ifndef EXTRA_COUNTERS_MISSING
if (ap != NULL) {
- ap = set_counter_attribute(cpu_stats, "user_count", cpu[i].user);
+ ap = set_counter_attribute(test, cpu_stats, "user_count", cpu[i].user);
}
if (ap != NULL) {
- ap = set_counter_attribute(cpu_stats, "sys_count", cpu[i].kernel);
+ ap = set_counter_attribute(test, cpu_stats, "sys_count", cpu[i].kernel);
}
if (ap != NULL) {
- ap = set_counter_attribute(cpu_stats, "int_count", cpu[i].interrupt);
+ ap = set_counter_attribute(test, cpu_stats, "int_count", cpu[i].interrupt);
}
if (ap != NULL) {
- ap = set_counter_attribute(cpu_stats, "other_count", cpu[i].other);
+ ap = set_counter_attribute(test, cpu_stats, "other_count", cpu[i].other);
}
#endif
xmlAddChild(stats,cpu_stats);
@@ -327,10 +344,12 @@
cpu_time_counters_t *total_cpu = tsd->total_cpu_counters;
cpu_time_counters_t *ending_cpu = tsd->ending_cpu_counters;
- if (debug) {
- fprintf(where,"sys_stats_get_stats: entering for %s test %s\n",
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
+ if (test->debug) {
+ fprintf(test->where,"sys_stats_get_stats: entering for %s test %s\n",
test->id, test->test_name);
- fflush(where);
+ fflush(test->where);
}
if ((stats = xmlNewNode(NULL,(xmlChar *)"sys_stats")) != NULL) {
@@ -342,62 +361,62 @@
/* get_cpu_time_counters sets current timestamp */
get_cpu_time_counters(tsd->ending_cpu_counters, &(tsd->curr_time), tsd);
if (ap != NULL) {
- ap = set_stat_attribute(stats,"time_sec",tsd->curr_time.tv_sec);
+ ap = set_stat_attribute(test, stats,"time_sec",tsd->curr_time.tv_sec);
}
if (ap != NULL) {
- ap = set_stat_attribute(stats,"time_usec",tsd->curr_time.tv_usec);
+ ap = set_stat_attribute(test, stats,"time_usec",tsd->curr_time.tv_usec);
}
if (ap != NULL) {
- ap = set_stat_attribute(stats,"number_cpus",tsd->num_cpus);
+ ap = set_stat_attribute(test, stats,"number_cpus",tsd->num_cpus);
}
if (ap != NULL) {
- ap = add_per_cpu_attributes(stats, ending_cpu, tsd->num_cpus);
+ ap = add_per_cpu_attributes(test, stats, ending_cpu, tsd->num_cpus);
}
} else {
if (ap != NULL) {
- ap = set_stat_attribute(stats,
+ ap = set_stat_attribute(test, stats,
"elapsed_sec",
tsd->total_elapsed_time.tv_sec);
}
if (ap != NULL) {
- ap = set_stat_attribute(stats,
+ ap = set_stat_attribute(test, stats,
"elapsed_usec",
tsd->total_elapsed_time.tv_usec);
}
if (ap != NULL) {
- ap = set_stat_attribute(stats, "number_cpus", tsd->num_cpus);
+ ap = set_stat_attribute(test, stats, "number_cpus", tsd->num_cpus);
}
if (ap != NULL) {
- ap = set_counter_attribute(stats, "calibration", total_sys->calibrate);
+ ap = set_counter_attribute(test, stats, "calibration", total_sys->calibrate);
}
if (ap != NULL) {
- ap = set_counter_attribute(stats, "idle_count", total_sys->idle);
+ ap = set_counter_attribute(test, stats, "idle_count", total_sys->idle);
}
#ifndef EXTRA_COUNTERS_MISSING
if (ap != NULL) {
- ap = set_counter_attribute(stats, "user_count", total_sys->user);
+ ap = set_counter_attribute(test, stats, "user_count", total_sys->user);
}
if (ap != NULL) {
- ap = set_counter_attribute(stats, "sys_count", total_sys->kernel);
+ ap = set_counter_attribute(test, stats, "sys_count", total_sys->kernel);
}
if (ap != NULL) {
- ap = set_counter_attribute(stats, "int_count", total_sys->interrupt);
+ ap = set_counter_attribute(test, stats, "int_count", total_sys->interrupt);
}
if (ap != NULL) {
- ap = set_counter_attribute(stats, "other_count", total_sys->other);
+ ap = set_counter_attribute(test, stats, "other_count", total_sys->other);
}
#endif
- ap = add_per_cpu_attributes(stats,total_cpu, tsd->num_cpus);
+ ap = add_per_cpu_attributes(test,stats,total_cpu, tsd->num_cpus);
}
if (ap == NULL) {
xmlFreeNode(stats);
stats = NULL;
}
}
- if (debug) {
- fprintf(where,"sys_stats_get_stats: exiting for %s test %s\n",
+ if (test->debug) {
+ fprintf(test->where,"sys_stats_get_stats: exiting for %s test %s\n",
test->id, test->test_name);
- fflush(where);
+ fflush(test->where);
}
return(stats);
}
@@ -406,6 +425,7 @@
void
sys_stats_decode_stats(xmlNodePtr stats, test_t *test)
{
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
}
void
@@ -417,34 +437,38 @@
netsysstat_data_t *tsd;
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
tsd = (netsysstat_data_t *)malloc(sizeof(netsysstat_data_t));
- memset(tsd,0,sizeof(netsysstat_data_t));
- test->test_specific_data = tsd;
- if (tsd == NULL) {
+ if (NULL == tsd) {
report_test_failure(test,
"sys_stats",
SYS_STATS_MALLOC_FAILED,
"call to malloc failed");
}
+ /* lets make sure we have a valid pointer before we go calling
+ memset, so put this after the if (tsd == NULL) bit... */
+ memset(tsd,0,sizeof(netsysstat_data_t));
+ test->test_specific_data = tsd;
while ((GET_TEST_STATE != TEST_ERROR) &&
(GET_TEST_STATE != TEST_DEAD)) {
switch (GET_TEST_STATE) {
case TEST_PREINIT:
/* following allocates and initializes num_cpus, and psd
in the netsysstat_data structure sgb 2005-10-17 */
- err = sys_cpu_util_init(tsd);
+ err = sys_cpu_util_init(test);
num_cpus = tsd->num_cpus;
if (num_cpus > 0) {
- if (debug) {
- fprintf(where,
+ if (test->debug) {
+ fprintf(test->where,
"sys_stats: allocating counters for %d cpus\n",
num_cpus);
- fflush(where);
+ fflush(test->where);
}
tsd->total_sys_counters =
(cpu_time_counters_t *)malloc(sizeof(cpu_time_counters_t));
- memset(tsd->total_sys_counters,0,sizeof(netsysstat_data_t));
+
tsd->starting_cpu_counters =
(cpu_time_counters_t *)malloc(num_cpus *
sizeof(cpu_time_counters_t));
@@ -457,16 +481,26 @@
tsd->total_cpu_counters =
(cpu_time_counters_t *)malloc(num_cpus *
sizeof(cpu_time_counters_t));
- memset(tsd->total_cpu_counters,0,(num_cpus *
- sizeof(netsysstat_data_t)));
if ((NULL != tsd->total_sys_counters) &&
(NULL != tsd->starting_cpu_counters) &&
(NULL != tsd->ending_cpu_counters) &&
(NULL != tsd->delta_cpu_counters) &&
(NULL != tsd->total_cpu_counters)) {
+ /* put the memset's here, once we know that the pointers are
+ good. raj 2005-10-27 */
+ memset(tsd->total_sys_counters,0,sizeof(netsysstat_data_t));
+ memset(tsd->total_cpu_counters,0,
+ (num_cpus * sizeof(netsysstat_data_t)));
SET_TEST_STATE(TEST_INIT);
} else {
+ /* lets see about cleaning-up some memory shall we? */
+ if (tsd->total_sys_counters) free(tsd->total_sys_counters);
+ if (tsd->starting_cpu_counters) free(tsd->starting_cpu_counters);
+ if (tsd->ending_cpu_counters) free(tsd->ending_cpu_counters);
+ if (tsd->delta_cpu_counters) free(tsd->delta_cpu_counters);
+ if (tsd->total_cpu_counters) free(tsd->total_cpu_counters);
+
report_test_failure(test,
"sys_stats",
SYS_STATS_MALLOC_FAILED,
@@ -480,11 +514,11 @@
}
break;
case TEST_INIT:
+ if (test->debug) {
+ fprintf(test->where,"sys_stats: in INIT state\n");
+ fflush(test->where);
+ }
if (CHECK_REQ_STATE == TEST_IDLE) {
- if (debug) {
- fprintf(where,"sys_stats: in INIT state\n");
- fflush(where);
- }
SET_TEST_STATE(TEST_IDLE);
} else {
report_test_failure(test,
@@ -494,6 +528,10 @@
}
break;
case TEST_IDLE:
+ if (test->debug) {
+ fprintf(test->where,"sys_stats: in IDLE state\n");
+ fflush(test->where);
+ }
/* check for state transition */
if (CHECK_REQ_STATE == TEST_IDLE) {
sleep(1);
@@ -509,12 +547,17 @@
}
break;
case TEST_MEASURE:
+ if (test->debug) {
+ fprintf(test->where,"sys_stats: in MEAS state\n");
+ fflush(test->where);
+ }
+
if (CHECK_REQ_STATE == TEST_MEASURE) {
sleep(1);
} else if (CHECK_REQ_STATE == TEST_LOADED) {
/* get_cpu_time_counters sets current timestamp */
- get_cpu_time_counters(tsd->ending_cpu_counters,&(tsd->curr_time),tsd);
- update_sys_stats(tsd);
+ get_cpu_time_counters(tsd->ending_cpu_counters,&(tsd->curr_time),test);
+ update_sys_stats(test);
SET_TEST_STATE(TEST_LOADED);
} else {
report_test_failure(test,
@@ -524,12 +567,17 @@
}
break;
case TEST_LOADED:
+ if (test->debug) {
+ fprintf(test->where,"sys_stats: in LOAD state\n");
+ fflush(test->where);
+ }
+
if (CHECK_REQ_STATE == TEST_LOADED) {
sleep(1);
} else if (CHECK_REQ_STATE == TEST_MEASURE) {
/* transitioning to measure state from loaded state set
get_cpu_time_counters sets previous timestamp */
- get_cpu_time_counters(tsd->starting_cpu_counters,&(tsd->prev_time),tsd);
+ get_cpu_time_counters(tsd->starting_cpu_counters,&(tsd->prev_time),test);
SET_TEST_STATE(TEST_MEASURE);
} else if (CHECK_REQ_STATE == TEST_IDLE) {
SET_TEST_STATE(TEST_IDLE);
Modified: trunk/src/netsysstats_hpux.c
===================================================================
--- trunk/src/netsysstats_hpux.c 2005-10-27 00:56:05 UTC (rev 8)
+++ trunk/src/netsysstats_hpux.c 2005-10-27 21:30:24 UTC (rev 9)
@@ -47,9 +47,6 @@
#include "netlib.h"
#include "netsysstats.h"
-extern FILE *where;
-extern int debug;
-
/* data is kept is malloced data structures which are referenced from
the test specific data structure. a pointer to platform specific data
is passed for holding data needed for each platform. 255-10-18 sgb */
@@ -65,23 +62,24 @@
int
-sys_cpu_util_init(netsysstat_data_t *tsd)
+sys_cpu_util_init(test_t *test)
{
struct pst_processor *psp;
struct pst_dynamic psd;
int num_cpus;
int err = HPUX_SYS_STATS_SUCCESS;
-
+ netsysstat_data_t *tsd = GET_TEST_DATA(test);
+
if (pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0) != -1) {
num_cpus = psd.psd_proc_cnt;
- if (debug) {
- fprintf(where,"sys_cpu_util_init: num_cpus = %d\n\n",num_cpus);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"sys_cpu_util_init: num_cpus = %d\n\n",num_cpus);
+ fflush(test->where);
}
psp = (struct pst_processor *)malloc(num_cpus * sizeof(*psp));
- if (debug) {
- fprintf(where,"sys_cpu_util_init: allocated pst_processor\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"sys_cpu_util_init: allocated pst_processor\n");
+ fflush(test->where);
}
tsd->num_cpus = num_cpus;
tsd->psd = psp;
@@ -95,15 +93,16 @@
void
get_cpu_time_counters(cpu_time_counters_t *res,
struct timeval *time,
- netsysstat_data_t *tsd)
+ test_t *test);
{
- int loc_debug = 0;
+
struct pst_processor *psp = tsd->psd;
int num_cpus = tsd->num_cpus;
int i;
double ticks;
double iticksperclktick;
double elapsed;
+ netsysstat_data_t *tsd = GET_TEST_DATA(test);
/* get the idle cycle counter for each processor. now while on a
64-bit kernel the ".psc_hi" and ".psc_lo" fields are 64 bits,
@@ -135,22 +134,22 @@
res[i].other -= res[i].interrupt;
#endif
- if(debug) {
- fprintf(where, "\tidle[%d] = %#llx", i, res[i].idle);
+ if(test->debug) {
+ fprintf(test->where, "\tidle[%d] = %#llx", i, res[i].idle);
#ifndef EXTRA_COUNTERS_MISSING
- fprintf(where, "\tuser[%d] = %#llx", i, res[i].user);
- fprintf(where, "\tkern[%d] = %#llx", i, res[i].kernel);
- fprintf(where, "\tintr[%d] = %#llx", i, res[i].interrupt);
- fprintf(where, "\tothr[%d] = %#llx", i, res[i].other);
+ fprintf(test->where, "\tuser[%d] = %#llx", i, res[i].user);
+ fprintf(test->where, "\tkern[%d] = %#llx", i, res[i].kernel);
+ fprintf(test->where, "\tintr[%d] = %#llx", i, res[i].interrupt);
+ fprintf(test->where, "\tothr[%d] = %#llx", i, res[i].other);
#endif
- fprintf(where, "\n");
- fflush(where);
+ fprintf(test->where, "\n");
+ fflush(test->where);
}
}
- if (debug | loc_debug) {
- fprintf(where, "\tseconds=%d\tusec=%d\telapsed=%f\n",
+ if (test->debug) {
+ fprintf(test->where, "\tseconds=%d\tusec=%d\telapsed=%f\n",
time->tv_sec,time->tv_usec,elapsed);
- fflush(where);
+ fflush(test->where);
}
}
}
Modified: trunk/src/netsysstats_linux.c
===================================================================
--- trunk/src/netsysstats_linux.c 2005-10-27 00:56:05 UTC (rev 8)
+++ trunk/src/netsysstats_linux.c 2005-10-27 21:30:24 UTC (rev 9)
@@ -39,9 +39,11 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
+
#if HAVE_INTTYPES_H
# include <inttypes.h>
#else
@@ -49,9 +51,23 @@
# include <stdint.h>
# endif
#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
#include <fcntl.h>
+#endif
+
#include <errno.h>
#include "netperf.h"
@@ -75,9 +91,6 @@
LINUX_SYS_STATS_SUCCESS = 0
};
-extern int debug;
-FILE *where;
-
int ticks;
struct timeval prev_time;
@@ -87,11 +100,14 @@
struct timeval delta_elapsed_time;
int
-sys_cpu_util_init(netsysstat_data_t *tsd)
+sys_cpu_util_init(test_t *test)
{
- where = stderr;
+
int err;
+ netsysstat_data_t *tsd = GET_TEST_DATA(test);
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
if ((tsd->num_cpus = sysconf(_SC_NPROCESSORS_ONLN)) == -1) {
return(LINUX_SYS_STATS_SYSCONF_FAILED);
}
@@ -127,20 +143,23 @@
void
get_cpu_time_counters(cpu_time_counters_t *res,
struct timeval *time,
- netsysstat_data_t *tsd)
+ test_t *test)
{
int i,space,records;
char *p = proc_stat_buf;
char cpunam[64];
uint64_t nicetime;
+ netsysstat_data_t *tsd = GET_TEST_DATA(test);
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
lseek (proc_stat_fd, 0, SEEK_SET);
read (proc_stat_fd, p, proc_stat_buflen);
- if (debug) {
- fprintf(where,"proc_stat_buf %s\n",p);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"proc_stat_buf %s\n",p);
+ fflush(test->where);
}
/* Skip first line (total) on SMP */
if (tsd->num_cpus > 1) p = strchr (p, '\n');
@@ -158,21 +177,21 @@
res[i].other = 0;
res[i].interrupt = 0;
- if(debug) {
- fprintf(where,
+ if(test->debug) {
+ fprintf(test->where,
"\tidle[%d] = 0x%"PRIx64" ",
i,
res[i].idle);
- fprintf(where,
+ fprintf(test->where,
"user[%d] = 0x%"PRIx64" ",
i,
res[i].user);
- fprintf(where,
+ fprintf(test->where,
"kern[%d] = 0x%"PRIx64" ",
i,
res[i].kernel);
- fflush(where);
- fprintf(where,
+ fflush(test->where);
+ fprintf(test->where,
"intr[%d] = 0x%"PRIx64"\n",
i,
res[i].interrupt);
Modified: trunk/src/nettest_bsd.c
===================================================================
--- trunk/src/nettest_bsd.c 2005-10-27 00:56:05 UTC (rev 8)
+++ trunk/src/nettest_bsd.c 2005-10-27 21:30:24 UTC (rev 9)
@@ -30,7 +30,7 @@
*/
#ifndef lint
char nettest_id[]="\
-@(#)nettest_bsd.c (c) Copyright 2005 Hewlett-Packard Co. Version 4.0.0";
+@(#)nettest_bsd.c (c) Copyright 2005 Hewlett-Packard Co. $Id$";
#else
#define DIRTY
#define HISTOGRAM
@@ -86,9 +86,6 @@
#include "netperf.h"
-static int debug = 0;
-FILE *where;
-
#ifdef HISTOGRAM
#include "hist.h"
#else
@@ -123,10 +120,10 @@
int err_code;
char *err_string;
{
- if (debug) {
- fprintf(where,"%s: called report_test_failure:",function);
- fprintf(where,"reporting %s errno = %d\n",err_string,GET_ERRNO);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"%s: called report_test_failure:",function);
+ fprintf(test->where,"reporting %s errno = %d\n",err_string,GET_ERRNO);
+ fflush(test->where);
}
test->err_rc = err_code;
test->err_fn = function;
@@ -177,11 +174,6 @@
static int
strtofam(xmlChar *familystr)
{
- if (debug) {
- fprintf(where, "strtofam called with %s\n", familystr);
- fflush(where);
- }
-
if (!xmlStrcmp(familystr,(const xmlChar *)"AF_INET")) {
return(AF_INET);
} else if (!xmlStrcmp(familystr,(const xmlChar *)"AF_UNSPEC")) {
@@ -192,8 +184,6 @@
#endif /* AF_INET6 */
} else {
/* we should never get here if the validator is doing its thing */
- fprintf(where, "strtofam: unknown address family %s\n",familystr);
- fflush(where);
return(-1);
}
}
@@ -233,25 +223,25 @@
&hints, &remote_ai);
count += 1;
if (error == EAI_AGAIN) {
- if (debug) {
- fprintf(where,"Sleeping on getaddrinfo EAI_AGAIN\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"Sleeping on getaddrinfo EAI_AGAIN\n");
+ fflush(test->where);
}
sleep(1);
}
} while ((error == EAI_AGAIN) && (count <= 5));
- if (debug) {
- dump_addrinfo(where, remote_ai, remotehost, remoteport, remotefam);
+ if (test->debug) {
+ dump_addrinfo(test->where, remote_ai, remotehost, remoteport, remotefam);
}
if (!error) {
my_data->remaddr = remote_ai;
} else {
- if (debug) {
- fprintf(where,"get_dependency_data: getaddrinfo returned %d %s\n",
+ if (test->debug) {
+ fprintf(test->where,"get_dependency_data: getaddrinfo returned %d %s\n",
error, gai_strerror(error));
- fflush(where);
+ fflush(test->where);
}
report_test_failure(test,
"get_dependency_data",
@@ -454,9 +444,9 @@
return(temp_socket);
}
- if (debug) {
- fprintf(where,"create_data_socket: socket %d obtained...\n",temp_socket);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"create_data_socket: socket %d obtained...\n",temp_socket);
+ fflush(test->where);
}
/* Modify the local socket size. The reason we alter the send buffer */
@@ -482,11 +472,11 @@
"error setting local send socket buffer size");
return(temp_socket);
}
- if (debug > 1) {
- fprintf(where,
+ if (test->debug > 1) {
+ fprintf(test->where,
"nettest_bsd: create_data_socket: SO_SNDBUF of %d requested.\n",
lss_size);
- fflush(where);
+ fflush(test->where);
}
}
@@ -499,11 +489,11 @@
"error setting local recv socket buffer size");
return(temp_socket);
}
- if (debug > 1) {
- fprintf(where,
+ if (test->debug > 1) {
+ fprintf(test->where,
"nettest_bsd: create_data_socket: SO_RCVBUF of %d requested.\n",
lsr_size);
- fflush(where);
+ fflush(test->where);
}
}
@@ -517,10 +507,10 @@
SO_SNDBUF,
(char *)&lss_size,
&sock_opt_len) < 0) {
- fprintf(where,
+ fprintf(test->where,
"nettest_bsd: create_data_socket: getsockopt SO_SNDBUF: errno %d\n",
errno);
- fflush(where);
+ fflush(test->where);
lss_size = -1;
}
if (getsockopt(temp_socket,
@@ -528,19 +518,19 @@
SO_RCVBUF,
(char *)&lsr_size,
&sock_opt_len) < 0) {
- fprintf(where,
+ fprintf(test->where,
"nettest_bsd: create_data_socket: getsockopt SO_RCVBUF: errno %d\n",
errno);
- fflush(where);
+ fflush(test->where);
lsr_size = -1;
}
- if (debug) {
- fprintf(where,
+ if (test->debug) {
+ fprintf(test->where,
"nettest_bsd: create_data_socket: socket sizes determined...\n");
- fprintf(where,
+ fprintf(test->where,
" send: %d recv: %d\n",
lss_size,lsr_size);
- fflush(where);
+ fflush(test->where);
}
#else /* SO_SNDBUF */
@@ -562,9 +552,9 @@
SO_RCV_COPYAVOID,
&loc_rcvavoid,
sizeof(int)) < 0) {
- fprintf(where,
+ fprintf(test->where,
"nettest_bsd: create_data_socket: Could not enable receive copy avoidance");
- fflush(where);
+ fflush(test->where);
loc_rcvavoid = 0;
}
}
@@ -580,9 +570,9 @@
SO_SND_COPYAVOID,
&loc_sndavoid,
sizeof(int)) < 0) {
- fprintf(where,
+ fprintf(test->where,
"netperf: create_data_socket: Could not enable send copy avoidance\n");
- fflush(where);
+ fflush(test->where);
loc_sndavoid = 0;
}
}
@@ -605,16 +595,16 @@
TCP_NODELAY,
(char *)&one,
sizeof(one)) < 0) {
- fprintf(where,
+ fprintf(test->where,
"netperf: create_data_socket: nodelay: errno %d\n",
errno);
- fflush(where);
+ fflush(test->where);
}
- if (debug > 1) {
- fprintf(where,
+ if (test->debug > 1) {
+ fprintf(test->where,
"netperf: create_data_socket: TCP_NODELAY requested...\n");
- fflush(where);
+ fflush(test->where);
}
}
#else /* TCP_NODELAY */
@@ -655,8 +645,6 @@
struct addrinfo *local_ai;
struct addrinfo *local_temp;
- where = stderr;
-
/* allocate memory to store the information about this test */
new_data = (bsd_data_t *)malloc(sizeof(bsd_data_t));
@@ -752,25 +740,25 @@
&hints, &local_ai);
count += 1;
if (error == EAI_AGAIN) {
- if (debug) {
- fprintf(where,"Sleeping on getaddrinfo EAI_AGAIN\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"Sleeping on getaddrinfo EAI_AGAIN\n");
+ fflush(test->where);
}
sleep(1);
}
} while ((error == EAI_AGAIN) && (count <= 5));
- if (debug) {
- dump_addrinfo(where, local_ai, localhost, localport, localfam);
+ if (test->debug) {
+ dump_addrinfo(test->where, local_ai, localhost, localport, localfam);
}
if (!error) {
new_data->locaddr = local_ai;
} else {
- if (debug) {
- fprintf(where,"bsd_test_init: getaddrinfo returned %d %s\n",
+ if (test->debug) {
+ fprintf(test->where,"bsd_test_init: getaddrinfo returned %d %s\n",
error, gai_strerror(error));
- fflush(where);
+ fflush(test->where);
}
report_test_failure(test,
"bsd_test_init",
@@ -844,10 +832,10 @@
bsd_data_t *my_data = GET_TEST_DATA(test);
- if (debug) {
- fprintf(where,"bsd_test_get_stats: entered for %s test %s\n",
+ if (test->debug) {
+ fprintf(test->where,"bsd_test_get_stats: entered for %s test %s\n",
test->id, test->test_name);
- fflush(where);
+ fflush(test->where);
}
if ((stats = xmlNewNode(NULL,(xmlChar *)"test_stats")) != NULL) {
/* set the properites of the test_stats message -
@@ -856,8 +844,8 @@
ap = xmlSetProp(stats,(xmlChar *)"tid",test->id);
for (i = 0; i < BSD_MAX_COUNTERS; i++) {
loc_cnt[i] = my_data->stats.counter[i];
- if (debug) {
- fprintf(where,"BSD_COUNTER%X = %#llx\n",i,loc_cnt[i]);
+ if (test->debug) {
+ fprintf(test->where,"BSD_COUNTER%X = %#llx\n",i,loc_cnt[i]);
}
}
if (GET_TEST_STATE == TEST_MEASURE) {
@@ -865,34 +853,34 @@
if (ap != NULL) {
sprintf(value,"%#ld",my_data->curr_time.tv_sec);
ap = xmlSetProp(stats,(xmlChar *)"time_sec",(xmlChar *)value);
- if (debug) {
- fprintf(where,"time_sec=%s\n",value);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"time_sec=%s\n",value);
+ fflush(test->where);
}
}
if (ap != NULL) {
sprintf(value,"%#ld",my_data->curr_time.tv_usec);
ap = xmlSetProp(stats,(xmlChar *)"time_usec",(xmlChar *)value);
- if (debug) {
- fprintf(where,"time_usec=%s\n",value);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"time_usec=%s\n",value);
+ fflush(test->where);
}
}
} else {
if (ap != NULL) {
sprintf(value,"%#ld",my_data->elapsed_time.tv_sec);
ap = xmlSetProp(stats,(xmlChar *)"elapsed_sec",(xmlChar *)value);
- if (debug) {
- fprintf(where,"elapsed_sec=%s\n",value);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"elapsed_sec=%s\n",value);
+ fflush(test->where);
}
}
if (ap != NULL) {
sprintf(value,"%#ld",my_data->elapsed_time.tv_usec);
ap = xmlSetProp(stats,(xmlChar *)"elapsed_usec",(xmlChar *)value);
- if (debug) {
- fprintf(where,"elapsed_usec=%s\n",value);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"elapsed_usec=%s\n",value);
+ fflush(test->where);
}
}
}
@@ -904,9 +892,9 @@
sprintf(value,"%#llx",my_data->stats.counter[i]);
sprintf(name,"cntr%1X_value",i);
ap = xmlSetProp(stats,(xmlChar *)name,(xmlChar *)value);
- if (debug) {
- fprintf(where,"%s=%s\n",name,value);
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"%s=%s\n",name,value);
+ fflush(test->where);
}
}
}
@@ -915,10 +903,10 @@
stats == NULL;
}
}
- if (debug) {
- fprintf(where,"bsd_test_get_stats: exiting for %s test %s\n",
+ if (test->debug) {
+ fprintf(test->where,"bsd_test_get_stats: exiting for %s test %s\n",
test->id, test->test_name);
- fflush(where);
+ fflush(test->where);
}
return(stats);
}
@@ -1013,21 +1001,21 @@
firsttime = 0;
recv_ring = my_data->recv_ring;
recv_size = my_data->recv_size;
- if (debug) {
- dump_addrinfo(where, my_data->locaddr,
+ if (test->debug) {
+ dump_addrinfo(test->where, my_data->locaddr,
(xmlChar *)NULL, (xmlChar *)NULL, -1);
}
- if (debug) {
- fprintf(where,"recv_tcp_stream:create_data_socket returned %d\n",
+ if (test->debug) {
+ fprintf(test->where,"recv_tcp_stream:create_data_socket returned %d\n",
s_listen);
- fflush(where);
+ fflush(test->where);
}
rc = bind(s_listen, my_data->locaddr->ai_addr,
my_data->locaddr->ai_addrlen);
- if (debug) {
- fprintf(where,"recv_tcp_stream:bind returned %d errno=%d\n",
+ if (test->debug) {
+ fprintf(test->where,"recv_tcp_stream:bind returned %d errno=%d\n",
rc,errno);
- fflush(where);
+ fflush(test->where);
}
if (len == -1) {
report_test_failure(test,
@@ -1062,9 +1050,9 @@
case TEST_INIT:
if (CHECK_REQ_STATE == TEST_IDLE) {
peerlen = sizeof(peeraddr);
- if (debug) {
- fprintf(where,"recv_tcp_stream:waiting in accept\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"recv_tcp_stream:waiting in accept\n");
+ fflush(test->where);
}
if ((s_data=accept(s_listen,
&peeraddr,
@@ -1074,10 +1062,10 @@
BSDE_ACCEPT_FAILED,
"listen socket accept failed");
} else {
- if (debug) {
- fprintf(where,"recv_tcp_stream:accept returned successfully %d\n",
+ if (test->debug) {
+ fprintf(test->where,"recv_tcp_stream:accept returned successfully %d\n",
s_data);
- fflush(where);
+ fflush(test->where);
}
SET_TEST_STATE(TEST_IDLE);
}
@@ -1140,8 +1128,8 @@
}
} else {
/* how do we deal with a closed connection in the loaded state */
- fprintf(where,"\nWE JUST GOT A CLOSE INDICATION !!!!!!!!!!!!!!!!\n\n");
- fflush(where);
+ fprintf(test->where,"\nWE JUST GOT A CLOSE INDICATION !!!!!!!!!!!!!!!!\n\n");
+ fflush(test->where);
}
/* code to timestamp enabled by HISTOGRAM */
HIST_TIMESTAMP(&time_two);
@@ -1164,9 +1152,9 @@
} else {
close(s_data);
peerlen = sizeof(peeraddr);
- if (debug) {
- fprintf(where,"recv_tcp_stream:waiting in accept\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"recv_tcp_stream:waiting in accept\n");
+ fflush(test->where);
}
if ((s_data=accept(s_listen,
&peeraddr,
@@ -1176,11 +1164,11 @@
BSDE_ACCEPT_FAILED,
"listen socket accept failed");
} else {
- if (debug) {
- fprintf(where,
+ if (test->debug) {
+ fprintf(test->where,
"recv_tcp_stream:accept returned successfully %d\n",
s_data);
- fflush(where);
+ fflush(test->where);
}
SET_TEST_STATE(TEST_IDLE);
}
@@ -1267,9 +1255,9 @@
break;
case TEST_INIT:
if (CHECK_REQ_STATE == TEST_IDLE) {
- if (debug) {
- fprintf(where,"send_tcp_stream: in INIT state making connect call\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"send_tcp_stream: in INIT state making connect call\n");
+ fflush(test->where);
}
if (connect(send_socket,
my_data->remaddr->ai_addr,
@@ -1279,9 +1267,9 @@
BSDE_CONNECT_FAILED,
"data socket connect failed");
} else {
- if (debug) {
- fprintf(where,"send_tcp_stream: connected and moving to IDLE\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"send_tcp_stream: connected and moving to IDLE\n");
+ fflush(test->where);
}
SET_TEST_STATE(TEST_IDLE);
}
@@ -1367,9 +1355,9 @@
close(send_socket);
send_socket = create_data_socket(test);
if (GET_TEST_STATE != TEST_ERROR) {
- if (debug) {
- fprintf(where,"send_tcp_stream: connecting from LOAD state\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"send_tcp_stream: connecting from LOAD state\n");
+ fflush(test->where);
}
if (connect(send_socket,
my_data->remaddr->ai_addr,
@@ -1379,9 +1367,9 @@
BSDE_CONNECT_FAILED,
"data socket connect failed");
} else {
- if (debug) {
- fprintf(where,"send_tcp_stream: connected moving to IDLE\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"send_tcp_stream: connected moving to IDLE\n");
+ fflush(test->where);
}
SET_TEST_STATE(TEST_IDLE);
}
@@ -1520,21 +1508,21 @@
recv_size = my_data->recv_size;
send_ring = my_data->send_ring;
send_size = my_data->send_size;
- if (debug) {
- dump_addrinfo(where, my_data->locaddr,
+ if (test->debug) {
+ dump_addrinfo(test->where, my_data->locaddr,
(xmlChar *)NULL, (xmlChar *)NULL, -1);
}
- if (debug || loc_debug) {
- fprintf(where,"recv_tcp_rr:create_data_socket returned %d\n",
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"recv_tcp_rr:create_data_socket returned %d\n",
s_listen);
- fflush(where);
+ fflush(test->where);
}
rc = bind(s_listen, my_data->locaddr->ai_addr,
my_data->locaddr->ai_addrlen);
- if (debug || loc_debug) {
- fprintf(where,"recv_tcp_rr:bind returned %d errno=%d\n",
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"recv_tcp_rr:bind returned %d errno=%d\n",
rc,errno);
- fflush(where);
+ fflush(test->where);
}
if (len == -1) {
report_test_failure(test,
@@ -1569,9 +1557,9 @@
case TEST_INIT:
if (CHECK_REQ_STATE == TEST_IDLE) {
peerlen = sizeof(peeraddr);
- if (debug || loc_debug) {
- fprintf(where,"recv_tcp_rr:waiting in accept\n");
- fflush(where);
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"recv_tcp_rr:waiting in accept\n");
+ fflush(test->where);
}
if ((s_data=accept(s_listen,
&peeraddr,
@@ -1581,10 +1569,10 @@
BSDE_ACCEPT_FAILED,
"listen socket accept failed");
} else {
- if (debug || loc_debug) {
- fprintf(where,"recv_tcp_rr:accept returned successfully %d\n",
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"recv_tcp_rr:accept returned successfully %d\n",
s_data);
- fflush(where);
+ fflush(test->where);
}
SET_TEST_STATE(TEST_IDLE);
}
@@ -1698,9 +1686,9 @@
recv(s_data, send_ring->buffer_ptr, send_size, 0);
close(s_data);
peerlen = sizeof(peeraddr);
- if (debug || loc_debug) {
- fprintf(where,"recv_tcp_rr:waiting in accept\n");
- fflush(where);
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"recv_tcp_rr:waiting in accept\n");
+ fflush(test->where);
}
if ((s_data=accept(s_listen,
&peeraddr,
@@ -1710,10 +1698,10 @@
BSDE_ACCEPT_FAILED,
"listen socket accept failed");
} else {
- if (debug || loc_debug) {
- fprintf(where,"recv_tcp_rr:accept returned successfully %d\n",
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"recv_tcp_rr:accept returned successfully %d\n",
s_data);
- fflush(where);
+ fflush(test->where);
}
SET_TEST_STATE(TEST_IDLE);
}
@@ -1812,9 +1800,9 @@
break;
case TEST_INIT:
if (CHECK_REQ_STATE == TEST_IDLE) {
- if (debug) {
- fprintf(where,"send_tcp_rr: in INIT state making connect call\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"send_tcp_rr: in INIT state making connect call\n");
+ fflush(test->where);
}
if (connect(send_socket,
my_data->remaddr->ai_addr,
@@ -1824,9 +1812,9 @@
BSDE_CONNECT_FAILED,
"data socket connect failed");
} else {
- if (debug) {
- fprintf(where,"send_tcp_rr: connected and moving to IDLE\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"send_tcp_rr: connected and moving to IDLE\n");
+ fflush(test->where);
}
SET_TEST_STATE(TEST_IDLE);
}
@@ -1934,9 +1922,9 @@
close(send_socket);
send_socket = create_data_socket(test);
if (GET_TEST_STATE != TEST_ERROR) {
- if (debug) {
- fprintf(where,"send_tcp_rr: connecting from LOAD state\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"send_tcp_rr: connecting from LOAD state\n");
+ fflush(test->where);
}
if (connect(send_socket,
my_data->remaddr->ai_addr,
@@ -1946,9 +1934,9 @@
BSDE_CONNECT_FAILED,
"data socket connect failed");
} else {
- if (debug) {
- fprintf(where,"send_tcp_rr: connected moving to IDLE\n");
- fflush(where);
+ if (test->debug) {
+ fprintf(test->where,"send_tcp_rr: connected moving to IDLE\n");
+ fflush(test->where);
}
SET_TEST_STATE(TEST_IDLE);
}
@@ -2099,16 +2087,16 @@
if (my_data == NULL) {
if (output) {
- if (debug || loc_debug) {
- fprintf(where,"report_bsd_test_results: report going to file %s\n",
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"report_bsd_test_results: report going to file %s\n",
output);
- fflush(where);
+ fflush(test->where);
}
outfd = fopen(output,"a");
} else {
- if (debug || loc_debug) {
- fprintf(where,"report_bsd_test_results: report going to file stdout\n");
- fflush(where);
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"report_bsd_test_results: report going to file stdout\n");
+ fflush(test->where);
}
outfd = stdout;
}
@@ -2129,10 +2117,10 @@
}
if (max_count != my_data->max_count) {
/* someone is playing games don't generate report*/
- fprintf(where,"Max_count changed between invocations of %s\n",
+ fprintf(test->where,"Max_count changed between invocations of %s\n",
"report_bsd_test_results");
- fprintf(where,"exiting netperf now!!\n");
- fflush(where);
+ fprintf(test->where,"exiting netperf now!!\n");
+ fflush(test->where);
exit;
}
@@ -2144,10 +2132,10 @@
sys_seconds = 0.0;
sys_util = 0.0;
set_elt = test_set->tests;
- if (debug || loc_debug) {
- fprintf(where,"test_set %s has %d tests looking for statistics\n",
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"test_set %s has %d tests looking for statistics\n",
test_set->id,test_set->num_tests);
- fflush(where);
+ fflush(test->where);
}
while (set_elt != NULL) {
int stats_for_test;
@@ -2155,28 +2143,28 @@
test = set_elt->test;
stats = test->received_stats->xmlChildrenNode;
- if (debug || loc_debug) {
+ if (test->debug || loc_debug) {
if (stats) {
- fprintf(where,"\ttest %s has '%s' statistics\n", test->id,stats->name);
+ fprintf(test->where,"\ttest %s has '%s' statistics\n", test->id,stats->name);
} else {
- fprintf(where,"\ttest %s has no statistics available!\n", test->id);
+ fprintf(test->where,"\ttest %s has no statistics available!\n", test->id);
}
- fflush(where);
+ fflush(test->where);
}
stats_for_test = 0;
while(stats != NULL) {
/* process all the statistics records for this test */
- if (debug || loc_debug) {
- fprintf(where,"\tfound some statistics");
- fflush(where);
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"\tfound some statistics");
+ fflush(test->where);
}
if(!xmlStrcmp(stats->name,(const xmlChar *)"sys_stats")) {
/* process system statistics */
test_stats = 0;
- if (debug || loc_debug) {
- fprintf(where,"\tprocessing sys_stats\n");
- fflush(where);
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"\tprocessing sys_stats\n");
+ fflush(test->where);
}
for (i=0; i<MAX_SYS_CNTRS; i++) {
char *value_str =
@@ -2191,8 +2179,8 @@
} else {
sys_cntr[i] = 0.0;
}
- if (debug || loc_debug) {
- fprintf(where,"\t%12s sys_stats[%d] = %10g '%s'\n",
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"\t%12s sys_stats[%d] = %10g '%s'\n",
sys_cntr_name[i], i, sys_cntr[i],
xmlGetProp(stats, (const xmlChar *)sys_cntr_name[i]));
}
@@ -2206,14 +2194,14 @@
local_idle = sys_cntr[IDLE] / calibration;
local_busy = (calibration-sys_cntr[IDLE])/calibration;
- if (debug || loc_debug) {
- fprintf(where,"\tnum_cpus = %f\n",local_cpus);
- fprintf(where,"\telapsed_seconds = %7.2f\n",elapsed_seconds);
- fprintf(where,"\tidle_cntr = %e\n",sys_cntr[IDLE]);
- fprintf(where,"\tcalibrate_cntr = %e\n",sys_cntr[CALIBRATE]);
- fprintf(where,"\tlocal_idle = %e\n",local_idle);
- fprintf(where,"\tlocal_busy = %e\n",local_busy);
- fflush(where);
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"\tnum_cpus = %f\n",local_cpus);
+ fprintf(test->where,"\telapsed_seconds = %7.2f\n",elapsed_seconds);
+ fprintf(test->where,"\tidle_cntr = %e\n",sys_cntr[IDLE]);
+ fprintf(test->where,"\tcalibrate_cntr = %e\n",sys_cntr[CALIBRATE]);
+ fprintf(test->where,"\tlocal_idle = %e\n",local_idle);
+ fprintf(test->where,"\tlocal_busy = %e\n",local_busy);
+ fflush(test->where);
}
if (stats_for_test == 0) {
sys_stats_count++;
@@ -2226,9 +2214,9 @@
if(!xmlStrcmp(stats->name,(const xmlChar *)"test_stats")) {
/* process test statistics */
test_stats = 1;
- if (debug || loc_debug) {
- fprintf(where,"\tprocessing test_stats\n");
- fflush(where);
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"\tprocessing test_stats\n");
+ fflush(test->where);
}
for (i=0; i<MAX_TEST_CNTRS; i++) {
char *value_str =
@@ -2243,8 +2231,8 @@
} else {
test_cntr[i] = 0.0;
}
- if (debug || loc_debug) {
- fprintf(where,"\t%12s test_cntr[%2d] = %10g\t'%s'\n",
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"\t%12s test_cntr[%2d] = %10g\t'%s'\n",
cntr_name[i], i, test_cntr[i],
xmlGetProp(stats, (const xmlChar *)cntr_name[i]));
}
@@ -2254,16 +2242,16 @@
recv_rate = test_cntr[TST_R_BYTES]*8/(elapsed_seconds*1000000);
xmit_trans_rate = test_cntr[TST_X_TRANS]/elapsed_seconds;
recv_trans_rate = test_cntr[TST_R_TRANS]/elapsed_seconds;
- if (debug || loc_debug) {
- fprintf(where,"\txmit_rate = %7g\t%7g\n",
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"\txmit_rate = %7g\t%7g\n",
xmit_rate, test_cntr[TST_X_BYTES]);
- fprintf(where,"\trecv_rate = %7g\t%7g\n",
+ fprintf(test->where,"\trecv_rate = %7g\t%7g\n",
recv_rate, test_cntr[TST_R_BYTES]);
- fprintf(where,"\txmit_trans_rate = %7g\t%7g\n",
+ fprintf(test->where,"\txmit_trans_rate = %7g\t%7g\n",
xmit_trans_rate, test_cntr[TST_X_TRANS]);
- fprintf(where,"\trecv_trans_rate = %7g\t%7g\n",
+ fprintf(test->where,"\trecv_trans_rate = %7g\t%7g\n",
recv_trans_rate, test_cntr[TST_X_TRANS]);
- fflush(where);
+ fflush(test->where);
}
if (sd_denominator == 0.0) {
if (xmit_rate > 0.0 || recv_rate > 0.0) {
@@ -2272,18 +2260,18 @@
sd_denominator = 1.0;
}
}
- if (debug || loc_debug) {
- fprintf(where,"\tsd_denominator = %f\n",sd_denominator);
- fflush(where);
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"\tsd_denominator = %f\n",sd_denominator);
+ fflush(test->where);
}
if (sd_denominator != 1.0) {
result = recv_rate + xmit_rate;
} else {
result = recv_trans_rate + xmit_trans_rate;
}
- if (debug || loc_debug) {
- fprintf(where,"\tresult = %f\n",result);
- fflush(where);
+ if (test->debug || loc_debug) {
+ fprintf(test->where,"\tresult = %f\n",result);
+ fflush(test->where);
}
if (stats_for_test == 0) {
test_stats_count++;
@@ -2307,12 +2295,12 @@
/* should only have one stats record for this test otherwise error */
if (stats_for_test > 1) {
/* someone is playing games don't generate report*/
- fprintf(where,"More than one statistics measurement for test %d\n",
+ fprintf(test->where,"More than one statistics measurement for test %d\n",
stats_for_test);
- fprintf(where,"%s was not designed to deal with this.\n",
+ fprintf(test->where,"%s was not designed to deal with this.\n",
"report_bsd_test_results");
- fprintf(where,"exiting netperf now!!\n");
- fflush(where);
+ fprintf(test->where,"exiting netperf now!!\n");
+ fflush(test->where);
exit;
}
@@ -2428,12 +2416,12 @@
/* should only have one system stats count otherwise error */
if (sys_stats_count > 1) {
/* someone is playing games don't generate report*/
- fprintf(where,"More than one system statistics measurement %d\n",
+ fprintf(test->where,"More than one system statistics measurement %d\n",
sys_stats_count);
- fprintf(where,"%s was not designed to deal with this.\n",
+ fprintf(test->where,"%s was not designed to deal with this.\n",
"report_bsd_test_results");
- fprintf(where,"exiting netperf now!!\n");
- fflush(where);
+ fprintf(test->where,"exiting netperf now!!\n");
+ fflush(test->where);
exit;
}
Property changes on: trunk/src/nettest_bsd.c
___________________________________________________________________
Name: svn:keywords
+ Id
More information about the netperf-dev
mailing list