diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 9dfae84053..5af7ac0bb1 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -54,25 +54,6 @@ int test(char *URL) return -1; } - /* get the file size of the local file */ - hd = stat(libtest_arg2, &file_info); - if(hd == -1) { - /* can't open file, bail out */ - error = ERRNO; - fprintf(stderr, "stat() failed with error: %d %s\n", - error, strerror(error)); - fprintf(stderr, "WARNING: cannot open file %s\n", libtest_arg2); - return -1; - } - - if(! file_info.st_size) { - fprintf(stderr, "WARNING: file %s has no size!\n", libtest_arg2); - return -4; - } - - /* get a FILE * of the same file, could also be made with - fdopen() from the previous descriptor, but hey this is just - an example! */ hd_src = fopen(libtest_arg2, "rb"); if(NULL == hd_src) { error = ERRNO; @@ -82,6 +63,24 @@ int test(char *URL) return -2; /* if this happens things are major weird */ } + /* get the file size of the local file */ + hd = fstat(fileno(hd_src), &file_info); + if(hd == -1) { + /* can't open file, bail out */ + error = ERRNO; + fprintf(stderr, "fstat() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2); + fclose(hd_src); + return -1; + } + + if(! file_info.st_size) { + fprintf(stderr, "ERROR: file %s has zero size!\n", libtest_arg2); + fclose(hd_src); + return -4; + } + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); fclose(hd_src); diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index d2542577b9..ade6370121 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -40,14 +40,6 @@ int test(char *URL) return -1; } - /* get the file size of the local file */ - hd = open(libtest_arg2, O_RDONLY) ; - fstat(hd, &file_info); - close(hd) ; - - /* get a FILE * of the same file, could also be made with - fdopen() from the previous descriptor, but hey this is just - an example! */ hd_src = fopen(libtest_arg2, "rb"); if(NULL == hd_src) { error = ERRNO; @@ -57,6 +49,18 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } + /* get the file size of the local file */ + hd = fstat(fileno(hd_src), &file_info); + if(hd == -1) { + /* can't open file, bail out */ + error = ERRNO; + fprintf(stderr, "fstat() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2); + fclose(hd_src); + return -1; + } + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); fclose(hd_src); diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c index c060b8ac75..2fc85b97d4 100644 --- a/tests/libtest/lib541.c +++ b/tests/libtest/lib541.c @@ -46,25 +46,6 @@ int test(char *URL) return -1; } - /* get the file size of the local file */ - hd = stat(libtest_arg2, &file_info); - if(hd == -1) { - /* can't open file, bail out */ - error = ERRNO; - fprintf(stderr, "stat() failed with error: %d %s\n", - error, strerror(error)); - fprintf(stderr, "WARNING: cannot open file %s\n", libtest_arg2); - return -1; - } - - if(! file_info.st_size) { - fprintf(stderr, "WARNING: file %s has no size!\n", libtest_arg2); - return -4; - } - - /* get a FILE * of the same file, could also be made with - fdopen() from the previous descriptor, but hey this is just - an example! */ hd_src = fopen(libtest_arg2, "rb"); if(NULL == hd_src) { error = ERRNO; @@ -74,6 +55,24 @@ int test(char *URL) return -2; /* if this happens things are major weird */ } + /* get the file size of the local file */ + hd = fstat(fileno(hd_src), &file_info); + if(hd == -1) { + /* can't open file, bail out */ + error = ERRNO; + fprintf(stderr, "fstat() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2); + fclose(hd_src); + return -1; + } + + if(! file_info.st_size) { + fprintf(stderr, "ERROR: file %s has zero size!\n", libtest_arg2); + fclose(hd_src); + return -4; + } + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); fclose(hd_src);