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)
--- /dev/null
+#! /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
--- /dev/null
+// $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;
+}