summaryrefslogtreecommitdiff
path: root/src/test/test-condition-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test-condition-util.c')
-rw-r--r--src/test/test-condition-util.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/test/test-condition-util.c b/src/test/test-condition-util.c
index 7a247fbdbd..4f9ae8ab90 100644
--- a/src/test/test-condition-util.c
+++ b/src/test/test-condition-util.c
@@ -22,21 +22,37 @@
#include "util.h"
#include "log.h"
#include "architecture.h"
-#include "systemd/sd-id128.h"
+#include "sd-id128.h"
+
+static void test_condition_test_path_exists(void) {
+ Condition *condition;
+
+ condition = condition_new(CONDITION_PATH_EXISTS, "/bin/sh", false, false);
+ assert_se(condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_PATH_EXISTS, "/thiscertainlywontexist", false, false);
+ assert_se(!condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_PATH_EXISTS, "/thiscertainlywontexist", false, true);
+ assert_se(condition_test(condition));
+ condition_free(condition);
+}
static void test_condition_test_ac_power(void) {
Condition *condition;
condition = condition_new(CONDITION_AC_POWER, "true", false, false);
- assert_se(condition_test_ac_power(condition) == on_ac_power());
+ assert_se(condition_test(condition) == on_ac_power());
condition_free(condition);
condition = condition_new(CONDITION_AC_POWER, "false", false, false);
- assert_se(condition_test_ac_power(condition) != on_ac_power());
+ assert_se(condition_test(condition) != on_ac_power());
condition_free(condition);
condition = condition_new(CONDITION_AC_POWER, "false", false, true);
- assert_se(condition_test_ac_power(condition) == on_ac_power());
+ assert_se(condition_test(condition) == on_ac_power());
condition_free(condition);
}
@@ -52,22 +68,22 @@ static void test_condition_test_host(void) {
assert_se(sd_id128_to_string(id, sid));
condition = condition_new(CONDITION_HOST, sid, false, false);
- assert_se(condition_test_host(condition));
+ assert_se(condition_test(condition));
condition_free(condition);
condition = condition_new(CONDITION_HOST, "garbage value jjjjjjjjjjjjjj", false, false);
- assert_se(!condition_test_host(condition));
+ assert_se(!condition_test(condition));
condition_free(condition);
condition = condition_new(CONDITION_HOST, sid, false, true);
- assert_se(!condition_test_host(condition));
+ assert_se(!condition_test(condition));
condition_free(condition);
hostname = gethostname_malloc();
assert_se(hostname);
condition = condition_new(CONDITION_HOST, hostname, false, false);
- assert_se(condition_test_host(condition));
+ assert_se(condition_test(condition));
condition_free(condition);
}
@@ -83,15 +99,15 @@ static void test_condition_test_architecture(void) {
assert_se(sa);
condition = condition_new(CONDITION_ARCHITECTURE, sa, false, false);
- assert_se(condition_test_architecture(condition));
+ assert_se(condition_test(condition));
condition_free(condition);
condition = condition_new(CONDITION_ARCHITECTURE, "garbage value", false, false);
- assert_se(condition_test_architecture(condition) < 0);
+ assert_se(condition_test(condition) < 0);
condition_free(condition);
condition = condition_new(CONDITION_ARCHITECTURE, sa, false, true);
- assert_se(!condition_test_architecture(condition));
+ assert_se(!condition_test(condition));
condition_free(condition);
}
@@ -99,11 +115,11 @@ static void test_condition_test_kernel_command_line(void) {
Condition *condition;
condition = condition_new(CONDITION_KERNEL_COMMAND_LINE, "thisreallyshouldntbeonthekernelcommandline", false, false);
- assert_se(!condition_test_kernel_command_line(condition));
+ assert_se(!condition_test(condition));
condition_free(condition);
condition = condition_new(CONDITION_KERNEL_COMMAND_LINE, "andthis=neither", false, false);
- assert_se(!condition_test_kernel_command_line(condition));
+ assert_se(!condition_test(condition));
condition_free(condition);
}
@@ -111,6 +127,7 @@ int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
+ test_condition_test_path_exists();
test_condition_test_ac_power();
test_condition_test_host();
test_condition_test_architecture();