[netperf-dev] netperf2 commit notice r370 - in trunk: . src
raj at netperf.org
raj at netperf.org
Mon Dec 20 11:57:31 PST 2010
Author: raj
Date: 2010-12-20 11:57:31 -0800 (Mon, 20 Dec 2010)
New Revision: 370
Modified:
trunk/config.h.in
trunk/configure
trunk/configure.ac
trunk/src/netlib.c
trunk/src/netsh.c
Log:
upshift test_name to allow use of strstr on it
Modified: trunk/config.h.in
===================================================================
--- trunk/config.h.in 2010-11-30 01:01:49 UTC (rev 369)
+++ trunk/config.h.in 2010-12-20 19:57:31 UTC (rev 370)
@@ -247,6 +247,9 @@
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
+/* Define to 1 if you have the `toupper' function. */
+#undef HAVE_TOUPPER
+
/* Define to 1 if you have the `uname' function. */
#undef HAVE_UNAME
Modified: trunk/configure
===================================================================
--- trunk/configure 2010-11-30 01:01:49 UTC (rev 369)
+++ trunk/configure 2010-12-20 19:57:31 UTC (rev 370)
@@ -7358,7 +7358,8 @@
-for ac_func in alarm bzero gethostbyname gethrtime gettimeofday inet_ntoa memset memcpy munmap select socket sqrt strcasecmp strchr strstr strtoul uname
+
+for ac_func in alarm bzero gethostbyname gethrtime gettimeofday inet_ntoa memset memcpy munmap select socket sqrt strcasecmp strchr strstr strtoul uname toupper
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-11-30 01:01:49 UTC (rev 369)
+++ trunk/configure.ac 2010-12-20 19:57:31 UTC (rev 370)
@@ -75,7 +75,7 @@
# AC_FUNC_STAT
# remove pstat_getdynamic (at least for now) since we don't do
# anything conditional with the check anyway...
-AC_CHECK_FUNCS([alarm bzero gethostbyname gethrtime gettimeofday inet_ntoa memset memcpy munmap select socket sqrt strcasecmp strchr strstr strtoul uname])
+AC_CHECK_FUNCS([alarm bzero gethostbyname gethrtime gettimeofday inet_ntoa memset memcpy munmap select socket sqrt strcasecmp strchr strstr strtoul uname toupper])
#AC_CONFIG_SUBDIRS(src/missing)
Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c 2010-11-30 01:01:49 UTC (rev 369)
+++ trunk/src/netlib.c 2010-12-20 19:57:31 UTC (rev 370)
@@ -712,9 +712,16 @@
-unsigned long
+/* The original patch from Google used lrand48, but I have been
+ informed that is not easily available under Windows. So, rather
+ than have some #ifdefs here I'll just simplistically replace
+ lrand48 with rand(), which should be "good enough" at some point it
+ may be sufficient to just call rand() directly rather than call
+ this raj 20101130 */
+
+unsigned int
rand32(){
- return (unsigned long)lrand48() * 2 + lrand48() % 2;
+ return (unsigned int)rand() * 2 + rand() % 2;
}
/* this routine will set the ip address of the sockaddr in the
@@ -729,7 +736,7 @@
case AF_INET: {
struct sockaddr_in *foo = (struct sockaddr_in *)res->ai_addr;
unsigned int addr = ntohl(foo->sin_addr.s_addr);
- unsigned long mask = ((unsigned long)1 << (32 - mask_len)) - 1;
+ unsigned int mask = ((unsigned int)1 << (32 - mask_len)) - 1;
if ((mask_len < 0) || (mask_len > 32)) {
fprintf(where,
@@ -751,7 +758,7 @@
unsigned int i, len;
unsigned int *addr = (unsigned int *)&(foo->sin6_addr.s6_addr);
- unsigned long mask;
+ unsigned int mask;
if ((mask_len < 0) || (mask_len > 128)) {
fprintf(where,
@@ -765,7 +772,7 @@
len = mask_len - i * 32;
len = ((len < 32) ? len : 32);
len = ((len > 0) ? len : 0);
- mask = ((unsigned long)1 << (32 - len)) - 1;
+ mask = ((unsigned int)1 << (32 - len)) - 1;
addr[i] = (addr[i] & ~mask) | (rand32() & mask);
addr[i] = htonl(addr[i]);
}
Modified: trunk/src/netsh.c
===================================================================
--- trunk/src/netsh.c 2010-11-30 01:01:49 UTC (rev 369)
+++ trunk/src/netsh.c 2010-12-20 19:57:31 UTC (rev 370)
@@ -583,6 +583,23 @@
fprintf(stderr, "%s%s", netperf_usage1, netperf_usage2);
}
+/* convert the specified string to upper case if we know how */
+static void
+convert_to_upper(char *source)
+{
+#if defined(HAVE_TOUPPER)
+ int i,length;
+
+ length = strlen(source);
+
+ for (i=0; i < length; i++) {
+ source[i] = toupper(source[i]);
+ }
+#endif
+ return;
+
+}
+
void
scan_cmd_line(int argc, char *argv[])
{
@@ -827,8 +844,10 @@
wait_time_secs = convert(optarg);
break;
case 't':
- /* set the test name */
- strcpy(test_name,optarg);
+ /* set the test name and shift it to upper case so we don't have
+ to worry about compares on things like substrings */
+ strncpy(test_name,optarg,sizeof(test_name)-1);
+ convert_to_upper(test_name);
break;
case 'T':
/* We want to set the processor on which netserver or netperf */
@@ -1089,9 +1108,13 @@
}
/* parsing test-specific options used to be conditional on there
- being a "--" in the option stream. however, some of the tests
- have other initialization happening in their "scan" routines so we
- want to call them regardless. raj 2005-02-08 */
+ being a "--" in the option stream. however, some of the tests
+ have other initialization happening in their "scan" routines so
+ we want to call them regardless. raj 2005-02-08 */
+ /* while the parsing of the command line will upshift the test name,
+ since we don't know that there will always be a way to do so? we
+ will retain for now the strcasecmp calls rather than switch to
+ strcmp. raj 20101220 */
if (
#ifndef WANT_MIGRATION
(strcasecmp(test_name,"TCP_STREAM") == 0) ||
More information about the netperf-dev
mailing list