tmpl_dcursor_ctx_t cc; \
int err; \
tmpl_t *vpt; \
- char const *ref; \
fr_pair_t *vp
-/*
- * Common code for every test
+/** Initialise a tmpl using the _attr_str string, and return the first pair
+ *
+ * @param[out] _out The first pair found.
+ * @param[in] _attr_str Attribute reference string.
*/
-#define tmpl_setup_and_cursor_init(_attr) \
- ref = _attr; \
+#define tmpl_setup_and_cursor_init(_out, _attr_str) \
+do { \
+ char const *ref = _attr_str; \
tmpl_afrom_attr_substr(autofree, NULL, &vpt, &FR_SBUFF_IN(ref, strlen(ref)), NULL, &(tmpl_rules_t){.attr = {.dict_def = test_dict}}); \
- vp = tmpl_dcursor_init(&err, NULL, &cc, &cursor, request, vpt);
+ *(_out) = tmpl_dcursor_init(&err, NULL, &cc, &cursor, request, vpt); \
+} while (0)
-#define tmpl_setup_and_cursor_build_init(_attr) \
- ref = _attr; \
+/** Initialise a tmpl using the _attr_str string, and build out the first pair
+ *
+ * @param[out] _out The first pair allocated.
+ * @param[in] _attr_str Attribute reference string.
+ */
+#define tmpl_setup_and_cursor_build_init(_out, _attr_str) \
+do { \
+ char const *ref = _attr_str; \
tmpl_afrom_attr_substr(autofree, NULL, &vpt, &FR_SBUFF_IN(ref, strlen(ref)), NULL, &(tmpl_rules_t){.attr = {.dict_def = test_dict}}); \
- inserted = tmpl_dcursor_build_init(&err, autofree, &cc, &cursor, request, vpt, &tmpl_dcursor_pair_build, NULL);
+ *(_out) = tmpl_dcursor_build_init(&err, autofree, &cc, &cursor, request, vpt); \
+} while (0)
/*
* How every test ends
TEST_CHECK_PAIR(vp, NULL); \
TEST_MSG("Cursor should've been empty (i.e. returned NULL) at end of test"); \
tmpl_dcursor_clear(&cc); \
+ TEST_CHECK_RET(talloc_free(vpt), 0); \
TEST_CHECK_RET(talloc_free(request), 0)
/*
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Int32-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int32-0");
TEST_CHECK_PAIR(vp, int32_vp1);
test_end;
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Int32-0[1]");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int32-0[1]");
TEST_CHECK_PAIR(vp, NULL);
test_end;
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Int32-0[*]");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int32-0[*]");
TEST_CHECK_PAIR(vp, int32_vp1);
test_end;
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Int16-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int16-0");
TEST_CHECK_PAIR(vp, NULL);
test_end;
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Int32-0[n]");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int32-0[n]");
TEST_CHECK_PAIR(vp, int32_vp1);
test_end;
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Int32-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int32-0");
TEST_CHECK_PAIR(vp, int32_vp1);
test_end;
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Int32-0[1]");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int32-0[1]");
TEST_CHECK_PAIR(vp, int32_vp2);
test_end;
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Int32-0[2]");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int32-0[2]");
TEST_CHECK_PAIR(vp, NULL);
test_end;
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Int32-0[*]");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int32-0[*]");
TEST_CHECK_PAIR(vp, int32_vp1);
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Int32-0[n]");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int32-0[n]");
TEST_CHECK_PAIR(vp, int32_vp2);
test_end;
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Int32-0[#]");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int32-0[#]");
TEST_CHECK_PAIR(vp, int32_vp1);
vp = fr_dcursor_next(&cursor);
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Group-0.Test-Int16-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0.Test-Int16-0");
TEST_CHECK_PAIR(vp, child_vp1);
test_end;
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Group-0.Test-Int16-0[1]");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0.Test-Int16-0[1]");
TEST_CHECK_PAIR(vp, NULL);
test_end;
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Group-0.Test-Int16-0[*]");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0.Test-Int16-0[*]");
TEST_CHECK_PAIR(vp, child_vp1);
test_end;
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Group-0.Test-Int32-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0.Test-Int32-0");
TEST_CHECK_PAIR(vp, NULL);
test_end;
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Group-0.Test-Int16-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0.Test-Int16-0");
TEST_CHECK_PAIR(vp, child_vp1);
test_end;
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Group-0[1].Test-Int16-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0[1].Test-Int16-0");
TEST_CHECK_PAIR(vp, child_vp2);
test_end;
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Group-0[*].Test-Int16-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0[*].Test-Int16-0");
TEST_CHECK_PAIR(vp, child_vp1);
vp = fr_dcursor_next(&cursor);
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Group-0[n].Test-Int16-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0[n].Test-Int16-0");
TEST_CHECK_PAIR(vp, child_vp2);
test_end;
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Group-0[*].Test-Int32-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0[*].Test-Int32-0");
TEST_CHECK_PAIR(vp, NULL);
test_end;
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Nested-Top-TLV-0[0].Child-TLV[0].Leaf-String");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Nested-Top-TLV-0[0].Child-TLV[0].Leaf-String");
TEST_CHECK_PAIR(vp, leaf_string_vp1);
test_end;
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Nested-Top-TLV-0[0].Child-TLV[1].Leaf-String");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Nested-Top-TLV-0[0].Child-TLV[1].Leaf-String");
TEST_CHECK_PAIR(vp, NULL);
test_end;
pair_defs(1);
pair_populate(1);
- tmpl_setup_and_cursor_init("&Test-Nested-Top-TLV-0[0].Child-TLV[*].Leaf-String");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Nested-Top-TLV-0[0].Child-TLV[*].Leaf-String");
TEST_CHECK_PAIR(vp, leaf_string_vp1);
test_end;
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Nested-Top-TLV-0[0].Child-TLV[0].Leaf-Int32");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Nested-Top-TLV-0[0].Child-TLV[0].Leaf-Int32");
TEST_CHECK_PAIR(vp, leaf_int32_vp1);
test_end;
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Nested-Top-TLV-0[*].Child-TLV[*].Leaf-Int32");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Nested-Top-TLV-0[*].Child-TLV[*].Leaf-Int32");
TEST_CHECK_PAIR(vp, leaf_int32_vp1);
vp = fr_dcursor_next(&cursor);
pair_populate(1);
pair_populate(2);
- tmpl_setup_and_cursor_init("&Test-Nested-Top-TLV-0[n].Child-TLV[n].Leaf-Int32[n]");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Nested-Top-TLV-0[n].Child-TLV[n].Leaf-Int32[n]");
TEST_CHECK_PAIR(vp, leaf_int32_vp2);
test_end;
fr_pair_t *inserted;
pair_populate(1);
- tmpl_setup_and_cursor_build_init("&Test-Int16-0");
+ tmpl_setup_and_cursor_build_init(&inserted, "&Test-Int16-0");
TEST_CHECK_PAIR_NEQ(inserted, NULL);
build_test_end;
- tmpl_setup_and_cursor_init("&Test-Int16-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Int16-0");
TEST_CHECK_PAIR(vp, inserted);
test_end;
fr_pair_t *inserted;
pair_populate(1);
- tmpl_setup_and_cursor_build_init("&Test-Group-0.Test-Int32-0");
+ tmpl_setup_and_cursor_build_init(&inserted, "&Test-Group-0.Test-Int32-0");
TEST_CHECK_PAIR_NEQ(inserted, NULL);
build_test_end;
- tmpl_setup_and_cursor_init("&Test-Group-0.Test-Int32-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0.Test-Int32-0");
TEST_CHECK_PAIR(vp, inserted);
test_end;
common_vars;
fr_pair_t *inserted;
- tmpl_setup_and_cursor_build_init("&Test-Group-0.Test-Int16-0");
+ tmpl_setup_and_cursor_build_init(&inserted, "&Test-Group-0.Test-Int16-0");
TEST_CHECK_PAIR_NEQ(inserted, NULL);
build_test_end;
- tmpl_setup_and_cursor_init("&Test-Group-0.Test-Int16-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0.Test-Int16-0");
TEST_CHECK_PAIR(vp, inserted);
test_end;
pair_populate_thin(1);
pair_populate_thin(2);
- tmpl_setup_and_cursor_build_init("&Test-Group-0[*].Test-Int32-0");
+ tmpl_setup_and_cursor_build_init(&inserted, "&Test-Group-0[*].Test-Int32-0");
TEST_CHECK_PAIR_NEQ(inserted, NULL);
second = fr_dcursor_next(&cursor);
TEST_CHECK_PAIR(second, inserted);
build_test_end;
- tmpl_setup_and_cursor_init("&Test-Group-0[*].Test-Int32-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0[*].Test-Int32-0");
TEST_CHECK_PAIR(vp, inserted);
vp = fr_dcursor_next(&cursor);
TEST_CHECK_PAIR(vp, second);
fr_pair_t *inserted;
pair_populate(1);
- tmpl_setup_and_cursor_build_init("&Test-Group-0.Test-Group-0.Test-String-0");
+ tmpl_setup_and_cursor_build_init(&inserted, "&Test-Group-0.Test-Group-0.Test-String-0");
TEST_CHECK_PAIR_NEQ(inserted, NULL);
build_test_end;
- tmpl_setup_and_cursor_init("&Test-Group-0.Test-Group-0.Test-String-0");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Group-0.Test-Group-0.Test-String-0");
TEST_CHECK_PAIR(vp, inserted);
test_end;
common_vars;
fr_pair_t *inserted;
- tmpl_setup_and_cursor_build_init("&Test-Nested-Top-TLV-0[0].Child-TLV[0].Leaf-String");
+ tmpl_setup_and_cursor_build_init(&inserted, "&Test-Nested-Top-TLV-0[0].Child-TLV[0].Leaf-String");
TEST_CHECK_PAIR_NEQ(inserted, NULL);
build_test_end;
- tmpl_setup_and_cursor_init("&Test-Nested-Top-TLV-0[0].Child-TLV[0].Leaf-String");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Nested-Top-TLV-0[0].Child-TLV[0].Leaf-String");
TEST_CHECK_PAIR(vp, inserted);
test_end;
pair_populate(1);
pair_populate_thin(2);
- tmpl_setup_and_cursor_build_init("&Test-Nested-Top-TLV-0[1].Child-TLV[0].Leaf-String");
+ tmpl_setup_and_cursor_build_init(&inserted, "&Test-Nested-Top-TLV-0[1].Child-TLV[0].Leaf-String");
TEST_CHECK_PAIR_NEQ(inserted, NULL);
TEST_CHECK_PAIR_NEQ(inserted, leaf_string_vp1);
build_test_end;
- tmpl_setup_and_cursor_init("&Test-Nested-Top-TLV-0[1].Child-TLV[0].Leaf-String");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Nested-Top-TLV-0[1].Child-TLV[0].Leaf-String");
TEST_CHECK_PAIR(vp, inserted);
test_end;
common_vars;
fr_pair_t *inserted;
- tmpl_setup_and_cursor_build_init("&Test-Nested-Top-TLV-0[3].Child-TLV[0].Leaf-String");
+ tmpl_setup_and_cursor_build_init(&inserted, "&Test-Nested-Top-TLV-0[3].Child-TLV[0].Leaf-String");
TEST_CHECK_PAIR(inserted, NULL);
build_test_end;
- tmpl_setup_and_cursor_init("&Test-Nested-Top-TLV-0[3].Child-TLV[0].Leaf-String");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Nested-Top-TLV-0[3].Child-TLV[0].Leaf-String");
TEST_CHECK_PAIR(vp, NULL);
test_end;
common_vars;
fr_pair_t *inserted;
- tmpl_setup_and_cursor_build_init("&Test-Nested-Top-TLV-0[*].Child-TLV[0].Leaf-String");
+ tmpl_setup_and_cursor_build_init(&inserted, "&Test-Nested-Top-TLV-0[*].Child-TLV[0].Leaf-String");
TEST_CHECK_PAIR(inserted, NULL);
build_test_end;
- tmpl_setup_and_cursor_init("&Test-Nested-Top-TLV-0[*].Child-TLV[0].Leaf-String");
+ tmpl_setup_and_cursor_init(&vp, "&Test-Nested-Top-TLV-0[*].Child-TLV[0].Leaf-String");
TEST_CHECK_PAIR(vp, NULL);
test_end;