test_server.c revision 2689efa614826d45cab60ea1186d44b8bdd243ad
/*
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2014 Red Hat
SSSD tests: Server instantiation
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 <fcntl.h>
#include <popt.h>
#include "tests/cmocka/common_mock.h"
{
int status;
}
static void wait_for_bg_server(const char *pidfile)
{
int fd;
long tmp;
char buf[16];
int ret;
int count;
count = 0;
do {
count++;
if (count > 100) {
break;
}
usleep(50);
} while (ret != 0);
/* read the pidfile */
assert_false(fd < 0);
assert_false(ret <= 0);
/* Make sure the daemon goes away! */
assert_true(ret == 0);
}
void test_run_as_root_fg(void **state)
{
int ret;
struct main_context *main_ctx;
/* Must root as root, real or fake */
assert_int_equal(geteuid(), 0);
if (pid == 0) {
__FUNCTION__, &main_ctx);
assert_int_equal(ret, 0);
exit(0);
}
}
void test_run_as_sssd_fg(void **state)
{
int ret;
struct main_context *main_ctx;
/* Must root as root, real or fake */
assert_int_equal(geteuid(), 0);
if (pid == 0) {
__FUNCTION__, &main_ctx);
assert_int_equal(ret, 0);
exit(0);
}
}
void test_run_as_root_daemon(void **state)
{
int ret;
struct main_context *main_ctx;
char *pidfile;
/* Must root as root, real or fake */
assert_int_equal(geteuid(), 0);
/* Make sure there are no leftovers */
if (pid == 0) {
0, 0, __FUNCTION__, &main_ctx);
assert_int_equal(ret, 0);
exit(0);
}
}
{
int opt;
int rv;
struct poptOption long_options[] = {
};
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
/* Even though normally the tests should clean up after themselves
* they might not after a failed run. Remove the old db to be sure */
return rv;
}