summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-06 02:11:08 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-06 14:21:10 +0100
commitb80ba1da1c66f570c10a92a40f54a044fb865739 (patch)
tree64ca022553e4ba16db87e2c7f569a31394fe1f25 /src/test
parent124aff6251c095367ce1323a21fa23235cbb0490 (diff)
condition: add more test cases
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-condition-util.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/test-condition-util.c b/src/test/test-condition-util.c
index 4f9ae8ab90..b69e62bfd3 100644
--- a/src/test/test-condition-util.c
+++ b/src/test/test-condition-util.c
@@ -31,6 +31,18 @@ static void test_condition_test_path_exists(void) {
assert_se(condition_test(condition));
condition_free(condition);
+ condition = condition_new(CONDITION_PATH_EXISTS, "/bin/s?", false, false);
+ assert_se(!condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_PATH_EXISTS_GLOB, "/bin/s?", false, false);
+ assert_se(condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_PATH_EXISTS_GLOB, "/bin/s?", false, true);
+ 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);
@@ -38,6 +50,38 @@ static void test_condition_test_path_exists(void) {
condition = condition_new(CONDITION_PATH_EXISTS, "/thiscertainlywontexist", false, true);
assert_se(condition_test(condition));
condition_free(condition);
+
+ condition = condition_new(CONDITION_PATH_IS_DIRECTORY, "/bin", false, false);
+ assert_se(condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_DIRECTORY_NOT_EMPTY, "/bin", false, false);
+ assert_se(condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_FILE_NOT_EMPTY, "/bin/sh", false, false);
+ assert_se(condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_FILE_IS_EXECUTABLE, "/bin/sh", false, false);
+ assert_se(condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_FILE_IS_EXECUTABLE, "/etc/passwd", false, false);
+ assert_se(!condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/proc", false, false);
+ assert_se(condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/", false, false);
+ assert_se(condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/bin", false, false);
+ assert_se(!condition_test(condition));
+ condition_free(condition);
}
static void test_condition_test_ac_power(void) {
@@ -123,6 +167,18 @@ static void test_condition_test_kernel_command_line(void) {
condition_free(condition);
}
+static void test_condition_test_null(void) {
+ Condition *condition;
+
+ condition = condition_new(CONDITION_NULL, NULL, false, false);
+ assert_se(condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_NULL, NULL, false, true);
+ assert_se(!condition_test(condition));
+ condition_free(condition);
+}
+
int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
@@ -132,6 +188,7 @@ int main(int argc, char *argv[]) {
test_condition_test_host();
test_condition_test_architecture();
test_condition_test_kernel_command_line();
+ test_condition_test_null();
return 0;
}