FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor


 
 
LinkBack Thread Tools
 
Old 06-30-2011, 06:07 PM
Dave Reisner
 
Default repo-add test harness

The attached script is what I used for testing my repo-add changes, and
worked out rather well. It's extremely primitive, but it does a bit of a
smoke test again bash3 and bash4, which is important.

I imagine that the next step might be to take a variety of .PKGINFO
files and provide those as inputs for writing DB entries. This is
hopefuly the next thing on my plate after I get some more work done on
the download code.

d

#!/bin/bash

cachedir=/var/cache/pacman/pkg

test_path() {
local -a packages=("$cachedir"/*.pkg.tar.xz)
printf $'e[1;33m::e[0m Testing path: `%s'
' "$1"
./scripts/repo-add "$1" "${packages[0]}"
}

paths=(foo.db.tar.gz::0
../foo.db.tar.gz::0
/foo.db.tar.gz::1
/tmp/foo.files.tar.gz::0
/mnt/lol/foo.files.tar.gz::1)

if [[ ! -f ./scripts/repo-add ]]; then
printf './scripts/repo-add not found!
'
exit 1
fi

# path check regression testing
for path in "${paths[@]}"; do
res=${path##*::}
repo=${path%%::*}

test_path "$repo"
ret=$?
printf 'got %d, expected %d: ' $ret $res
if (( ret == res )); then
printf "e[1;32mPASSe[0m
"
(( ++success ))
else
printf "e[1;31mFAILe[0m
"
(( ++failure ))
continue
fi

rm -f "$repo" "${repo%.tar.gz}"
done

# bash3 v. bash4
printf 'comparing bash3 repo tarball to bash4
'
if type -P bash3 &>/dev/null; then
{
bash3 ./scripts/repo-add bash3.db.tar "$cachedir"/a*.pkg.tar.xz
bash ./scripts/repo-add bash4.db.tar "$cachedir"/a*.pkg.tar.xz
} &>/dev/null
else
printf 'bash3 not found -- skipping test
'
fi

diff -u <(bsdtar xOf bash3.db.tar) <(bsdtar xOf bash4.db.tar)
res=0
ret=$?
printf 'got %d, expected %d: ' $ret $res
if (( ret == res )); then
printf "e[1;32mPASSe[0m
"
(( ++success ))
else
printf "e[1;31mFAILe[0m
"
(( ++failure ))
fi

rm bash?.db*

echo
if (( failure )); then
printf '%s tests failed
' "$failure"
else
printf 'all tests passed!
'
fi
 

Thread Tools




All times are GMT. The time now is 05:56 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org