|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +name=$(basename $0) |
| 5 | +root="$(dirname $(dirname $(dirname $0)))" |
| 6 | +gomtree=$(go run ${root}/test/realpath/main.go ${root}/gomtree) |
| 7 | +t=$(mktemp -d -t go-mtree.XXXXXX) |
| 8 | + |
| 9 | +echo "[${name}] Running in ${t}" |
| 10 | +# This test is for basic running check of manifest, and check against tar and file system |
| 11 | +# |
| 12 | + |
| 13 | +pushd ${root} |
| 14 | + |
| 15 | +git archive --format=tar -o "${t}/${name}.tar" HEAD^{tree} |
| 16 | + |
| 17 | +prev_umask=$(umask) |
| 18 | +umask 0 # this is so the tar command can set the mode's properly |
| 19 | +mkdir -p ${t}/extract |
| 20 | +tar -C ${t}/extract/ -xf "${t}/${name}.tar" |
| 21 | +umask ${prev_umask} |
| 22 | + |
| 23 | +# create manifest from tar |
| 24 | +${gomtree} validate -K sha256digest -c -T "${t}/${name}.tar" > "${t}/${name}.mtree" |
| 25 | + |
| 26 | +# check tar-manifest against the tar |
| 27 | +${gomtree} validate -f ${t}/${name}.mtree -T "${t}/${name}.tar" |
| 28 | + |
| 29 | +# check tar-manifest against the filesystem |
| 30 | +# git archive makes the uid/gid as 0, so don't check them for this test |
| 31 | +${gomtree} validate -k size,sha256digest,mode,type -f "${t}/${name}.mtree" -p ${t}/extract/ |
| 32 | + |
| 33 | +# create a manifest from filesystem |
| 34 | +${gomtree} validate -K sha256digest -c -p "${t}/extract/" > "${t}/${name}.mtree" |
| 35 | + |
| 36 | +# check filesystem-manifest against the filesystem |
| 37 | +${gomtree} validate -f "${t}/${name}.mtree" -p "${t}/extract/" |
| 38 | + |
| 39 | +# check filesystem-manifest against the tar |
| 40 | +# git archive makes the uid/gid as 0, so don't check them for this test |
| 41 | +${gomtree} validate -k size,sha256digest,mode,type -f "${t}/${name}.mtree" -T "${t}/${name}.tar" |
| 42 | + |
| 43 | +popd |
| 44 | +rm -rf ${t} |
0 commit comments