summaryrefslogtreecommitdiffstats
path: root/src/tests/common.c
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2012-03-28 11:51:21 -0400
committerStephen Gallagher <sgallagh@redhat.com>2012-03-28 15:07:05 -0400
commit4790f7b3cff3800df92b232aec1d779db52c72b1 (patch)
tree5be847ebe6bd3a54c186751e8c93ac1549410d3e /src/tests/common.c
parent419ddca29f074cf446c316b735fbbafc59084458 (diff)
downloadsssd_unused-4790f7b3cff3800df92b232aec1d779db52c72b1.tar.gz
sssd_unused-4790f7b3cff3800df92b232aec1d779db52c72b1.tar.xz
sssd_unused-4790f7b3cff3800df92b232aec1d779db52c72b1.zip
Add better dp_option tests
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 cd13507c..118684dd 100644
--- a/src/tests/common.c
+++ b/src/tests/common.c
@@ -41,3 +41,29 @@ tests_set_cwd(void)
}
}
}
+
+/* Check that the option names of the two maps are the same
+ * and appear in the same order.
+ */
+errno_t
+compare_dp_options(struct dp_option *map1, size_t size1,
+ struct dp_option *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;
+}