/*
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2014 Red Hat
SSSD tests: Data Provider Option Tests
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <popt.h>
#include "providers/data_provider.h"
#include "tests/cmocka/common_mock.h"
enum test_opts {
};
{ "blob_default", DP_OPT_BLOB,
sizeof(BLOB_DEFAULT) - 1 } },
NULL_BLOB },
};
{
char *s;
struct dp_opt_blob b;
int i;
bool bo;
assert_null(s);
assert_non_null(s);
assert_null(b.data);
assert_int_equal(b.length, 0);
assert_non_null(b.data);
assert_int_equal(i, 0);
assert_true(bo == true);
assert_true(bo == false);
}
{
int ret;
struct dp_opt_blob b;
/* Test that copy_defaults would still copy defaults even if we
* change the values
*/
}
{
int ret;
char *s;
struct dp_opt_blob b;
int i;
bool bo;
/* Test that options set to an explicit value retain
* the value and even options with default value
* do not return the default unless explicitly set
*/
assert_string_equal(s, "str1");
assert_null(s);
assert_non_null(b.data);
assert_null(b.data);
assert_int_equal(b.length, 0);
assert_int_equal(i, 456);
assert_int_equal(i, 0);
assert_false(bo == true);
}
{
int ret;
{ "string_nodefault", "stringval2" },
{ "blob_nodefault", "blobval2" },
{ "int_nodefault", "456" },
{ "bool_true", "false" },
};
char *s;
struct dp_opt_blob b;
int i;
bool bo;
/* Options that were not specified explicitly should only have the default
* value, those that have been specified explicitly should carry that
* value
*/
assert_non_null(s);
assert_string_equal(s, "stringval2");
assert_non_null(s);
assert_non_null(b.data);
assert_non_null(b.data);
assert_int_equal(i, 456);
assert_true(bo == false);
assert_true(bo == false);
}
{
int ret;
return 0;
}
{
return 0;
}
{
char *s;
assert_null(s);
}
{
int ret;
}
{
char *s;
assert_non_null(s);
assert_string_equal(s, "str1");
}
{
}
{
struct dp_opt_blob b;
assert_null(b.data);
assert_int_equal(b.length, 0);
}
{
struct dp_opt_blob b;
int ret;
}
{
struct dp_opt_blob b;
assert_non_null(b.data);
}
{
}
{
int i;
assert_int_equal(i, 0);
}
{
int ret;
}
{
int i;
assert_int_equal(i, 456);
}
{
}
{
int ret;
bool b;
assert_true(b == true);
assert_false(b == true);
}
{
int ret;
const char *s;
"blob_nodefault",
"int_nodefault",
"bool_true",
NULL };
assert_null(s);
/* string */
/* blob */
/* number */
/* bool */
}
{
int no_cleanup = 0;
int opt;
int ret;
_("Do not delete the test database after a test run"), NULL },
};
};
/* Set debug level to invalid value so we can decide if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
/* Even though normally the tests should clean up after themselves
* they might not after a failed run. Remove the old DB to be sure */
if (ret == 0 && !no_cleanup) {
}
return ret;
}