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); \ 348 #define pwtest_str_contains(haystack_, needle_) \ 350 const char *_h = haystack_; \ 351 const char *_n = needle_; \ 352 if (!strstr(_h, _n)) \ 353 _pwtest_fail_comparison_str(__FILE__, __LINE__, __func__, \ 354 #haystack_ " contains " #needle_, _h, _n); \ 455 #define pwtest_add(func_, ...) \ 456 _pwtest_add(ctx, suite, #func_, func_, __VA_ARGS__, NULL) 483 #define PWTEST(tname) \ 484 static enum pwtest_result tname(struct pwtest_test *current_test) 492 #define PWTEST_SUITE(cname) \ 493 static enum pwtest_result (cname##__setup)(struct pwtest_context *ctx, struct pwtest_suite *suite); \ 494 static const struct pwtest_suite_decl _test_suite \ 495 __attribute__((used)) \ 496 __attribute((section("pwtest_suite_section"))) = { \ 498 .setup = cname##__setup, \ 500 static enum pwtest_result (cname##__setup)(struct pwtest_context *ctx, struct pwtest_suite *suite) 503 #define PWTEST_PLUGIN_MAX 32 524 const char *factory_name,
525 const char *interface_name,
543 const char *factory_name,
544 const char *interface_name,
Definition: properties.h:49
size_t nsupport
Definition: pwtest.h:504
#define PWTEST_PLUGIN_MAX
Definition: pwtest.h:503
The next two int arguments are the minimum (inclusive) and maximum (exclusive) range for this test...
Definition: pwtest.h:382
The next two const char * arguments are the key and value for a property entry.
Definition: pwtest.h:397
struct spa_handle * handles[PWTEST_PLUGIN_MAX]
Definition: pwtest.h:511
void pwtest_mkstemp(char path[PATH_MAX])
Create a temporary file and copy its full path to path.
test was skipped
Definition: pwtest.h:168
Definition: pipewire.c:83
The next two const char * arguments are the key and value for the environment variable to be set in t...
Definition: pwtest.h:416
Definition: pipewire.c:62
Definition: utils/dict.h:48
test successful
Definition: pwtest.h:165
void * dlls[PWTEST_PLUGIN_MAX]
Definition: pwtest.h:508
test failed.
Definition: pwtest.h:166
unrelated error occured
Definition: pwtest.h:170
pwtest_arg
Definition: pwtest.h:359
test aborted after timeout
Definition: pwtest.h:169
The next argument is an int specifying the numerical signal number.
Definition: pwtest.h:371
pwtest_result
Result returned from tests or suites.
Definition: pwtest.h:164
Takes no extra arguments.
Definition: pwtest.h:432
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...
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.
struct pwtest_spa_plugin * pwtest_spa_plugin_new(void)
size_t nhandles
Definition: pwtest.h:510
Extra supporting infrastructure passed to the init() function of a factory.
Definition: plugin.h:89
size_t ndlls
Definition: pwtest.h:507
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...
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...
struct pwtest_context * pwtest_get_context(struct pwtest_test *t)
void pwtest_spa_plugin_destroy(struct pwtest_spa_plugin *plugin)