Commit 984622b0 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1665 minicron-test is quiet unless verbose is on

git-svn-id: file:///svn/toku/tokudb@11302 c7de825b-a66e-492c-adef-691d508d4ae1
parent 2d66b390
#include "minicron.h" #include "minicron.h"
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
#include <string.h>
#include <stdlib.h>
int verbose=0;
static inline void
default_parse_args (int argc, const char *argv[]) {
const char *progname=argv[0];
argc--; argv++;
while (argc>0) {
if (strcmp(argv[0],"-v")==0) {
verbose=1;
} else if (strcmp(argv[0],"-q")==0) {
verbose=0;
} else {
fprintf(stderr, "Usage:\n %s [-v] [-q]\n", progname);
exit(1);
}
argc--; argv++;
}
}
static double static double
tdiff (struct timeval *a, struct timeval *b) { tdiff (struct timeval *a, struct timeval *b) {
...@@ -53,7 +74,7 @@ run_5x (void *v) { ...@@ -53,7 +74,7 @@ run_5x (void *v) {
struct timeval now; struct timeval now;
gettimeofday(&now, 0); gettimeofday(&now, 0);
double diff = tdiff(&now, &tx->tv); double diff = tdiff(&now, &tx->tv);
printf("T=%f\n", diff); if (verbose) printf("T=%f\n", diff);
assert(diff>0.5 + tx->counter); assert(diff>0.5 + tx->counter);
assert(diff<1.5 + tx->counter); assert(diff<1.5 + tx->counter);
tx->counter++; tx->counter++;
...@@ -77,11 +98,11 @@ test3 (void* v) ...@@ -77,11 +98,11 @@ test3 (void* v)
static int static int
run_3sec (void *v) { run_3sec (void *v) {
printf("start3sec at %.6f\n", elapsed()); if (verbose) printf("start3sec at %.6f\n", elapsed());
int *counter = v; int *counter = v;
(*counter)++; (*counter)++;
sleep(3); sleep(3);
printf("end3sec at %.6f\n", elapsed()); if (verbose) printf("end3sec at %.6f\n", elapsed());
return 0; return 0;
} }
...@@ -121,8 +142,9 @@ test6 (void *v) { ...@@ -121,8 +142,9 @@ test6 (void *v) {
typedef void*(*ptf)(void*); typedef void*(*ptf)(void*);
int int
main (int argc __attribute__((__unused__)), const char *argv[] __attribute__((__unused__))) main (int argc, const char *argv[])
{ {
default_parse_args(argc,argv);
gettimeofday(&starttime, 0); gettimeofday(&starttime, 0);
ptf testfuns[] = {test1, test2, test3, ptf testfuns[] = {test1, test2, test3,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment