X-Git-Url: http://git.alex.org.uk diff --git a/nbd-tester-client.c b/nbd-tester-client.c index cecddf7..3169ab1 100644 --- a/nbd-tester-client.c +++ b/nbd-tester-client.c @@ -24,20 +24,24 @@ #include #include #include -#include #include #include -#include #include +#include #include #include "config.h" #include "lfs.h" #define MY_NAME "nbd-tester-client" #include "cliserv.h" +#include +#include + static gchar errstr[1024]; const static int errstr_len=1024; +static uint64_t size; + typedef enum { CONNECTION_TYPE_NONE, CONNECTION_TYPE_CONNECT, @@ -67,12 +71,14 @@ inline int read_all(int f, void *buf, size_t len) { return retval; } -int setup_connection(gchar *hostname, int port, CONNECTION_TYPE ctype) { +int setup_connection(gchar *hostname, int port, gchar* name, CONNECTION_TYPE ctype) { int sock; struct hostent *host; struct sockaddr_in addr; char buf[256]; + uint64_t mymagic = (name ? opts_magic : cliserv_magic); u64 tmp64; + uint32_t tmp32 = 0; sock=0; if(ctype1024) { + speed>>=10; + speedchar[0]='K'; + } + if(speed>1024) { + speed>>=10; + speedchar[0]='M'; + } + if(speed>1024) { + speed>>=10; + speedchar[0]='G'; + } + g_message("%d: Throughput test complete. Took %.3f seconds to complete, %d%sB/s", (int)getpid(), timespan,speed,speedchar); err_open: if(close_sock) { @@ -293,25 +327,32 @@ err: int main(int argc, char**argv) { gchar *hostname; - long int p; + long int p = 0; int port; - int sock; + char* name = NULL; + int sock=0; if(argc<3) { - g_message("Not enough arguments"); - g_message("Usage: %s ", argv[0]); + g_message("%d: Not enough arguments", (int)getpid()); + g_message("%d: Usage: %s ", (int)getpid(), argv[0]); + g_message("%d: Or: %s -N ", (int)getpid(), argv[0]); exit(EXIT_FAILURE); } logging(); hostname=g_strdup(argv[1]); - p=(strtol(argv[2], NULL, 0)); - if(p==LONG_MIN||p==LONG_MAX) { - g_critical("Could not parse port number: %s", strerror(errno)); - exit(EXIT_FAILURE); + if(!strncmp(argv[2], "-N", 2)) { + name = g_strdup(argv[3]); + p = 10809; + } else { + p=(strtol(argv[2], NULL, 0)); + if(p==LONG_MIN||p==LONG_MAX) { + g_critical("Could not parse port number: %s", strerror(errno)); + exit(EXIT_FAILURE); + } } port=(int)p; - if(throughput_test(hostname, port, sock, FALSE, TRUE)<0) { + if(throughput_test(hostname, port, name, sock, FALSE, TRUE)<0) { g_warning("Could not run throughput test: %s", errstr); exit(EXIT_FAILURE); }