diff --git a/test/testsuite.sh b/test/testsuite.sh index 6dbee36..b327444 100755 --- a/test/testsuite.sh +++ b/test/testsuite.sh @@ -63,8 +63,9 @@ for r in 0.0 0.00001 0.001 0.1 10.0; do else check "$ZZOPTS" "< $file" "zzuf" fi - check "$ZZOPTS" "$ZZCAT 1 $file" "zzcat 1" - check "$ZZOPTS" "$ZZCAT 2 $file" "zzcat 2" + for n in 1 2 3; do + check "$ZZOPTS" "$ZZCAT $n $file" "zzcat $n" + done if [ "$STATIC_CAT" = "" ]; then check "$ZZOPTS" "cat $file" "cat" check "$ZZOPTS" "-i cat < $file" "|cat" diff --git a/test/zzcat.c b/test/zzcat.c index 3424611..c22bf5e 100644 --- a/test/zzcat.c +++ b/test/zzcat.c @@ -22,6 +22,9 @@ #if defined HAVE_UNISTD_H # include #endif +#if defined HAVE_SYS_MMAN_H +# include +#endif #include #include #include @@ -102,6 +105,25 @@ int main(int argc, char *argv[]) } fclose(stream); break; + case 3: /* mmap() */ + fd = open(name, O_RDONLY); + if(fd < 0) + return EXIT_FAILURE; +#ifdef HAVE_MMAP + for(i = 0; i < 128; i++) + { + int moff = myrand() % len; + int mlen = myrand() % (len - moff); + char *map = mmap(NULL, mlen, PROT_READ, MAP_PRIVATE, fd, moff); + for(j = 0; j < 128; j++) + { + int x = myrand() % mlen; + data[moff + x] = data[x]; + } + munmap(map); + } +#endif + close(fd); } /* Write what we have read */