Skip to content

Commit

Permalink
zlib: add lrand48 data source zlib method
Browse files Browse the repository at this point in the history
Generate data from lrand48, the period of this is so large that
zlib should not be able to compress this data.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
  • Loading branch information
Colin Ian King committed May 18, 2019
1 parent d480037 commit 961b996
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stress-ng.1
Expand Up @@ -3874,6 +3874,9 @@ T}
latin T{
Random latin sentences from a sample of Lorem Ipsum text.
T}
lrand48 T{
Uniformly distributed pseudo-random 32 bit values generated from lrand48(3).
T}
nybble T{
randomly distributed bytes in the range of 0x00 to 0x0f.
T}
Expand Down
22 changes: 22 additions & 0 deletions stress-zlib.c
Expand Up @@ -512,6 +512,26 @@ static void stress_rand_data_brown(const args_t *args, uint32_t *data, const int
}
}

/*
* stress_rand_data_lrand48()
* fills buffer with random data from lrand48
*/
static void stress_rand_data_lrand48(const args_t *args, uint32_t *data, const int size)
{
static bool seeded = false;
const int n = size / sizeof(*data);
register int i;

if (UNLIKELY(!seeded)) {
srand48(mwc32());
seeded = true;
}

(void)args;

for (i = 0; i < n; i++, data++)
*data = lrand48();
}

/*
* stress_rand_data_latin()
Expand Down Expand Up @@ -614,6 +634,7 @@ static const stress_zlib_rand_data_func rand_data_funcs[] = {
stress_rand_data_fixed,
stress_rand_data_gray,
stress_rand_data_latin,
stress_rand_data_lrand48,
stress_rand_data_nybble,
stress_rand_data_objcode,
stress_rand_data_parity,
Expand Down Expand Up @@ -651,6 +672,7 @@ static stress_zlib_rand_data_info_t zlib_rand_data_methods[] = {
{ "gray", stress_rand_data_gray },
{ "fixed", stress_rand_data_fixed },
{ "latin", stress_rand_data_latin },
{ "lrand48", stress_rand_data_lrand48 },
{ "nybble", stress_rand_data_nybble },
{ "objcode", stress_rand_data_objcode },
{ "parity", stress_rand_data_parity },
Expand Down

0 comments on commit 961b996

Please sign in to comment.