Skip to content

Commit 345deb3

Browse files
committed
test: file size fix
1 parent 845c8da commit 345deb3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

tests/rest_scripts/put_object_openssl_chunked_example.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# under the License.
1616

1717
source ./tests/rest_scripts/rest.sh
18+
source ./tests/util/util_file.sh
1819

1920
# Fields
2021

@@ -113,7 +114,7 @@ Content-Length: 66824
113114
}
114115

115116
get_file_size_and_content_length() {
116-
if ! file_size=$(stat -f %z "$data_file" 2>&1); then
117+
if ! file_size=$(get_file_size "$data_file"); then
117118
log_rest 2 "error getting file size: $file_size"
118119
return 1
119120
fi

tests/util/util_file.sh

+20
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@ delete_test_files() {
102102
return 0
103103
}
104104

105+
get_file_size() {
106+
if [ $# -ne 1 ]; then
107+
log 2 "'get_file_size' requires file location"
108+
return 1
109+
fi
110+
local file_size=""
111+
if [[ "$OSTYPE" == "darwin"* ]]; then
112+
if ! file_size=$(stat -f %z "$1" 2>&1); then
113+
log 2 "error getting file size: $file_size"
114+
return 1
115+
fi
116+
else
117+
if ! file_size=$(stat -c %s "$1" 2>&1); then
118+
log 2 "error getting file size: $file_size"
119+
return 1
120+
fi
121+
fi
122+
echo "$file_size"
123+
}
124+
105125
# split file into pieces to test multipart upload
106126
# param: file location
107127
# return 0 for success, 1 for error

0 commit comments

Comments
 (0)