~ubuntu-branches/ubuntu/wily/qemu-kvm-spice/wily

« back to all changes in this revision

Viewing changes to tests/cris/check_openpf1.c

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-10-19 10:44:56 UTC
  • Revision ID: james.westby@ubuntu.com-20111019104456-xgvskumk3sxi97f4
Tags: upstream-0.15.0+noroms
ImportĀ upstreamĀ versionĀ 0.15.0+noroms

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Check that --sysroot is applied to open(2).
 
2
#sim: --sysroot=@exedir@
 
3
 
 
4
   We assume, with EXE being the name of the executable:
 
5
   - The simulator executes with cwd the same directory where the executable
 
6
     is located (so argv[0] contains a plain filename without directory
 
7
     components).
 
8
   - There's no /EXE on the host file system.  */
 
9
 
 
10
#include <stdio.h>
 
11
#include <stdlib.h>
 
12
#include <string.h>
 
13
#include <errno.h>
 
14
int main (int argc, char *argv[])
 
15
{
 
16
  char *fnam = argv[0];
 
17
  FILE *f;
 
18
  if (argv[0][0] != '/')
 
19
    {
 
20
      fnam = malloc (strlen (argv[0]) + 2);
 
21
      if (fnam == NULL)
 
22
        abort ();
 
23
      strcpy (fnam, "/");
 
24
      strcat (fnam, argv[0]);
 
25
    }
 
26
 
 
27
  f = fopen (fnam, "rb");
 
28
  if (f == NULL)
 
29
    abort ();
 
30
  fclose(f);
 
31
 
 
32
  /* Cover another execution path.  */
 
33
  if (fopen ("/nonexistent", "rb") != NULL
 
34
      || errno != ENOENT)
 
35
    abort ();
 
36
  printf ("pass\n");
 
37
  return 0;
 
38
}