Fix some unit test

Run abi checks only on x86_64 until we have sizes for more archs
Don't start a daemon in the tests because that would require
XDG_RUNTIME_DIR set
This commit is contained in:
Wim Taymans 2020-01-15 13:23:49 +01:00
parent 1cedfade3a
commit 4e8d85da2f
7 changed files with 59 additions and 12 deletions

View file

@ -36,9 +36,15 @@ static void test_abi(void)
spa_assert(SPA_DATA_MemId == 4);
spa_assert(SPA_DATA_LAST == 5);
#if defined(__x86_64__)
spa_assert(sizeof(struct spa_chunk) == 16);
spa_assert(sizeof(struct spa_data) == 40);
spa_assert(sizeof(struct spa_buffer) == 24);
#else
fprintf(stderr, "%zd\n", sizeof(struct spa_chunk));
fprintf(stderr, "%zd\n", sizeof(struct spa_data));
fprintf(stderr, "%zd\n", sizeof(struct spa_buffer));
#endif
/* meta */
spa_assert(SPA_META_Invalid == 0);
@ -50,13 +56,19 @@ static void test_abi(void)
spa_assert(SPA_META_Control == 6);
spa_assert(SPA_META_LAST == 7);
#if defined(__x86_64__)
spa_assert(sizeof(struct spa_meta) == 16);
fprintf(stderr, "%zd", sizeof(struct spa_meta_header));
spa_assert(sizeof(struct spa_meta_header) == 32);
spa_assert(sizeof(struct spa_meta_region) == 16);
spa_assert(sizeof(struct spa_meta_bitmap) == 20);
spa_assert(sizeof(struct spa_meta_cursor) == 28);
#else
fprintf(stderr, "%zd\n", sizeof(struct spa_meta));
fprintf(stderr, "%zd\n", sizeof(struct spa_meta_header));
fprintf(stderr, "%zd\n", sizeof(struct spa_meta_region));
fprintf(stderr, "%zd\n", sizeof(struct spa_meta_bitmap));
fprintf(stderr, "%zd\n", sizeof(struct spa_meta_cursor));
#endif
}
static void test_alloc(void)

View file

@ -42,6 +42,7 @@ static void test_io_abi(void)
spa_assert(SPA_IO_RateMatch == 8);
spa_assert(SPA_IO_Memory == 9);
#if defined(__x86_64__)
spa_assert(sizeof(struct spa_io_buffers) == 8);
spa_assert(sizeof(struct spa_io_memory) == 16);
spa_assert(sizeof(struct spa_io_range) == 16);
@ -50,17 +51,31 @@ static void test_io_abi(void)
spa_assert(sizeof(struct spa_io_sequence) == 16);
spa_assert(sizeof(struct spa_io_segment_bar) == 64);
spa_assert(sizeof(struct spa_io_segment_video) == 80);
fprintf(stderr, "%zd", sizeof(struct spa_io_segment));
spa_assert(sizeof(struct spa_io_segment) == 184);
#else
fprintf(stderr, "%zd\n", sizeof(struct spa_io_buffers));
fprintf(stderr, "%zd\n", sizeof(struct spa_io_memory));
fprintf(stderr, "%zd\n", sizeof(struct spa_io_range));
fprintf(stderr, "%zd\n", sizeof(struct spa_io_clock));
fprintf(stderr, "%zd\n", sizeof(struct spa_io_latency));
fprintf(stderr, "%zd\n", sizeof(struct spa_io_sequence));
fprintf(stderr, "%zd\n", sizeof(struct spa_io_segment_bar));
fprintf(stderr, "%zd\n", sizeof(struct spa_io_segment_video));
fprintf(stderr, "%zd\n", sizeof(struct spa_io_segment));
#endif
/* position state */
spa_assert(SPA_IO_POSITION_STATE_STOPPED == 0);
spa_assert(SPA_IO_POSITION_STATE_STARTING == 1);
spa_assert(SPA_IO_POSITION_STATE_RUNNING == 2);
fprintf(stderr, "%zd", sizeof(struct spa_io_position));
#if defined(__x86_64__)
spa_assert(sizeof(struct spa_io_position) == 1688);
spa_assert(sizeof(struct spa_io_rate_match) == 48);
#else
fprintf(stderr, "%zd\n", sizeof(struct spa_io_position));
fprintf(stderr, "%zd\n", sizeof(struct spa_io_rate_match));
#endif
}
static void test_command_abi(void)
@ -195,11 +210,20 @@ static void test_node_abi(void)
spa_assert(SPA_NODE_METHOD_NUM == 15);
spa_assert(sizeof(m) == sizeof(methods));
#if defined(__x86_64__)
spa_assert(sizeof(struct spa_node_info) == 48);
spa_assert(sizeof(struct spa_port_info) == 48);
spa_assert(sizeof(struct spa_result_node_error) == 8);
spa_assert(sizeof(struct spa_result_node_params) == 24);
#else
fprintf(stderr, "%zd\n", sizeof(struct spa_node_info));
fprintf(stderr, "%zd\n", sizeof(struct spa_port_info));
fprintf(stderr, "%zd\n", sizeof(struct spa_result_node_error));
fprintf(stderr, "%zd\n", sizeof(struct spa_result_node_params));
#endif
}
int main(int argc, char *argv[])

View file

@ -35,6 +35,7 @@
static void test_abi(void)
{
/* pod */
#if defined(__x86_64__)
spa_assert(sizeof(struct spa_pod) == 8);
spa_assert(sizeof(struct spa_pod_bool) == 16);
spa_assert(sizeof(struct spa_pod_id) == 16);
@ -85,6 +86,7 @@ static void test_abi(void)
/* parser */
spa_assert(sizeof(struct spa_pod_parser_state) == 16);
spa_assert(sizeof(struct spa_pod_parser) == 32);
#endif
}

View file

@ -63,6 +63,7 @@ static void test_abi(void)
spa_assert(f.denom == 125);
}
#if defined(__x86_64__)
/* dict */
spa_assert(sizeof(struct spa_dict_item) == 16);
spa_assert(sizeof(struct spa_dict) == 16);
@ -73,6 +74,7 @@ static void test_abi(void)
/* list */
spa_assert(sizeof(struct spa_list) == 16);
#endif
/* ringbuffer */
spa_assert(sizeof(struct spa_ringbuffer) == 8);

View file

@ -27,7 +27,11 @@
static void test_abi(void)
{
/* array */
#if defined(__x86_64__)
spa_assert(sizeof(struct pw_array) == 32);
#else
fprintf(stderr, "%zd\n", sizeof(struct pw_array));
#endif
}
static void test_array(void)

View file

@ -26,7 +26,11 @@
static void test_abi(void)
{
#if defined(__x86_64__)
spa_assert(sizeof(struct pw_properties) == 24);
#else
fprintf(stderr, "%zd\n", sizeof(struct pw_properties));
#endif
}
static void test_empty(void)

View file

@ -59,8 +59,13 @@ static void test_abi(void)
TEST_FUNC(ev, test, process);
TEST_FUNC(ev, test, drained);
#if defined(__x86_64__)
spa_assert(sizeof(struct pw_buffer) == 24);
spa_assert(sizeof(struct pw_time) == 40);
#else
fprintf(stderr, "%zd\n", sizeof(struct pw_buffer));
fprintf(stderr, "%zd\n", sizeof(struct pw_time));
#endif
spa_assert(PW_VERSION_STREAM_EVENTS == 0);
spa_assert(sizeof(ev) == sizeof(test));
@ -142,10 +147,7 @@ static void test_create(void)
struct pw_time tm;
loop = pw_main_loop_new(NULL);
context = pw_context_new(pw_main_loop_get_loop(loop),
pw_properties_new(
PW_KEY_CORE_DAEMON, "1",
NULL), 12);
context = pw_context_new(pw_main_loop_get_loop(loop), NULL, 12);
spa_assert(context != NULL);
core = pw_context_connect_self(context, NULL, 0);
spa_assert(core != NULL);
@ -194,10 +196,7 @@ static void test_properties(void)
struct spa_dict_item items[3];
loop = pw_main_loop_new(NULL);
context = pw_context_new(pw_main_loop_get_loop(loop),
pw_properties_new(
PW_KEY_CORE_DAEMON, "1",
NULL), 12);
context = pw_context_new(pw_main_loop_get_loop(loop), NULL, 12);
spa_assert(context != NULL);
core = pw_context_connect_self(context, NULL, 0);
spa_assert(core != NULL);