]> wimlib.net Git - wimlib/commitdiff
Test suite without coreutils
authorEric Biggers <ebiggers3@gmail.com>
Thu, 22 Nov 2012 06:03:01 +0000 (00:03 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Thu, 22 Nov 2012 06:03:01 +0000 (00:03 -0600)
Makefile.am
README
tests/test-imagex
tests/test-imagex-capture_and_apply
tests/test-imagex-mount
tests/test-imagex-ntfs
tests/tests-common.sh [new file with mode: 0644]

index 5bcf8c1fc415843a069d9907883c5999200bafc3..60c3af3c05164a86ef228eb31ecd7850839f9139 100644 (file)
@@ -104,6 +104,7 @@ EXTRA_DIST =                                        \
        rpm                                     \
        programs/install.cmd                    \
        tests/common_tests.sh                   \
        rpm                                     \
        programs/install.cmd                    \
        tests/common_tests.sh                   \
+       tests/tests-common.sh                   \
        tests/security_descriptor_1.base64      \
        tests/security_descriptor_1.bin         \
        tests/security_descriptor_2.base64      \
        tests/security_descriptor_1.base64      \
        tests/security_descriptor_1.bin         \
        tests/security_descriptor_2.base64      \
diff --git a/README b/README
index 6352e6bdc832d0a8718e428f7b13490e8e2225aa..2f0a6841e75a44e01336ed40f96352d9d7419ab7 100644 (file)
--- a/README
+++ b/README
@@ -219,11 +219,10 @@ wimlib has mostly been developed and tested on x86_64 (64-bit) GNU/Linux.
 
 It has been tested on x86 (32-bit) GNU/Linux occasionally.
 
 
 It has been tested on x86 (32-bit) GNU/Linux occasionally.
 
-wimlib may work on FreeBSD.  However, this is not well tested.  If you do not
-have libntfs-3g 2011-4-12 or later available, you must configure with
---without-ntfs-3g.  Also, GNU coreutils is needed to run the test suite.  Before
-mounting a WIM you need to load the POSIX message queue module (run `kldload
-mqueuefs').
+wimlib may work on FreeBSD and Mac OS X.  However, this is not well tested.  If
+you do not have libntfs-3g 2011-4-12 or later available, you must configure with
+--without-ntfs-3g.  Before mounting a WIM you need to load the POSIX message
+queue module (run `kldload mqueuefs').
 
 wimlib should work on big endian machines but it has not been tested.
 
 
 wimlib should work on big endian machines but it has not been tested.
 
index 0ac5fc3592672214aa6502a2fe855ae45be59b3c..b6ed7694b37da8cc79c349f15e2754e15e6a1f8a 100755 (executable)
@@ -5,8 +5,7 @@
 
 set -e
 cd tests
 
 set -e
 cd tests
-srcdir="${srcdir:-.}/.."
-srcdir="$(cd $srcdir; pwd)"
+. tests-common.sh
 
 imagex() {
        echo "imagex $@"
 
 imagex() {
        echo "imagex $@"
@@ -62,13 +61,13 @@ for comp_type in None LZX XPRESS; do
        if ! diff -q -r dir tmp; then
                error "Recursive diff of extracted directory with original failed"
        fi
        if ! diff -q -r dir tmp; then
                error "Recursive diff of extracted directory with original failed"
        fi
-       if ! test `stat -c %h tmp/subdir/hello` = 2; then
+       if ! test `get_link_count tmp/subdir/hello` = 2; then
                error "Incorrect number of hard links in extracted file"
        fi
                error "Incorrect number of hard links in extracted file"
        fi
-       if ! test `stat -c %i tmp/subdir/hello` != `stat -c %i tmp/subdir/hello2`; then
+       if ! test `get_inode_number tmp/subdir/hello` != `get_inode_number tmp/subdir/hello2`; then
                error "Expected different inode numbers in files not hard-linked"
        fi
                error "Expected different inode numbers in files not hard-linked"
        fi
-       if ! test "`stat -c %i tmp/subdir/hello`" = "`stat -c %i tmp/subdir/hellolink`"; then
+       if ! test "`get_inode_number tmp/subdir/hello`" = "`get_inode_number tmp/subdir/hellolink`"; then
                error "Expected same inode numbers in hard-linked files"
        fi
        if ! test -L tmp/subdir/rel_symlink; then
                error "Expected same inode numbers in hard-linked files"
        fi
        if ! test -L tmp/subdir/rel_symlink; then
@@ -288,13 +287,13 @@ fi
 if ! diff -q -r tmp/dir tmp/myname || ! diff -q -r dir tmp/dir; then
        error "Recursive diff of applied WIM with original directory failed"
 fi
 if ! diff -q -r tmp/dir tmp/myname || ! diff -q -r dir tmp/dir; then
        error "Recursive diff of applied WIM with original directory failed"
 fi
-if test "`stat -c %h tmp/dir/lz.c`" != 1; then
+if test "`get_link_count tmp/dir/lz.c`" != 1; then
        error "Incorrect link count on extracted file"
 fi
        error "Incorrect link count on extracted file"
 fi
-if test "`stat -c %h tmp/myname/lz.c`" != 1; then
+if test "`get_link_count tmp/myname/lz.c`" != 1; then
        error "Incorrect link count on extracted file"
 fi
        error "Incorrect link count on extracted file"
 fi
-if test "`stat -c %i tmp/myname/lz.c`" = "`stat -c %i tmp/dir/lz.c`"; then
+if test "`get_inode_number tmp/myname/lz.c`" = "`get_inode_number tmp/dir/lz.c`"; then
        error "Incorrect inode number"
 fi
 rm -rf tmp
        error "Incorrect inode number"
 fi
 rm -rf tmp
@@ -305,13 +304,13 @@ fi
 if ! diff -q -r tmp/dir tmp/myname || ! diff -q -r dir tmp/dir; then
        error "Recursive diff of applied WIM with original directory failed"
 fi
 if ! diff -q -r tmp/dir tmp/myname || ! diff -q -r dir tmp/dir; then
        error "Recursive diff of applied WIM with original directory failed"
 fi
-if test "`stat -c %h tmp/dir/lz.c`" != 2; then
+if test "`get_link_count tmp/dir/lz.c`" != 2; then
        error "Incorrect link count on extracted file"
 fi
        error "Incorrect link count on extracted file"
 fi
-if test "`stat -c %h tmp/myname/lz.c`" != 2; then
+if test "`get_link_count tmp/myname/lz.c`" != 2; then
        error "Incorrect link count on extracted file"
 fi
        error "Incorrect link count on extracted file"
 fi
-if test "`stat -c %i tmp/myname/lz.c`" != "`stat -c %i tmp/dir/lz.c`"; then
+if test "`get_inode_number tmp/myname/lz.c`" != "`get_inode_number tmp/dir/lz.c`"; then
        error "Incorrect inode number"
 fi
 rm -rf tmp
        error "Incorrect inode number"
 fi
 rm -rf tmp
@@ -320,16 +319,16 @@ echo "Testing application of single image containing identical files"
 if ! imagex apply dir.wim 1 tmp; then
        error "Failed to apply WIM"
 fi
 if ! imagex apply dir.wim 1 tmp; then
        error "Failed to apply WIM"
 fi
-if test "`stat -c %h tmp/subdir/hello`" != 2; then
+if test "`get_link_count tmp/subdir/hello`" != 2; then
        error "Incorrect link count on extracted file"
 fi
        error "Incorrect link count on extracted file"
 fi
-if test "`stat -c %h tmp/subdir/hello2`" != 1; then
+if test "`get_link_count tmp/subdir/hello2`" != 1; then
        error "Incorrect link count on extracted file"
 fi
        error "Incorrect link count on extracted file"
 fi
-if test "`stat -c %i tmp/subdir/hello`" = "`stat -c %i tmp/subdir/hello2`"; then
+if test "`get_inode_number tmp/subdir/hello`" = "`get_inode_number tmp/subdir/hello2`"; then
        error "Inode numbers on non-hard-linked files are the same"
 fi
        error "Inode numbers on non-hard-linked files are the same"
 fi
-if test "`stat -c %i tmp/subdir/hello`" != "`stat -c %i tmp/subdir/hellolink`"; then
+if test "`get_inode_number tmp/subdir/hello`" != "`get_inode_number tmp/subdir/hellolink`"; then
        error "Inode numbers on hard-linked files are different"
 fi
 rm -rf tmp
        error "Inode numbers on hard-linked files are different"
 fi
 rm -rf tmp
@@ -338,16 +337,16 @@ echo "Testing application of single image containing identical files with hardli
 if ! imagex apply dir.wim 1 tmp --hardlink; then
        error "Failed to apply WIM"
 fi
 if ! imagex apply dir.wim 1 tmp --hardlink; then
        error "Failed to apply WIM"
 fi
-if test "`stat -c %h tmp/subdir/hello`" != 3; then
+if test "`get_link_count tmp/subdir/hello`" != 3; then
        error "Incorrect link count on extracted file"
 fi
        error "Incorrect link count on extracted file"
 fi
-if test "`stat -c %h tmp/subdir/hello2`" != 3; then
+if test "`get_link_count tmp/subdir/hello2`" != 3; then
        error "Incorrect link count on extracted file"
 fi
        error "Incorrect link count on extracted file"
 fi
-if test "`stat -c %i tmp/subdir/hello`" != "`stat -c %i tmp/subdir/hello2`"; then
+if test "`get_inode_number tmp/subdir/hello`" != "`get_inode_number tmp/subdir/hello2`"; then
        error "Hard link set does not share inode number"
 fi
        error "Hard link set does not share inode number"
 fi
-if test "`stat -c %i tmp/subdir/hello`" != "`stat -c %i tmp/subdir/hellolink`"; then
+if test "`get_inode_number tmp/subdir/hello`" != "`get_inode_number tmp/subdir/hellolink`"; then
        error "Hard link set does not share inode number"
 fi
 rm -rf tmp
        error "Hard link set does not share inode number"
 fi
 rm -rf tmp
@@ -356,13 +355,13 @@ echo "Testing application of single image containing identical files with symlin
 if ! imagex apply dir.wim 1 tmp --symlink; then
        error "Failed to apply WIM"
 fi
 if ! imagex apply dir.wim 1 tmp --symlink; then
        error "Failed to apply WIM"
 fi
-if test "`stat -c %h tmp/subdir/hello`" != 1; then
+if test "`get_link_count tmp/subdir/hello`" != 1; then
        error "Incorrect link count on extracted file"
 fi
        error "Incorrect link count on extracted file"
 fi
-if test "`stat -c %h tmp/subdir/hello2`" != 1; then
+if test "`get_link_count tmp/subdir/hello2`" != 1; then
        error "Incorrect link count on extracted file"
 fi
        error "Incorrect link count on extracted file"
 fi
-if test "`stat -c %i tmp/subdir/hello`" = "`stat -c %i tmp/subdir/hello2`"; then
+if test "`get_inode_number tmp/subdir/hello`" = "`get_inode_number tmp/subdir/hello2`"; then
        error "Incorrect inode number"
 fi
 if ! test -L tmp/subdir/hello -o -L tmp/subdir/hello2 -o -L tmp/subdir/hellolink; then
        error "Incorrect inode number"
 fi
 if ! test -L tmp/subdir/hello -o -L tmp/subdir/hello2 -o -L tmp/subdir/hellolink; then
@@ -375,7 +374,7 @@ rm -rf dir.wim tmp
 
 echo "Creating random files to test WIM splitting on"
 mkdir tmp
 
 echo "Creating random files to test WIM splitting on"
 mkdir tmp
-for i in `seq 1 100`; do
+for ((i = 0; i < 100; i++)); do
        dd if=/dev/urandom of=tmp/file$i bs=4096 count=10 &> /dev/null
 done
 for flag in "--compress=none" "--compress=maximum" "--compress=fast"; do
        dd if=/dev/urandom of=tmp/file$i bs=4096 count=10 &> /dev/null
 done
 for flag in "--compress=none" "--compress=maximum" "--compress=fast"; do
index caa4d47ea8abb7b1f12fddf05763fae3a17a1251..d281f8ec10df337872e53ff492eb8fb5bb09963d 100755 (executable)
@@ -10,8 +10,7 @@
 
 set -e
 cd tests
 
 set -e
 cd tests
-srcdir="${srcdir:-.}/.."
-srcdir="$(cd $srcdir; pwd)"
+. tests-common.sh
 
 imagex() {
        echo "imagex $@"
 
 imagex() {
        echo "imagex $@"
index 4f6d1c95e58521ae0570339abdf65e2c5b207646..276dcbb5ad19824fd5e628d2e186339a57ba6ecf 100755 (executable)
@@ -4,8 +4,7 @@
 
 set -e
 cd tests
 
 set -e
 cd tests
-srcdir="${srcdir:-.}/.."
-srcdir="$(cd $srcdir; pwd)"
+. tests-common.sh
 
 if [ ! -r /dev/fuse ]; then
        echo "WARNING: /dev/fuse is not readable."
 
 if [ ! -r /dev/fuse ]; then
        echo "WARNING: /dev/fuse is not readable."
@@ -167,7 +166,7 @@ fi
 if ! test -f tmp/newdir/empty_file; then
        error "New empty file not created correctly in read-write mounted WIM"
 fi
 if ! test -f tmp/newdir/empty_file; then
        error "New empty file not created correctly in read-write mounted WIM"
 fi
-if ! test "`stat -c %s tmp/newdir/empty_file`" = 0; then
+if ! test "`get_file_size tmp/newdir/empty_file`" = 0; then
        error "New empty file in read-write mounted WIM is not empty"
 fi
 echo "Testing making new non-empty file in mounted WIM"
        error "New empty file in read-write mounted WIM is not empty"
 fi
 echo "Testing making new non-empty file in mounted WIM"
@@ -194,10 +193,10 @@ fi
 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
        error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
 fi
 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
        error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
 fi
-if test `stat -c %s tmp/newdir/empty_file` != 0; then
+if test `get_file_size tmp/newdir/empty_file` != 0; then
        error "The new empty file we made in the read-write mounted WIM was not extracted correctly"
 fi
        error "The new empty file we made in the read-write mounted WIM was not extracted correctly"
 fi
-if test `stat -c %s tmp/newdir/zeroes1` != 4096; then
+if test `get_file_size tmp/newdir/zeroes1` != 4096; then
        error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
 fi
 
        error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
 fi
 
index c046c2de7fa39dbe326bb72b8578ed2d98ea0920..45404d17a15a0dfdd50f1adabe91e00811465009 100755 (executable)
@@ -10,8 +10,7 @@
 
 set -e
 cd tests
 
 set -e
 cd tests
-srcdir="${srcdir:-.}/.."
-srcdir="$(cd $srcdir; pwd)"
+. tests-common.sh
 
 imagex() {
        ../imagex $@ > /dev/null
 
 imagex() {
        ../imagex $@ > /dev/null
@@ -23,6 +22,7 @@ __do_unmount() {
        fi
 
 }
        fi
 
 }
+
 do_unmount() {
        if mountpoint $1 &> /dev/null; then
                __do_unmount $1
 do_unmount() {
        if mountpoint $1 &> /dev/null; then
                __do_unmount $1
diff --git a/tests/tests-common.sh b/tests/tests-common.sh
new file mode 100644 (file)
index 0000000..c80dbef
--- /dev/null
@@ -0,0 +1,35 @@
+srcdir="${srcdir:-.}/.."
+srcdir="$(cd $srcdir; pwd)"
+
+if stat -c %i . ; then
+       BSD_STAT=0
+else
+       BSD_STAT=1
+fi
+
+get_inode_number() 
+{
+       if [ "$BSD_STAT" -eq 1 ]; then
+               stat -f %i "$1"
+       else
+               stat -c %i "$1"
+       fi
+}
+
+get_link_count()
+{
+       if [ "$BSD_STAT" -eq 1 ]; then
+               stat -f %l "$1"
+       else
+               stat -c %h "$1"
+       fi
+}
+
+get_file_size()
+{
+       if [ "$BSD_STAT" -eq 1 ]; then
+               stat -f %z "$1"
+       else
+               stat -c %s "$1"
+       fi
+}