Rename find_binary to find_executable

"executable" is more correct than "binary", since scripts are OK too.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-09-18 15:28:48 +02:00
parent 0706c01259
commit f7bc0c324a
8 changed files with 29 additions and 35 deletions
+6 -6
View File
@@ -328,7 +328,7 @@ static void test_exec_privatedevices(Manager *m) {
/* We use capsh to test if the capabilities are
* properly set, so be sure that it exists */
r = find_binary("capsh", NULL);
r = find_executable("capsh", NULL);
if (r < 0) {
log_notice_errno(r, "Could not find capsh binary, skipping remaining tests in %s: %m", __func__);
return;
@@ -361,7 +361,7 @@ static void test_exec_protectkernelmodules(Manager *m) {
return;
}
r = find_binary("capsh", NULL);
r = find_executable("capsh", NULL);
if (r < 0) {
log_notice_errno(r, "Skipping %s, could not find capsh binary: %m", __func__);
return;
@@ -435,7 +435,7 @@ static void test_exec_systemcallfilter(Manager *m) {
test(m, "exec-systemcallfilter-failing.service", SIGSYS, CLD_KILLED);
test(m, "exec-systemcallfilter-failing2.service", SIGSYS, CLD_KILLED);
r = find_binary("python3", NULL);
r = find_executable("python3", NULL);
if (r < 0) {
log_notice_errno(r, "Skipping remaining tests in %s, could not find python3 binary: %m", __func__);
return;
@@ -458,7 +458,7 @@ static void test_exec_systemcallerrornumber(Manager *m) {
return;
}
r = find_binary("python3", NULL);
r = find_executable("python3", NULL);
if (r < 0) {
log_notice_errno(r, "Skipping %s, could not find python3 binary: %m", __func__);
return;
@@ -694,7 +694,7 @@ static void test_exec_runtimedirectory(Manager *m) {
static void test_exec_capabilityboundingset(Manager *m) {
int r;
r = find_binary("capsh", NULL);
r = find_executable("capsh", NULL);
if (r < 0) {
log_notice_errno(r, "Skipping %s, could not find capsh binary: %m", __func__);
return;
@@ -756,7 +756,7 @@ static void test_exec_ambientcapabilities(Manager *m) {
static void test_exec_privatenetwork(Manager *m) {
int r;
r = find_binary("ip", NULL);
r = find_executable("ip", NULL);
if (r < 0) {
log_notice_errno(r, "Skipping %s, could not find ip binary: %m", __func__);
return;
+7 -7
View File
@@ -164,31 +164,31 @@ static void test_path_equal_root(void) {
assert_se(!path_equal_or_files_same("/", "/.../", AT_SYMLINK_NOFOLLOW));
}
static void test_find_binary(const char *self) {
static void test_find_executable(const char *self) {
char *p;
log_info("/* %s */", __func__);
assert_se(find_binary("/bin/sh", &p) == 0);
assert_se(find_executable("/bin/sh", &p) == 0);
puts(p);
assert_se(path_equal(p, "/bin/sh"));
free(p);
assert_se(find_binary(self, &p) == 0);
assert_se(find_executable(self, &p) == 0);
puts(p);
/* libtool might prefix the binary name with "lt-" */
assert_se(endswith(p, "/lt-test-path-util") || endswith(p, "/test-path-util"));
assert_se(path_is_absolute(p));
free(p);
assert_se(find_binary("sh", &p) == 0);
assert_se(find_executable("sh", &p) == 0);
puts(p);
assert_se(endswith(p, "/sh"));
assert_se(path_is_absolute(p));
free(p);
assert_se(find_binary("xxxx-xxxx", &p) == -ENOENT);
assert_se(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT);
assert_se(find_executable("xxxx-xxxx", &p) == -ENOENT);
assert_se(find_executable("/some/dir/xxxx-xxxx", &p) == -ENOENT);
}
static void test_prefixes(void) {
@@ -670,7 +670,7 @@ int main(int argc, char **argv) {
test_print_paths();
test_path();
test_path_equal_root();
test_find_binary(argv[0]);
test_find_executable(argv[0]);
test_prefixes();
test_path_join();
test_fsck_exists();