Permalink
Browse files

make tests work on FreeBSD

  • Loading branch information...
phreaker0 committed Jan 8, 2019
1 parent 582ab5b commit ea482ce7b6d7f662701874c2ef889054831f36d5
@@ -39,7 +39,7 @@ function cleanUp {
trap cleanUp EXIT

while [ $timestamp -le $END ]; do
date --utc --set @$timestamp; date; "${SANOID}" --cron --verbose
setdate $timestamp; date; "${SANOID}" --cron --verbose
timestamp=$((timestamp+3600))
done

@@ -42,7 +42,7 @@ function cleanUp {
trap cleanUp EXIT

while [ $timestamp -le $END ]; do
date --utc --set @$timestamp; date; "${SANOID}" --cron --verbose
setdate $timestamp; date; "${SANOID}" --cron --verbose
timestamp=$((timestamp+900))
done

@@ -1,5 +1,7 @@
#!/bin/bash

unamestr="$(uname)"

function setup {
export LANG=C
export LANGUAGE=C
@@ -90,7 +92,7 @@ function verifySnapshotList {
message="${message}monthly snapshot count is wrong: ${monthly_count}\n"
fi

checksum=$(sha256sum "${RESULT}" | cut -d' ' -f1)
checksum=$(shasum -a 256 "${RESULT}" | cut -d' ' -f1)
if [ "${checksum}" != "${CHECKSUM}" ]; then
failed=1
message="${message}result checksum mismatch\n"
@@ -105,3 +107,13 @@ function verifySnapshotList {

exit 1
}

function setdate {
TIMESTAMP="$1"

if [ "$unamestr" == 'FreeBSD' ]; then
date -u -f '%s' "${TIMESTAMP}"
else
date --utc --set "@${TIMESTAMP}"
fi
}
@@ -15,7 +15,7 @@ for test in */; do

echo -n "Running test ${testName} ... "
cd "${test}"
echo | bash run.sh > "${LOGFILE}" 2>&1
echo -n y | bash run.sh > "${LOGFILE}" 2>&1

if [ $? -eq 0 ]; then
echo "[PASS]"
@@ -46,8 +46,8 @@ zfs snapshot "${POOL_NAME}"/src@snap5
../../../syncoid --debug --compress=none "${POOL_NAME}"/src "${POOL_NAME}"/dst || exit 1

# verify
output=$(zfs list -t snapshot -r "${POOL_NAME}" -H -o name)
checksum=$(echo "${output}" | grep -v syncoid_ | sha256sum)
output=$(zfs list -t snapshot -r -H -o name "${POOL_NAME}")
checksum=$(echo "${output}" | grep -v syncoid_ | shasum -a 256)

if [ "${checksum}" != "${TARGET_CHECKSUM}" ]; then
exit 1
@@ -46,8 +46,8 @@ zfs snapshot "${POOL_NAME}"/src@snap5
../../../syncoid --no-stream --no-sync-snap --debug --compress=none "${POOL_NAME}"/src "${POOL_NAME}"/dst || exit 1

# verify
output=$(zfs list -t snapshot -r "${POOL_NAME}" -H -o name)
checksum=$(echo "${output}" | sha256sum)
output=$(zfs list -t snapshot -r -H -o name "${POOL_NAME}")
checksum=$(echo "${output}" | shasum -a 256)

if [ "${checksum}" != "${TARGET_CHECKSUM}" ]; then
exit 1
@@ -37,8 +37,8 @@ sleep 1
../../../syncoid -r --force-delete --debug --compress=none "${POOL_NAME}"/src "${POOL_NAME}"/dst || exit 1

# verify
output=$(zfs list -t snapshot -r "${POOL_NAME}" -H -o name | sed 's/@syncoid_.*$'/@syncoid_/)
checksum=$(echo "${output}" | sha256sum)
output=$(zfs list -t snapshot -r -H -o name "${POOL_NAME}" | sed 's/@syncoid_.*$'/@syncoid_/)
checksum=$(echo "${output}" | shasum -a 256)

if [ "${checksum}" != "${TARGET_CHECKSUM}" ]; then
exit 1

0 comments on commit ea482ce

Please sign in to comment.