From 32243fadeab8cf244861e3df89744b78ba3eff92 Mon Sep 17 00:00:00 2001 From: Ken Sumrall Date: Wed, 27 Jun 2012 16:01:40 -0700 Subject: Fix a few bugs in rand_emmc_perf Fix the code to properly read urandom to init the random number generator. Fix to properly read the arguments if any options are given. Fix to enable it to be built against glibc. Change-Id: I9127a71232e39afa3054fe9f1612def9ae13d9d3 --- tests/ext4/rand_emmc_perf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/ext4/rand_emmc_perf.c b/tests/ext4/rand_emmc_perf.c index d55adc93..1f79c753 100644 --- a/tests/ext4/rand_emmc_perf.c +++ b/tests/ext4/rand_emmc_perf.c @@ -19,7 +19,8 @@ * out. Without O_SYNC, the close(2) blocks until all the dirty buffers are written * out, but the numbers tend to be higher. */ - + +#define _LARGEFILE64_SOURCE #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #define TST_BLK_SIZE 4096 /* Number of seconds to run the test */ @@ -79,14 +81,14 @@ int main(int argc, char *argv[]) } /* Size is given in megabytes, so compute the number of TST_BLK_SIZE blocks. */ - max_blocks = atol(argv[2]) * ((1024*1024) / TST_BLK_SIZE); + max_blocks = atol(argv[optind]) * ((1024*1024) / TST_BLK_SIZE); - if ((fd = open(argv[3], O_RDWR | o_sync)) < 0) { - fprintf(stderr, "Cannot open block device %s\n", argv[2]); + if ((fd = open(argv[optind + 1], O_RDWR | o_sync)) < 0) { + fprintf(stderr, "Cannot open block device %s\n", argv[optind + 1]); exit(1); } - fd2 = open("/dev/urandom\n", O_RDONLY); + fd2 = open("/dev/urandom", O_RDONLY); if (fd2 < 0) { fprintf(stderr, "Cannot open /dev/urandom\n"); } -- cgit v1.2.3