sbus_tests.c revision f5e47e1d65f80ffdb1893feab18583a74d661214
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly sbus_codegen tests.
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly Stef Walter <stefw@redhat.com>
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly Copyright (C) Red Hat, Inc 2014
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly This program is free software; you can redistribute it and/or modify
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly it under the terms of the GNU General Public License as published by
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly the Free Software Foundation; either version 3 of the License, or
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly (at your option) any later version.
9aeda2b3ae8ce0b018955521e4ca835a8ba8a27bLiam O'Reilly This program is distributed in the hope that it will be useful,
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
66bc8d6e69cde43f1ccbeb76104cf7b8038acd6cChristian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66bc8d6e69cde43f1ccbeb76104cf7b8038acd6cChristian Maeder GNU General Public License for more details.
d5833d2ee7bafcbf2fdd2bdfd9a728c769b100c7Christian Maeder You should have received a copy of the GNU General Public License
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly along with this program. If not, see <http://www.gnu.org/licenses/>.
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly * Although one would normally rely on the codegen to generate these
7830e8fa7442fb7452af7ecdba102bc297ae367eChristian Maeder * structures, we want to test this functionality *before* we test
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly * the codegen in sbus_codegen_tests ... so these are hand rolled.
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly/* our vtable */
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reillyconst struct sbus_method_meta pilot_methods[] = {
648fe1220044aac847acbdfbc4155af5556063ebChristian Maederconst struct sbus_interface_meta pilot_meta = {
d5833d2ee7bafcbf2fdd2bdfd9a728c769b100c7Christian Maederstatic int blink_handler(struct sbus_request *req, void *data)
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder ck_assert(req->intf->vtable->meta == &pilot_meta);
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder ck_assert(data == req->intf->instance_data);
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder } else if (strcmp(path, "/test/leela") == 0) {
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder ck_assert_str_eq(data, "Crash into the billboard");
fa373bc327620e08861294716b4454be8d25669fChristian Maeder if (!dbus_message_get_args (req->message, &error,
9aeda2b3ae8ce0b018955521e4ca835a8ba8a27bLiam O'Reilly /* Pilot crashes when eyes closed too long */
648fe1220044aac847acbdfbc4155af5556063ebChristian Maederstatic int pilot_test_server_init(struct sbus_connection *server, void *unused)
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder "Crash into the billboard"));
eb48217dfa67ddb87b8fbd846de293d0636bd578Christian Maeder "Don't crash"));
ebd23ec61635b0bebf7969d14f65b9d1e39f2b26Liam O'Reilly client = test_dbus_setup_mock(ctx, NULL, pilot_test_server_init, NULL);
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder /* Leela crashes with a duration higher than 5 */
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maeder ck_assert(dbus_message_get_args(reply, NULL,
2a5b885d9350ec6dd8bc4992ee91d2f68aa592f4Christian Maeder /* Fry daesn't crash with a duration lower than 5 */
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder ck_assert(dbus_message_get_args(reply, NULL,
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder suite_add_tcase(s, create_sbus_tests());
580f1724640a78be687e79d0ec95dd2665e77e91Liam O'Reilly pc = poptGetContext(argv[0], argc, argv, long_options, 0);
b1f12c962a6fb28a298b36cf6a1dcf2ad788fb58Christian Maeder fprintf(stderr, "\nInvalid option %s: %s\n\n",
f19dc06364e8d6ea36f7c170e1f7a0677de63184Liam O'Reilly /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */