-#!/bin/bash
+#!/usr/bin/env bash
# Test capturing and applying a WIM image in the normal (non-NTFS) capture mode
#
# Also, test if the capture configuration file works correctly.
set -e
-srcdir=${srcdir:-.}
-srcdir=`realpath $srcdir`
cd tests
+srcdir="${srcdir:-.}/.."
+srcdir="$(cd $srcdir; pwd)"
+. "$srcdir/tests/tests-common.sh"
-imagex() {
- echo "imagex $@"
- ../imagex "$@" > /dev/null
-}
-
-imagex_info() {
- echo "imagex info $@"
- ../imagex info "$@"
-}
-
-init() {
- mkdir in.dir out.dir
-}
-
-cleanup() {
- rm -rf in.dir out.dir test*.wim test*.swm
-}
-
-error() {
- echo "****************************************************************"
- echo " Test failure "
- echo $*
- echo "****************************************************************"
- exit 1
-}
-
-wim_ctype() {
- ../imagex info $1 | grep Compression | awk '{print $2}'
-}
+TEST_SUBDIR=tmpdir_test-imagex-capture_and_apply
do_tree_cmp() {
- if ! ./tree-cmp in.dir out.dir; then
+ if ! ../tree-cmp in.dir out.dir; then
if [ -x /usr/bin/tree ]; then
echo "Dumping tree of applied image"
echo "(Note: compression type was $ctype)"
# Can we split the WIM, apply the split WIM, join the split WIM,
# and apply the joined WIM, and get the same results every time?
- if ! imagex split test.wim test.swm 0.01M; then
+ if ! imagex split test.wim test.swm 0.01; then
error "Failed to split WIM"
fi
if ! imagex apply test.swm 1 out.dir --ref "test*.swm" ; then
done
}
-msg() {
+__msg() {
echo "--------------------------------------------------------------------"
- echo "Testing image capture and application of directory containing $1"
+ echo $1
echo "--------------------------------------------------------------------"
}
-cleanup
-init
+msg() {
+ __msg "Testing image capture and application of directory containing $1"
+}
+
+default_cleanup
+mkdir $TEST_SUBDIR
+cd $TEST_SUBDIR
+mkdir in.dir out.dir
-. common_tests.sh
+. $srcdir/tests/common_tests.sh
# Make sure exclusion list works
-msg "Testing default capture configuration file"
+__msg "Testing default capture configuration file"
touch in.dir/hiberfil.sys
mkdir -p "in.dir/System Volume Information/subdir"
imagex capture in.dir test.wim
if [ -e out.dir/hiberfil.sys -o -e "out.dir/System Volume Information" ]; then
error "Files were not excluded from capture as expected"
fi
-rm -rf out.dir/* in.dir/*
-
-cleanup
echo "**********************************************************"
echo " imagex capture/apply tests passed "
echo "**********************************************************"
+
+cd ..
+default_cleanup