~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to tests/cris/check_mmap2.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno, Aurelien Jarno
  • Date: 2008-08-25 04:38:35 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080825043835-8e3tftavy8bujdch
Tags: 0.9.1-6
[ Aurelien Jarno ]
* debian/control: 
  - Update list of supported targets (Closes: bug#488339).
* debian/qemu-make-debian-root:
  - Use mktemp instead of $$ to create temporary directories (Closes: 
    bug#496394).
* debian/links:
  - Add missing links to manpages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
#notarget: cris*-*-elf
 
3
*/
 
4
 
 
5
#define _GNU_SOURCE
 
6
#include <string.h>
 
7
#include <stdlib.h>
 
8
#include <stdio.h>
 
9
#include <sys/types.h>
 
10
#include <sys/stat.h>
 
11
#include <fcntl.h>
 
12
#include <unistd.h>
 
13
#include <sys/mman.h>
 
14
 
 
15
int main (int argc, char *argv[])
 
16
{
 
17
  int fd = open (argv[0], O_RDONLY);
 
18
  struct stat sb;
 
19
  int size;
 
20
  void *a;
 
21
  const char *str = "a string you'll only find in the program";
 
22
 
 
23
  if (fd == -1)
 
24
    {
 
25
      perror ("open");
 
26
      abort ();
 
27
    }
 
28
 
 
29
  if (fstat (fd, &sb) < 0)
 
30
    {
 
31
      perror ("fstat");
 
32
      abort ();
 
33
    }
 
34
 
 
35
  size = sb.st_size;
 
36
 
 
37
  /* We want to test mmapping a size that isn't exactly a page.  */
 
38
  if ((size & 8191) == 0)
 
39
    size--;
 
40
 
 
41
  a = mmap (NULL, size, PROT_READ, MAP_SHARED, fd, 0);
 
42
 
 
43
  if (memmem (a, size, str, strlen (str) + 1) == NULL)
 
44
    abort ();
 
45
 
 
46
  printf ("pass\n");
 
47
  exit (0);
 
48
}