|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +### Constants |
| 4 | +c_valgrind_min=1 |
| 5 | +sampledir=${scriptdir}/sample-backup |
| 6 | + |
| 7 | +check_ie() { |
| 8 | + name=$1 |
| 9 | + args=$2 |
| 10 | + |
| 11 | + # Set up variables. |
| 12 | + out_name=${s_basename}-${name}.txt |
| 13 | + good_name=${scriptdir}/07-selecting-files-${name}.good |
| 14 | + |
| 15 | + # Run command. We need to `sort` because the OS doesn't necessarily |
| 16 | + # process files in alphabetical order. Don't quote the ${args}. |
| 17 | + setup_check "check ${name}" |
| 18 | + ${c_valgrind_cmd} ./tarsnap --no-default-config \ |
| 19 | + -c --dry-run -v \ |
| 20 | + -C "${sampledir}" \ |
| 21 | + ${args} \ |
| 22 | + . 2>&1 | LC_ALL=C sort > "${out_name}" |
| 23 | + echo $? > "${c_exitfile}" |
| 24 | + |
| 25 | + # Check against expected output. |
| 26 | + setup_check "check ${name} output" |
| 27 | + cmp "${good_name}" "${out_name}" |
| 28 | + echo $? > "${c_exitfile}" |
| 29 | + |
| 30 | +} |
| 31 | + |
| 32 | +check_nT() { |
| 33 | + name=$1 |
| 34 | + cmd=$2 |
| 35 | + |
| 36 | + # Set up variables. |
| 37 | + out_name=${s_basename}-nT-${name}.txt |
| 38 | + good_name=${scriptdir}/07-selecting-files-nT-${name}.good |
| 39 | + filelist=${s_basename}-filelist-${name}.txt |
| 40 | + |
| 41 | + # Create filelist. Don't quote ${cmd}. |
| 42 | + (cd "${sampledir}" && eval ${cmd} | sort > "${filelist}") |
| 43 | + |
| 44 | + # Run command. We need to `sort` because the OS doesn't necessarily |
| 45 | + # process files in alphabetical order. |
| 46 | + setup_check "check ${name}" |
| 47 | + ( |
| 48 | + cd "${sampledir}" && |
| 49 | + ${c_valgrind_cmd} \ |
| 50 | + "${out}"/../tarsnap --no-default-config \ |
| 51 | + -c --dry-run -v \ |
| 52 | + -C "${sampledir}" \ |
| 53 | + -n -T "${filelist}" \ |
| 54 | + 2>&1 | LC_ALL=C sort > "${out_name}" |
| 55 | + echo $? > "${c_exitfile}" |
| 56 | + ) |
| 57 | + |
| 58 | + # Check against expected output. |
| 59 | + setup_check "check ${name} output" |
| 60 | + cmp "${good_name}" "${out_name}" |
| 61 | + echo $? > "${c_exitfile}" |
| 62 | + |
| 63 | +} |
| 64 | + |
| 65 | +scenario_cmd() { |
| 66 | + # Run a baseline, then check include, exclude, and both. |
| 67 | + # For --include, we need "." otherwise it won't match anything. |
| 68 | + check_ie "baseline" "" |
| 69 | + check_ie "include" "--include . --include dir1" |
| 70 | + check_ie "exclude" "--exclude dir1" |
| 71 | + check_ie "include-exclude" "--include . --include dir1 --exclude b" |
| 72 | + |
| 73 | + # Check passing a list of files via -n -T. |
| 74 | + check_nT "full" "find ." |
| 75 | + check_nT "partial" "find . | grep -v dir1" |
| 76 | +} |
0 commit comments