summaryrefslogtreecommitdiff
path: root/src/lib/tests
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2017-01-31 19:41:35 +0000
committerSander Vrijders <[email protected]>2017-01-31 19:41:35 +0000
commit5be7963e8b319b9b0c191f7ff0b31f7fbbeafb6c (patch)
tree7406c71252aef416061e255d41352b105afbeac5 /src/lib/tests
parent9728a845eb6896219b7653640fb2b8d39da1bc83 (diff)
parent988355d5bb62405f3bd3fbaade1f26ba4b2c274e (diff)
downloadouroboros-5be7963e8b319b9b0c191f7ff0b31f7fbbeafb6c.tar.gz
ouroboros-5be7963e8b319b9b0c191f7ff0b31f7fbbeafb6c.zip
Merged in dstaesse/ouroboros/be-ribmgrv2 (pull request #356)
lib: Add packing and unpacking RIB
Diffstat (limited to 'src/lib/tests')
-rw-r--r--src/lib/tests/rib_test.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/lib/tests/rib_test.c b/src/lib/tests/rib_test.c
index bad01083..efc35d63 100644
--- a/src/lib/tests/rib_test.c
+++ b/src/lib/tests/rib_test.c
@@ -49,6 +49,9 @@ int rib_test(int argc,
char ** kids;
ssize_t ch;
+ uint8_t * buf;
+ ssize_t buf_len;
+
struct timespec t = {0, 100 * BILLION};
(void) argc;
@@ -198,6 +201,42 @@ int rib_test(int argc,
free(addr_name);
+ buf_len = rib_pack("/static_info", &buf, PACK_HASH_ALL);
+ if (buf_len < 0) {
+ printf("Failed pack.\n");
+ rib_fini();
+ return -1;
+ }
+
+ if (rib_del("/static_info")) {
+ printf("Failed to delete.\n");
+ rib_fini();
+ return -1;
+ }
+
+ if (rib_unpack(buf, buf_len, UNPACK_CREATE)) {
+ printf("Failed to unpack.\n");
+ rib_fini();
+ return -1;
+ }
+
+ if (!rib_has("/static_info")) {
+ printf("Failed to find unpacked element.\n");
+ rib_fini();
+ return -1;
+ }
+
+ ch = rib_children("/static_info", &kids);
+ if (ch != 2) {
+ printf("Wrong number of children returned.\n");
+ rib_fini();
+ return -1;
+ }
+
+ while (ch > 0)
+ free(kids[--ch]);
+ free(kids);
+
set = ro_set_create();
if (set == NULL) {
printf("Failed to create ro_set.\n");