File: test.rb

package info (click to toggle)
ruby-kyotocabinet 1.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 496 kB
  • sloc: cpp: 3,501; ruby: 1,580; sh: 15; makefile: 2
file content (68 lines) | stat: -rwxr-xr-x 2,142 bytes parent folder | download
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
#! /usr/bin/ruby

require 'rbconfig'

confs = [
         [ ":", 10000 ],
         [ "*", 10000 ],
         [ "%", 10000 ],
         [ "casket.kch", 10000 ],
         [ "casket.kct", 10000 ],
         [ "casket.kcd", 1000 ],
         [ "casket.kcf", 10000 ],
        ]
formats = [
            "kctest.rb order '%s' '%d'",
            "kctest.rb order -rnd '%s' '%d'",
            "kctest.rb order -etc '%s' '%d'",
            "kctest.rb order -rnd -etc '%s' '%d'",
            "kctest.rb order -th 4 '%s' '%d'",
            "kctest.rb order -th 4 -rnd '%s' '%d'",
            "kctest.rb order -th 4 -etc '%s' '%d'",
            "kctest.rb order -th 4 -rnd -etc '%s' '%d'",
            "kctest.rb order -cc -th 4 -rnd -etc '%s' '%d'",
            "kctest.rb wicked '%s' '%d'",
            "kctest.rb wicked -it 4 '%s' '%d'",
            "kctest.rb wicked -th 4 '%s' '%d'",
            "kctest.rb wicked -th 4 -it 4 '%s' '%d'",
            "kctest.rb wicked -cc -th 4 -it 4 '%s' '%d'",
            "kctest.rb misc '%s'",
           ]

# For Debian: gem2deb builds both 1.8 and 1.9 in succession, before testing.
# This leads to this file to being the wrong version, causing segfaults.
# Check for that, so that we call force fall back to gem2deb installed .so files
if ("ruby" + /libruby-?(\d+.\d+(.\d+)?)\.so/.match(`ldd kyotocabinet.so`).to_a[1].to_s != RbConfig::CONFIG['ruby_install_name'])
  begin
    File.unlink "kyotocabinet.so"
  rescue Errno::ENOENT
  end
end if File.exist? "kyotocabinet.so"

system("rm -rf casket*")
rubycmd = RbConfig::CONFIG["bindir"] + "/" + RbConfig::CONFIG['ruby_install_name']
all = confs.size * formats.size
cnt = 0
oknum = 0
confs.each do |conf|
  path = conf[0]
  rnum = conf[1]
  formats.each do |format|
    cnt += 1
    command = sprintf(format, path, rnum)
    printf("%03d/%03d: %s: ", cnt, all, command)
    rv = system("#{rubycmd} -I. #{command} >/dev/null")
    if rv
      oknum += 1
      printf("ok\n")
    else
      printf("failed\n")
    end
  end
end
system("rm -rf casket*")
if oknum == cnt
  printf("%d tests were all ok\n", cnt)
else
  printf("%d/%d tests failed\n", cnt - oknum, cnt)
end