Debian Codegraph @

tests/simple-test.sh.in

raw
1 #!/bin/sh
2 # Simple test for e2tools <URL:https://github.com/e2tools/e2tools>
3 # Copyright (C) 2006 Hans Ulrich Niedermann
4 # Copyright (C) 2020 Hans Ulrich Niedermann
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 set -ex
21
22 # Note on compatibility: Both GNU coreutils dd and busybox dd accept
23 # sizes like 16M or 1G, but other dd implementations like OSX dd do
24 # not. So instead of requiring GNU coreutils or busybox, we try to be
25 # cross-platform compatible and use numbers only.
26
27 # Caution: Even with a sparse image file, a filesystem image of 100G
28 # size needs 1.6GB on disk just to be formatted!
29 for imgsize in 16777216; do
30 testimg="test-${imgsize}.img"
31 trap "" EXIT
32 # create sparse image file full of zeros
33 rm -f "${testimg}"
34 @DD@ if=/dev/null of="${testimg}" bs=1 count=1 seek="$imgsize"
35 # create file system on image file
36 @MKE2FS@ -F "${testimg}"
37 # check a few things
38 @top_builddir@/e2mkdir "${testimg}:/foo"
39 @top_builddir@/e2ls -l "${testimg}:"
40
41 @top_builddir@/e2mkdir "${testimg}:/bar"
42 @top_builddir@/e2mkdir "${testimg}:/bla"
43 @top_builddir@/e2ls -l "${testimg}:"
44
45 for srcfile in @top_srcdir@/README.md @top_srcdir@/configure; do
46
47 @top_builddir@/e2cp "${srcfile}" "${testimg}:/foo"
48 @top_builddir@/e2ls -l "${testimg}:/foo"
49 @top_builddir@/e2ls -ln "${testimg}:/foo"
50 @HAVE_EXT2FS_XATTRS_FALSE@@top_builddir@/e2ls -lnZ "${testimg}:/foo"
51 @HAVE_EXT2FS_XATTRS_FALSE@@top_builddir@/e2ls -lZ "${testimg}:/foo"
52
53 filebase="$(basename "$srcfile")"
54 trap "rm -f ${filebase}.test-c" EXIT
55 @top_builddir@/e2cp "${testimg}:/foo/${filebase}" "${filebase}.test-c"
56
57 @top_builddir@/e2rm ${testimg}:/foo/${filebase}
58 @top_builddir@/e2ls -l "${testimg}:/foo"
59
60 cmp ${srcfile} ${filebase}.test-c
61 rm -f ${filebase}.test-c
62 done
63
64 # remove the test image
65 rm -f "${testimg}"
66 trap "" EXIT
67 done
68
69 exit 0