added testcases for Unify_copy()
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 18 Mar 2005 03:33:34 +0000 (03:33 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 18 Mar 2005 03:33:34 +0000 (03:33 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1924 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/lib_internal/testsuite/Makefile-files
util-vserver/lib_internal/testsuite/copy-check [new file with mode: 0755]
util-vserver/lib_internal/testsuite/copy.c [new file with mode: 0644]

index 3030a14..50293b4 100644 (file)
 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 (executable)
index 0000000..a70edf4
--- /dev/null
@@ -0,0 +1,74 @@
+#! /bin/bash
+## $Id$
+
+# Copyright (C) 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+#  
+# 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 <nr> [<dd-args>*]
+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 (file)
index 0000000..e029590
--- /dev/null
@@ -0,0 +1,41 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// 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 <config.h>
+#endif
+
+#include "lib_internal/unify.h"
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+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;
+}