summaryrefslogtreecommitdiff
path: root/src/test/test-util.c
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-09-17 15:47:08 -0400
committerDave Reisner <dreisner@archlinux.org>2013-09-17 16:31:32 -0400
commit22f5f6281fc25f43a85938e9dad2480b2595c471 (patch)
tree44701cb1a2ee05621feaad1f938eaa02c9ca299d /src/test/test-util.c
parent02a36bc9a1769c744f141f127898dbe076dbfd96 (diff)
Use udev_encode_string in fstab_node_to_udev_node
Resolves a longstanding bug which caused this function to wrongly handle (escape) valid utf8 characters.
Diffstat (limited to 'src/test/test-util.c')
-rw-r--r--src/test/test-util.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c
index dd7768d36c..ad13d53de3 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -547,6 +547,41 @@ static void test_split_pair(void) {
assert_se(streq(b, "="));
}
+static void test_fstab_node_to_udev_node(void) {
+ char *n;
+
+ n = fstab_node_to_udev_node("LABEL=applé/jack");
+ puts(n);
+ assert_se(streq(n, "/dev/disk/by-label/applé\\x2fjack"));
+ free(n);
+
+ n = fstab_node_to_udev_node("PARTLABEL=pinkié pie");
+ puts(n);
+ assert_se(streq(n, "/dev/disk/by-partlabel/pinkié\\x20pie"));
+ free(n);
+
+ n = fstab_node_to_udev_node("UUID=037b9d94-148e-4ee4-8d38-67bfe15bb535");
+ puts(n);
+ assert_se(streq(n, "/dev/disk/by-uuid/037b9d94-148e-4ee4-8d38-67bfe15bb535"));
+ free(n);
+
+ n = fstab_node_to_udev_node("PARTUUID=037b9d94-148e-4ee4-8d38-67bfe15bb535");
+ puts(n);
+ assert_se(streq(n, "/dev/disk/by-partuuid/037b9d94-148e-4ee4-8d38-67bfe15bb535"));
+ free(n);
+
+
+ n = fstab_node_to_udev_node("PONIES=awesome");
+ puts(n);
+ assert_se(streq(n, "PONIES=awesome"));
+ free(n);
+
+ n = fstab_node_to_udev_node("/dev/xda1");
+ puts(n);
+ assert_se(streq(n, "/dev/xda1"));
+ free(n);
+}
+
int main(int argc, char *argv[]) {
test_streq_ptr();
test_first_word();
@@ -582,6 +617,7 @@ int main(int argc, char *argv[]) {
test_strrep();
test_parse_user_at_host();
test_split_pair();
+ test_fstab_node_to_udev_node();
return 0;
}