Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>
- Loading branch information
Denis Zalevskiy
committed
Jul 20, 2015
1 parent
a759a24
commit 7c3ed09
Showing
5 changed files
with
123 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
|
||
initial_dir=$(pwd) | ||
|
||
src=$(dirname $0) | ||
src=$(cd $src;pwd) | ||
lib_dir=$src | ||
if [ "x$VAULT_LIB_DIR" != "x" ]; then | ||
if ! [ -d $VAULT_LIB_DIR ]; then | ||
echo "No such dir $VAULT_LIB_DIR" | ||
exit 1 | ||
fi | ||
lib_dir="$VAULT_LIB_DIR" | ||
elif [ -d "$src/../tools" ]; then | ||
export VAULT_LIB_DIR=$src/../tools | ||
lib_dir="$VAULT_LIB_DIR" | ||
fi | ||
source $lib_dir/vault-misc | ||
|
||
cur_test="Begin" | ||
function NEXT_TEST { | ||
trace $@ | ||
cur_test=$1 | ||
} | ||
|
||
function test_failed { | ||
echo 'stdout {' >&2; | ||
cat $test_out >&2; | ||
echo '} stderr {' >&2; | ||
cat $test_err >&2; | ||
echo '}' >&2; | ||
error $1 "Test: $cur_test." ${@:2} | ||
} | ||
|
||
function check_is_vault_storage { | ||
d=$1 | ||
[ -d $d ] || test_failed 7 "Not a dir $d" | ||
[ -f $d/config ] || test_failed 7 "Not a git storage" | ||
[ -d $d/blobs ] || test_failed 7 "Not a vault storage $d?" | ||
} | ||
|
||
|
||
function create_test_dir { | ||
test_dir=$(mktemp -t -d vault.XXXXXXXXXX) | ||
test_out=$test_dir/stdout.txt | ||
test_err=$test_dir/stderr.txt | ||
touch $test_out | ||
touch $test_err | ||
cd $test_dir || test_failed 1 "Can't enter $test_dir" | ||
normal_cleanup="$normal_cleanup; echo 'OK' 1>&2; cd $initial_dir; rm -rf $test_dir" | ||
failed_cleanup="warn 'Dir $test_dir is left';$failed_cleanup;" | ||
} | ||
|
||
test_home= | ||
storage= | ||
|
||
function create_test_dirs { | ||
ensure_param_count_exit_usage $# 1 "create_test_dirs prefix" | ||
prefix=$1 | ||
test_home=$test_dir/$prefix/home | ||
storage=$test_dir/$prefix/vault | ||
mkdir -p $test_home || test_failed 1 "Can't create $test_home" | ||
mkdir -p $storage || test_failed 1 "Can't create $storage" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,6 @@ | ||
#!/bin/bash | ||
|
||
src=`dirname $0` | ||
src=`cd $src;pwd` | ||
source $src/vault-misc $src | ||
|
||
root=$(git rev-parse --show-toplevel) | ||
rc=$? | ||
|
||
if [ $rc -ne 0 ] || [ "x$root" == "x" ]; then | ||
error 1 "Not a git `pwd`" | ||
fi | ||
|
||
if ! [ -d "$root" ]; then | ||
error 2 "Wrong location, not a git repo? `pwd`" | ||
fi | ||
|
||
if [ -f $root/.vault ]; then | ||
echo $root | ||
else | ||
if [ root == "`dirname /`" ]; then | ||
error 3 "Reached /, vault is not found" | ||
fi | ||
root=`dirname $root` | ||
res=$(cd $root && git vault-root) || exit 34 | ||
echo $res | ||
fi | ||
src=$(dirname $0) | ||
src=$(cd $src;pwd) | ||
source $src/vault-misc | ||
get_root $(pwd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters