c90c597ee3
We provide a way via the '-' symbol to ignore errors when nonexistent executable files are passed to Exec* parameters & so on. In such a case, the flag `EXEC_COMMAND_IGNORE_FAILURE` is set and we go on happily with our life if that happens. However, `systemd-analyze verify` complained about missing executables even in such a case. In such a case it is not an error for this to happen so check if the flag is set before checking if the file is accessible and executable. Add some small tests to check this condition. Closes #15218.
20 lines
770 B
C
20 lines
770 B
C
/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
#include "analyze-verify.h"
|
|
#include "tests.h"
|
|
|
|
static void test_verify_nonexistent(void) {
|
|
/* Negative cases */
|
|
assert_se(verify_executable(NULL, &(ExecCommand) {.flags = EXEC_COMMAND_IGNORE_FAILURE, .path = (char*) "/non/existent"}) == 0);
|
|
assert_se(verify_executable(NULL, &(ExecCommand) {.path = (char*) "/non/existent"}) < 0);
|
|
|
|
/* Ordinary cases */
|
|
assert_se(verify_executable(NULL, &(ExecCommand) {.path = (char*) "/bin/echo"}) == 0);
|
|
assert_se(verify_executable(NULL, &(ExecCommand) {.flags = EXEC_COMMAND_IGNORE_FAILURE, .path = (char*) "/bin/echo"}) == 0);
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
test_setup_logging(LOG_DEBUG);
|
|
|
|
test_verify_nonexistent();
|
|
}
|