| 1 | #include <unistd.h>
|
|---|
| 2 | #include <sys/stat.h>
|
|---|
| 3 | #include <stdio.h>
|
|---|
| 4 | #include <errno.h>
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 | int main(int argc, char **argv)
|
|---|
| 8 | {
|
|---|
| 9 | int cErrors = 0;
|
|---|
| 10 | int rc;
|
|---|
| 11 | struct stat s;
|
|---|
| 12 | printf("stat-1: TESTING\n");
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | /*
|
|---|
| 16 | * Current dir.
|
|---|
| 17 | */
|
|---|
| 18 | rc = stat(".", &s);
|
|---|
| 19 | if (rc != 0)
|
|---|
| 20 | {
|
|---|
| 21 | printf("stat(%s) -> %d errno=%d\n", ".", rc, errno);
|
|---|
| 22 | cErrors++;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | /*
|
|---|
| 26 | * Parent dir.
|
|---|
| 27 | */
|
|---|
| 28 | rc = stat("..", &s);
|
|---|
| 29 | if (rc != 0)
|
|---|
| 30 | {
|
|---|
| 31 | printf("stat(%s) -> %d errno=%d\n", "..", rc, errno);
|
|---|
| 32 | cErrors++;
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 | /*
|
|---|
| 37 | * Executable.
|
|---|
| 38 | */
|
|---|
| 39 | rc = stat(argv[0], &s);
|
|---|
| 40 | if (rc != 0)
|
|---|
| 41 | {
|
|---|
| 42 | printf("stat(%s) -> %d errno=%d\n", argv[0], rc, errno);
|
|---|
| 43 | cErrors++;
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | /*
|
|---|
| 47 | * Summary.
|
|---|
| 48 | */
|
|---|
| 49 | if (cErrors)
|
|---|
| 50 | printf("stat-1: FAILURE %d failures\n", cErrors);
|
|---|
| 51 | else
|
|---|
| 52 | printf("stat-1: SUCCESS\n");
|
|---|
|
|---|