# This script does some sanity testing of the 'imagex' program. It by no means
# tests every aspect of wimlib comprehensively.
set -e
# This script does some sanity testing of the 'imagex' program. It by no means
# tests every aspect of wimlib comprehensively.
set -e
# Capturing and applying WIM with None, LZX, and XPRESS compression
for comp_type in None LZX XPRESS; do
# Capturing and applying WIM with None, LZX, and XPRESS compression
for comp_type in None LZX XPRESS; do
- if ! test "`imagex_info dir.wim | grep Compression | awk '{print $2}'`" = "$comp_type"; then
- error "'imagex_info' didn't report the compression type correctly"
+ if ! test `wim_ctype dir.wim` = "$comp_type"; then
+ error "'imagex info' didn't report the compression type correctly"
error "WIM description not set correctly"
fi
echo "Testing capture of WIM with default boot flag"
imagex capture dir dir.wim
error "WIM description not set correctly"
fi
echo "Testing capture of WIM with default boot flag"
imagex capture dir dir.wim
error "Bootable image not reset correctly"
fi
echo "Testing changing image bootable flag to invalid image (this should generate errors)"
error "Bootable image not reset correctly"
fi
echo "Testing changing image bootable flag to invalid image (this should generate errors)"
if ! imagex capture dir dir.wim "myname" "mydesc"; then
error "Failed to capture WIM with specified name and description"
fi
if ! imagex capture dir dir.wim "myname" "mydesc"; then
error "Failed to capture WIM with specified name and description"
fi
error "Integrity table not set correctly on image append"
fi
echo "Testing appending WIM image with no integrity check"
if ! imagex append dir2 dir.wim "newname3"; then
error "Appending WIM image failed"
fi
error "Integrity table not set correctly on image append"
fi
echo "Testing appending WIM image with no integrity check"
if ! imagex append dir2 dir.wim "newname3"; then
error "Appending WIM image failed"
fi
error "WIM does not contain the expected 5 images"
fi
echo "Testing deleting first WIM image"
if ! imagex delete dir.wim 1; then
error "Failed to delete WIM image"
fi
error "WIM does not contain the expected 5 images"
fi
echo "Testing deleting first WIM image"
if ! imagex delete dir.wim 1; then
error "Failed to delete WIM image"
fi
error "WIM image not deleted correctly"
fi
echo "Testing deleting last WIM image"
if ! imagex delete dir.wim 4; then
error "Failed to delete WIM image"
fi
error "WIM image not deleted correctly"
fi
echo "Testing deleting last WIM image"
if ! imagex delete dir.wim 4; then
error "Failed to delete WIM image"
fi
error "WIM image not deleted correctly"
fi
echo "Testing deleting invalid WIM image (this should generate errors)"
if imagex delete dir.wim 4; then
error "Expected to fail to delete non-existent WIM image"
fi
error "WIM image not deleted correctly"
fi
echo "Testing deleting invalid WIM image (this should generate errors)"
if imagex delete dir.wim 4; then
error "Expected to fail to delete non-existent WIM image"
fi
error "Image count changed even though we intentionally failed to delete an image"
fi
echo "Testing deleting all WIM images"
if ! imagex delete dir.wim all; then
error "Failed to delete all images from WIM"
fi
error "Image count changed even though we intentionally failed to delete an image"
fi
echo "Testing deleting all WIM images"
if ! imagex delete dir.wim all; then
error "Failed to delete all images from WIM"
fi
error "Couldn't delete all WIM images correctly"
fi
echo "Testing appending directory to empty WIM and making it bootable"
if ! imagex append dir dir.wim "myname" "mydesc" --check --boot; then
error "Couldn't append named, described, bootable image to empty WIM with integrity check"
fi
error "Couldn't delete all WIM images correctly"
fi
echo "Testing appending directory to empty WIM and making it bootable"
if ! imagex append dir dir.wim "myname" "mydesc" --check --boot; then
error "Couldn't append named, described, bootable image to empty WIM with integrity check"
fi
error "Bootable image not set correctly"
fi
echo "Testing appending non-directory (should generate errors)"
error "Bootable image not set correctly"
fi
echo "Testing appending non-directory (should generate errors)"
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 ! 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
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
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
error "Should not have been able to change boot index of split WIM"
fi
echo "Joining the split WIMs and applying the result"
error "Should not have been able to change boot index of split WIM"
fi
echo "Joining the split WIMs and applying the result"
error "Exporting single image to new WIM wasn't done correctly"
fi
echo "Testing export of single image to existing WIM"
if ! imagex export dir.wim dir2 new.wim; then
error "Failed to export single image to existing WIM"
fi
error "Exporting single image to new WIM wasn't done correctly"
fi
echo "Testing export of single image to existing WIM"
if ! imagex export dir.wim dir2 new.wim; then
error "Failed to export single image to existing WIM"
fi
error "Exporting single image to existing WIM wasn't done correctly"
fi
echo "Testing export of single image to existing WIM using wrong compression type"
error "Exporting single image to existing WIM wasn't done correctly"
fi
echo "Testing export of single image to existing WIM using wrong compression type"
error "Exporting multiple images to new WIM wasn't done correctly"
fi
if ! imagex capture dir2 new.wim newname; then
error "Exporting multiple images to new WIM wasn't done correctly"
fi
if ! imagex capture dir2 new.wim newname; then
# 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.
# 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.
echo "**********************************************************"
echo " Basic imagex tests passed "
echo "**********************************************************"
echo "**********************************************************"
echo " Basic imagex tests passed "
echo "**********************************************************"