From ba412430a97ffbc02b3911c1b34db63e1524f7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 12 Apr 2018 15:51:39 +0200 Subject: tests: use manager_load_startable_unit_or_warn() to load units Doing manager_load_unit() followed by UNIT_VTABLE(unit)->start(unit) would result in an assertion failure in ->start() if the unit failed to load properly. Something like this is okey-ish is tests, since the test units are not expected to fail to load, but the reason for failure is clearer if we fail immediately. --- src/test/test-path.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/test/test-path.c') diff --git a/src/test/test-path.c b/src/test/test-path.c index ec9d2626e2..9eaa61f950 100644 --- a/src/test/test-path.c +++ b/src/test/test-path.c @@ -134,7 +134,7 @@ static void test_path_exists(Manager *m) { assert_se(m); - assert_se(manager_load_unit(m, "path-exists.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-exists.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); assert_se(touch(test_path) >= 0); @@ -147,7 +147,7 @@ static void test_path_existsglob(Manager *m) { Unit *unit = NULL; assert_se(m); - assert_se(manager_load_unit(m, "path-existsglob.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-existsglob.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); assert_se(touch(test_path) >= 0); @@ -164,7 +164,7 @@ static void test_path_changed(Manager *m) { assert_se(touch(test_path) >= 0); - assert_se(manager_load_unit(m, "path-changed.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-changed.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); f = fopen(test_path, "w"); @@ -183,7 +183,7 @@ static void test_path_modified(Manager *m) { assert_se(touch(test_path) >= 0); - assert_se(manager_load_unit(m, "path-modified.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-modified.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); f = fopen(test_path, "w"); @@ -199,7 +199,7 @@ static void test_path_unit(Manager *m) { assert_se(m); - assert_se(manager_load_unit(m, "path-unit.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-unit.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); assert_se(touch(test_path) >= 0); @@ -215,7 +215,7 @@ static void test_path_directorynotempty(Manager *m) { assert_se(access(test_path, F_OK) < 0); - assert_se(manager_load_unit(m, "path-directorynotempty.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-directorynotempty.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); /* MakeDirectory default to no */ @@ -236,7 +236,7 @@ static void test_path_makedirectory_directorymode(Manager *m) { assert_se(access(test_path, F_OK) < 0); - assert_se(manager_load_unit(m, "path-makedirectory.path", NULL, NULL, &unit) >= 0); + assert_se(manager_load_startable_unit_or_warn(m, "path-makedirectory.path", NULL, &unit) >= 0); assert_se(UNIT_VTABLE(unit)->start(unit) >= 0); /* Check if the directory has been created */ -- cgit v1.2.1