test_child_common.c revision b4f87b42b18888c396e44e7359f7aafb092221bf
/*
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 "test-child"
#define ECHO_STR "Hello child"
struct child_test_ctx {
int pipefd_to_child[2];
int pipefd_from_child[2];
struct sss_test_ctx *test_ctx;
};
void child_test_setup(void **state)
{
struct child_test_ctx *child_tctx;
*state = child_tctx;
}
void child_test_teardown(void **state)
{
struct child_test_ctx);
}
/* 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);
}
}
}
/* Just make sure the exec works. The child does nothing but exits */
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);
}
}
}
{
int rv;
int opt;
struct poptOption long_options[] = {
};
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
return rv;
}