summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-rtnl/test-rtnl.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-03-26 19:25:01 +0100
committerTom Gundersen <teg@jklm.no>2014-03-28 19:11:59 +0100
commitd8e538ecd9e62f841242f07e3df5c835c1ba6313 (patch)
tree0fba56485f73d01a985ed4afaff83cffa19068d2 /src/libsystemd/sd-rtnl/test-rtnl.c
parent9f5bbfe354c52cd9e28cca32c35596b73e8d738b (diff)
sd-rtnl: rework rtnl type system
Use a static table with all the typing information, rather than repeated switch statements. This should make it a lot simpler to add new types. We need to keep all the type info to be able to create containers without exposing their implementation details to the users of the library. As a freebee we verify the types of appended/read attributes. The API is extended to nicely deal with unions of container types.
Diffstat (limited to 'src/libsystemd/sd-rtnl/test-rtnl.c')
-rw-r--r--src/libsystemd/sd-rtnl/test-rtnl.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index 8f1f95353f..44369628f4 100644
--- a/src/libsystemd/sd-rtnl/test-rtnl.c
+++ b/src/libsystemd/sd-rtnl/test-rtnl.c
@@ -279,10 +279,7 @@ static void test_container(void) {
assert_se(sd_rtnl_message_new_link(NULL, &m, RTM_NEWLINK, 0) >= 0);
assert_se(sd_rtnl_message_open_container(m, IFLA_LINKINFO) >= 0);
- assert_se(sd_rtnl_message_open_container(m, IFLA_LINKINFO) == -ENOTSUP);
- assert_se(sd_rtnl_message_append_string(m, IFLA_INFO_KIND, "vlan") >= 0);
- assert_se(sd_rtnl_message_open_container(m, IFLA_INFO_DATA) >= 0);
- assert_se(sd_rtnl_message_open_container(m, IFLA_INFO_DATA) == -ENOTSUP);
+ assert_se(sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, "vlan") >= 0);
assert_se(sd_rtnl_message_append_u16(m, IFLA_VLAN_ID, 100) >= 0);
assert_se(sd_rtnl_message_close_container(m) >= 0);
assert_se(sd_rtnl_message_append_string(m, IFLA_INFO_KIND, "vlan") >= 0);
@@ -303,7 +300,7 @@ static void test_container(void) {
assert_se(streq("vlan", string_data));
assert_se(sd_rtnl_message_exit_container(m) >= 0);
- assert_se(sd_rtnl_message_read_u32(m, IFLA_LINKINFO, &u32_data) == 0);
+ assert_se(sd_rtnl_message_read_u32(m, IFLA_LINKINFO, &u32_data) < 0);
assert_se(sd_rtnl_message_exit_container(m) == -EINVAL);
}