aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/lib582.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-04-03 11:57:34 +0200
committerDaniel Stenberg <daniel@haxx.se>2016-04-03 11:57:34 +0200
commit365322b8bcf9efb6a361473d227b70f2032212ce (patch)
tree1c6aa49fce74e802ac29e33098abf4c81ed4836b /tests/libtest/lib582.c
parentc7e4266a2e52d0dd0ad446044174c60ebfe10f73 (diff)
tests/libtest: follow our code style guidelines better
... checksrc of all test code is pending.
Diffstat (limited to 'tests/libtest/lib582.c')
-rw-r--r--tests/libtest/lib582.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c
index 738aa63c2..444b416ff 100644
--- a/tests/libtest/lib582.c
+++ b/tests/libtest/lib582.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -51,9 +51,9 @@ static void removeFd(struct Sockets* sockets, curl_socket_t fd, int mention)
if(mention)
fprintf(stderr, "Remove socket fd %d\n", (int) fd);
- for (i = 0; i < sockets->count; ++i) {
- if (sockets->sockets[i] == fd) {
- if (i < sockets->count - 1)
+ for(i = 0; i < sockets->count; ++i) {
+ if(sockets->sockets[i] == fd) {
+ if(i < sockets->count - 1)
memmove(&sockets->sockets[i], &sockets->sockets[i + 1],
sizeof(curl_socket_t) * (sockets->count - (i + 1)));
--sockets->count;
@@ -110,10 +110,10 @@ static int curlSocketCallback(CURL *easy, curl_socket_t s, int action,
(void)easy; /* unused */
(void)socketp; /* unused */
- if (action == CURL_POLL_IN || action == CURL_POLL_INOUT)
+ if(action == CURL_POLL_IN || action == CURL_POLL_INOUT)
addFd(&sockets->read, s, "read");
- if (action == CURL_POLL_OUT || action == CURL_POLL_INOUT)
+ if(action == CURL_POLL_OUT || action == CURL_POLL_INOUT)
addFd(&sockets->write, s, "write");
if(action == CURL_POLL_REMOVE) {
@@ -132,7 +132,7 @@ static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp)
struct timeval* timeout = userp;
(void)multi; /* unused */
- if (timeout_ms != -1) {
+ if(timeout_ms != -1) {
*timeout = tutil_tvnow();
timeout->tv_usec += timeout_ms * 1000;
}
@@ -151,10 +151,10 @@ static int checkForCompletion(CURLM* curl, int* success)
CURLMsg* message;
int result = 0;
*success = 0;
- while ((message = curl_multi_info_read(curl, &numMessages)) != NULL) {
- if (message->msg == CURLMSG_DONE) {
+ while((message = curl_multi_info_read(curl, &numMessages)) != NULL) {
+ if(message->msg == CURLMSG_DONE) {
result = 1;
- if (message->data.result == CURLE_OK)
+ if(message->data.result == CURLE_OK)
*success = 1;
else
*success = 0;
@@ -176,7 +176,7 @@ static int getMicroSecondTimeout(struct timeval* timeout)
now = tutil_tvnow();
result = (timeout->tv_sec - now.tv_sec) * 1000000 +
timeout->tv_usec - now.tv_usec;
- if (result < 0)
+ if(result < 0)
result = 0;
return curlx_sztosi(result);
@@ -189,9 +189,9 @@ static void updateFdSet(struct Sockets* sockets, fd_set* fdset,
curl_socket_t *maxFd)
{
int i;
- for (i = 0; i < sockets->count; ++i) {
+ for(i = 0; i < sockets->count; ++i) {
FD_SET(sockets->sockets[i], fdset);
- if (*maxFd < sockets->sockets[i] + 1) {
+ if(*maxFd < sockets->sockets[i] + 1) {
*maxFd = sockets->sockets[i] + 1;
}
}
@@ -202,7 +202,7 @@ static void notifyCurl(CURLM *curl, curl_socket_t s, int evBitmask,
{
int numhandles = 0;
CURLMcode result = curl_multi_socket_action(curl, s, evBitmask, &numhandles);
- if (result != CURLM_OK) {
+ if(result != CURLM_OK) {
fprintf(stderr, "Curl error on %s: %i (%s)\n",
info, result, curl_multi_strerror(result));
}
@@ -215,8 +215,8 @@ static void checkFdSet(CURLM *curl, struct Sockets *sockets, fd_set *fdset,
int evBitmask, const char *name)
{
int i;
- for (i = 0; i < sockets->count; ++i) {
- if (FD_ISSET(sockets->sockets[i], fdset)) {
+ for(i = 0; i < sockets->count; ++i) {
+ if(FD_ISSET(sockets->sockets[i], fdset)) {
notifyCurl(curl, sockets->sockets[i], evBitmask, name);
}
}
@@ -227,7 +227,7 @@ int test(char *URL)
int res = 0;
CURL *curl = NULL;
FILE *hd_src = NULL;
- int hd ;
+ int hd;
int error;
struct_stat file_info;
CURLM *m = NULL;
@@ -237,7 +237,7 @@ int test(char *URL)
start_test_timing();
- if (!libtest_arg3) {
+ if(!libtest_arg3) {
fprintf(stderr, "Usage: lib582 [url] [filename] [username]\n");
return TEST_ERR_USAGE;
}
@@ -276,7 +276,7 @@ int test(char *URL)
easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */
- easy_setopt(curl,CURLOPT_URL, URL);
+ easy_setopt(curl, CURLOPT_URL, URL);
/* go verbose */
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
@@ -300,8 +300,7 @@ int test(char *URL)
multi_add_handle(m, curl);
- while (!checkForCompletion(m, &success))
- {
+ while(!checkForCompletion(m, &success)) {
fd_set readSet, writeSet;
curl_socket_t maxFd = 0;
struct timeval tv = {10, 0};
@@ -311,14 +310,12 @@ int test(char *URL)
updateFdSet(&sockets.read, &readSet, &maxFd);
updateFdSet(&sockets.write, &writeSet, &maxFd);
- if (timeout.tv_sec != -1)
- {
+ if(timeout.tv_sec != -1) {
int usTimeout = getMicroSecondTimeout(&timeout);
tv.tv_sec = usTimeout / 1000000;
tv.tv_usec = usTimeout % 1000000;
}
- else if (maxFd <= 0)
- {
+ else if(maxFd <= 0) {
tv.tv_sec = 0;
tv.tv_usec = 100000;
}
@@ -329,8 +326,7 @@ int test(char *URL)
checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read");
checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write");
- if (timeout.tv_sec != -1 && getMicroSecondTimeout(&timeout) == 0)
- {
+ if(timeout.tv_sec != -1 && getMicroSecondTimeout(&timeout) == 0) {
/* Curl's timer has elapsed. */
notifyCurl(m, CURL_SOCKET_TIMEOUT, 0, "timeout");
}
@@ -338,8 +334,7 @@ int test(char *URL)
abort_on_test_timeout();
}
- if (!success)
- {
+ if(!success) {
fprintf(stderr, "Error uploading file.\n");
res = TEST_ERR_MAJOR_BAD;
}