Changeset 1745 for zzuf/trunk


Ignore:
Timestamp:
Feb 19, 2007, 10:16:10 AM (13 years ago)
Author:
Sam Hocevar
Message:
  • Added mmap() to the testsuite.
Location:
zzuf/trunk/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/test/testsuite.sh

    r1725 r1745  
    6464            check "$ZZOPTS" "< $file" "zzuf"
    6565        fi
    66         check "$ZZOPTS" "$ZZCAT 1 $file" "zzcat 1"
    67         check "$ZZOPTS" "$ZZCAT 2 $file" "zzcat 2"
     66        for n in 1 2 3; do
     67            check "$ZZOPTS" "$ZZCAT $n $file" "zzcat $n"
     68        done
    6869        if [ "$STATIC_CAT" = "" ]; then
    6970            check "$ZZOPTS" "cat $file" "cat"
  • zzuf/trunk/test/zzcat.c

    r1728 r1745  
    2222#if defined HAVE_UNISTD_H
    2323#   include <unistd.h>
     24#endif
     25#if defined HAVE_SYS_MMAN_H
     26#   include <sys/mman.h>
    2427#endif
    2528#include <stdlib.h>
     
    103106        fclose(stream);
    104107        break;
     108    case 3: /* mmap() */
     109        fd = open(name, O_RDONLY);
     110        if(fd < 0)
     111            return EXIT_FAILURE;
     112#ifdef HAVE_MMAP
     113        for(i = 0; i < 128; i++)
     114        {
     115            int moff = myrand() % len;
     116            int mlen = myrand() % (len - moff);
     117            char *map = mmap(NULL, mlen, PROT_READ, MAP_PRIVATE, fd, moff);
     118            for(j = 0; j < 128; j++)
     119            {
     120                int x = myrand() % mlen;
     121                data[moff + x] = data[x];
     122            }
     123            munmap(map);
     124        }
     125#endif
     126        close(fd);
    105127    }
    106128
Note: See TracChangeset for help on using the changeset viewer.