1 /* Test if /proc/{self,$PID}/auxv is correctly simulated and that the aux
2 vector contains plausible values. */
11 static int check_file(const char *path
, auxv_t
*auxv
)
17 if (!(fi
= fopen(path
, "r"))) {
22 if (fread(&rauxv
, sizeof(rauxv
), 1, fi
) != 1) {
27 fprintf(stderr
, "unexpected EOF\n");
30 if (memcmp(auxv
, &rauxv
, sizeof(rauxv
))) {
31 fprintf(stderr
, "incorrect auxv in %s\n", path
);
32 fprintf(stderr
, "expected: type=%d, val=%ld\n", auxv
->a_type
,
34 fprintf(stderr
, "got: type=%d, val=%ld\n", rauxv
.a_type
,
39 if (auxv
->a_type
== AT_NULL
)
52 int main(int argc
, char *argv
[], char *envp
[])
57 /* Find aux vector. */
60 auxv
= (auxv_t
*)(envp
+ 1);
62 /* /proc/self/auxv check */
63 if (check_file("/proc/self/auxv", auxv
))
66 /* /proc/$PID/auxv check */
67 snprintf(buf
, sizeof(buf
), "/proc/%ld/auxv", (long)getpid());
68 if (check_file(buf
, auxv
))
71 /* AT_SUN_EXECNAME check */
72 while (auxv
->a_type
!= AT_NULL
) {
73 if (auxv
->a_type
== AT_SUN_EXECNAME
) {
74 const char *execname
= auxv
->a_un
.a_ptr
;
76 fprintf(stderr
, "AT_SUN_EXECNAME is null\n");
79 if (access(execname
, R_OK
| X_OK
)) {
80 fprintf(stderr
, "AT_SUN_EXECNAME (%s) is invalid: %s\n",
81 execname
, strerror(errno
));