5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek/*
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek Authors:
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek Copyright (C) 2014 Red Hat
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek SSSD tests: User utilities
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek This program is free software; you can redistribute it and/or modify
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek it under the terms of the GNU General Public License as published by
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek the Free Software Foundation; either version 3 of the License, or
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek (at your option) any later version.
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek This program is distributed in the hope that it will be useful,
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek GNU General Public License for more details.
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek You should have received a copy of the GNU General Public License
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek*/
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek#include <sys/types.h>
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek#include <sys/stat.h>
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek#include <fcntl.h>
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek#include <talloc.h>
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek#include <popt.h>
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek#include "util/util.h"
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek#include "responder/common/responder.h"
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek#include "tests/cmocka/common_mock.h"
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek/* Just to satisfy dependencies */
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozekstruct cli_protocol_version *register_cli_protocol_version(void)
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek{
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek static struct cli_protocol_version responder_test_cli_protocol_version[] = {
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek {0, NULL, NULL}
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek };
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek return responder_test_cli_protocol_version;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek}
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozekvoid test_uid_csv_to_uid_list(void **state)
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek{
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek TALLOC_CTX *tmp_ctx;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek errno_t ret;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek size_t count;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek uid_t *list;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek tmp_ctx = talloc_new(global_talloc_context);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_non_null(tmp_ctx);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek check_leaks_push(tmp_ctx);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek ret = csv_string_to_uid_array(tmp_ctx, "1, 2, 3", false, &count, &list);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_int_equal(ret, EOK);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_int_equal(count, 3);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_int_equal(list[0], 1);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_int_equal(list[1], 2);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_int_equal(list[2], 3);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek talloc_free(list);
20a2be57d764f58c4a6532310331e26a3273ada8Lukas Slebodnik assert_true(check_leaks_pop(tmp_ctx));
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek talloc_free(tmp_ctx);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek}
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozekvoid test_name_csv_to_uid_list(void **state)
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek{
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek TALLOC_CTX *tmp_ctx;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek errno_t ret;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek size_t count;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek uid_t *list;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek tmp_ctx = talloc_new(global_talloc_context);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_non_null(tmp_ctx);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek check_leaks_push(tmp_ctx);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek ret = csv_string_to_uid_array(tmp_ctx, "sssd, foobar", true, &count, &list);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_int_equal(ret, EOK);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_int_equal(count, 2);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_int_equal(list[0], 123);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_int_equal(list[1], 10001);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek talloc_free(list);
20a2be57d764f58c4a6532310331e26a3273ada8Lukas Slebodnik assert_true(check_leaks_pop(tmp_ctx));
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek talloc_free(tmp_ctx);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek}
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozekvoid test_csv_to_uid_list_neg(void **state)
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek{
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek TALLOC_CTX *tmp_ctx;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek errno_t ret;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek size_t count;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek uid_t *list = NULL;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek tmp_ctx = talloc_new(global_talloc_context);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_non_null(tmp_ctx);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek check_leaks_push(tmp_ctx);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek ret = csv_string_to_uid_array(tmp_ctx, "nosuchuser", true, &count, &list);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek assert_int_not_equal(ret, EOK);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
20a2be57d764f58c4a6532310331e26a3273ada8Lukas Slebodnik assert_true(check_leaks_pop(tmp_ctx));
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek talloc_free(tmp_ctx);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek}
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozekstruct create_pipe_ctx {
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek int fd;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek const char *sock_name;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek};
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozekstatic int test_create_pipe_fd_setup(void **state)
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek{
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek struct create_pipe_ctx *ctx;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ctx = talloc(global_talloc_context, struct create_pipe_ctx);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_non_null(ctx);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ctx->fd = -1;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek *state = ctx;
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek return 0;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek}
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozekvoid check_sock_properties(struct create_pipe_ctx *ctx, mode_t mode)
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek{
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek int ret;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek int optval;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek socklen_t optlen;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek struct stat sbuf;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek /* Check existence of the file and the permissions */
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ret = stat(ctx->sock_name, &sbuf);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_equal(ret, 0);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_true(S_ISSOCK(sbuf.st_mode));
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_true((sbuf.st_mode & ~S_IFMT) == mode);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek /* Check it's a UNIX socket */
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek optlen = sizeof(optval);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ret = getsockopt(ctx->fd, SOL_SOCKET, SO_DOMAIN, &optval, &optlen);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_equal(ret, 0);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_equal(optval, AF_UNIX);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek optlen = sizeof(optval);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ret = getsockopt(ctx->fd, SOL_SOCKET, SO_TYPE, &optval, &optlen);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_equal(ret, 0);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_equal(optval, SOCK_STREAM);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek /* Make sure this is a listening socket */
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek optlen = sizeof(optval);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ret = getsockopt(ctx->fd, SOL_SOCKET, SO_ACCEPTCONN, &optval, &optlen);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_equal(ret, 0);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_equal(optval, 1);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek /* Check the right protocol */
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek optlen = sizeof(optval);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ret = getsockopt(ctx->fd, SOL_SOCKET, SO_PROTOCOL, &optval, &optlen);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_equal(ret, 0);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_equal(optval, 0);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek}
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozekvoid test_create_pipe_fd(void **state)
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek{
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek int ret;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek struct create_pipe_ctx *ctx;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ctx = talloc_get_type(*state, struct create_pipe_ctx);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ctx->sock_name = __FUNCTION__;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ret = create_pipe_fd(ctx->sock_name, &ctx->fd, 0111);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_equal(ret, EOK);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_not_equal(ctx->fd, -1);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek check_sock_properties(ctx, 0666);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek /* Make sure we can overwrite an existing socket */
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ret = create_pipe_fd(ctx->sock_name, &ctx->fd, 0000);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_equal(ret, EOK);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek assert_int_not_equal(ctx->fd, -1);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek check_sock_properties(ctx, 0777);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek}
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozekstatic int test_create_pipe_fd_teardown(void **state)
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek{
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek struct create_pipe_ctx *ctx;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek ctx = talloc_get_type(*state, struct create_pipe_ctx);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek if (ctx->fd != -1) {
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek unlink(ctx->sock_name);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek close(ctx->fd);
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek }
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek return 0;
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek}
4a5cced91df68a85ef0b30de8efe104c8a0aab7aJakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozekint main(int argc, const char *argv[])
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek{
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek poptContext pc;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek int opt;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek struct poptOption long_options[] = {
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek POPT_AUTOHELP
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek SSSD_DEBUG_OPTS
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek POPT_TABLEEND
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek };
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek const struct CMUnitTest tests[] = {
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test(test_uid_csv_to_uid_list),
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test(test_name_csv_to_uid_list),
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test(test_csv_to_uid_list_neg),
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_create_pipe_fd,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek test_create_pipe_fd_setup,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek test_create_pipe_fd_teardown)
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek };
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
49dd8ee2834d9477418961dbaffa4a03cfa9fd1eRené Genz /* Set debug level to invalid value so we can decide if -d 0 was used. */
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek debug_level = SSSDBG_INVALID;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek pc = poptGetContext(argv[0], argc, argv, long_options, 0);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek while((opt = poptGetNextOpt(pc)) != -1) {
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek switch(opt) {
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek default:
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek fprintf(stderr, "\nInvalid option %s: %s\n\n",
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek poptBadOption(pc, 0), poptStrerror(opt));
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek poptPrintUsage(pc, stderr, 0);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek return 1;
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek }
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek }
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek poptFreeContext(pc);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek DEBUG_CLI_INIT(debug_level);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek tests_set_cwd();
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek return cmocka_run_group_tests(tests, NULL, NULL);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek}