| 1 |
#!/bin/sh |
| 2 |
set -e |
| 3 |
|
| 4 |
DB=$(mktemp).db |
| 5 |
DATA=debian/tests/data |
| 6 |
|
| 7 |
echo "testing DB_File reading..." |
| 8 |
|
| 9 |
msg="current DB file read OK" |
| 10 |
|
| 11 |
printf "%s\n%s\n" foo "$msg" | db_load -T -t hash $DB |
| 12 |
|
| 13 |
# also test with DB files created on jessie and stretch |
| 14 |
for db in $DB $DATA/*.db; do |
| 15 |
perl -MDB_File -le 'tie %h, q(DB_File), shift, O_RDONLY, 0640, $DB_HASH or die "opening DB file failed: $!"; die "contents of DB file not found?" if !exists $h{foo}; print $h{foo}' $db | grep OK |
| 16 |
done |
| 17 |
|
| 18 |
rm $DB |
| 19 |
|
| 20 |
echo "testing DB_File writing..." |
| 21 |
|
| 22 |
msg="DB file written OK" |
| 23 |
|
| 24 |
DB=$(mktemp).db |
| 25 |
perl -MDB_File -e 'tie %h, q(DB_File), shift, O_WRONLY | O_CREAT, 0640, $DB_BTREE or die "opening DB file failed: $!"; $h{foo} = shift; untie %h' $DB "$msg" |
| 26 |
|
| 27 |
db_dump -p $DB | grep OK |
| 28 |
|
| 29 |
rm $DB |