mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-22 16:58:55 +00:00
Refactor tests into individual functions
This commit is contained in:
parent
2e344bb48f
commit
17d223b542
@ -61,18 +61,8 @@ function rm_test_dir {
|
||||
fi
|
||||
}
|
||||
|
||||
CUR_DIR=`pwd`
|
||||
TEST_BUCKET_MOUNT_POINT_1=$1
|
||||
if [ "$TEST_BUCKET_MOUNT_POINT_1" == "" ]; then
|
||||
echo "Mountpoint missing"
|
||||
exit 1
|
||||
fi
|
||||
cd $TEST_BUCKET_MOUNT_POINT_1
|
||||
|
||||
if [ -e $TEST_TEXT_FILE ]
|
||||
then
|
||||
rm -f $TEST_TEXT_FILE
|
||||
fi
|
||||
function test_append_file {
|
||||
echo "Testing append to file ..."
|
||||
|
||||
# Write a small test file
|
||||
for x in `seq 1 $TEST_TEXT_FILE_LENGTH`
|
||||
@ -91,10 +81,9 @@ then
|
||||
fi
|
||||
|
||||
rm_test_file
|
||||
}
|
||||
|
||||
##########################################################
|
||||
# Rename test (individual file)
|
||||
##########################################################
|
||||
function test_mv_file {
|
||||
echo "Testing mv file function ..."
|
||||
|
||||
# if the rename file exists, delete it
|
||||
@ -131,10 +120,9 @@ fi
|
||||
|
||||
# clean up
|
||||
rm_test_file $ALT_TEST_TEXT_FILE
|
||||
}
|
||||
|
||||
##########################################################
|
||||
# Rename test (individual directory)
|
||||
##########################################################
|
||||
function test_mv_directory {
|
||||
echo "Testing mv directory function ..."
|
||||
if [ -e $TEST_DIR ]; then
|
||||
echo "Unexpected, this file/directory exists: ${TEST_DIR}"
|
||||
@ -155,10 +143,9 @@ if [ -e "${TEST_DIR}_rename" ]; then
|
||||
echo "Could not remove the test directory, it still exists: ${TEST_DIR}_rename"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
###################################################################
|
||||
# test redirects > and >>
|
||||
###################################################################
|
||||
function test_redirects {
|
||||
echo "Testing redirects ..."
|
||||
|
||||
mk_test_file ABCDEF
|
||||
@ -194,13 +181,11 @@ if [ ${LINE2} != "123456" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# clean up
|
||||
rm_test_file
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
# Simple directory test mkdir/rmdir
|
||||
#####################################################################
|
||||
function test_mkdir_rmdir {
|
||||
echo "Testing creation/removal of a directory"
|
||||
|
||||
if [ -e $TEST_DIR ]; then
|
||||
@ -210,10 +195,9 @@ fi
|
||||
|
||||
mk_test_dir
|
||||
rm_test_dir
|
||||
}
|
||||
|
||||
##########################################################
|
||||
# File permissions test (individual file)
|
||||
##########################################################
|
||||
function test_chmod {
|
||||
echo "Testing chmod file function ..."
|
||||
|
||||
# create the test file again
|
||||
@ -232,10 +216,9 @@ fi
|
||||
|
||||
# clean up
|
||||
rm_test_file
|
||||
}
|
||||
|
||||
##########################################################
|
||||
# File permissions test (individual file)
|
||||
##########################################################
|
||||
function test_chown {
|
||||
echo "Testing chown file function ..."
|
||||
|
||||
# create the test file again
|
||||
@ -254,10 +237,9 @@ fi
|
||||
|
||||
# clean up
|
||||
rm_test_file
|
||||
}
|
||||
|
||||
##########################################################
|
||||
# Testing list
|
||||
##########################################################
|
||||
function test_list {
|
||||
echo "Testing list"
|
||||
mk_test_file
|
||||
mk_test_dir
|
||||
@ -270,21 +252,18 @@ fi
|
||||
|
||||
rm_test_file
|
||||
rm_test_dir
|
||||
}
|
||||
|
||||
##########################################################
|
||||
# Testing removing a non-empty directory
|
||||
##########################################################
|
||||
function test_remove_nonempty_directory {
|
||||
echo "Testing removing a non-empty directory"
|
||||
mk_test_dir
|
||||
touch "${TEST_DIR}/file"
|
||||
rmdir "${TEST_DIR}" 2>&1 | grep -q "Directory not empty"
|
||||
rm "${TEST_DIR}/file"
|
||||
rm_test_dir
|
||||
}
|
||||
|
||||
##########################################################
|
||||
# Testing rename before close
|
||||
##########################################################
|
||||
if false; then
|
||||
function test_rename_before_close {
|
||||
echo "Testing rename before close ..."
|
||||
(
|
||||
echo foo
|
||||
@ -298,11 +277,9 @@ fi
|
||||
|
||||
rm_test_file ${TEST_TEXT_FILE}.new
|
||||
rm -f ${TEST_TEXT_FILE}
|
||||
fi
|
||||
}
|
||||
|
||||
##########################################################
|
||||
# Testing multi-part upload
|
||||
##########################################################
|
||||
function test_multipart_upload {
|
||||
echo "Testing multi-part upload ..."
|
||||
dd if=/dev/urandom of="/tmp/${BIG_FILE}" bs=$BIG_FILE_LENGTH count=1
|
||||
dd if="/tmp/${BIG_FILE}" of="${BIG_FILE}" bs=$BIG_FILE_LENGTH count=1
|
||||
@ -316,14 +293,9 @@ fi
|
||||
|
||||
rm -f "/tmp/${BIG_FILE}"
|
||||
rm_test_file "${BIG_FILE}"
|
||||
}
|
||||
|
||||
##########################################################
|
||||
# Testing multi-part copy
|
||||
##########################################################
|
||||
# TODO: test disabled until S3Proxy 1.5.0 is released
|
||||
if false
|
||||
then
|
||||
|
||||
function test_multipart_copy {
|
||||
echo "Testing multi-part copy ..."
|
||||
dd if=/dev/urandom of="/tmp/${BIG_FILE}" bs=$BIG_FILE_LENGTH count=1
|
||||
dd if="/tmp/${BIG_FILE}" of="${BIG_FILE}" bs=$BIG_FILE_LENGTH count=1
|
||||
@ -338,12 +310,9 @@ fi
|
||||
|
||||
rm -f "/tmp/${BIG_FILE}"
|
||||
rm_test_file "${BIG_FILE}-copy"
|
||||
}
|
||||
|
||||
fi
|
||||
|
||||
##########################################################
|
||||
# Testing special characters
|
||||
##########################################################
|
||||
function test_special_characters {
|
||||
echo "Testing special characters ..."
|
||||
|
||||
ls 'special' 2>&1 | grep -q 'No such file or directory'
|
||||
@ -351,10 +320,10 @@ ls 'special?' 2>&1 | grep -q 'No such file or directory'
|
||||
ls 'special*' 2>&1 | grep -q 'No such file or directory'
|
||||
ls 'special~' 2>&1 | grep -q 'No such file or directory'
|
||||
ls 'specialµ' 2>&1 | grep -q 'No such file or directory'
|
||||
}
|
||||
|
||||
##########################################################
|
||||
# Testing extended attributes
|
||||
##########################################################
|
||||
function test_extended_attributes {
|
||||
echo "Testing extended attributes ..."
|
||||
|
||||
rm -f $TEST_TEXT_FILE
|
||||
touch $TEST_TEXT_FILE
|
||||
@ -372,10 +341,42 @@ getfattr -n key2 --only-values $TEST_TEXT_FILE | grep -q '^value2$'
|
||||
setfattr -x key1 $TEST_TEXT_FILE
|
||||
! getfattr -n key1 --only-values $TEST_TEXT_FILE
|
||||
getfattr -n key2 --only-values $TEST_TEXT_FILE | grep -q '^value2$'
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
# Tests are finished
|
||||
#####################################################################
|
||||
function run_all_tests {
|
||||
test_append_file
|
||||
test_mv_file
|
||||
test_mv_directory
|
||||
test_redirects
|
||||
test_mkdir_rmdir
|
||||
test_chmod
|
||||
test_chown
|
||||
test_list
|
||||
test_remove_nonempty_directory
|
||||
# TODO: broken: https://github.com/s3fs-fuse/s3fs-fuse/issues/145
|
||||
#test_rename_before_close
|
||||
test_multipart_upload
|
||||
# TODO: test disabled until S3Proxy 1.5.0 is released
|
||||
#test_multipart_copy
|
||||
test_special_characters
|
||||
test_extended_attributes
|
||||
}
|
||||
|
||||
# Mount the bucket
|
||||
CUR_DIR=`pwd`
|
||||
TEST_BUCKET_MOUNT_POINT_1=$1
|
||||
if [ "$TEST_BUCKET_MOUNT_POINT_1" == "" ]; then
|
||||
echo "Mountpoint missing"
|
||||
exit 1
|
||||
fi
|
||||
cd $TEST_BUCKET_MOUNT_POINT_1
|
||||
|
||||
if [ -e $TEST_TEXT_FILE ]
|
||||
then
|
||||
rm -f $TEST_TEXT_FILE
|
||||
fi
|
||||
|
||||
run_all_tests
|
||||
|
||||
# Unmount the bucket
|
||||
cd $CUR_DIR
|
||||
|
Loading…
Reference in New Issue
Block a user