/*
SSSD
Authors:
Stephen Gallagher <sgallagh@redhat.com>
Copyright (C) 2010 Red Hat
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 <talloc.h>
#include <check.h>
#include <fcntl.h>
#include <stdlib.h>
#include <ctype.h>
#include "util/sss_utf8.h"
#include "util/murmurhash3.h"
#include "tests/common_check.h"
char *filename;
int atio_fd;
{
int ret;
"Wrong string added to newly created list.");
"Missing terminating NULL in newly created list.");
"Wrong string added to empty list.");
"Missing terminating NULL in newly created list.");
}
{
bool is_in;
discard_const("DEF"),
discard_const("GHI"),
NULL};
}
{
struct pa_testcase {
const char *argstr;
const char **parsed;
};
int i, ii;
int ret;
char **parsed;
char **only_ret;
char **only_exp;
char **both;
/* Positive tests */
{ "foo", parsed1 },
{ "foo a", parsed2 },
{ "foo b", parsed3 },
{ "foo a\\ c", parsed4 },
{ "foo a d ", parsed5 },
{ "foo a e ", parsed6 },
{ "foo\ta\t \tf \t", parsed7 },
{ "foo a\\\tg", parsed8 },
{ " foo ", parsed9 },
{ "\\ foo \\\t \\' ", parsed10 },
{ "a", parsed11 },
{ " ", NULL },
{ "", NULL },
{ " \t ", NULL },
};
"Could not parse correct %d argument string '%s'\n",
if (parsed) {
int parsed_len;
int expected_len;
"Test %d: length of 1st array [%d] != length of 2nd "
}
}
}
{
char **l1;
char **l2;
char **l3;
char **only_l1;
char **only_l2;
char **both;
int ret;
/* Test with all values returned */
/* Test with restricted return values */
/* Test with no overlap */
/* Test with 100% overlap */
/* Test with no second list */
}
{
"Expected [%s], got [%s]",
"Expected [%s], got [%s]",
"Expected [%s], got [%s]",
"Expected [%s], got [%s]",
"Expected [%s], got [%s]",
"Expected [%s], got [%s]",
/* Input is reused from previous test - "\\(user)*name" */
"Expected [%s], got [%s]",
}
{
int fd;
int flags;
fail_unless(fd > 0);
}
{
"overflow not detected");
"overflow not detected");
}
{
strlen((const char *)munchen_utf8_upcase),
&nlen);
fail_if(strlen((const char *) munchen_utf8_upcase) != nlen); /* This is not true for utf8 strings in general */
}
{
strlen((const char *) munchen_utf8_upcase),
&nsize);
}
{
char *lcase;
}
{
}
{
bool ret;
}
{
"abcdefghijk", "abcdefghili", "abcdefgh000" };
int i, j;
for (i = 0; i< 6; i++) {
0xdeadbeef);
for (j = 0; j < i; j++) {
}
}
}
{
unsigned int init_seed;
unsigned int seed;
int i;
/* generate a random string so each time we test with different values */
/* use also random length (min len = 1) */
for (i = 0; i < len; i++) {
}
}
void setup_atomicio(void)
{
int ret;
atio_fd = -1;
}
void teardown_atomicio(void)
{
int ret;
if (atio_fd != -1) {
}
}
{
int fd;
errno = 0;
}
{
errno = 0;
errno = 0;
}
{
errno = 0;
total = 0;
do {
errno = 0;
} while (numread != 0);
}
{
errno = 0;
errno = 0;
/* We've reached end-of-file, next read must return 0 */
errno = 0;
}
{
int fd;
errno = 0;
fail_unless(numread == 0,
"Read %d bytes expected 0\n", numread);
}
struct split_data {
const char *input;
const char **expected_list;
bool trim;
bool skip_empty;
int expected_size;
int expected_ret;
};
{
int size;
const char *str_ref;
const char *str_out;
int i;
int a;
int num_of_tests;
{
"one,two,three", /* input string */
false, false, /* trim, skip_empty */
3, 0 /* expec. size, expec. retval */
},
{
"one,two,three",
true, true,
3, 0
},
{
" one, two ,three ",
true, true,
3, 0
},
{
/* If skip empty is false, single comma means "empty,empty" */
",",
false, false,
2, 0
},
{
"one, ,",
(const char*[]){"one", " ", "NULL", "NULL"},
false, true,
2, 0
},
{
", ,,",
(const char*[]){NULL},
true, true,
0, 0
},
{
NULL,
NULL,
false, false,
0, EINVAL
},
};
for (a = 0; a < num_of_tests; a++) {
"split_on_separator failed [%d]: %s\n", ret,
if (ret) {
continue;
}
}
}
}
struct check_ip_test_data {
const char *str_ipaddr;
bool expected_ret;
};
{
int a;
int num_of_tests;
int ret;
bool bret;
{
"192.168.100.1", /* input IPv4 address */
0, /* flags value */
true /* Expected return value */
},
{
"224.0.0.22", /* multicast address */
false
},
{
"192.186.0.224",
true
},
{
"127.0.0.1",
false
},
{
"169.254.0.11",
false
},
{
"255.255.255.255",
false
},
{
"255.255.255.255",
false
},
{
"192.168.254.169",
true
},
};
for (a = 0; a < num_of_tests; a++) {
/* fill sockaddr_in structure */
"check_ipv4_addr failed (iteration %d)", a);
}
}
{
int a;
int num_of_tests;
int ret;
bool bret;
{
"fde9:7e3f:1ed3:24a5::4", /* input IPv6 address */
0, /* flags value */
true /* Expected return value */
},
{
"fe80::f2de:f1ff:fefa:67f0",
false
},
{
"::1",
false
},
{
"ff00::123",
false
},
{
"ff00::321",
false
},
};
for (a = 0; a < num_of_tests; a++) {
/* fill sockaddr_in structure */
"check_ipv6_addr failed (iteration %d)", a);
}
}
{
struct {
const char *host;
const char *domain;
bool expected;
{"client.example.com", "example.com", true},
{"client.child.example.com", "example.com", true},
{"example.com", "child.example.com", false},
{"client.example.com", "child.example.com", false},
{"client.child.example.com", "child.example.com", true},
{"myexample.com", "example.com", false},
bool ret;
int i;
}
}
{
const char * const * svcs;
bool found_nss = false;
int i;
/* Just make sure we can't find a bogus service and nss
* is always available
*/
svcs = get_known_services();
for (i = 0; svcs[i]; i++) {
found_nss = true;
}
}
}
{
orig_tz = "";
}
if (tz) {
}
/* restore */
}
}
{
/* test that results are still same no matter what timezone is set */
convert_time_tz("GST-1");
convert_time_tz("GST-2");
}
{
}
{
const char *error;
char last_character;
"Error string [%s] must finish with alphabetic character\n",
error);
}
}
{
suite_add_tcase (s, tc_util);
suite_add_tcase (s, tc_utf8);
suite_add_tcase (s, tc_mh3);
suite_add_tcase (s, tc_atomicio);
return s;
}
{
int opt;
int failure_count;
Suite *s = util_suite();
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
srunner_free (sr);
if (failure_count == 0) {
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}