From: Eric Biggers Date: Thu, 22 Nov 2012 06:03:01 +0000 (-0600) Subject: Test suite without coreutils X-Git-Tag: v1.2.0~10 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=08a55221fc6904ceaf4bd1c0532eb03e792d5420;hp=00b7886e84f81cf10d3adc3ab4594ea9ff5d7fc0 Test suite without coreutils --- diff --git a/Makefile.am b/Makefile.am index 5bcf8c1f..60c3af3c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -104,6 +104,7 @@ EXTRA_DIST = \ 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 \ diff --git a/README b/README index 6352e6bd..2f0a6841 100644 --- 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. -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. diff --git a/tests/test-imagex b/tests/test-imagex index 0ac5fc35..b6ed7694 100755 --- a/tests/test-imagex +++ b/tests/test-imagex @@ -5,8 +5,7 @@ set -e cd tests -srcdir="${srcdir:-.}/.." -srcdir="$(cd $srcdir; pwd)" +. tests-common.sh 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 ! 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 - 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 - 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 @@ -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 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 -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 -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 @@ -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 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 -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 -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 @@ -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 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 -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 -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 -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 @@ -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 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 -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 -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 -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 @@ -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 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 -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 -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 @@ -375,7 +374,7 @@ rm -rf dir.wim 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 diff --git a/tests/test-imagex-capture_and_apply b/tests/test-imagex-capture_and_apply index caa4d47e..d281f8ec 100755 --- a/tests/test-imagex-capture_and_apply +++ b/tests/test-imagex-capture_and_apply @@ -10,8 +10,7 @@ set -e cd tests -srcdir="${srcdir:-.}/.." -srcdir="$(cd $srcdir; pwd)" +. tests-common.sh imagex() { echo "imagex $@" diff --git a/tests/test-imagex-mount b/tests/test-imagex-mount index 4f6d1c95..276dcbb5 100755 --- a/tests/test-imagex-mount +++ b/tests/test-imagex-mount @@ -4,8 +4,7 @@ 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." @@ -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 "`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" @@ -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 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 -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 diff --git a/tests/test-imagex-ntfs b/tests/test-imagex-ntfs index c046c2de..45404d17 100755 --- a/tests/test-imagex-ntfs +++ b/tests/test-imagex-ntfs @@ -10,8 +10,7 @@ set -e cd tests -srcdir="${srcdir:-.}/.." -srcdir="$(cd $srcdir; pwd)" +. tests-common.sh imagex() { ../imagex $@ > /dev/null @@ -23,6 +22,7 @@ __do_unmount() { fi } + 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 index 00000000..c80dbeff --- /dev/null +++ b/tests/tests-common.sh @@ -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 +}