1212#include <crm/common/unittest_internal.h>
1313#include <crm/common/agents.h>
1414
15+ /*!
16+ * \internal
17+ * \brief Parse an agent spec and compare against expected values
18+ *
19+ * \param[in] line Line number of caller (for error output)
20+ * \param[in] spec Agent spec
21+ * \param[in] expected_std Expected standard
22+ * \param[in] expected_prov Expected provider
23+ * \param[in] expected_type Expected type
24+ * \param[in] expected_rc Expected return code of \c crm_parse_agent_spec()
25+ */
1526static void
1627assert_parse_agent_spec_as (int line , const char * spec , const char * expected_std ,
1728 const char * expected_prov , const char * expected_type ,
18- int expected_rc , bool check_spt )
29+ int expected_rc )
1930{
2031 char * std = NULL ;
2132 char * prov = NULL ;
@@ -43,40 +54,46 @@ assert_parse_agent_spec_as(int line, const char *spec, const char *expected_std,
4354 cast_ptr_to_largest_integral_type(NULL), \
4455 __FILE__, (line))
4556
46- if (!check_spt ) {
47- /* This is a temporary hack to work around an issue that will be fixed
48- * in an upcoming commit
49- */
50- return ;
51- }
52-
5357 if (expected_std == NULL ) {
5458 pcmk__assert_null (std );
59+
5560 } else {
5661 _assert_string_equal (std , expected_std , __FILE__ , line );
5762 free (std );
5863 }
5964
6065 if (expected_prov == NULL ) {
6166 pcmk__assert_null (prov );
67+
6268 } else {
6369 _assert_string_equal (prov , expected_prov , __FILE__ , line );
6470 free (prov );
6571 }
6672
6773 if (expected_type == NULL ) {
6874 pcmk__assert_null (type );
75+
6976 } else {
7077 _assert_string_equal (type , expected_type , __FILE__ , line );
7178 free (type );
7279 }
7380}
7481
75- #define assert_parse_agent_spec (spec , expected_std , expected_prov , \
76- expected_type , expected_rc , check_spt ) \
77- assert_parse_agent_spec_as(__LINE__, (spec), (expected_std), \
78- (expected_prov), (expected_type), \
79- (expected_rc), (check_spt))
82+ /*!
83+ * \internal
84+ * \brief Parse an agent spec and compare against expected values
85+ *
86+ * \param[in] spec Agent spec
87+ * \param[in] expected_std Expected standard
88+ * \param[in] expected_prov Expected provider
89+ * \param[in] expected_type Expected type
90+ * \param[in] expected_rc Expected return code of \c crm_parse_agent_spec()
91+ */
92+ #define assert_parse_agent_spec (spec , expected_std , expected_prov , \
93+ expected_type , expected_rc ) \
94+ assert_parse_agent_spec_as(__LINE__, (spec), (expected_std), \
95+ (expected_prov), (expected_type), \
96+ (expected_rc))
8097
8198static void
8299null_params (void * * state )
@@ -139,11 +156,9 @@ null_params(void **state)
139156static void
140157no_prov_or_type (void * * state )
141158{
142- assert_parse_agent_spec ("ocf" , NULL , NULL , NULL , - EINVAL , true);
143-
144- // @FIXME std is freed on error, so set it to NULL or don't check its value
145- assert_parse_agent_spec ("ocf:" , NULL , NULL , NULL , - EINVAL , false);
146- assert_parse_agent_spec ("ocf::" , NULL , NULL , NULL , - EINVAL , false);
159+ assert_parse_agent_spec ("ocf" , NULL , NULL , NULL , - EINVAL );
160+ assert_parse_agent_spec ("ocf:" , NULL , NULL , NULL , - EINVAL );
161+ assert_parse_agent_spec ("ocf::" , NULL , NULL , NULL , - EINVAL );
147162}
148163
149164static void
@@ -152,28 +167,28 @@ no_type(void **state)
152167 /* @FIXME std and prov are freed on error, so set them to NULL or don't
153168 * check their values
154169 */
155- assert_parse_agent_spec ("ocf:pacemaker:" , NULL , NULL , NULL , - EINVAL , false );
170+ assert_parse_agent_spec ("ocf:pacemaker:" , NULL , NULL , NULL , - EINVAL );
156171}
157172
158173static void
159174get_std_and_ty (void * * state )
160175{
161176 assert_parse_agent_spec ("stonith:fence_xvm" , "stonith" , NULL , "fence_xvm" ,
162- pcmk_ok , true );
177+ pcmk_ok );
163178}
164179
165180static void
166181get_all_values (void * * state )
167182{
168183 assert_parse_agent_spec ("ocf:pacemaker:ping" , "ocf" , "pacemaker" , "ping" ,
169- pcmk_ok , true );
184+ pcmk_ok );
170185}
171186
172187static void
173188get_systemd_values (void * * state )
174189{
175190 assert_parse_agent_spec ("systemd:UNIT@A:B" , "systemd" , NULL , "UNIT@A:B" ,
176- pcmk_ok , true );
191+ pcmk_ok );
177192}
178193
179194static void
@@ -184,7 +199,7 @@ type_ends_with_colon(void **state)
184199 * should be considered the type. This includes a trailing colon.
185200 */
186201 assert_parse_agent_spec ("stonith:fence_xvm:" , "stonith" , NULL , "fence_xvm:" ,
187- pcmk_ok , true );
202+ pcmk_ok );
188203}
189204
190205PCMK__UNIT_TEST (NULL , NULL ,
0 commit comments