summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/test-bus-marshal.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-21 01:03:26 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-21 01:03:26 +0100
commit28383ba18963cdedd98ced271b3425f7321119b7 (patch)
tree5d6254dbdd2dd07476cfaf7b4fd9a72c9048e9c2 /src/libsystemd-bus/test-bus-marshal.c
parent850516e012f0e2c96cecb63c1e8997e13912fcd6 (diff)
bus: add API calls to escape string components of objects paths
Diffstat (limited to 'src/libsystemd-bus/test-bus-marshal.c')
-rw-r--r--src/libsystemd-bus/test-bus-marshal.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libsystemd-bus/test-bus-marshal.c b/src/libsystemd-bus/test-bus-marshal.c
index b7606d7708..98737b6811 100644
--- a/src/libsystemd-bus/test-bus-marshal.c
+++ b/src/libsystemd-bus/test-bus-marshal.c
@@ -39,6 +39,29 @@
#include "bus-util.h"
#include "bus-dump.h"
+static void test_bus_label_escape_one(const char *a, const char *b) {
+ _cleanup_free_ char *t = NULL, *x = NULL, *y = NULL;
+
+ assert_se(t = sd_bus_label_escape(a));
+ assert_se(streq(t, b));
+
+ assert_se(x = sd_bus_label_unescape(t));
+ assert_se(streq(a, x));
+
+ assert_se(y = sd_bus_label_unescape(b));
+ assert_se(streq(a, y));
+}
+
+static void test_bus_label_escape(void) {
+ test_bus_label_escape_one("foo123bar", "foo123bar");
+ test_bus_label_escape_one("foo.bar", "foo_2ebar");
+ test_bus_label_escape_one("foo_2ebar", "foo_5f2ebar");
+ test_bus_label_escape_one("", "_");
+ test_bus_label_escape_one("_", "_5f");
+ test_bus_label_escape_one("1", "_31");
+ test_bus_label_escape_one(":1", "_3a1");
+}
+
int main(int argc, char *argv[]) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *copy = NULL;
int r, boolean;
@@ -294,5 +317,7 @@ int main(int argc, char *argv[]) {
assert_se(streq(c, "ccc"));
assert_se(streq(d, "3"));
+ test_bus_label_escape();
+
return 0;
}