Artifact
df18637493bcc06de1e8ad538bde4a65f2572f8c :
Executable file
tests/tests/sqlitespeed/runscript.rb
— part of check-in
[ae6dbecf17]
at
2011-05-01 23:05:22
on branch trunk
— Importing 1.0.1 version of megatest, (nb// work in progress, please wait for next release)
(user:
matt
size: 1040)
0000: 23 21 20 2f 75 73 72 2f 62 69 6e 2f 72 75 62 79 #! /usr/bin/ruby
0010: 0a 0a 72 65 71 75 69 72 65 20 22 23 7b 45 4e 56 ..require "#{ENV
0020: 5b 27 4d 54 5f 52 55 4e 5f 41 52 45 41 5f 48 4f ['MT_RUN_AREA_HO
0030: 4d 45 27 5d 7d 2f 73 75 70 70 6f 72 74 66 69 6c ME']}/supportfil
0040: 65 73 2f 72 75 62 79 2f 6c 69 62 72 75 6e 73 63 es/ruby/librunsc
0050: 72 69 70 74 2e 72 62 22 0a 0a 23 20 72 75 6e 5f ript.rb"..# run_
0060: 72 65 63 6f 72 64 28 73 74 65 70 6e 61 6d 65 2c record(stepname,
0070: 20 63 6d 64 29 20 2d 20 77 69 6c 6c 20 72 65 63 cmd) - will rec
0080: 6f 72 64 20 69 6e 20 64 62 20 69 66 20 65 78 69 ord in db if exi
0090: 74 20 63 6f 64 65 20 6f 66 20 73 63 72 69 70 74 t code of script
00a0: 20 77 61 73 20 7a 65 72 6f 20 6f 72 20 6e 6f 74 was zero or not
00b0: 0a 72 75 6e 5f 61 6e 64 5f 72 65 63 6f 72 64 28 .run_and_record(
00c0: 27 63 72 65 61 74 65 20 64 62 27 2c 22 73 71 6c 'create db',"sql
00d0: 69 74 65 33 20 74 65 73 74 69 6e 67 2e 64 62 20 ite3 testing.db
00e0: 3c 3c 20 45 4f 46 5c 6e 63 72 65 61 74 65 20 74 << EOF\ncreate t
00f0: 61 62 6c 65 20 69 66 20 6e 6f 74 20 65 78 69 73 able if not exis
0100: 74 73 20 62 6c 61 68 28 69 64 20 49 4e 54 45 47 ts blah(id INTEG
0110: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 6e ER PRIMARY KEY,n
0120: 61 6d 65 20 54 45 58 54 29 3b 5c 6e 2e 71 5c 6e ame TEXT);\n.q\n
0130: 45 4f 46 22 2c 22 22 29 0a 0a 23 20 66 69 6c 65 EOF","")..# file
0140: 5f 73 69 7a 65 5f 63 68 65 63 6b 65 72 28 73 74 _size_checker(st
0150: 65 70 6e 61 6d 65 2c 20 66 69 6c 65 6e 61 6d 65 epname, filename
0160: 2c 20 6d 69 6e 73 69 7a 65 2c 20 6d 61 78 73 69 , minsize, maxsi
0170: 7a 65 29 20 2d 20 6e 65 67 61 74 69 76 65 20 6d ze) - negative m
0180: 65 61 6e 73 20 69 67 6e 6f 72 65 0a 23 20 66 69 eans ignore.# fi
0190: 6c 65 5f 73 69 7a 65 5f 63 68 65 63 6b 65 72 28 le_size_checker(
01a0: 27 63 72 65 61 74 65 20 64 62 27 2c 27 74 65 73 'create db','tes
01b0: 74 69 6e 67 2e 64 62 27 2c 31 30 30 2c 2d 31 29 ting.db',100,-1)
01c0: 0a 0a 6e 75 6d 5f 72 65 63 6f 72 64 73 3d 72 61 ..num_records=ra
01d0: 6e 64 28 36 30 29 20 23 20 30 30 30 30 0a 72 65 nd(60) # 0000.re
01e0: 63 6f 72 64 5f 73 74 65 70 28 22 61 64 64 20 23 cord_step("add #
01f0: 7b 6e 75 6d 5f 72 65 63 6f 72 64 73 7d 22 2c 22 {num_records}","
0200: 73 74 61 72 74 22 2c 22 6e 2f 61 22 29 0a 73 74 start","n/a").st
0210: 61 74 75 73 3d 66 61 6c 73 65 0a 28 30 2e 2e 6e atus=false.(0..n
0220: 75 6d 5f 72 65 63 6f 72 64 73 29 2e 65 61 63 68 um_records).each
0230: 20 64 6f 20 7c 69 7c 0a 20 20 72 61 6e 64 73 74 do |i|. randst
0240: 72 69 6e 67 3d 22 61 3b 6c 73 6b 64 66 6a 61 3b ring="a;lskdfja;
0250: 73 64 66 6a 3b 61 6c 73 64 66 6a 3b 61 73 6c 66 sdfj;alsdfj;aslf
0260: 64 6a 3b 61 6c 73 66 6a 61 3b 6c 73 66 64 6a 3b dj;alsfja;lsfdj;
0270: 61 6c 73 66 6a 61 3b 6c 73 6a 66 64 3b 6c 61 73 alsfja;lsjfd;las
0280: 66 6a 6c 3b 61 73 64 66 6a 61 3b 73 6c 66 6a 3b fjl;asdfja;slfj;
0290: 61 6c 73 6a 66 3b 61 73 6c 6a 66 3b 61 6c 73 6a alsjf;asljf;alsj
02a0: 66 3b 6c 61 73 64 6a 66 3b 6c 61 73 6a 66 3b 6c f;lasdjf;lasjf;l
02b0: 61 73 6a 66 3b 61 6c 73 6a 66 3b 6c 61 73 68 66 asjf;alsjf;lashf
02c0: 6c 6b 61 73 68 66 6c 6b 65 72 68 66 6c 6b 64 73 lkashflkerhflkds
02d0: 76 6e 6c 61 73 6c 64 68 6c 66 61 6c 64 66 22 0a vnlasldhlfaldf".
02e0: 20 20 23 20 73 74 61 74 75 73 3d 73 79 73 74 65 # status=syste
02f0: 6d 20 22 73 71 6c 69 74 65 33 20 74 65 73 74 69 m "sqlite3 testi
0300: 6e 67 2e 64 62 20 5c 22 69 6e 73 65 72 74 20 69 ng.db \"insert i
0310: 6e 74 6f 20 62 6c 61 68 20 28 6e 61 6d 65 29 20 nto blah (name)
0320: 76 61 6c 75 65 73 20 28 27 23 7b 72 61 6e 64 73 values ('#{rands
0330: 74 72 69 6e 67 7d 27 29 3b 5c 22 22 0a 20 20 73 tring}');\"". s
0340: 79 73 74 65 6d 20 22 6d 65 67 61 74 65 73 74 20 ystem "megatest
0350: 2d 73 74 65 70 20 74 65 73 74 69 6e 67 20 3a 73 -step testing :s
0360: 74 61 74 65 20 77 72 6f 74 65 5f 6a 75 6e 6b 20 tate wrote_junk
0370: 3a 73 74 61 74 75 73 20 23 7b 6e 75 6d 5f 72 65 :status #{num_re
0380: 63 6f 72 64 73 7d 22 0a 20 20 73 6c 65 65 70 28 cords}". sleep(
0390: 31 29 0a 20 20 70 75 74 73 20 22 69 3d 23 7b 69 1). puts "i=#{i
03a0: 7d 22 0a 65 6e 64 0a 69 66 20 73 74 61 74 75 73 }".end.if status
03b0: 3d 3d 30 0a 20 20 73 74 61 74 75 73 3d 27 70 61 ==0. status='pa
03c0: 73 73 27 0a 65 6c 73 65 0a 20 20 73 74 61 74 75 ss'.else. statu
03d0: 73 3d 27 66 61 69 6c 27 0a 65 6e 64 0a 72 65 63 s='fail'.end.rec
03e0: 6f 72 64 5f 73 74 65 70 28 22 61 64 64 20 23 7b ord_step("add #{
03f0: 6e 75 6d 5f 72 65 63 6f 72 64 73 7d 22 2c 22 65 num_records}","e
0400: 6e 64 22 2c 73 74 61 74 75 73 29 0a 0a 0a 0a 0a nd",status).....