* Added a stupid PRNG to streamcat and fdcat.
* Do not use sed in the testsuite, because of OS X.
This commit is contained in:
20
test/fdcat.c
20
test/fdcat.c
@@ -24,14 +24,22 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static inline int myrand(void)
|
||||
{
|
||||
static int seed = 1;
|
||||
int x, y;
|
||||
x = (seed + 0x12345678) << 11;
|
||||
y = (seed + 0xfedcba98) >> 21;
|
||||
seed = x * 1010101 + y * 343434;
|
||||
return seed;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
long int pos;
|
||||
unsigned char *data;
|
||||
int i, j, fd;
|
||||
|
||||
srand(0);
|
||||
|
||||
if(argc != 2)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@@ -51,13 +59,13 @@ int main(int argc, char *argv[])
|
||||
/* Read shit here and there */
|
||||
for(i = 0; i < 128; i++)
|
||||
{
|
||||
lseek(fd, rand() % pos, SEEK_SET);
|
||||
lseek(fd, myrand() % pos, SEEK_SET);
|
||||
for(j = 0; j < 16; j++)
|
||||
read(fd, data + lseek(fd, 0, SEEK_CUR), rand() % 4096);
|
||||
read(fd, data + lseek(fd, 0, SEEK_CUR), myrand() % 4096);
|
||||
#ifdef HAVE_LSEEK64
|
||||
lseek64(fd, rand() % pos, SEEK_SET);
|
||||
lseek64(fd, myrand() % pos, SEEK_SET);
|
||||
for(j = 0; j < 16; j++)
|
||||
read(fd, data + lseek(fd, 0, SEEK_CUR), rand() % 4096);
|
||||
read(fd, data + lseek(fd, 0, SEEK_CUR), myrand() % 4096);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,16 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static inline int myrand(void)
|
||||
{
|
||||
static int seed = 1;
|
||||
int x, y;
|
||||
x = (seed + 0x12345678) << 11;
|
||||
y = (seed + 0xfedcba98) >> 21;
|
||||
seed = x * 1010101 + y * 343434;
|
||||
return seed;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
long int pos;
|
||||
@@ -25,8 +35,6 @@ int main(int argc, char *argv[])
|
||||
int i, j;
|
||||
FILE *stream;
|
||||
|
||||
srand(0);
|
||||
|
||||
if(argc != 2)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@@ -48,10 +56,10 @@ int main(int argc, char *argv[])
|
||||
for(i = 0; i < 128; i++)
|
||||
{
|
||||
long int now;
|
||||
fseek(stream, rand() % pos, SEEK_SET);
|
||||
fseek(stream, myrand() % pos, SEEK_SET);
|
||||
for(j = 0; j < 16; j++)
|
||||
fread(data + ftell(stream), rand() % 4096, 1, stream);
|
||||
fseek(stream, rand() % pos, SEEK_SET);
|
||||
fread(data + ftell(stream), myrand() % 4096, 1, stream);
|
||||
fseek(stream, myrand() % pos, SEEK_SET);
|
||||
now = ftell(stream);
|
||||
for(j = 0; j < 16; j++)
|
||||
data[now + j] = getc(stream);
|
||||
|
||||
@@ -69,7 +69,9 @@ for file in /tmp/zzuf-zero-$$ /tmp/zzuf-text-$$ /tmp/zzuf-random-$$; do
|
||||
# We don't include grep in the testsuite because it puts a newline
|
||||
# at the end of its input if it was not there initially.
|
||||
#check $seed $r "grep -- -a \\'\\' $file" "grep -a"
|
||||
check $seed $r "-- sed -e n $file" "sed n"
|
||||
# We don't include sed in the testsuite because on OS X in also
|
||||
# puts a newline. Crap.
|
||||
#check $seed $r "-- sed -e n $file" "sed n"
|
||||
check $seed $r "dd bs=65536 if=$file" "dd(bs=65536)"
|
||||
check $seed $r "dd bs=1111 if=$file" "dd(bs=1111)"
|
||||
check $seed $r "dd bs=1024 if=$file" "dd(bs=1024)"
|
||||
|
||||
Reference in New Issue
Block a user