summaryrefslogtreecommitdiffstats
path: root/src/test/test-varlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test-varlink.c')
-rw-r--r--src/test/test-varlink.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/test/test-varlink.c b/src/test/test-varlink.c
index 2617ed0..8ad5757 100644
--- a/src/test/test-varlink.c
+++ b/src/test/test-varlink.c
@@ -107,7 +107,7 @@ static int method_passfd(Varlink *link, JsonVariant *parameters, VarlinkMethodFl
if (!a)
return varlink_error(link, "io.test.BadParameters", NULL);
- assert_se(streq_ptr(json_variant_string(a), "whoop"));
+ ASSERT_STREQ(json_variant_string(a), "whoop");
int xx = varlink_peek_fd(link, 0),
yy = varlink_peek_fd(link, 1),
@@ -123,8 +123,8 @@ static int method_passfd(Varlink *link, JsonVariant *parameters, VarlinkMethodFl
test_fd(yy, "bar", 3);
test_fd(zz, "quux", 4);
- _cleanup_close_ int vv = acquire_data_fd("miau", 4, 0);
- _cleanup_close_ int ww = acquire_data_fd("wuff", 4, 0);
+ _cleanup_close_ int vv = acquire_data_fd("miau");
+ _cleanup_close_ int ww = acquire_data_fd("wuff");
assert_se(vv >= 0);
assert_se(ww >= 0);
@@ -183,7 +183,7 @@ static int overload_reply(Varlink *link, JsonVariant *parameters, const char *er
* be talking to an overloaded server */
log_debug("Over reply triggered with error: %s", strna(error_id));
- assert_se(streq(error_id, VARLINK_ERROR_DISCONNECTED));
+ ASSERT_STREQ(error_id, VARLINK_ERROR_DISCONNECTED);
sd_event_exit(varlink_get_event(link), 0);
return 0;
@@ -238,10 +238,10 @@ static void flood_test(const char *address) {
static void *thread(void *arg) {
_cleanup_(varlink_flush_close_unrefp) Varlink *c = NULL;
- _cleanup_(json_variant_unrefp) JsonVariant *i = NULL, *j = NULL;
- JsonVariant *o = NULL, *k = NULL;
+ _cleanup_(json_variant_unrefp) JsonVariant *i = NULL;
+ _cleanup_(json_variant_unrefp) JsonVariant *wrong = NULL;
+ JsonVariant *o = NULL, *k = NULL, *j = NULL;
const char *error_id;
- VarlinkReplyFlags flags = 0;
const char *e;
int x = 0;
@@ -253,10 +253,16 @@ static void *thread(void *arg) {
assert_se(varlink_set_allow_fd_passing_input(c, true) >= 0);
assert_se(varlink_set_allow_fd_passing_output(c, true) >= 0);
- assert_se(varlink_collect(c, "io.test.DoSomethingMore", i, &j, &error_id, &flags) >= 0);
+ /* Test that client is able to perform two sequential varlink_collect calls if first resulted in an error */
+ assert_se(json_build(&wrong, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("a", JSON_BUILD_INTEGER(88)),
+ JSON_BUILD_PAIR("c", JSON_BUILD_INTEGER(99)))) >= 0);
+ assert_se(varlink_collect(c, "io.test.DoSomethingMore", wrong, &j, &error_id) >= 0);
+ assert_se(strcmp_ptr(error_id, "org.varlink.service.InvalidParameter") == 0);
+
+
+ assert_se(varlink_collect(c, "io.test.DoSomethingMore", i, &j, &error_id) >= 0);
assert_se(!error_id);
- assert_se(!flags);
assert_se(json_variant_is_array(j) && !json_variant_is_blank_array(j));
JSON_VARIANT_ARRAY_FOREACH(k, j) {
@@ -265,13 +271,13 @@ static void *thread(void *arg) {
}
assert_se(x == 6);
- assert_se(varlink_call(c, "io.test.DoSomething", i, &o, &e, NULL) >= 0);
+ assert_se(varlink_call(c, "io.test.DoSomething", i, &o, &e) >= 0);
assert_se(json_variant_integer(json_variant_by_key(o, "sum")) == 88 + 99);
assert_se(!e);
- int fd1 = acquire_data_fd("foo", 3, 0);
- int fd2 = acquire_data_fd("bar", 3, 0);
- int fd3 = acquire_data_fd("quux", 4, 0);
+ int fd1 = acquire_data_fd("foo");
+ int fd2 = acquire_data_fd("bar");
+ int fd3 = acquire_data_fd("quux");
assert_se(fd1 >= 0);
assert_se(fd2 >= 0);
@@ -281,7 +287,7 @@ static void *thread(void *arg) {
assert_se(varlink_push_fd(c, fd2) == 1);
assert_se(varlink_push_fd(c, fd3) == 2);
- assert_se(varlink_callb(c, "io.test.PassFD", &o, &e, NULL, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("fd", JSON_BUILD_STRING("whoop")))) >= 0);
+ assert_se(varlink_callb(c, "io.test.PassFD", &o, &e, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("fd", JSON_BUILD_STRING("whoop")))) >= 0);
int fd4 = varlink_peek_fd(c, 0);
int fd5 = varlink_peek_fd(c, 1);
@@ -292,9 +298,9 @@ static void *thread(void *arg) {
test_fd(fd4, "miau", 4);
test_fd(fd5, "wuff", 4);
- assert_se(varlink_callb(c, "io.test.IDontExist", &o, &e, NULL, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("x", JSON_BUILD_REAL(5.5)))) >= 0);
- assert_se(streq_ptr(json_variant_string(json_variant_by_key(o, "method")), "io.test.IDontExist"));
- assert_se(streq(e, VARLINK_ERROR_METHOD_NOT_FOUND));
+ assert_se(varlink_callb(c, "io.test.IDontExist", &o, &e, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("x", JSON_BUILD_REAL(5.5)))) >= 0);
+ ASSERT_STREQ(json_variant_string(json_variant_by_key(o, "method")), "io.test.IDontExist");
+ ASSERT_STREQ(e, VARLINK_ERROR_METHOD_NOT_FOUND);
flood_test(arg);