sbus_codegen_tests.c revision c3c6eb141d6a288b3da20ad6a2e5718844b2d4ad
/*
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 "sbus/sssd_dbus_meta.h"
#include "tests/sbus_codegen_tests_generated.h"
#include "util/util_errors.h"
#define N_ELEMENTS(arr) \
/* The following 2 macros were taken from check's project source files (0.9.10)
*/
#ifndef _ck_assert_uint
#define _ck_assert_uint(X, OP, Y) do { \
ck_assert_msg(_ck_x OP _ck_y, "Assertion '"#X#OP#Y"' failed: "#X"==%ju, "#Y"==%ju", _ck_x, _ck_y); \
} while (0)
#endif /* _ck_assert_uint */
#ifndef ck_assert_uint_eq
#define ck_assert_uint_eq(X, Y) _ck_assert_uint(X, ==, Y)
#endif /* ck_assert_uint_eq */
static const struct sbus_arg_meta *
const char *name)
{
const struct sbus_arg_meta *arg;
return arg;
}
return NULL;
}
{
/* Explicit C Symbol */
}
{
const struct sbus_method_meta *method;
const struct sbus_arg_meta *arg;
}
{
const struct sbus_property_meta *prop;
}
{
const struct sbus_signal_meta *signal;
const struct sbus_arg_meta *arg;
}
static int
{
/*
* The above arguments should match the handler signature,
* and the below finish function should have the right signature.
*
* Not called, just testing compilation
*/
}
static int
const char *where)
{
/*
* One argument, no return value, yet a finish function should
* have been generated.
*
* Not called, just testing compilation
*/
}
static int
{
/*
* Raw handler, no finish function, no special arguments.
*
* Not called, just testing compilation
*/
return 0;
}
{
struct com_planetexpress_Ship vtable = {
{ &com_planetexpress_Ship_meta, 0 },
NULL,
};
/*
* These are not silly tests:
* - Will fail compilation if c-symbol name was not respected
* - Will fail if method order was not respected
*/
}
{
/* constants for com.planetexpress.Pilot */
}
TCase *create_defs_tests(void)
{
/* Do some testing */
return tc;
}
/* This is a handler which has all the basic arguments types */
double arg_double_array[], int len_double_array,
const char *arg_string_array[], int len_string_array,
const char *arg_object_path_array[], int len_object_path_array)
{
int i;
/* Only called for leela, so double check here */
/* Murge the various values for test case */
arg_byte++;
arg_int16++;
arg_uint16++;
arg_int32++;
arg_uint32++;
arg_int64++;
arg_uint64++;
arg_double++;
arg_string = "bears, beets, battlestar galactica";
arg_object_path = "/another/object/path";
for (i = 0; i < len_byte_array; i++)
arg_byte_array[i]++;
for (i = 0; i < len_int16_array; i++)
arg_int16_array[i]++;
for (i = 0; i < len_uint16_array; i++)
arg_uint16_array[i]++;
for (i = 0; i < len_int32_array; i++)
arg_int32_array[i]++;
for (i = 0; i < len_uint32_array; i++)
arg_uint32_array[i]++;
for (i = 0; i < len_int64_array; i++)
arg_int64_array[i]++;
for (i = 0; i < len_uint64_array; i++)
arg_uint64_array[i]++;
for (i = 0; i < len_double_array; i++)
arg_double_array[i]++;
for (i = 0; i < len_double_array; i++) {
arg_string_array[i] = "beets";
}
arg_object_path_array = talloc_memdup(req, arg_object_path_array, sizeof(char *) * len_object_path_array);
for (i = 0; i < len_object_path_array; i++) {
arg_object_path_array[i] = "/changed";
}
/* And reply with those values */
}
} while(0);
static const bool pilot_bool = true;
void *instance_data,
bool *val)
{
}
static const char *pilot_full_name = "Turanga Leela";
void *instance_data,
const char **name)
{
}
void *instance_data,
{
}
void *instance_data,
{
}
void *instance_data,
{
}
void *instance_data,
{
}
void *instance_data,
{
}
void *instance_data,
{
}
void *instance_data,
{
}
static const double pilot_double = 3.14;
void *instance_data,
double *double_val)
{
}
static const char *pilot_string = "leela";
void *instance_data,
const char **string_val)
{
}
static const char *pilot_path = "/path/leela";
void *instance_data,
const char **path_val)
{
*path_val = pilot_path;
}
void *instance_data,
const char **string_val)
{
*string_val = NULL;
}
void *instance_data,
const char **path_val)
{
}
} while(0);
void *instance_data,
{
}
void *instance_data,
{
}
void *instance_data,
{
}
void *instance_data,
{
}
void *instance_data,
{
}
void *instance_data,
{
}
void *instance_data,
{
}
static double pilot_double_array[] = { 3.14, 0 };
void *instance_data,
{
}
void *data,
const char ***arr_out,
int *arr_len)
{
}
void *data,
const char ***arr_out,
int *arr_len)
{
}
struct test_pilot pilot_iface = {
{ &test_pilot_meta, 0 },
.Eject = eject_handler,
};
{
int ret;
"Crash into the billboard"));
return EOK;
}
{
unsigned char arg_byte = 11;
double arg_double = 1.1;
const char *arg_string = "hello";
const char *arg_object_path = "/original/object/path";
double *arr_double = v_double;
char **arr_string = v_string;
char **arr_object_path = v_object_path;
&error,
ck_assert_int_eq(arr_int32[0], 0);
}
{
}
const char *object_path,
const char *iface,
const char *prop,
int type,
void *val)
{
"Get",
&error,
}
{
const char *string_val;
const char *path_val;
double double_val;
/* If a string getter returns NULL, the caller should receive "" */
/* If a string getter returns NULL, the caller should receive "/" */
}
{
int n = 0, i = 0;;
const char **strings;
const char *s;
do {
n++;
} while (dbus_message_iter_next(&arriter));
/* Allocating on NULL is bad, but this is unit test */
do {
i++;
} while (dbus_message_iter_next(&arriter));
*nels = n;
} else {
/* Fixed types are easy */
}
}
const char *object_path,
const char *iface,
const char *prop,
int type,
void **values,
int *nels)
{
"Get",
&error,
}
} while(0); \
{
const char **string_arr_val;
int string_arr_len;
const char **path_arr_val;
int path_arr_len;
int byte_arr_len;
int int16_arr_len;
int uint16_arr_len;
int int32_arr_len;
int uint32_arr_len;
int int64_arr_len;
int uint64_arr_len;
double *double_arr_val;
int double_arr_len;
}
TCase *create_handler_tests(void)
{
return tc;
}
Suite *create_suite(void)
{
suite_add_tcase(s, create_defs_tests ());
suite_add_tcase(s, create_handler_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 */
}