@@ -79,8 +79,11 @@ assert_parse_agent_spec_as(int line, const char *spec, const char *expected_std,
7979 (expected_rc), (check_spt))
8080
8181static void
82- all_params_null (void * * state )
82+ null_params (void * * state )
8383{
84+ char * std = NULL ;
85+ char * prov = NULL ;
86+ char * type = NULL ;
8487 int rc = pcmk_ok ;
8588
8689 rc = crm_parse_agent_spec (NULL , NULL , NULL , NULL );
@@ -94,6 +97,43 @@ all_params_null(void **state)
9497
9598 rc = crm_parse_agent_spec ("::" , NULL , NULL , NULL );
9699 assert_int_equal (rc , - EINVAL );
100+
101+ // With valid spec (no provider)
102+ rc = crm_parse_agent_spec ("stonith:fence_xvm" , NULL , NULL , NULL );
103+ assert_int_equal (rc , - EINVAL );
104+
105+ // With valid spec (has provider)
106+ rc = crm_parse_agent_spec ("ocf:pacemaker:ping" , NULL , NULL , NULL );
107+ assert_int_equal (rc , - EINVAL );
108+
109+ // Test varying NULL params with valid spec
110+
111+ rc = crm_parse_agent_spec ("ocf:pacemaker:ping" , NULL , NULL , & type );
112+ assert_int_equal (rc , - EINVAL );
113+ assert_null (type );
114+
115+ rc = crm_parse_agent_spec ("ocf:pacemaker:ping" , NULL , & prov , NULL );
116+ assert_int_equal (rc , - EINVAL );
117+ assert_null (prov );
118+
119+ rc = crm_parse_agent_spec ("ocf:pacemaker:ping" , NULL , & prov , & type );
120+ assert_int_equal (rc , - EINVAL );
121+ assert_null (prov );
122+ assert_null (type );
123+
124+ rc = crm_parse_agent_spec ("ocf:pacemaker:ping" , & std , NULL , NULL );
125+ assert_int_equal (rc , - EINVAL );
126+ assert_null (std );
127+
128+ rc = crm_parse_agent_spec ("ocf:pacemaker:ping" , & std , NULL , & type );
129+ assert_int_equal (rc , - EINVAL );
130+ assert_null (std );
131+ assert_null (type );
132+
133+ rc = crm_parse_agent_spec ("ocf:pacemaker:ping" , & std , & prov , NULL );
134+ assert_int_equal (rc , - EINVAL );
135+ assert_null (std );
136+ assert_null (prov );
97137}
98138
99139static void
@@ -136,10 +176,22 @@ get_systemd_values(void **state)
136176 pcmk_ok , true);
137177}
138178
179+ static void
180+ type_ends_with_colon (void * * state )
181+ {
182+ /* It's not clear that this would ever be allowed in practice. However, for
183+ * standards that support a provider, everything after the first colon
184+ * should be considered the type. This includes a trailing colon.
185+ */
186+ assert_parse_agent_spec ("stonith:fence_xvm:" , "stonith" , NULL , "fence_xvm:" ,
187+ pcmk_ok , true);
188+ }
189+
139190PCMK__UNIT_TEST (NULL , NULL ,
140- cmocka_unit_test (all_params_null ),
191+ cmocka_unit_test (null_params ),
141192 cmocka_unit_test (no_prov_or_type ),
142193 cmocka_unit_test (no_type ),
143194 cmocka_unit_test (get_std_and_ty ),
144195 cmocka_unit_test (get_all_values ),
145- cmocka_unit_test (get_systemd_values ))
196+ cmocka_unit_test (get_systemd_values ),
197+ cmocka_unit_test (type_ends_with_colon ))
0 commit comments