X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Ftest%2Ftest-path-util.c;h=b0aeb11a63f239e117aef0f16a6ecc8c8cf71f63;hp=f396b32ffeb72b4e15bb648c6afeb32e6df7ac76;hb=c9d954b27ee125c3c90a6d2951c62eec4abb160b;hpb=116cc028742836e61abce7582ec9ecf9f0aaeb53 diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index f396b32ff..b0aeb11a6 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -83,7 +83,31 @@ static void test_path(void) { } } +static void test_find_binary(void) { + char *p; + + assert(find_binary("/bin/sh", &p) == 0); + puts(p); + assert(streq(p, "/bin/sh")); + free(p); + + assert(find_binary("./test-path-util", &p) == 0); + puts(p); + assert(endswith(p, "/test-path-util")); + assert(path_is_absolute(p)); + free(p); + + assert(find_binary("sh", &p) == 0); + puts(p); + assert(endswith(p, "/sh")); + assert(path_is_absolute(p)); + free(p); + + assert(find_binary("xxxx-xxxx", &p) == -ENOENT); +} + int main(void) { test_path(); + test_find_binary(); return 0; }