test: move the client and utils tests over here
This commit is contained in:
parent
99a10c1606
commit
d0060fbddd
|
@ -1,10 +1,8 @@
|
||||||
test_apps = [
|
test_apps = [
|
||||||
'test-client',
|
|
||||||
'test-endpoint',
|
'test-endpoint',
|
||||||
'test-interfaces',
|
'test-interfaces',
|
||||||
# 'test-remote',
|
# 'test-remote',
|
||||||
'test-stream',
|
'test-stream',
|
||||||
'test-utils'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
foreach a : test_apps
|
foreach a : test_apps
|
||||||
|
|
|
@ -51,6 +51,7 @@ test('test pipewire utils',
|
||||||
executable('test-pw-utils',
|
executable('test-pw-utils',
|
||||||
'test-properties.c',
|
'test-properties.c',
|
||||||
'test-array.c',
|
'test-array.c',
|
||||||
|
'test-utils.c',
|
||||||
include_directories: pwtest_inc,
|
include_directories: pwtest_inc,
|
||||||
link_with: pwtest_lib)
|
link_with: pwtest_lib)
|
||||||
)
|
)
|
||||||
|
@ -60,6 +61,12 @@ test('test lib',
|
||||||
include_directories: pwtest_inc,
|
include_directories: pwtest_inc,
|
||||||
link_with: pwtest_lib)
|
link_with: pwtest_lib)
|
||||||
)
|
)
|
||||||
|
test('test client',
|
||||||
|
executable('test-client',
|
||||||
|
'test-client.c',
|
||||||
|
include_directories: pwtest_inc,
|
||||||
|
link_with: pwtest_lib)
|
||||||
|
)
|
||||||
test('test context',
|
test('test context',
|
||||||
executable('test-context',
|
executable('test-context',
|
||||||
'test-context.c',
|
'test-context.c',
|
||||||
|
|
|
@ -22,16 +22,18 @@
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "pwtest.h"
|
||||||
|
|
||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/pipewire.h>
|
||||||
#include <pipewire/impl-client.h>
|
#include <pipewire/impl-client.h>
|
||||||
|
|
||||||
#define TEST_FUNC(a,b,func) \
|
#define TEST_FUNC(a,b,func) \
|
||||||
do { \
|
do { \
|
||||||
a.func = b.func; \
|
a.func = b.func; \
|
||||||
spa_assert_se(SPA_PTRDIFF(&a.func, &a) == SPA_PTRDIFF(&b.func, &b)); \
|
pwtest_ptr_eq(SPA_PTRDIFF(&a.func, &a), SPA_PTRDIFF(&b.func, &b)); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
static void test_abi(void)
|
PWTEST(client_abi)
|
||||||
{
|
{
|
||||||
static const struct {
|
static const struct {
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
@ -54,15 +56,15 @@ static void test_abi(void)
|
||||||
TEST_FUNC(ev, test, resource_removed);
|
TEST_FUNC(ev, test, resource_removed);
|
||||||
TEST_FUNC(ev, test, busy_changed);
|
TEST_FUNC(ev, test, busy_changed);
|
||||||
|
|
||||||
spa_assert_se(PW_VERSION_IMPL_CLIENT_EVENTS == 0);
|
pwtest_int_eq(PW_VERSION_IMPL_CLIENT_EVENTS, 0);
|
||||||
spa_assert_se(sizeof(ev) == sizeof(test));
|
pwtest_int_eq(sizeof(ev), sizeof(test));
|
||||||
|
|
||||||
|
return PWTEST_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
PWTEST_SUITE(client)
|
||||||
{
|
{
|
||||||
pw_init(&argc, &argv);
|
pwtest_add(client_abi, PWTEST_NOARG);
|
||||||
|
|
||||||
test_abi();
|
return PWTEST_PASS;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
|
@ -22,6 +22,7 @@
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "pwtest.h"
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <pipewire/utils.h>
|
#include <pipewire/utils.h>
|
||||||
|
@ -30,14 +31,16 @@
|
||||||
|
|
||||||
static void test_destroy(void *object)
|
static void test_destroy(void *object)
|
||||||
{
|
{
|
||||||
spa_assert_not_reached();
|
pwtest_fail_if_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_abi(void)
|
PWTEST(utils_abi)
|
||||||
{
|
{
|
||||||
pw_destroy_t f;
|
pw_destroy_t f = test_destroy;
|
||||||
f = test_destroy;
|
|
||||||
spa_assert_se(f == test_destroy);
|
pwtest_ptr_eq(f, &test_destroy);
|
||||||
|
|
||||||
|
return PWTEST_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test__pw_split_walk(void)
|
static void test__pw_split_walk(void)
|
||||||
|
@ -177,13 +180,14 @@ static void test__pw_split_walk(void)
|
||||||
size_t j = 0, len;
|
size_t j = 0, len;
|
||||||
|
|
||||||
while ((s = pw_split_walk(str, tc->delim, &len, &state)) != NULL && tc->expected[j] != NULL) {
|
while ((s = pw_split_walk(str, tc->delim, &len, &state)) != NULL && tc->expected[j] != NULL) {
|
||||||
spa_assert_se(strlen(tc->expected[j]) == len);
|
pwtest_int_eq(strlen(tc->expected[j]), len);
|
||||||
spa_assert_se(strncmp(s, tc->expected[j], len) == 0);
|
pwtest_str_eq_n(s, tc->expected[j], len);
|
||||||
|
|
||||||
j += 1;
|
j += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
spa_assert_se(s == NULL && tc->expected[j] == NULL);
|
pwtest_ptr_null(s);
|
||||||
|
pwtest_ptr_null(tc->expected[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,30 +199,32 @@ static void test__pw_split_strv(void)
|
||||||
char **res;
|
char **res;
|
||||||
|
|
||||||
res = pw_split_strv(test1, del, INT_MAX, &n_tokens);
|
res = pw_split_strv(test1, del, INT_MAX, &n_tokens);
|
||||||
spa_assert_se(res != NULL);
|
pwtest_ptr_notnull(res);
|
||||||
spa_assert_se(n_tokens == 3);
|
pwtest_int_eq(n_tokens, 3);
|
||||||
spa_assert_se(spa_streq(res[0], "a"));
|
pwtest_str_eq(res[0], "a");
|
||||||
spa_assert_se(spa_streq(res[1], "test"));
|
pwtest_str_eq(res[1], "test");
|
||||||
spa_assert_se(spa_streq(res[2], "string"));
|
pwtest_str_eq(res[2], "string");
|
||||||
spa_assert_se(res[3] == NULL);
|
pwtest_ptr_null(res[3]);
|
||||||
pw_free_strv(res);
|
pw_free_strv(res);
|
||||||
|
|
||||||
res = pw_split_strv(test1, del, 2, &n_tokens);
|
res = pw_split_strv(test1, del, 2, &n_tokens);
|
||||||
spa_assert_se(res != NULL);
|
pwtest_ptr_notnull(res);
|
||||||
spa_assert_se(n_tokens == 2);
|
pwtest_int_eq(n_tokens, 2);
|
||||||
spa_assert_se(spa_streq(res[0], "a"));
|
pwtest_str_eq(res[0], "a");
|
||||||
spa_assert_se(spa_streq(res[1], "test string \n \r "));
|
pwtest_str_eq(res[1], "test string \n \r ");
|
||||||
spa_assert_se(res[2] == NULL);
|
pwtest_ptr_null(res[2]);
|
||||||
pw_free_strv(res);
|
pw_free_strv(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_split(void)
|
PWTEST(utils_split)
|
||||||
{
|
{
|
||||||
test__pw_split_walk();
|
test__pw_split_walk();
|
||||||
test__pw_split_strv();
|
test__pw_split_strv();
|
||||||
|
|
||||||
|
return PWTEST_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_strip(void)
|
PWTEST(utils_strip)
|
||||||
{
|
{
|
||||||
char test1[] = " \n\r \n a test string \n \r ";
|
char test1[] = " \n\r \n a test string \n \r ";
|
||||||
char test2[] = " \n\r \n \n \r ";
|
char test2[] = " \n\r \n \n \r ";
|
||||||
|
@ -226,13 +232,15 @@ static void test_strip(void)
|
||||||
spa_assert_se(spa_streq(pw_strip(test1, "\n\r "), "a test string"));
|
spa_assert_se(spa_streq(pw_strip(test1, "\n\r "), "a test string"));
|
||||||
spa_assert_se(spa_streq(pw_strip(test2, "\n\r "), ""));
|
spa_assert_se(spa_streq(pw_strip(test2, "\n\r "), ""));
|
||||||
spa_assert_se(spa_streq(pw_strip(test3, "\n\r "), "a test string"));
|
spa_assert_se(spa_streq(pw_strip(test3, "\n\r "), "a test string"));
|
||||||
|
|
||||||
|
return PWTEST_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
PWTEST_SUITE(utils)
|
||||||
{
|
{
|
||||||
test_abi();
|
pwtest_add(utils_abi, PWTEST_NOARG);
|
||||||
test_split();
|
pwtest_add(utils_split, PWTEST_NOARG);
|
||||||
test_strip();
|
pwtest_add(utils_strip, PWTEST_NOARG);
|
||||||
|
|
||||||
return 0;
|
return PWTEST_PASS;
|
||||||
}
|
}
|
Loading…
Reference in New Issue