/*
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_INTROSPECT \
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\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=\"org.freedesktop.DBus.Properties\">\n" \
" <method name=\"Get\">\n" \
" <arg type=\"s\" name=\"interface_name\" direction=\"in\" />\n" \
" <arg type=\"s\" name=\"property_name\" direction=\"in\" />\n" \
" <arg type=\"v\" name=\"value\" direction=\"out\" />\n" \
" </method>\n" \
" <method name=\"Set\">\n" \
" <arg type=\"s\" name=\"interface_name\" direction=\"in\" />\n" \
" <arg type=\"s\" name=\"property_name\" direction=\"in\" />\n" \
" <arg type=\"v\" name=\"value\" direction=\"in\" />\n" \
" </method>\n" \
" <method name=\"GetAll\">\n" \
" <arg type=\"s\" name=\"interface_name\" direction=\"in\" />\n" \
" <arg type=\"a{sv}\" name=\"props\" direction=\"out\" />\n" \
" </method>\n" \
" </interface>\n" \
" <interface name=\"test.Pilot\">\n" \
" <method name=\"Blink\" />\n" \
" <method name=\"Eat\" />\n" \
" <method name=\"Crash\" />\n" \
" </interface>\n" \
"</node>\n"
/* our vtable */
struct pilot_vtable {
};
{
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 */
},
{
PILOT_CRASH, /* method name */
NULL, /* in args: manually parsed */
NULL, /* out args: manually parsed */
},
{ NULL, }
};
PILOT_IFACE, /* name */
NULL, /* no signals */
NULL, /* no properties */
NULL, /* no GetAll invoker */
};
{
} 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 */
}
}
{
/* Pilot crashes by returning a malformed UTF-8 string */
return sbus_request_return_and_finish(req,
}
{ &pilot_meta, 0 },
.Blink = blink_handler,
.Eat = eat_handler,
.Crash = crash_handler,
};
{
int ret;
discard_const("Crash into the billboard"));
discard_const("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 */
}
{
#ifdef HAVE_DBUSBASICVALUE
&error,
DBUS_TYPE_INVALID); /* bad agruments */
#endif /* HAVE_DBUSBASICVALUE */
}
{
char *xml;
&error,
DBUS_TYPE_INVALID); /* bad agruments */
}
{
"The answer should have been %d", 42);
/* NULL message must also work */
}
{
return tc;
}
{
suite_add_tcase(s, create_sbus_tests());
return s;
}
{
int opt;
int failure_count;
};
switch (opt) {
default:
return 1;
}
}
suite = create_suite();
/* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
}