diff options
author | Amitay Isaacs <amitay@gmail.com> | 2018-07-18 19:00:42 +1000 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2018-07-28 03:50:11 +0200 |
commit | 3bf753e830c20183ef4f3278880d3be362e53bef (patch) | |
tree | ecc4d85d0ebe07d42fabb1ffb891d217986ef8c6 /ctdb/tests/src | |
parent | c9b42d27e6cf9e6ae36f44970f0a388edc737a7a (diff) | |
download | samba-3bf753e830c20183ef4f3278880d3be362e53bef.tar.gz |
ctdb-common: Add fd argument to ctdb_connection_list_read()
This makes testing easier.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/tests/src')
-rw-r--r-- | ctdb/tests/src/protocol_util_test.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/ctdb/tests/src/protocol_util_test.c b/ctdb/tests/src/protocol_util_test.c index 9b4729ec5ee..178ce1d6429 100644 --- a/ctdb/tests/src/protocol_util_test.c +++ b/ctdb/tests/src/protocol_util_test.c @@ -183,7 +183,7 @@ static void test_connection_list_read(const char *s1, const char *s2) TALLOC_CTX *tmp_ctx; int pipefd[2]; pid_t pid; - struct ctdb_connection_list *conn_list; + struct ctdb_connection_list *conn_list = NULL; const char *t; int ret; @@ -212,14 +212,11 @@ static void test_connection_list_read(const char *s1, const char *s2) close(pipefd[1]); - ret = dup2(pipefd[0], STDIN_FILENO); - assert(ret != -1); + ret = ctdb_connection_list_read(tmp_ctx, pipefd[0], false, &conn_list); + assert(ret == 0); close(pipefd[0]); - ret = ctdb_connection_list_read(tmp_ctx, false, &conn_list); - assert(ret == 0); - ret = ctdb_connection_list_sort(conn_list); assert(ret == 0); @@ -236,7 +233,7 @@ static void test_connection_list_read_bad(const char *s1) TALLOC_CTX *tmp_ctx; int pipefd[2]; pid_t pid; - struct ctdb_connection_list *conn_list; + struct ctdb_connection_list *conn_list = NULL; int ret; tmp_ctx = talloc_new(NULL); @@ -264,14 +261,11 @@ static void test_connection_list_read_bad(const char *s1) close(pipefd[1]); - ret = dup2(pipefd[0], STDIN_FILENO); - assert(ret != -1); + ret = ctdb_connection_list_read(tmp_ctx, pipefd[0], false, &conn_list); + assert(ret == EINVAL); close(pipefd[0]); - ret = ctdb_connection_list_read(tmp_ctx, false, &conn_list); - assert(ret == EINVAL); - talloc_free(tmp_ctx); } |