-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API: libcrmcommon: add pcmk_set_scheduler_cib()
This is intended to replace direct access to scheduler->input
- Loading branch information
Showing
6 changed files
with
119 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ SUBDIRS = \ | |
resources \ | ||
results \ | ||
rules \ | ||
scheduler \ | ||
schemas \ | ||
scores \ | ||
strings \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# Copyright 2024 the Pacemaker project contributors | ||
# | ||
# The version control history for this file may have further details. | ||
# | ||
# This source code is licensed under the GNU General Public License version 2 | ||
# or later (GPLv2+) WITHOUT ANY WARRANTY. | ||
# | ||
|
||
include $(top_srcdir)/mk/tap.mk | ||
include $(top_srcdir)/mk/unittest.mk | ||
|
||
# Add "_test" to the end of all test program names to simplify .gitignore. | ||
check_PROGRAMS = pcmk_set_scheduler_cib_test | ||
|
||
TESTS = $(check_PROGRAMS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2024 the Pacemaker project contributors | ||
* | ||
* The version control history for this file may have further details. | ||
* | ||
* This source code is licensed under the GNU General Public License version 2 | ||
* or later (GPLv2+) WITHOUT ANY WARRANTY. | ||
*/ | ||
|
||
#include <crm_internal.h> | ||
|
||
#include <crm/common/scheduler.h> | ||
#include <crm/common/unittest_internal.h> | ||
|
||
static void | ||
null_scheduler(void **state) | ||
{ | ||
xmlNode *cib = pcmk__xe_create(NULL, "test"); | ||
|
||
assert_int_equal(pcmk_set_scheduler_cib(NULL, NULL), EINVAL); | ||
assert_int_equal(pcmk_set_scheduler_cib(NULL, cib), EINVAL); | ||
|
||
free_xml(cib); | ||
} | ||
|
||
static void | ||
null_cib(void **state) | ||
{ | ||
pcmk_scheduler_t scheduler = { | ||
.input = NULL, | ||
}; | ||
|
||
assert_int_equal(pcmk_set_scheduler_cib(&scheduler, NULL), pcmk_rc_ok); | ||
assert_null(scheduler.input); | ||
} | ||
|
||
static void | ||
previous_cib_null(void **state) | ||
{ | ||
pcmk_scheduler_t scheduler = { | ||
.input = NULL, | ||
}; | ||
xmlNode *cib = pcmk__xe_create(NULL, "test"); | ||
|
||
assert_int_equal(pcmk_set_scheduler_cib(&scheduler, cib), pcmk_rc_ok); | ||
assert_ptr_equal(scheduler.input, cib); | ||
|
||
free_xml(cib); | ||
} | ||
|
||
static void | ||
previous_cib_nonnull(void **state) | ||
{ | ||
xmlNode *old_cib = pcmk__xe_create(NULL, "old"); | ||
xmlNode *new_cib = pcmk__xe_create(NULL, "new"); | ||
pcmk_scheduler_t scheduler = { | ||
.input = old_cib, | ||
}; | ||
|
||
assert_int_equal(pcmk_set_scheduler_cib(&scheduler, new_cib), pcmk_rc_ok); | ||
assert_ptr_equal(scheduler.input, new_cib); | ||
|
||
free_xml(old_cib); | ||
free_xml(new_cib); | ||
} | ||
|
||
PCMK__UNIT_TEST(NULL, NULL, | ||
cmocka_unit_test(null_scheduler), | ||
cmocka_unit_test(null_cib), | ||
cmocka_unit_test(previous_cib_null), | ||
cmocka_unit_test(previous_cib_nonnull)) |