summaryrefslogtreecommitdiffstats
path: root/tests/protocol.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/protocol.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/protocol.c')
-rw-r--r--tests/protocol.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/tests/protocol.c b/tests/protocol.c
index 1d29db3..c0d28e7 100644
--- a/tests/protocol.c
+++ b/tests/protocol.c
@@ -7,36 +7,49 @@
*/
#include "test.h"
-#include <spa/pod/builder.h>
-#include <spa/pod/parser.h>
+#include "data.h"
#include <icipc.h>
+typedef struct DataInt {
+ struct icipc_data hdr;
+ int value;
+} DataInt;
+
static void test_icipc_protocol() {
uint8_t b[1024];
/* request null value */
{
- icipc_protocol_build_request(b, sizeof(b), "name", NULL);
const char *name = NULL;
- const struct spa_pod *value = NULL;
+ const struct icipc_data *value = NULL;
+
+ icipc_protocol_build_request(b, sizeof(b), "name", NULL);
test_bool_true(icipc_protocol_parse_request
(b, sizeof(b), &name, &value));
test_str_eq(name, "name");
- test_bool_true(spa_pod_is_none(value));
+ test_cmpint(value->type, ==, (uint32_t) DATA_TYPE_NONE);
}
/* request */
{
- struct spa_pod_int i = SPA_POD_INIT_Int(8);
- icipc_protocol_build_request(b, sizeof(b), "name",
- (struct spa_pod *)&i);
+ DataInt i = {
+ .hdr.size = sizeof(int),
+ .hdr.type = DATA_TYPE_INT,
+ .value = 8,
+ };
const char *name = NULL;
- const struct spa_pod_int *value = NULL;
+ const struct icipc_data *value = NULL;
+
+ icipc_protocol_build_request(b, sizeof(b), "name",
+ (struct icipc_data *)&i);
test_bool_true(icipc_protocol_parse_request
(b, sizeof(b), &name,
- (const struct spa_pod **)&value));
+ (const struct icipc_data **)&value));
test_str_eq(name, "name");
- test_cmpint(value->value, ==, 8);
+ test_cmpint(ICIPC_DATA_BODY_SIZE(value), ==,
+ ROUND_UP_TO_ALIGN(sizeof(int)));
+ test_cmpint(value->type, ==, (uint32_t) DATA_TYPE_INT);
+ test_cmpint(*((const int*)ICIPC_DATA_BODY_CONST(value)), ==, 8);
}
/* reply error */
@@ -51,25 +64,34 @@ static void test_icipc_protocol() {
/* reply ok null value */
{
+ const struct icipc_data *value = NULL;
+
icipc_protocol_build_reply_ok(b, sizeof(b), NULL);
test_bool_true(icipc_protocol_is_reply_ok(b, sizeof(b)));
- const struct spa_pod *value = NULL;
test_bool_true(icipc_protocol_parse_reply_ok
(b, sizeof(b), &value));
test_ptr_notnull(value);
- test_bool_true(spa_pod_is_none(value));
+ test_cmpint(value->type, ==, (uint32_t) DATA_TYPE_NONE);
}
/* reply ok */
{
- struct spa_pod_int i = SPA_POD_INIT_Int(3);
+ DataInt i = {
+ .hdr.size = sizeof(int),
+ .hdr.type = DATA_TYPE_INT,
+ .value = 3,
+ };
+ const struct icipc_data *value = NULL;
+
icipc_protocol_build_reply_ok(b, sizeof(b),
- (struct spa_pod *)&i);
+ (struct icipc_data *)&i);
test_bool_true(icipc_protocol_is_reply_ok(b, sizeof(b)));
- const struct spa_pod_int *value = NULL;
test_bool_true(icipc_protocol_parse_reply_ok
- (b, sizeof(b), (const struct spa_pod **)&value));
- test_cmpint(value->value, ==, 3);
+ (b, sizeof(b), (const struct icipc_data **)&value));
+ test_cmpint(ICIPC_DATA_BODY_SIZE(value), ==,
+ ROUND_UP_TO_ALIGN(sizeof(int)));
+ test_cmpint(value->type, ==, (uint32_t) DATA_TYPE_INT);
+ test_cmpint(*((const int*)ICIPC_DATA_BODY_CONST(value)), ==, 3);
}
}