sbus_tests.c revision 80d0bd38268c02fd32f62b02ae59f19229ca1a79
/*
SSSD
sbus_codegen tests.
Authors:
Stef Walter <stefw@redhat.com>
Copyright (C) Red Hat, Inc 2014
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 <stdlib.h>
#include <check.h>
#include <talloc.h>
#include <tevent.h>
#include <popt.h>
#include "common.h"
#include "sbus/sssd_dbus.h"
#include "sbus/sssd_dbus_meta.h"
#include "util/util_errors.h"
/*
* Although one would normally rely on the codegen to generate these
* structures, we want to test this functionality *before* we test
* the codegen in sbus_codegen_tests ... so these are hand rolled.
*/
#define PILOT_IFACE "test.Pilot"
#define PILOT_BLINK "Blink"
#define PILOT_EAT "Eat"
#define PILOT_IFACE_INTROSPECT \
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" \
"<node>\n" \
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n" \
" <method name=\"Introspect\">\n" \
" <arg type=\"s\" name=\"data\" direction=\"out\" />\n" \
" </method>\n" \
" </interface>\n" \
" <interface name=\"test.Pilot\">\n" \
" <method name=\"Blink\" />\n" \
" <method name=\"Eat\" />\n" \
" </interface>\n" \
"</node>\n"
/* our vtable */
struct pilot_vtable {
struct sbus_vtable vtable;
};
const struct sbus_method_meta pilot_methods[] = {
{
PILOT_BLINK, /* method name */
NULL, /* in args: manually parsed */
NULL, /* out args: manually parsed */
},
{
PILOT_EAT, /* method name */
NULL, /* in args: manually parsed */
NULL, /* out args: manually parsed */
},
{ NULL, }
};
const struct sbus_interface_meta pilot_meta = {
PILOT_IFACE, /* name */
NULL, /* no signals */
NULL, /* no properties */
NULL, /* no GetAll invoker */
};
{
dbus_int32_t duration = 0;
} else {
ck_abort();
}
return EOK;
}
/* Pilot crashes when eyes closed too long */
return sbus_request_return_and_finish(req,
}
{
const char **array;
int count;
if (!sbus_request_parse_or_finish (req,
return EOK; /* handled */
}
}
struct pilot_vtable pilot_impl = {
{ &pilot_meta, 0 },
.Blink = blink_handler,
.Eat = eat_handler,
};
{
int ret;
"Crash into the billboard");
"Don't crash");
return EOK;
}
{
/* Leela crashes with a duration higher than 5 */
duration = 10;
&error,
/* Fry daesn't crash with a duration lower than 5 */
duration = 1;
&error,
}
{
const char **array;
int count;
integer = 5;
count = 3;
&error,
}
{
&error,
DBUS_TYPE_INVALID); /* bad agruments */
}
{
char *xml;
&error,
DBUS_TYPE_INVALID); /* bad agruments */
}
{
"The answer should have been %d", 42);
/* NULL message must also work */
}
TCase *create_sbus_tests(void)
{
return tc;
}
Suite *create_suite(void)
{
suite_add_tcase(s, create_sbus_tests());
return s;
}
{
int opt;
int failure_count;
struct poptOption long_options[] = {
};
switch (opt) {
default:
return 1;
}
}
suite = create_suite();
/* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
}