diff options
author | Brian Norris <computersforpeace@gmail.com> | 2011-12-02 09:46:12 -0800 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@intel.com> | 2011-12-05 08:27:31 +0200 |
commit | 4e37713af46f289eac21ca24d2e7d50aed014237 (patch) | |
tree | ad897f947004df1cb97b16911e3cbd424262b36d | |
parent | 1cf7295ecd343090e7327bade716f25e0bf737cb (diff) |
nandtest: seed random generator with time
If a seed is not provided via --seed, we use the default rand() values,
which produces the same sequence of values every run. Since this is
undesirable, we should choose a random seed via the current time().
Note that this patch moves the srand() until after all the initial
options processing.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
-rw-r--r-- | nandtest.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -140,6 +140,8 @@ int main(int argc, char **argv) uint32_t offset = 0; uint32_t length = -1; + seed = time(NULL); + for (;;) { static const char *short_options="hkl:mo:p:s:"; static const struct option long_options[] = { @@ -173,7 +175,6 @@ int main(int argc, char **argv) case 's': seed = atol(optarg); - srand(seed); break; case 'p': @@ -244,6 +245,8 @@ int main(int argc, char **argv) printf("Bad blocks : %d\n", oldstats.badblocks); printf("BBT blocks : %d\n", oldstats.bbtblocks); + srand(seed); + for (pass = 0; pass < nr_passes; pass++) { loff_t test_ofs; |