]> git.ozlabs.org Git - ccan/blob - ccan/tal/path/test/run-cwd.c
base64: fix for unsigned chars (e.g. ARM).
[ccan] / ccan / tal / path / test / run-cwd.c
1 #include <ccan/tal/path/path.h>
2 #include <ccan/tal/path/path.c>
3 #include <ccan/tap/tap.h>
4
5 int main(void)
6 {
7         char path1[1024], *cwd, *ctx = tal_strdup(NULL, "ctx");
8
9         /* This is how many tests you plan to run */
10         plan_tests(5);
11
12         if (!getcwd(path1, sizeof(path1)))
13                 abort();
14
15         cwd = path_cwd(ctx);
16         ok1(cwd);
17         ok1(tal_parent(cwd) == ctx);
18         tal_free(cwd);
19
20         rmdir("run-cwd-long-long-long-name/bar-long-long-long-long-name");
21         rmdir("run-cwd-long-long-long-name");
22         if (mkdir("run-cwd-long-long-long-name", 0700) != 0)
23                 abort();
24         if (mkdir("run-cwd-long-long-long-name/bar-long-long-long-long-name", 0700) != 0)
25                 abort();
26         if (chdir("run-cwd-long-long-long-name/bar-long-long-long-long-name") != 0)
27                 abort();
28
29         cwd = path_cwd(ctx);
30         ok1(cwd);
31         ok1(tal_parent(cwd) == ctx);
32         ok1(strends(cwd,
33                     "run-cwd-long-long-long-name/bar-long-long-long-long-name"));
34         tal_free(ctx);
35
36         return exit_status();
37 }