NUM_ERRS=0 if [ -z "$CLIENTBIN" ]; then echo "Meld client is not set" exit 1 fi TEST_BIN=/tmp/meld_bin TEST_CONF=/tmp/meld_test.conf TEST_CONF_BAD=/tmp/meld_test.conf.bad TEST_CONF_DIR=/tmp/meld_test_dir # Cleanup Functionality to reset state cleanup() { rm -rf "$TEST_BIN" &> /dev/null rm "$TEST_CONF" &> /dev/null rm -rf "$TEST_CONF_DIR" &> /dev/null } setup() { $CLIENTBIN $TEST_BIN init &> /dev/null || return 1 echo "opt1=false" > $TEST_CONF mkdir $TEST_CONF_DIR cp $TEST_CONF $TEST_CONF_DIR return 0 } # Test config push to bad bin push_config_bad_bin() { $CLIENTBIN $TEST_BIN/BAD push $TEST_CONF&> /dev/null && return 0 OWNER=$(printf '%s' $TEST_CONF | sha512sum | cut -d ' ' -f1) # Check new dir in blobs created if [ -d "$TEST_BIN/BAD/blobs/$OWNER" ]; then echo "This dir should not exist" >&2 return 1 fi return 1 } # Test config push to bad bin push_config_bad_config() { rm $TEST_CONF $CLIENTBIN $TEST_BIN push $TEST_CONF &> /dev/null && return 0 OWNER=$(printf '%s' $TEST_CONF | sha512sum | cut -d ' ' -f1) # Check new dir in blobs created if [ -f "$TEST_BIN/BAD/blobs/$OWNER/1" ]; then echo "This file should not exist" >&2 return 1 fi return 1 } # Test Setup cleanup setup || exit 1 # Tested Functions push_config_bad_bin || NUM_ERRS=$(( NUM_ERRS + $? )) push_config_bad_config || NUM_ERRS=$(( NUM_ERRS + $? )) # Test Teardown cleanup if [ $NUM_ERRS -eq 0 ]; then echo "[+] SUCCESS" else echo "[-] FAILURE" >&2 fi exit $NUM_ERRS