aboutsummaryrefslogtreecommitdiffstats
path: root/tests/client-server.c
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2021-07-09 13:22:35 +0300
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2021-07-28 13:19:02 +0300
commitd61cc219f6bd3c4ffc96239893a8ded9b5a83b30 (patch)
tree4ac3c1b1ed0ede9b347e27b262f939213146a221 /tests/client-server.c
parenta2a3f6912e60c7932bad87a6d2249f0e83e637e1 (diff)
lib: remove dependency on spa_pod and spa in general
Replace spa_pod with a custom icipc_data structure, which is based on spa_pod and it's fully compatible with it Signed-off-by: George Kiagiadakis <george.kiagiadakis@collabora.com>
Diffstat (limited to 'tests/client-server.c')
-rw-r--r--tests/client-server.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/tests/client-server.c b/tests/client-server.c
index 9954b86..f6e8fa5 100644
--- a/tests/client-server.c
+++ b/tests/client-server.c
@@ -8,12 +8,16 @@
#define _GNU_SOURCE
#include "test.h"
-#include <spa/pod/builder.h>
-#include <spa/pod/parser.h>
+#include "data.h"
#include <icipc.h>
#include <unistd.h>
#include <pthread.h>
+typedef struct DataInt {
+ struct icipc_data hdr;
+ int value;
+} DataInt;
+
static inline char *new_address() {
char *address = NULL;
(void)asprintf(&address, "icipc-test-%d-%d", getpid(), rand());
@@ -25,20 +29,27 @@ static bool increment_request_handler(
struct icipc_server *self,
int client_fd,
const char *name,
- const struct spa_pod *args,
+ const struct icipc_data *args,
void *data) {
int32_t val = 0;
- test_bool_true(spa_pod_is_int(args));
- test_bool_true(spa_pod_get_int(args, &val) == 0);
- struct spa_pod_int res = SPA_POD_INIT_Int(val + 1);
- return icipc_server_reply_ok(self, client_fd, (struct spa_pod *)&res);
+ test_cmpint(args->type, ==, (uint32_t) DATA_TYPE_INT);
+ test_cmpint(ICIPC_DATA_BODY_SIZE(args), ==,
+ ROUND_UP_TO_ALIGN(sizeof(int)));
+ val = *((const int*)ICIPC_DATA_BODY_CONST(args));
+
+ DataInt res = {
+ .hdr.size = sizeof(int),
+ .hdr.type = DATA_TYPE_INT,
+ .value = val + 1,
+ };
+ return icipc_server_reply_ok(self, client_fd, (struct icipc_data *)&res);
}
static bool error_request_handler(
struct icipc_server *self,
int client_fd,
const char *name,
- const struct spa_pod *args,
+ const struct icipc_data *args,
void *data) {
return icipc_server_reply_error(self, client_fd, "error message");
}
@@ -68,11 +79,13 @@ static void reply_handler(
pthread_mutex_lock(&data->mutex);
- const struct spa_pod *pod =
+ const struct icipc_data *args =
icipc_client_send_request_finish(self, buffer, size, &data->error);
- if (pod) {
- test_bool_true(spa_pod_is_int(pod));
- test_bool_true(spa_pod_get_int(pod, &data->incremented) == 0);
+ if (args) {
+ test_cmpint(args->type, ==, (uint32_t) DATA_TYPE_INT);
+ test_cmpint(ICIPC_DATA_BODY_SIZE(args), ==,
+ ROUND_UP_TO_ALIGN(sizeof(int)));
+ data->incremented = *((const int*)ICIPC_DATA_BODY_CONST(args));
}
data->n_replies++;
pthread_cond_signal(&data->cond);
@@ -100,9 +113,13 @@ static void test_icipc_server_client() {
data.incremented = -1;
data.error = NULL;
data.n_replies = 0;
- struct spa_pod_int i = SPA_POD_INIT_Int(3);
+ DataInt i = {
+ .hdr.size = sizeof(int),
+ .hdr.type = DATA_TYPE_INT,
+ .value = 3,
+ };
test_bool_true(icipc_client_send_request
- (c, "INCREMENT", (struct spa_pod *)&i, reply_handler,
+ (c, "INCREMENT", (struct icipc_data *)&i, reply_handler,
&data));
wait_for_reply(&data, 1);
test_ptr_null(data.error);