Added a simple integration test, and properly integrated it with autotools.

To run integration tests, just use: sudo make check
This will give you a report of all passes and failures.

To add an integration test, just add it to the TESTS variable in s3fs/test/Makefile.am
Make sure your test sources integration-test-common.sh and require-root.sh

Having many of these for every feature will help us avoid regressions and develop with confidence.


git-svn-id: http://s3fs.googlecode.com/svn/trunk@230 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
apetresc 2010-11-09 07:04:47 +00:00
parent cc2e440276
commit 3022b87738
6 changed files with 61 additions and 2 deletions

View File

@ -1 +1 @@
SUBDIRS=src
SUBDIRS=src test

View File

@ -11,6 +11,6 @@ AC_PROG_CXX
PKG_CHECK_MODULES([DEPS], [fuse >= 2.7 libcurl >= 7.0 libxml-2.0 >= 2.6 libcrypto >= 0.9])
AC_CONFIG_FILES(Makefile src/Makefile)
AC_CONFIG_FILES(Makefile src/Makefile test/Makefile)
AC_OUTPUT

1
s3fs/test/Makefile.am Normal file
View File

@ -0,0 +1 @@
TESTS=small-integration-test.sh

View File

@ -0,0 +1,14 @@
#!/bin/bash -e
S3FS=../src/s3fs
S3FS_CREDENTIALS_FILE=~/.passwd-s3fs
TEST_BUCKET_1=apetresc-s3fs
TEST_BUCKET_MOUNT_POINT_1=/mnt/s3fs-test
if [ ! -f "$S3FS_CREDENTIALS_FILE" ]
then
echo "Missing credentials file: $S3FS_CREDENTIALS_FILE"
exit 1
fi

7
s3fs/test/require-root.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash -e
if [[ $EUID -ne 0 ]]
then
echo "This test script must be run as root" 1>&2
exit 1
fi

View File

@ -0,0 +1,37 @@
#!/bin/bash -e
COMMON=integration-test-common.sh
source $COMMON
# Require root
REQUIRE_ROOT=require-root.sh
source $REQUIRE_ROOT
# Configuration
TEST_TEXT="HELLO WORLD"
TEST_TEXT_FILE=test-s3fs.txt
TEST_TEXT_FILE_LENGTH=15
# Mount the bucket
$S3FS $TEST_BUCKET_1 $TEST_BUCKET_MOUNT_POINT_1
CUR_DIR=`pwd`
cd $TEST_BUCKET_MOUNT_POINT_1
# Write a small test file
for x in `seq 1 $TEST_TEXT_FILE_LENGTH`
do
echo $TEST_TEXT >> $TEST_TEXT_FILE
done
# Verify contents of file
FILE_LENGTH=`wc -l $TEST_TEXT_FILE | awk '{print $1}'`
if [ "$FILE_LENGTH" -ne "$TEST_TEXT_FILE_LENGTH" ]
then
exit 1
fi
# Delete the test file
rm $TEST_TEXT_FILE
# Unmount the bucket
cd $CUR_DIR
umount $TEST_BUCKET_MOUNT_POINT_1