Files
RedBear-OS/tests/stdlib/realpath.c
T
Tibor Nagy d1a424c002 tests: Replace returns with exits in the main functions
This will allow us to redefine the exit function.

For example:
```
#define exit(code) { \
    fprintf(stderr, "%s:%d: exit(%s) in function ‘%s’\n",
        __FILE__, __LINE__, #code, __func__); \
    _exit(code); \
}
```
2019-02-21 12:15:06 +01:00

30 lines
519 B
C

#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
char* path = realpath("stdlib/realpath.c", NULL);
if (!path) {
perror("realpath");
exit(EXIT_FAILURE);
}
puts(path);
free(path);
path = malloc(PATH_MAX);
memset(path, 0, PATH_MAX);
realpath("stdlib/realpath.c", path);
if (!path) {
perror("realpath");
free(path);
exit(EXIT_FAILURE);
}
puts(path);
free(path);
}