summaryrefslogtreecommitdiffstats
path: root/src/tests/common.c
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2012-03-28 12:02:45 -0400
committerStephen Gallagher <sgallagh@redhat.com>2012-03-28 15:07:05 -0400
commit4ed94554593e8a20fa361ea8d7a7f223dc6ee4e8 (patch)
tree10bebb463468f92c3af3e484537a2edf2ec5de87 /src/tests/common.c
parente980f8b95f2fb89e872babffdd94b3ccb2d42ccf (diff)
downloadsssd_unused-4ed94554593e8a20fa361ea8d7a7f223dc6ee4e8.tar.gz
sssd_unused-4ed94554593e8a20fa361ea8d7a7f223dc6ee4e8.tar.xz
sssd_unused-4ed94554593e8a20fa361ea8d7a7f223dc6ee4e8.zip
Add better tests for sdap_attr compability
Diffstat (limited to 'src/tests/common.c')
-rw-r--r--src/tests/common.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/tests/common.c b/src/tests/common.c
index 118684dd..3e4753e0 100644
--- a/src/tests/common.c
+++ b/src/tests/common.c
@@ -67,3 +67,29 @@ compare_dp_options(struct dp_option *map1, size_t size1,
return EOK;
}
+
+/* Check that the option names of the two maps are the same
+ * and appear in the same order.
+ */
+errno_t
+compare_sdap_attr_maps(struct sdap_attr_map *map1, size_t size1,
+ struct sdap_attr_map *map2)
+{
+ size_t i;
+
+ for (i = 0; i < size1; i++) {
+ /* Check for a valid option */
+ if (map1[i].opt_name == NULL) return EINVAL;
+
+ /* Check whether we've gone past the end of map2 */
+ if (map2[i].opt_name == NULL) return ERANGE;
+
+ /* Ensure that the option names are the same */
+ if(strcmp(map1[i].opt_name, map2[i].opt_name) != 0) return EINVAL;
+ }
+
+ /* Leftover options in map2 */
+ if (map2[i].opt_name != NULL) return ERANGE;
+
+ return EOK;
+}