File: db

package info (click to toggle)
perl 5.40.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 126,156 kB
  • sloc: ansic: 668,539; perl: 525,522; sh: 72,038; pascal: 6,925; xml: 2,428; yacc: 1,410; makefile: 1,191; cpp: 208; lisp: 1
file content (29 lines) | stat: -rwxr-xr-x 747 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
set -e

DB=$(mktemp).db
DATA=debian/tests/data

echo "testing DB_File reading..."

msg="current DB file read OK"

printf "%s\n%s\n" foo "$msg" | db_load -T -t hash $DB

# also test with DB files created on jessie and stretch
for db in $DB $DATA/*.db; do
    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
done

rm $DB

echo "testing DB_File writing..."

msg="DB file written OK"

DB=$(mktemp).db
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"

db_dump -p $DB | grep OK

rm $DB