| 1 |
#!/bin/sh |
| 2 |
set -e |
| 3 |
|
| 4 |
ARCH=$(dpkg --print-architecture) |
| 5 |
DB=$(mktemp).gdbm |
| 6 |
DATA=debian/tests/data |
| 7 |
|
| 8 |
[ -d $DATA/$ARCH ] || exit 77 |
| 9 |
|
| 10 |
echo "testing GDBM reading..." |
| 11 |
|
| 12 |
msg="GDBM file read OK" |
| 13 |
|
| 14 |
printf 'open %s\nstore %s "%s"\n' $DB foo "$msg" | gdbmtool -f - |
| 15 |
|
| 16 |
for db in $DB $DATA/$ARCH/*.gdbm; do |
| 17 |
perl -MGDBM_File -le 'tie %h, q(GDBM_File), shift, &GDBM_READER, 0640 or die "opening GDBM file failed: $!"; die "contents of GDBM file not found?" if !exists $h{foo}; print $h{foo}' $db | grep OK |
| 18 |
done |
| 19 |
|
| 20 |
rm $DB |
| 21 |
|
| 22 |
echo "testing GDBM writing..." |
| 23 |
|
| 24 |
msg="GDBM file written OK" |
| 25 |
|
| 26 |
DB=$(mktemp).db |
| 27 |
|
| 28 |
perl -MGDBM_File -e 'tie %h, q(GDBM_File), shift, &GDBM_WRCREAT, 0640 or die "opening GDBM file failed: $!"; $h{foo} = shift; untie %h' $DB "$msg" |
| 29 |
|
| 30 |
printf 'open %s\nfetch %s\n' $DB foo | gdbmtool -f - | grep "$msg" |
| 31 |
|
| 32 |
rm $DB |