test_utils.c revision 393306307bd908fcec8858f665226ac56238a21b
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder Sumit Bose <sbose@redhat.com>
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder Copyright (C) 2013 Red Hat
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder SSSD tests: Tests for utility functions
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder This program is free software; you can redistribute it and/or modify
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder it under the terms of the GNU General Public License as published by
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder the Free Software Foundation; either version 3 of the License, or
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder (at your option) any later version.
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder This program is distributed in the hope that it will be useful,
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder GNU General Public License for more details.
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder You should have received a copy of the GNU General Public License
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder test_ctx = talloc_zero(global_talloc_context, struct dom_list_test_ctx);
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder for (c = 0; c < test_ctx->dom_count; c++) {
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder dom = talloc_zero(test_ctx, struct sss_domain_info);
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder dom->name = talloc_asprintf(dom, DOMNAME_TMPL, c);
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder dom->flat_name = talloc_asprintf(dom, FLATNAME_TMPL, c);
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder dom->domain_id = talloc_asprintf(dom, SID_TMPL, c);
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder DEBUG(SSSDBG_CRIT_FAILURE, "Type mismatch\n");
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder assert_true(check_leaks_pop(test_ctx) == true);
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maedervoid test_find_domain_by_name_null(void **state)
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder dom = find_domain_by_name(NULL, NULL, false);
7710f7c3425e45af11af124ff37bec27229d24f7Christian Maeder dom = find_domain_by_name(test_ctx->dom_list, NULL, false);
b579e1a98aa30fb6093cbbdfeae51edbd5ba26adChristian Maeder dom = find_domain_by_name(NULL, "test", false);
7710f7c3425e45af11af124ff37bec27229d24f7Christian Maeder struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
b579e1a98aa30fb6093cbbdfeae51edbd5ba26adChristian Maeder for (c = 0; c < test_ctx->dom_count; c++) {
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder name = talloc_asprintf(global_talloc_context, DOMNAME_TMPL, c);
b579e1a98aa30fb6093cbbdfeae51edbd5ba26adChristian Maeder flat_name = talloc_asprintf(global_talloc_context, FLATNAME_TMPL, c);
d97700a22b2585ece83b05f3fff945fdfd0c44b4Christian Maeder sid = talloc_asprintf(global_talloc_context, SID_TMPL, c);
d97700a22b2585ece83b05f3fff945fdfd0c44b4Christian Maeder dom = find_domain_by_name(test_ctx->dom_list, name, false);
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder assert_string_equal(flat_name, dom->flat_name);
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder dom = find_domain_by_name(test_ctx->dom_list, name, true);
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);
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);
size_t c;
char *name;
char *flat_name;
char *sid;
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);
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;
#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;