aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/tests/posix/getcwd.c
blob: f3ba8da18b6daa61b19c53ae92d9a271d0156118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <assert.h>
#include <limits.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

int main() {
	char buf[PATH_MAX];
	char *ret = getcwd(buf, PATH_MAX);

	assert(ret);
	assert((strlen(ret) == strlen(buf)) && strlen(ret));
	assert(!strcmp(ret, buf));

	char *ret2 = getcwd(NULL, 0);
	assert(ret2);
	assert(strlen(ret2));
	assert(!strcmp(ret, ret2));
	free(ret2);

	return 0;
}