test_utils.c revision 059904af2d20debcb8ffe1c6f45b996c2c57574e
af84459fbf938e508fd10b01cb8d699c79083813takashi Sumit Bose <sbose@redhat.com>
af84459fbf938e508fd10b01cb8d699c79083813takashi Copyright (C) 2013 Red Hat
af84459fbf938e508fd10b01cb8d699c79083813takashi SSSD tests: Tests for utility functions
af84459fbf938e508fd10b01cb8d699c79083813takashi This program is free software; you can redistribute it and/or modify
af84459fbf938e508fd10b01cb8d699c79083813takashi it under the terms of the GNU General Public License as published by
af84459fbf938e508fd10b01cb8d699c79083813takashi the Free Software Foundation; either version 3 of the License, or
af84459fbf938e508fd10b01cb8d699c79083813takashi (at your option) any later version.
af84459fbf938e508fd10b01cb8d699c79083813takashi This program is distributed in the hope that it will be useful,
3f08db06526d6901aa08c110b5bc7dde6bc39905nd but WITHOUT ANY WARRANTY; without even the implied warranty of
af84459fbf938e508fd10b01cb8d699c79083813takashi MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
af84459fbf938e508fd10b01cb8d699c79083813takashi GNU General Public License for more details.
3f08db06526d6901aa08c110b5bc7dde6bc39905nd You should have received a copy of the GNU General Public License
af84459fbf938e508fd10b01cb8d699c79083813takashi along with this program. If not, see <http://www.gnu.org/licenses/>.
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe test_ctx = talloc_zero(global_talloc_context, struct dom_list_test_ctx);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe dom->flat_name = talloc_asprintf(dom, FLATNAME_TMPL, c);
af84459fbf938e508fd10b01cb8d699c79083813takashi struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe dom = find_domain_by_name(test_ctx->dom_list, NULL, false);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe name = talloc_asprintf(global_talloc_context, DOMNAME_TMPL, c);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe flat_name = talloc_asprintf(global_talloc_context, FLATNAME_TMPL, c);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe sid = talloc_asprintf(global_talloc_context, SID_TMPL, c);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe dom = find_domain_by_name(test_ctx->dom_list, name, false);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe dom = find_domain_by_name(test_ctx->dom_list, name, true);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe dom = find_domain_by_name(test_ctx->dom_list, flat_name, true);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe dom = find_domain_by_name(test_ctx->dom_list, flat_name, false);
af84459fbf938e508fd10b01cb8d699c79083813takashivoid test_find_domain_by_name_missing_flat_name(void **state)
2d39a41e98476f5235b7c37ce745a4aa0904b1cbrbowen struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
b7f8d802ecaed65eada1fc31472d06d8460d5528igalic assert_true((mis >= 1 && mis < test_ctx->dom_count));
b7f8d802ecaed65eada1fc31472d06d8460d5528igalic for (c = 0; c < mis; c++) {
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe name = talloc_asprintf(global_talloc_context, DOMNAME_TMPL, c);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe flat_name = talloc_asprintf(global_talloc_context, FLATNAME_TMPL, c);
7c7e501f542451bf7225b23cb299ee4228bfe15dgryzor sid = talloc_asprintf(global_talloc_context, SID_TMPL, c);
4bebf996eb7002ebfe897d46a0e0572390604a77nd dom = find_domain_by_name(test_ctx->dom_list, name, true);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe dom = find_domain_by_name(test_ctx->dom_list, name, false);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe dom = find_domain_by_name(test_ctx->dom_list, flat_name, true);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe dom = find_domain_by_name(test_ctx->dom_list, flat_name, false);
c8c717fafa0a09ed13469a603a178921b851dd22igalic struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
8559a67073808d84d85bb5dd552d4247caafe709sf for (c = 0; c < mis; c++) {
8559a67073808d84d85bb5dd552d4247caafe709sf name = talloc_asprintf(global_talloc_context, DOMNAME_TMPL, c);
8559a67073808d84d85bb5dd552d4247caafe709sf flat_name = talloc_asprintf(global_talloc_context, FLATNAME_TMPL, c);
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf sid = talloc_asprintf(global_talloc_context, SID_TMPL, c);
4bebf996eb7002ebfe897d46a0e0572390604a77nd dom = find_domain_by_name(test_ctx->dom_list, name, true);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe dom = find_domain_by_name(test_ctx->dom_list, name, false);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe dom = find_domain_by_name(test_ctx->dom_list, flat_name, true);
7159c12b7697fe9f5ab3a533cc6dfc3d57803053igalic dom = find_domain_by_name(test_ctx->dom_list, flat_name, false);
1d45c1463a8bc69bab1c07a4729269ec7333e713rbowen struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
af84459fbf938e508fd10b01cb8d699c79083813takashi struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe name = talloc_asprintf(global_talloc_context, DOMNAME_TMPL, c);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe flat_name = talloc_asprintf(global_talloc_context, FLATNAME_TMPL, c);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe sid = talloc_asprintf(global_talloc_context, SID_TMPL, c);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
c8c717fafa0a09ed13469a603a178921b851dd22igalic assert_true((mis >= 1 && mis < test_ctx->dom_count));
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe for (c = 0; c < mis; c++) {
af84459fbf938e508fd10b01cb8d699c79083813takashi name = talloc_asprintf(global_talloc_context, DOMNAME_TMPL, c);
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung flat_name = talloc_asprintf(global_talloc_context, FLATNAME_TMPL, c);
af84459fbf938e508fd10b01cb8d699c79083813takashi sid = talloc_asprintf(global_talloc_context, SID_TMPL, c);
struct dom_list_test_ctx);
size_t c;
char *name;
char *flat_name;
char *sid;
for (c = 0; c < mis; c++) {
struct dom_list_test_ctx);
struct dom_list_test_ctx);
struct dom_list_test_ctx);
struct dom_list_test_ctx);
struct dom_list_test_ctx);
gnd_flags = 0;
gnd_flags = 0;
struct name_init_test_ctx {
int ret;
int ret;
&names_ctx);
int ret;
const char *name;
const char *dom;
int ret;
const char *sid;
int ret;
char *sanitized;
char *lc_sanitized;
char *homedir;
struct sss_nss_homedir_ctx);
struct sss_nss_homedir_ctx);
char *homedir;
NULL };
struct sss_nss_homedir_ctx);
char **res;
int ret;
size_t c;
size_t d;
int ret;
char *cwd;
char *path;
char *file;
char *file_krb5_libdefaults;
#ifdef HAVE_KRB5_LOCALAUTH_PLUGIN
struct unique_file_test_ctx {
char *filename;
errno = 0;
fail();
int fd;
char *check_filename;
bool test_destructor)
int fd;
if (test_destructor) {
int fd;
bool test_destructor)
int fd;
char *tmp_filename;
if (test_destructor) {
int ret;
&cv_opts);
&cv_opts);
&cv_opts);
&cv_opts);
const char *exp_shortname,
const char *exp_domname)
if (exp_shortname) {
if (exp_domname) {
char *outname;
char *fqname;
int opt;
int rv;
switch(opt) {
if (rv == 0) {
return rv;