Go to the documentation of this file.
159 #include "pwtest-implementation.h"
189 #define pwtest_fail() \
190 _pwtest_fail_condition(PWTEST_FAIL, __FILE__, __LINE__, __func__, "aborting", "")
193 #define pwtest_fail_if_reached() \
194 _pwtest_fail_condition(PWTEST_FAIL, __FILE__, __LINE__, __func__, "This line is supposed to be unreachable", "")
197 #define pwtest_fail_with_msg(...) \
198 _pwtest_fail_condition(PWTEST_FAIL, __FILE__, __LINE__, __func__, \
199 "aborting", __VA_ARGS__)
202 #define pwtest_error_with_msg(...) \
203 _pwtest_fail_condition(PWTEST_SYSTEM_ERROR, __FILE__, __LINE__, __func__, \
204 "error", __VA_ARGS__)
207 #define pwtest_errno_ok(r_) \
208 pwtest_errno_check(r_, 0);
211 #define pwtest_errno(r_, errno_) \
212 pwtest_errno_check(r_, errno_);
215 #define pwtest_neg_errno_ok(r_) \
216 pwtest_neg_errno_check(r_, 0);
219 #define pwtest_neg_errno(r_, errno_) \
220 pwtest_neg_errno_check(r_, errno_);
223 #define pwtest_bool_eq(a_, b_) \
224 pwtest_comparison_bool_(a_, ==, b_)
227 #define pwtest_bool_ne(a_, b_) \
228 pwtest_comparison_bool_(a_, !=, b_)
231 #define pwtest_bool_true(cond_) \
232 pwtest_comparison_bool_(cond_, ==, true)
235 #define pwtest_bool_false(cond_) \
236 pwtest_comparison_bool_(cond_, ==, false)
239 #define pwtest_int_eq(a_, b_) \
240 pwtest_comparison_int_(a_, ==, b_)
243 #define pwtest_int_ne(a_, b_) \
244 pwtest_comparison_int_(a_, !=, b_)
247 #define pwtest_int_lt(a_, b_) \
248 pwtest_comparison_int_(a_, <, b_)
251 #define pwtest_int_le(a_, b_) \
252 pwtest_comparison_int_(a_, <=, b_)
255 #define pwtest_int_ge(a_, b_) \
256 pwtest_comparison_int_(a_, >=, b_)
259 #define pwtest_int_gt(a_, b_) \
260 pwtest_comparison_int_(a_, >, b_)
263 #define pwtest_ptr_eq(a_, b_) \
264 pwtest_comparison_ptr_(a_, ==, b_)
267 #define pwtest_ptr_ne(a_, b_) \
268 pwtest_comparison_ptr_(a_, !=, b_)
271 #define pwtest_ptr_null(a_) \
272 pwtest_comparison_ptr_(a_, ==, NULL)
275 #define pwtest_ptr_notnull(a_) \
276 pwtest_comparison_ptr_(a_, !=, NULL)
279 #define pwtest_double_eq(a_, b_)\
280 pwtest_comparison_double_((a_), ==, (b_))
283 #define pwtest_double_ne(a_, b_)\
284 pwtest_comparison_double_((a_), !=, (b_))
287 #define pwtest_double_lt(a_, b_)\
288 pwtest_comparison_double_((a_), <, (b_))
291 #define pwtest_double_le(a_, b_)\
292 pwtest_comparison_double_((a_), <=, (b_))
295 #define pwtest_double_ge(a_, b_)\
296 pwtest_comparison_double_((a_), >=, (b_))
299 #define pwtest_double_gt(a_, b_)\
300 pwtest_comparison_double_((a_), >, (b_))
302 #define pwtest_int(a_, op_, b_) \
303 pwtest_comparison_int_(a_, op_, b_)
307 #define pwtest_str_eq(a_, b_) \
309 const char *_a = a_; \
310 const char *_b = b_; \
311 if (!spa_streq(_a, _b)) \
312 _pwtest_fail_comparison_str(__FILE__, __LINE__, __func__, \
313 #a_ " equals " #b_, _a, _b); \
317 #define pwtest_str_eq_n(a_, b_, l_) \
319 const char *_a = a_; \
320 const char *_b = b_; \
321 if (!spa_strneq(_a, _b, l_)) \
322 _pwtest_fail_comparison_str(__FILE__, __LINE__, __func__, \
323 #a_ " equals " #b_ ", len: " #l_, _a, _b); \
327 #define pwtest_str_ne(a_, b_) \
329 const char *_a = a_; \
330 const char *_b = b_; \
331 if (spa_streq(_a, _b)) \
332 _pwtest_fail_comparison_str(__FILE__, __LINE__, __func__, \
333 #a_ " not equal to " #b_, _a, _b); \
337 #define pwtest_str_ne_n(a_, b_, l_) \
339 __typeof__(a_) _a = a_; \
340 __typeof__(b_) _b = b_; \
341 if (spa_strneq(_a, _b, l_)) \
342 _pwtest_fail_comparison_str(__FILE__, __LINE__, __func__, \
343 #a_ " not equal to " #b_ ", len: " #l_, _a, _b); \
444 #define pwtest_add(func_, ...) \
445 _pwtest_add(ctx, suite, #func_, func_, __VA_ARGS__, NULL)
472 #define PWTEST(tname) \
473 static enum pwtest_result tname(struct pwtest_test *current_test)
481 #define PWTEST_SUITE(cname) \
482 static enum pwtest_result (cname##__setup)(struct pwtest_context *ctx, struct pwtest_suite *suite); \
483 static const struct pwtest_suite_decl _test_suite \
484 __attribute__((used)) \
485 __attribute((section("pwtest_suite_section"))) = { \
487 .setup = cname##__setup, \
489 static enum pwtest_result (cname##__setup)(struct pwtest_context *ctx, struct pwtest_suite *suite)
492 #define PWTEST_PLUGIN_MAX 32
513 const char *factory_name,
514 const char *interface_name,
532 const char *factory_name,
533 const char *interface_name,
@ PWTEST_ARG_PROP
The next two const char * arguments are the key and value for a property entry.
Definition: pwtest.h:386
@ PWTEST_FAIL
test failed.
Definition: pwtest.h:166
@ PWTEST_ARG_RANGE
The next two int arguments are the minimum (inclusive) and maximum (exclusive) range for this test.
Definition: pwtest.h:371
size_t ndlls
Definition: pwtest.h:496
void pwtest_mkstemp(char path[PATH_MAX])
Create a temporary file and copy its full path to path.
size_t nsupport
Definition: pwtest.h:493
@ PWTEST_NOARG
Definition: pwtest.h:349
int pwtest_spa_plugin_try_load_interface(struct pwtest_spa_plugin *plugin, void **iface_return, const char *libname, const char *factory_name, const char *interface_name, const struct spa_dict *info)
Load interface_name from the factory in libname.
#define PWTEST_PLUGIN_MAX
Definition: pwtest.h:492
struct pw_properties * pwtest_get_props(struct pwtest_test *t)
If the test had properties set (see PWTEST_ARG_PROP), this function returns the Key-Value pairs.
int pwtest_get_iteration(struct pwtest_test *t)
If the test was added with a range (see PWTEST_ARG_RANGE), this function returns the current iteratio...
void * pwtest_spa_plugin_load_interface(struct pwtest_spa_plugin *plugin, const char *libname, const char *factory_name, const char *interface_name, const struct spa_dict *info)
Identical to pwtest_spa_plugin_try_load_interface() but returns the interface and fails if the interf...
@ PWTEST_SYSTEM_ERROR
unrelated error occured
Definition: pwtest.h:170
@ PWTEST_ARG_SIGNAL
The next argument is an int specifying the numerical signal number.
Definition: pwtest.h:360
@ PWTEST_PASS
test successful
Definition: pwtest.h:165
Definition: pipewire.c:59
pwtest_result
Result returned from tests or suites.
Definition: pwtest.h:164
struct pwtest_spa_plugin * pwtest_spa_plugin_new(void)
@ PWTEST_ARG_ENV
The next two const char * arguments are the key and value for the environment variable to be set in t...
Definition: pwtest.h:405
struct spa_handle * handles[PWTEST_PLUGIN_MAX]
Definition: pwtest.h:500
Definition: utils/dict.h:48
@ PWTEST_TIMEOUT
test aborted after timeout
Definition: pwtest.h:169
@ PWTEST_ARG_DAEMON
Takes no extra arguments.
Definition: pwtest.h:421
size_t nhandles
Definition: pwtest.h:499
void pwtest_spa_plugin_destroy(struct pwtest_spa_plugin *plugin)
@ PWTEST_SKIP
test was skipped
Definition: pwtest.h:168
void * dlls[PWTEST_PLUGIN_MAX]
Definition: pwtest.h:497
pwtest_arg
Definition: pwtest.h:348
Extra supporting infrastructure passed to the init() function of a factory.
Definition: plugin.h:89
struct pwtest_context * pwtest_get_context(struct pwtest_test *t)
Definition: pipewire.c:80
Definition: properties.h:49