Permalink
Browse files

MB-100 rand() cannot be trusted to be unique

Change-Id: I58e60408e4b102eec25a5b9bc0f38769602bfe22
Reviewed-on: http://review.couchbase.org/20715
Reviewed-by: Jens Alfke <jens@couchbase.com>
Tested-by: Jens Alfke <jens@couchbase.com>
  • Loading branch information...
1 parent c79f436 commit 29579bd47f7c916c43116722b8f4962b4ea9fff0 @apage43 committed with Peter Wansch Sep 11, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 tests/testapp.c
View
@@ -190,11 +190,11 @@ static void test_save_docs(int count, const char *doc_tpl)
fflush(stderr);
docset_init(count);
- srand(0xdeadbeef); // doc IDs should be consistent across runs
+ srandom(0xdeadbeef); // doc IDs should be consistent across runs
for (i = 0; i < count; ++i) {
idBuf = (char *) malloc(sizeof(char) * 32);
assert(idBuf != NULL);
- int idsize = sprintf(idBuf, "doc%lu", (unsigned long)rand());
+ int idsize = sprintf(idBuf, "doc%d-%lu", i, (unsigned long)random());
valueBuf = (char *) malloc(sizeof(char) * (strlen(doc_tpl) + 20));
assert(valueBuf != NULL);
int valsize = sprintf(valueBuf, doc_tpl, i + 1);

0 comments on commit 29579bd

Please sign in to comment.