2008-04-07 19:16:41 +04:00
|
|
|
#define _GNU_SOURCE /* asprintf */
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "support.h"
|
|
|
|
|
|
|
|
#include "vio/csync_vio_handle.h"
|
|
|
|
#include "vio/csync_vio_handle_private.h"
|
|
|
|
|
|
|
|
START_TEST (check_csync_vio_handle_new)
|
|
|
|
{
|
|
|
|
int *number = NULL;
|
|
|
|
csync_vio_handle_t *handle = NULL;
|
|
|
|
|
|
|
|
number = c_malloc(sizeof(int));
|
|
|
|
*number = 42;
|
|
|
|
|
2008-04-22 12:46:52 +04:00
|
|
|
handle = csync_vio_handle_new("/tmp", (csync_vio_method_handle_t *) number);
|
2008-04-07 19:16:41 +04:00
|
|
|
fail_if(handle == NULL, NULL);
|
|
|
|
fail_unless(strcmp(handle->uri, "/tmp") == 0, NULL);
|
|
|
|
|
|
|
|
SAFE_FREE(handle->method_handle);
|
|
|
|
|
|
|
|
csync_vio_handle_destroy(handle);
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST (check_csync_vio_handle_new_null)
|
|
|
|
{
|
|
|
|
int *number = NULL;
|
|
|
|
csync_vio_handle_t *handle = NULL;
|
|
|
|
|
|
|
|
number = c_malloc(sizeof(int));
|
|
|
|
*number = 42;
|
|
|
|
|
|
|
|
handle = csync_vio_handle_new(NULL, (csync_vio_method_handle_t *) number);
|
|
|
|
fail_unless(handle == NULL, NULL);
|
|
|
|
|
2008-04-10 17:46:01 +04:00
|
|
|
handle = csync_vio_handle_new((char *) "/tmp", NULL);
|
2008-04-07 19:16:41 +04:00
|
|
|
fail_unless(handle == NULL, NULL);
|
|
|
|
|
|
|
|
SAFE_FREE(number);
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
2008-05-07 13:09:56 +04:00
|
|
|
static Suite *make_csync_vio_suite(void) {
|
2008-04-07 19:16:41 +04:00
|
|
|
Suite *s = suite_create("csync_vio_handle");
|
|
|
|
|
|
|
|
create_case(s, "check_csync_vio_handle_new", check_csync_vio_handle_new);
|
|
|
|
create_case(s, "check_csync_vio_handle_new_null", check_csync_vio_handle_new_null);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2008-05-07 13:09:56 +04:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
Suite *s = NULL;
|
|
|
|
SRunner *sr = NULL;
|
|
|
|
struct argument_s arguments;
|
2008-04-07 19:16:41 +04:00
|
|
|
int nf;
|
|
|
|
|
2008-05-07 13:09:56 +04:00
|
|
|
ZERO_STRUCT(arguments);
|
|
|
|
|
|
|
|
cmdline_parse(argc, argv, &arguments);
|
|
|
|
|
|
|
|
s = make_csync_vio_suite();
|
2008-04-07 19:16:41 +04:00
|
|
|
|
|
|
|
sr = srunner_create(s);
|
2008-05-07 13:09:56 +04:00
|
|
|
if (arguments.nofork) {
|
|
|
|
srunner_set_fork_status(sr, CK_NOFORK);
|
|
|
|
}
|
2008-04-07 19:16:41 +04:00
|
|
|
srunner_run_all(sr, CK_VERBOSE);
|
|
|
|
nf = srunner_ntests_failed(sr);
|
|
|
|
srunner_free(sr);
|
|
|
|
|
|
|
|
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|