/usr/share/doc/ruby-bdb/examples/log.rb is in ruby-bdb 0.6.6-2build3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #!/usr/bin/ruby
require './clean.rb'
BDB::Env.cleanup("tmp", true)
env = BDB::Env.open "tmp", BDB::CREATE | BDB::INIT_LOG, "thread" => false
lsn = []
100.times do |i|
lsn.push(env.log_put("test toto #{i}"))
end
env.log_flush
i = 0
env.log_each do |l,|
if l != "test toto #{i}"
puts "Error #{i} -- #{l}"
end
i += 1
end
i = 99
env.log_reverse_each do |l,|
if l != "test toto #{i}"
puts "Error #{l}"
end
i -= 1
end
1000.times do
nb = rand(lsn.size)
if lsn[nb].log_get != "test toto #{nb}"
puts "Error #{nb}"
end
end
env.close
BDB::Env.cleanup "tmp"
max_log = 45000
env = BDB::Env.open "tmp", BDB::CREATE | BDB::INIT_LOG, "thread" => false,
"set_lg_bsize" => 10000, "set_lg_max" => max_log
init = "a" * 200
lsn = []
rec = []
500.times do |i|
j = env.log_put "init %d" % i
if (i % 25) == 0
rec.push "init %d" % i
lsn.push j
end
end
env.log_flush
log_file = Dir.glob("tmp/log*")
l = nil
lsn.each_with_index do |ls, i|
if l
if ls <= l
puts "Error compare"
end
end
if ls.log_get != rec[i]
puts "Error retrieve"
end
l = ls
end
lsn.each do |ls|
if !log_file.include? ls.log_file
puts "Error #{ls.log_file}"
end
end
env.log_stat.each do |k, v|
puts "%s\t%s" % [k, v]
end
env.close
BDB::Env.cleanup "tmp"
|