X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=tests%2Ftest-imagex-capture_and_apply;h=be789b8a7a2ab7b8f0a88e9c12e8ce42a59d91fe;hb=e0c9e124bb3603ce4677efc137850d17f51b53fc;hp=aa26a6355ca2624ae79ea99a9a2eff44cdab2e2e;hpb=dd836fd8710e130711935003e386de6755eb84ba;p=wimlib diff --git a/tests/test-imagex-capture_and_apply b/tests/test-imagex-capture_and_apply index aa26a635..be789b8a 100755 --- a/tests/test-imagex-capture_and_apply +++ b/tests/test-imagex-capture_and_apply @@ -142,6 +142,20 @@ mkdir in.dir out.dir . $srcdir/tests/common_tests.sh +# Test the data recovery mode +__msg "Testing data recovery mode" +for file in corrupted_file_1.wim corrupted_file_2.wim; do + rm -rf out.dir + wimapply $srcdir/tests/wims/$file 1 out.dir 2>/dev/null && \ + error "Applying $file in default mode unexpectedly succeeded" + rm -rf out.dir + wimapply --recover-data $srcdir/tests/wims/$file 1 out.dir || \ + error "Applying $file in data recovery mode unexpectedly failed" + if [ ! -e out.dir/file ]; then + error "Recovered file not found" + fi +done + # Make sure exclusion list works __msg "Testing default capture configuration file" touch in.dir/hiberfil.sys @@ -152,6 +166,73 @@ if [ -e out.dir/hiberfil.sys -o -e "out.dir/System Volume Information" ]; then error "Files were not excluded from capture as expected" fi +# +# Execute one of the exclusion list test cases in tests/exclusionlists/. +# The file is divided into two sections, separated by a line containing "@@@". +# The first is the capture configuration file. The second is a list of files +# and directories, where the ones that should be excluded are marked with "- ". +# +exclusionlist_test() { + local t_file="$1" + local in_paths_section=false + local path + local include + + __msg "Testing exclusion list: ${t_file##*/}" + + echo "/" > expected_out + sed -n -e '/^@@@/q;p' "$t_file" > config.txt + rm -rf in.dir + mkdir in.dir + cd in.dir + while read -r path; do + path="$(echo "$path" | sed -e 's/[[:space:]]*$//')" + if ! $in_paths_section; then + if [ "$path" = "# case insensitive" ]; then + export WIMLIB_IMAGEX_IGNORE_CASE=1 + elif [ "$path" = "@@@" ]; then + in_paths_section=true + fi + continue + fi + if [ -z "$path" ]; then + continue + fi + include=true + if [ "${path:0:2}" = "- " ]; then + include=false + path="${path:2}" + fi + if [ "${path: -1}" = "/" ]; then + path="${path:0:$(( ${#path} - 1))}" + mkdir "$path" + else + touch "$path" + fi + if $include; then + echo "/$path" >> ../expected_out + fi + done < "$t_file" + cd .. + $in_paths_section || error "malformed test file: $t_file (never found separator)" + wimcapture in.dir test.wim --compress=none --config=config.txt + unset WIMLIB_IMAGEX_IGNORE_CASE + wimdir test.wim 1 > actual_out + diff expected_out actual_out +} + +macOS=false +if [ "$(uname)" = Darwin ]; then + macOS=true +fi +for t_file in "$srcdir/tests/exclusionlists"/*; do + if $macOS && [[ $t_file == */case_*sensitive ]]; then + # Exclude test cases that fail on case-insensitive filesystem + continue + fi + exclusionlist_test "$t_file" +done + # Make sure reparse point fixups are working as expected __msg "Testing --rpfix" rm -r in.dir out.dir