* Added mmap() to the testsuite.

This commit is contained in:
Sam Hocevar
2007-02-19 09:16:10 +00:00
committed by sam
parent 538cd60bda
commit 68a2cee2df
2 changed files with 25 additions and 2 deletions

View File

@@ -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"

View File

@@ -22,6 +22,9 @@
#if defined HAVE_UNISTD_H
# include <unistd.h>
#endif
#if defined HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
@@ -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 */