test_child_common.c revision 9dcc7dbf04466cd8cd90aa0bb8acbebef9aca832
/*
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2014 Red Hat
SSSD tests: Child handlers
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 <talloc.h>
#include <tevent.h>
#include <errno.h>
#include <popt.h>
#include "util/child_common.h"
#include "tests/cmocka/common_mock.h"
#define TEST_BIN "dummy-child"
#define ECHO_STR "Hello child"
static int destructor_called;
struct child_test_ctx {
int pipefd_to_child[2];
int pipefd_from_child[2];
struct sss_test_ctx *test_ctx;
};
static int child_test_setup(void **state)
{
struct child_test_ctx *child_tctx;
*state = child_tctx;
return 0;
}
static int child_test_teardown(void **state)
{
struct child_test_ctx);
return 0;
}
/* Just make sure the exec works. The child does nothing but exits */
void test_exec_child(void **state)
{
int status;
struct child_test_ctx);
if (child_pid == 0) {
} else {
do {
errno = 0;
if (ret > 0) {
assert_int_equal(ret, 0);
}
} else {
"Failed to wait for children %d\n", child_pid);
}
}
}
/* Make sure extra arguments are passed correctly */
void test_exec_child_extra_args(void **state)
{
int status;
struct child_test_ctx);
const char *extra_args[] = { "--guitar=george",
"--drums=ringo",
NULL };
if (child_pid == 0) {
} else {
do {
errno = 0;
if (ret > 0) {
assert_int_equal(ret, 0);
}
} else {
"Failed to wait for children %d\n", child_pid);
}
}
}
struct child_test_ctx *child_tctx,
struct child_io_fds *io_fds,
const char *input);
int __real_child_io_destructor(void *ptr);
int __wrap_child_io_destructor(void *ptr)
{
destructor_called = 1;
return __real_child_io_destructor(ptr);
}
/* Test that writing to the pipes works as expected */
void test_exec_child_io_destruct(void **state)
{
struct child_test_ctx);
struct child_io_fds *io_fds;
destructor_called = 0;
errno = 0;
errno = 0;
assert_int_equal(errno, 0);
errno = 0;
assert_int_equal(errno, 0);
errno = 0;
}
void test_child_cb(int child_status,
struct tevent_signal *sige,
void *pvt);
/* Test that writing to the pipes works as expected */
void test_exec_child_handler(void **state)
{
struct child_test_ctx);
struct sss_child_ctx_old *child_old_ctx;
assert_int_equal(ret, 0);
if (child_pid == 0) {
}
}
void test_child_cb(int child_status,
struct tevent_signal *sige,
void *pvt)
{
}
}
/* Test that writing to the pipes works as expected */
void test_exec_child_echo(void **state)
{
struct child_test_ctx);
struct tevent_req *req;
struct child_io_fds *io_fds;
if (child_pid == 0) {
STDIN_FILENO, 3);
}
}
struct test_exec_echo_state {
struct child_io_fds *io_fds;
struct child_test_ctx *child_test_ctx;
};
struct child_test_ctx *child_tctx,
struct child_io_fds *io_fds,
const char *input)
{
struct tevent_req *req;
struct tevent_req *subreq;
struct test_exec_echo_state *echo_state;
return req;
}
{
struct tevent_req *req;
struct test_exec_echo_state *echo_state;
}
{
struct tevent_req *req;
struct test_exec_echo_state *echo_state;
}
/* Just make sure the exec works. The child does nothing but exits */
void test_sss_child(void **state)
{
struct child_test_ctx);
struct sss_sigchild_ctx *sc_ctx;
struct sss_child_ctx *sss_child;
assert_int_equal(ret, 0);
if (child_pid == 0) {
}
child_tctx, &sss_child);
}
{
}
}
{
int rv;
int opt;
struct poptOption long_options[] = {
};
const struct CMUnitTest tests[] = {
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
return rv;
}