From: Enrico Scholz Date: Fri, 18 Mar 2005 03:33:34 +0000 (+0000) Subject: added testcases for Unify_copy() X-Git-Tag: IPSENTINEL_VERSION_0_12~70 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=926a1d75c944761d0267cf6cbd4e82c8fc0795a4;p=util-vserver.git added testcases for Unify_copy() git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1924 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/lib_internal/testsuite/Makefile-files b/util-vserver/lib_internal/testsuite/Makefile-files index 3030a14..50293b4 100644 --- a/util-vserver/lib_internal/testsuite/Makefile-files +++ b/util-vserver/lib_internal/testsuite/Makefile-files @@ -18,14 +18,23 @@ check_PROGRAMS += lib_internal/testsuite/command if ENSC_HAVE_C99_COMPILER -check_PROGRAMS += lib_internal/testsuite/filecfg-ml -TESTS += lib_internal/testsuite/filecfg-ml +check_PROGRAMS += lib_internal/testsuite/filecfg-ml \ + lib_internal/testsuite/copy +TESTS += lib_internal/testsuite/filecfg-ml \ + lib_internal/testsuite/copy-check endif +EXTRA_DIST += lib_internal/testsuite/copy-check + +TESTS_ENVIRONMENT += libinternaltestsuitedir=$(top_builddir)/lib_internal/testsuite + lib_internal_testsuite_command_SOURCES = lib_internal/testsuite/command.c -lib_internal_testsuite_command_LDADD = $(LIBINTERNAL) \ - $(LIBENSCVECTOR) +lib_internal_testsuite_command_LDADD = $(LIBINTERNAL_GLIBC) \ + $(LIBENSCVECTOR_GLIBC) lib_internal_testsuite_filecfg_ml_SOURCES = lib_internal/testsuite/filecfg-ml.c -lib_internal_testsuite_filecfg_ml_LDADD = $(LIBINTERNAL) +lib_internal_testsuite_filecfg_ml_LDADD = $(LIBINTERNAL_GLIBC) + +lib_internal_testsuite_copy_SOURCES = lib_internal/testsuite/copy.c +lib_internal_testsuite_copy_LDADD = $(LIBINTERNAL_GLIBC) diff --git a/util-vserver/lib_internal/testsuite/copy-check b/util-vserver/lib_internal/testsuite/copy-check new file mode 100755 index 0000000..a70edf4 --- /dev/null +++ b/util-vserver/lib_internal/testsuite/copy-check @@ -0,0 +1,74 @@ +#! /bin/bash +## $Id$ + +# Copyright (C) 2005 Enrico Scholz +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +set -e + +dir=$(mktemp -d ${TMP:-/var/tmp}/copy-check.XXXXXX) +trap "ls -l $dir; rm -rf $dir" EXIT + +COPY=${libinternaltestsuitedir:-$(dirname "$0")}/copy + +test -x "$COPY" + +function doit() +{ + $COPY $dir/$nr-in $dir/$nr-out + cmp -s $dir/$nr-in $dir/$nr-out +} + +## Usage: execCheck [*] +function execCheck() +{ + local nr=$1 + shift + + dd if=/dev/urandom of=$dir/$nr-in "$@" &>/dev/null + + doit $nr +} + +### Check 1: small file copy +execCheck 01 bs=10 count=1 + +### Check 2: PAGESIZEd file copy +execCheck 02 bs=4096 count=1 + + +### Check 3: PAGESIZE+1 file copy +execCheck 03 bs=4097 count=1 + +### Check 4: small sparse file copy +execCheck 04 bs=10 count=1 seek=1 + +### Check 5: large sparse file copy +execCheck 05 bs=4097 count=1 seek=1 + +### Check 6: large sparse file copy +execCheck 06 bs=4098 count=1 seek=1 + +### Check 7: large sparse file copy +execCheck 07 bs=4099 count=1 seek=1 + +### Check 8: large sparse file copy +execCheck 08 bs=4100 count=1 seek=1 + +### Check 9: huge sparse file copy +execCheck 09 bs=1024 count=1 seek=$[ 1024*1024 * 5 ] + +# ls -l $dir/* +# du $dir/* \ No newline at end of file diff --git a/util-vserver/lib_internal/testsuite/copy.c b/util-vserver/lib_internal/testsuite/copy.c new file mode 100644 index 0000000..e029590 --- /dev/null +++ b/util-vserver/lib_internal/testsuite/copy.c @@ -0,0 +1,41 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2005 Enrico Scholz +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "lib_internal/unify.h" + +#include +#include +#include +#include + +int wrapper_exit_code = 1; + +int main(int argc, char *argv[]) +{ + struct stat st; + + if (argc<2) return EXIT_FAILURE; + if (lstat(argv[1],&st)==-1) return EXIT_FAILURE; + + unlink(argv[2]); + return Unify_copy(argv[1], &st, argv[2]) ? EXIT_SUCCESS : EXIT_FAILURE; +}