#!/bin/sh # Simple test for e2tools # Copyright (C) 2006 Hans Ulrich Niedermann # Copyright (C) 2020 Hans Ulrich Niedermann # # 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; either version 2 of the License, or # (at your option) any later version. # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA set -ex # Note on compatibility: Both GNU coreutils dd and busybox dd accept # sizes like 16M or 1G, but other dd implementations like OSX dd do # not. So instead of requiring GNU coreutils or busybox, we try to be # cross-platform compatible and use numbers only. # Caution: Even with a sparse image file, a filesystem image of 100G # size needs 1.6GB on disk just to be formatted! for imgsize in 16777216; do testimg="test-${imgsize}.img" trap "" EXIT # create sparse image file full of zeros rm -f "${testimg}" @DD@ if=/dev/null of="${testimg}" bs=1 count=1 seek="$imgsize" # create file system on image file @MKE2FS@ -F "${testimg}" # check a few things @top_builddir@/e2mkdir "${testimg}:/foo" @top_builddir@/e2ls -l "${testimg}:" @top_builddir@/e2mkdir "${testimg}:/bar" @top_builddir@/e2mkdir "${testimg}:/bla" @top_builddir@/e2ls -l "${testimg}:" for srcfile in @top_srcdir@/README.md @top_srcdir@/configure; do @top_builddir@/e2cp "${srcfile}" "${testimg}:/foo" @top_builddir@/e2ls -l "${testimg}:/foo" @top_builddir@/e2ls -ln "${testimg}:/foo" @HAVE_EXT2FS_XATTRS_FALSE@@top_builddir@/e2ls -lnZ "${testimg}:/foo" @HAVE_EXT2FS_XATTRS_FALSE@@top_builddir@/e2ls -lZ "${testimg}:/foo" filebase="$(basename "$srcfile")" trap "rm -f ${filebase}.test-c" EXIT @top_builddir@/e2cp "${testimg}:/foo/${filebase}" "${filebase}.test-c" @top_builddir@/e2rm ${testimg}:/foo/${filebase} @top_builddir@/e2ls -l "${testimg}:/foo" cmp ${srcfile} ${filebase}.test-c rm -f ${filebase}.test-c done # remove the test image rm -f "${testimg}" trap "" EXIT done exit 0