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