X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=tests%2Ftest-imagex;h=466976737ce8d693a3ec020e815ddca418a259d5;hp=85c17b4d6219470d530e29ef00e01c2f8f8da8c1;hb=36a737d734cdc6c6eb0ce9da3183a1f8fa4288e6;hpb=63a5804943519281f206ca0fefacfe2b99fc9958 diff --git a/tests/test-imagex b/tests/test-imagex index 85c17b4d..46697673 100755 --- a/tests/test-imagex +++ b/tests/test-imagex @@ -1,12 +1,13 @@ -#!/bin/sh +#!/usr/bin/env bash # This script does some sanity testing of the 'imagex' program. It by no means # tests every aspect of wimlib comprehensively. set -e -srcdir=${srcdir:-.} -srcdir=`realpath $srcdir` cd tests +srcdir="${srcdir:-.}/.." +srcdir="$(cd $srcdir; pwd)" +. "$srcdir/tests/tests-common.sh" imagex() { echo "imagex $@" @@ -20,7 +21,7 @@ imagex_info() { cleanup() { fusermount -u tmp &> /dev/null || true - rm -rf dir* tmp* *.wim *.swm + rm -rf dir* tmp* *.wim *.swm &> /dev/null || true } cleanup @@ -62,13 +63,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 @@ -77,7 +78,7 @@ for comp_type in None LZX XPRESS; do if ! test "`readlink tmp/subdir/rel_symlink`" = "hello"; then error "Symlink target not correct" fi - + rm -rf dir.wim tmp done @@ -288,13 +289,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/lz77.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/lz77.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/lz77.c`" = "`get_inode_number tmp/dir/lz77.c`"; then error "Incorrect inode number" fi rm -rf tmp @@ -305,13 +306,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/lz77.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/lz77.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/lz77.c`" != "`get_inode_number tmp/dir/lz77.c`"; then error "Incorrect inode number" fi rm -rf tmp @@ -320,16 +321,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 +339,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 +357,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 +376,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 @@ -487,8 +488,8 @@ fi # Test exporting an image to another WIM, then applying it. # We try with 5 different combinations of compression types to make sure we go # through all paths in the resource-handling code. -for i in `seq 1 3`; do - case $i in +for i in 1 2 3 4 5; do + case $i in 1) cflag1="--compress=none"; cflag2="--compress=none";