summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2016-07-13 15:44:36 +0200
committerSumit Bose <sbose@redhat.com>2016-07-13 15:45:07 +0200
commit1785eedc84f2633588e70f879c47596e047c3838 (patch)
treef673b4936437a8303bf7a1b1501d23e7fa8195ed
parented1efbfb95a9ee6577e47f26d250f70410290aea (diff)
downloadsssd-1785eedc84f2633588e70f879c47596e047c3838.zip
sssd-1785eedc84f2633588e70f879c47596e047c3838.tar.gz
sssd-1785eedc84f2633588e70f879c47596e047c3838.tar.xz
tests: add test_sss_idmap_calculate_range()
-rw-r--r--src/tests/cmocka/test_sss_idmap.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/tests/cmocka/test_sss_idmap.c b/src/tests/cmocka/test_sss_idmap.c
index f82e3dc..c6f18f8 100644
--- a/src/tests/cmocka/test_sss_idmap.c
+++ b/src/tests/cmocka/test_sss_idmap.c
@@ -161,6 +161,41 @@ static int setup_ranges_2922(struct test_ctx *test_ctx)
return 0;
}
+static void test_sss_idmap_calculate_range(void **state)
+{
+ struct test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type(*state, struct test_ctx);
+ assert_non_null(test_ctx);
+ enum idmap_error_code err;
+ struct sss_idmap_range range;
+ id_t slice_num = -1;
+
+ err = sss_idmap_calculate_range(test_ctx->idmap_ctx, "S-1-5-21-1213303737-1786771823-1669754145" , &slice_num,
+ &range);
+ assert_int_equal(err, IDMAP_SUCCESS);
+ fprintf(stdout, "[%d]\n", slice_num);
+
+ err = sss_idmap_ctx_set_rangesize(test_ctx->idmap_ctx, 20000000);
+ assert_int_equal(err, IDMAP_SUCCESS);
+
+ slice_num = -1;
+ err = sss_idmap_calculate_range(test_ctx->idmap_ctx, "S-1-5-21-1213303737-1786771823-1669754145" , &slice_num,
+ &range);
+ assert_int_equal(err, IDMAP_SUCCESS);
+ fprintf(stdout, "[%d]\n", slice_num);
+
+ err = sss_idmap_ctx_set_rangesize(test_ctx->idmap_ctx, 200000);
+ assert_int_equal(err, IDMAP_SUCCESS);
+
+ slice_num = -1;
+ err = sss_idmap_calculate_range(test_ctx->idmap_ctx, "S-1-5-21-1213303737-1786771823-1669754145" , &slice_num,
+ &range);
+ assert_int_equal(err, IDMAP_SUCCESS);
+ fprintf(stdout, "[%d]\n", slice_num);
+}
+
+
static int test_sss_idmap_setup_with_domains(void **state)
{
struct test_ctx *test_ctx;
@@ -713,6 +748,9 @@ int main(int argc, const char *argv[])
test_sss_idmap_setup_with_both,
test_sss_idmap_teardown),
cmocka_unit_test(test_sss_idmap_check_collision_ex),
+ cmocka_unit_test_setup_teardown(test_sss_idmap_calculate_range,
+ test_sss_idmap_setup,
+ test_sss_idmap_teardown),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */