]> git.cryptolib.org Git - arm-crypto-lib.git/blob - host/bigint_test.rb
Adding Khazad
[arm-crypto-lib.git] / host / bigint_test.rb
1 #!/usr/bin/ruby
2 # bigint_test.rb
3 =begin
4     This file is part of the ARM-Crypto-Lib.
5     Copyright (C) 2008, 2009  Daniel Otte (daniel.otte@rub.de)
6
7     This program is free software: you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation, either version 3 of the License, or
10     (at your option) any later version.
11
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 =end
20
21 $debug = true
22 $debug = false
23 require 'rubygems'
24 require 'serialport'
25 require 'getopt/std'
26 require 'ftools'
27 require 'date'
28 $buffer_size = 0
29 $conffile_check = Hash.new
30 $conffile_check.default = 0
31
32 ################################################################################
33 # readconfigfile                                                               #
34 ################################################################################
35
36 def readconfigfile(fname, conf)
37   return conf if $conffile_check[fname]==1
38   $conffile_check[fname]=1
39   section = "default"
40   if not File.exists?(fname)
41     return conf
42   end
43   file = File.open(fname, "r")
44   until file.eof
45     line = file.gets()
46         next if /[\s]*#/.match(line)
47         if m=/\[[\s]*([^\s]*)[\s]*\]/.match(line)
48           section=m[1]
49           conf[m[1]] = Hash.new
50           next
51         end
52         next if not /=/.match(line)
53         m=/[\s]*([^\s]*)[\s]*=[\s]*([^\s]*)/.match(line)
54         if m[1]=="include"
55           Dir.glob(m[2]){ |fn| conf = readconfigfile(fn, conf) }
56         else
57           conf[section][m[1]] = m[2]
58         end
59   end
60   file.close()
61   return conf
62 end
63
64 ################################################################################
65 # expmod                                                                       #
66 ################################################################################
67
68 def expmod(base, power, mod)
69   result = 1
70   while power > 0
71     result = (result * base) % mod if power & 1 == 1
72     base = (base * base) % mod
73     power >>= 1;
74   end
75   return result
76 end
77
78 ################################################################################
79 # gcdext                                                                 #
80 ################################################################################
81
82 def gcdext(x,y)
83   g=1
84   while(x&1==0 && y&1==0) do
85     x>>=1
86     y>>=1
87     g<<=1
88   end
89   u=x; v=y; a=1; b=0; c=0; d=1
90   begin
91     while(u&1==0) do
92       if(a%2==1 || b%2==1)
93         a += y
94         b -= x
95       end
96       u>>=1; a>>=1; b>>=1
97     end
98     while(v&1==0) do
99       if(c%2==1 || d%2==1)
100         c += y
101         d -= x
102       end
103       v>>=1; c>>=1; d>>=1;
104     end
105     if(u>=v)
106       u -= v; a-=c; b-=d
107     else
108       v -= u; c-=a; d-=b
109     end
110   end while(u!=0)
111   return[g*v, c, d]
112 end
113
114 ################################################################################
115 # reset_system                                                                 #
116 ################################################################################
117
118 def reset_system
119   $sp.print("exit\r")
120   sleep 0.1
121   $sp.print("exit\r")
122   sleep 0.1
123 end
124
125 ################################################################################
126 # init_system                                                                  #
127 ################################################################################
128
129 def init_system(test_prog)
130   $sp.print("echo off \r")
131   print("DBG i: " + "echo off \r"+"\n") if $debug
132   sleep 0.1
133   $sp.print("#{test_prog}\r")
134   print("DBG i: " + "#{test_prog} \r"+"\n") if $debug
135   sleep 1
136 end
137
138
139 ################################################################################
140 # screen_progress                                                              #
141 ################################################################################
142 def screen_progress(v)
143   if $linepos==0
144     printf("\n%5d [%04d]: ", $testno, $size)
145   end
146   putc((v)?('*'):('!'))
147   $testno += 1
148   $linepos = ($linepos+1)%$linewidth
149 end
150
151 ################################################################################
152 # add_test                                                                     #
153 ################################################################################
154
155 def add_test(a,b)
156   begin
157     line = $sp.gets()
158     line = "" if line==nil
159     puts("DBG got: "+line) if $debug
160     if /^Error:.*/.match(line)
161       puts line
162       return false
163     end
164   end while not /[\s]*enter a:[\s]*/.match(line)
165   $sp.print(a.to_s(16)+" ")
166   begin
167     line = $sp.gets()
168     line = "" if line==nil
169     puts("DBG got: "+line) if $debug
170     if /^Error:.*/.match(line)
171       puts line
172       return false
173     end
174   end while not /[\s]*enter b:[\s]*/.match(line)
175   $sp.print(b.to_s(16)+" ")
176   begin
177     line = $sp.gets()
178     line = "" if line==nil
179     puts("DBG got: "+line) if $debug
180     if /^Error:.*/.match(line)
181       puts line
182       return false
183     end
184   end while not m=/[\s]*([-]?[0-9a-fA-F]*)[\s]+\+[\s]+([+-]?[0-9a-fA-F]*)[\s]*=[\s]*([+-]?[0-9a-fA-F]*)/.match(line)
185   a_ = m[1].to_i(16)
186   b_ = m[2].to_i(16)
187   c_ = m[3].to_i(16)
188   line.chomp!
189   if(a_== a && b_ == b && c_ == (a+b))
190     $logfile.printf("[pass]: %s\n", line)
191     return true
192   else
193     $logfile.printf("[fail (%s%s%s)]: %s", (a==a_)?"":"a", (b==b_)?"":"b", (c_==a+b)?"":"c",line)
194     $logfile.printf(" ; should %s + %s = %s\n", a.to_s(16), b.to_s(16), (a+b).to_s(16))
195     return false
196   end
197   return false
198 end
199
200 ################################################################################
201 # mul_test                                                                     #
202 ################################################################################
203
204 def mul_test(a,b)
205   begin
206     line = $sp.gets()
207     line = "" if line==nil
208     puts("DBG got: "+line) if $debug
209     if /^Error:.*/.match(line)
210       puts line
211       return false
212     end
213   end while not /[\s]*enter a:[\s]*/.match(line)
214   $sp.print(a.to_s(16)+" ")
215   begin
216     line = $sp.gets()
217     line = "" if line==nil
218     puts("DBG got: "+line) if $debug
219     if /^Error:.*/.match(line)
220       puts line
221       return false
222     end
223   end while not /[\s]*enter b:[\s]*/.match(line)
224   $sp.print(b.to_s(16)+" ")
225   begin
226     line = $sp.gets()
227     line = "" if line==nil
228     puts("DBG got: "+line) if $debug
229     if /^Error:.*/.match(line)
230       puts line
231       return false
232     end
233   end while not m=/[\s]*([+-]?[0-9a-fA-F]*)[\s]+\*[\s]+([+-]?[0-9a-fA-F]*)[\s]*=[\s]*([+-]?[0-9a-fA-F]*)/.match(line)
234   a_ = m[1].to_i(16)
235   b_ = m[2].to_i(16)
236   c_ = m[3].to_i(16)
237   line.chomp!
238   if(a_== a && b_ == b && c_ == (a*b))
239     $logfile.printf("[pass]: %s\n", line)
240     return true
241   else
242     $logfile.printf("[fail (%s%s%s)]: %s", (a==a_)?"":"a", (b==b_)?"":"b", (c_==a*b)?"":"c",line)
243     $logfile.printf(" ; should %s * %s = %s\n", a.to_s(16), b.to_s(16), (a*b).to_s(16))
244     return false
245   end
246   return false
247 end
248
249 ################################################################################
250 # square_test                                                                  #
251 ################################################################################
252
253 def square_test(a)
254   begin
255     line = $sp.gets()
256     line = "" if line==nil
257     puts("DBG got: "+line) if $debug
258     if /^Error:.*/.match(line)
259       puts line
260       return false
261     end
262   end while not /[\s]*enter a:[\s]*/.match(line)
263   $sp.print(a.to_s(16)+" ")
264   begin
265     line = $sp.gets()
266     line = "" if line==nil
267     puts("DBG got: "+line) if $debug
268     if /^Error:.*/.match(line)
269       puts line
270       return false
271     end
272   end while not m=/[\s]*([+-]?[0-9a-fA-F]*)[\s]*\*\*2[\s]*=[\s]*([+-]?[0-9a-fA-F]*)/.match(line)
273   a_ = m[1].to_i(16)
274   c_ = m[2].to_i(16)
275   line.chomp!
276   if(a_== a && c_ == (a**2))
277     $logfile.printf("[pass]: %s\n", line)
278     return true
279   else
280     $logfile.printf("[fail (%s%s)]: %s", (a==a_)?"":"a", (c_==a**2)?"":"c",line)
281     $logfile.printf(" ; should %s **2 = %s\n", a.to_s(16), (a**2).to_s(16))
282     return false
283   end
284   return false
285 end
286
287 ################################################################################
288 # reduce_test                                                                  #
289 ################################################################################
290
291 def reduce_test(a,b)
292   begin
293     line = $sp.gets()
294     line = "" if line==nil
295     puts("DBG got: "+line) if $debug
296     if /^Error:.*/.match(line)
297       puts line
298       return false
299     end
300   end while not /[\s]*enter a:[\s]*/.match(line)
301   $sp.print(a.to_s(16)+" ")
302   begin
303     line = $sp.gets()
304     line = "" if line==nil
305     puts("DBG got: "+line) if $debug
306     if /^Error:.*/.match(line)
307       puts line
308       return false
309     end
310   end while not /[\s]*enter b:[\s]*/.match(line)
311   $sp.print(b.to_s(16)+" ")
312   line=''
313   begin
314     line_tmp = $sp.gets()
315     line_tmp = '' if line_tmp==nil
316     line += line_tmp
317     puts("DBG got: "+line) if $debug
318     if /^Error:.*/.match(line)
319       puts line
320       return false
321     end
322   end while not m=/[\s]*([+-]?[0-9a-fA-F]*)[\s]+%[\s]+([+-]?[0-9a-fA-F]*)[\s]*=[\s]*([+-]?[0-9a-fA-F]+)/.match(line)
323   a_ = m[1].to_i(16)
324   b_ = m[2].to_i(16)
325   c_ = m[3].to_i(16)
326   line.chomp!
327   if(a_== a && b_ == b && c_ == (a%b))
328     $logfile.printf("[pass]: %s\n", line)
329     return true
330   else
331     $logfile.printf("[fail (%s%s%s)]: %s", (a==a_)?"":"a", (b==b_)?"":"b", (c_==a%b)?"":"c",line)
332     $logfile.printf(" ; should %s %% %s = %s\n", a.to_s(16), b.to_s(16), (a%b).to_s(16))
333     return false
334   end
335   return false
336 end
337
338 ################################################################################
339 # expmod_test                                                                  #
340 ################################################################################
341
342 def expmod_test(a,b,c)
343   begin
344     line = $sp.gets()
345     line = "" if line==nil
346     puts("DBG got: "+line) if $debug
347     if /^Error:.*/.match(line)
348       puts line
349       return false
350     end
351   end while not /[\s]*enter a:[\s]*/.match(line)
352   $sp.print(a.to_s(16)+" ")
353   begin
354     line = $sp.gets()
355     line = "" if line==nil
356     puts("DBG got: "+line) if $debug
357     if /^Error:.*/.match(line)
358       puts line
359       return false
360     end
361   end while not /[\s]*enter b:[\s]*/.match(line)
362   $sp.print(b.to_s(16)+" ")
363   begin
364     line = $sp.gets()
365     line = "" if line==nil
366     puts("DBG got: "+line) if $debug
367     if /^Error:.*/.match(line)
368       puts line
369       return false
370     end
371   end while not /[\s]*enter c:[\s]*/.match(line)
372   $sp.print(c.to_s(16)+" ")
373   line=''
374   begin
375     line_tmp = $sp.gets()
376     line_tmp = '' if line_tmp==nil
377     line += line_tmp
378     puts("DBG got: "+line) if $debug
379     if /^Error:.*/.match(line)
380       puts line
381       return false
382     end
383   end while not m=/[\s]*([+-]?[0-9a-fA-F]*)\*\*([+-]?[0-9a-fA-F]*)[\s]+%[\s]+([+-]?[0-9a-fA-F]*)[\s]*=[\s]*([+-]?[0-9a-fA-F]+)/.match(line)
384   a_ = m[1].to_i(16)
385   b_ = m[2].to_i(16)
386   c_ = m[3].to_i(16)
387   d_ = m[4].to_i(16)
388   line.chomp!
389   if(a_== a && b_ == b && c_ == c && d_ ==expmod(a,b,c) )
390     $logfile.printf("[pass]: %s\n", line)
391     return true
392   else
393     $logfile.printf("[fail (%s%s%s%s)]: %s", (a==a_)?'':'a', (b==b_)?'':'b', (c_==c)?'':'c', (d_==expmod(a,b,c))?'':'d',line)
394     $logfile.printf(" ; should %s**%s %% %s = %s\n", a.to_s(16), b.to_s(16), c.to_s(16), expmod(a,b,c).to_s(16))
395     return false
396   end
397   return false
398 end
399
400 ################################################################################
401 # gcdext_test                                                                  #
402 ################################################################################
403
404 def gcdext_test(a,b)
405   begin
406     line = $sp.gets()
407     line = "" if line==nil
408     puts("DBG got: "+line) if $debug
409     if /^Error:.*/.match(line)
410       puts line
411       return false
412     end
413   end while not /[\s]*enter a:[\s]*/.match(line)
414   $sp.print(a.to_s(16)+" ")
415   begin
416     line = $sp.gets()
417     line = "" if line==nil
418     puts("DBG got: "+line) if $debug
419     if /^Error:.*/.match(line)
420       puts line
421       return false
422     end
423   end while not /[\s]*enter b:[\s]*/.match(line)
424   $sp.print(b.to_s(16)+" ")
425   line=''
426   begin
427     line_tmp = $sp.gets()
428     line_tmp = '' if line_tmp==nil
429     line = ''  if line.end_with?('\n')
430     line += line_tmp
431     puts("DBG got: "+line) if $debug
432     if /^Error:.*/.match(line)
433       puts line
434       return false
435     end
436   end while not m=/gcdext\([\s]*([+-]?[0-9a-fA-F]*)[\s]*,[\s]*([+-]?[0-9a-fA-F]*)[\s]*\)[\s]*=> a = ([+-]?[0-9a-fA-F]+); b = ([+-]?[0-9a-fA-F]+); gcd = ([+-]?[0-9a-fA-F]+)/.match(line)
437   a_ = m[1].to_i(16)
438   b_ = m[2].to_i(16)
439   c_ = m[3].to_i(16)
440   d_ = m[4].to_i(16)
441   e_ = m[5].to_i(16)
442   line.chomp!
443   line.gsub!("\r",'')
444   line.gsub!("\n",'')
445   ref = gcdext(a,b)
446   if(a_== a && b_ == b && c_ == ref[1] && d_ == ref[2] && e_== ref[0])
447     $logfile.printf("[pass]: %s\n", line)
448     return true
449   else
450     $logfile.printf("[fail (%s%s%s%s%s)]: %s", (a==a_)?'':'a', (b==b_)?'':'b', 
451        (c_==ref[1])?'':'c', (d_==ref[2])?'':'d', (e_==ref[0])?'':'e', line)
452     $logfile.printf(" ; should gcdext( %s, %s) => a = %s; b = %s; gcd = %s\n",
453        a.to_s(16), b.to_s(16), ref[1].to_s(16), ref[2].to_s(16), ref[0].to_s(16))
454     return false
455   end
456   return false
457 end
458
459 ################################################################################
460 # run_test_add                                                                 #
461 ################################################################################
462
463 def run_test_add(skip=0)
464   length_a_B = skip+1
465   length_b_B = skip+1
466   begin
467     $size = length_a_B
468     (0..16).each do |i|
469       s_a = rand(2)*2-1
470       s_b = rand(2)*2-1
471       a = rand(256**length_a_B) * s_a
472       b = rand(256**length_a_B) * s_b
473       v = add_test(a, b)
474       screen_progress(v)
475       v = add_test(b, a)
476       screen_progress(v)
477     end
478     (0..16).each do |i|
479       s_a = rand(2)-1
480       s_b = rand(2)-1
481       b_size = rand(length_b_B+1)
482       a = rand(256**length_a_B) * s_a
483       b = rand(256**b_size) * s_b
484       v = add_test(a, b)
485       screen_progress(v)      
486       v = add_test(b, a)
487       screen_progress(v)
488
489     end
490     length_a_B += 1
491     length_b_B += 1
492   end while length_a_B<4096/8
493 end
494
495 ################################################################################
496 # run_test_mul                                                                 #
497 ################################################################################
498
499 def run_test_mul(skip=0)
500   length_a_B = skip+1
501   length_b_B = skip+1
502   begin
503     $size = length_a_B
504     (0..16).each do |i|
505       s_a = rand(2)*2-1
506       s_b = rand(2)*2-1
507       a = rand(256**length_a_B) * s_a
508       b = rand(256**length_a_B) * s_b
509       v = mul_test(a, b)
510       screen_progress(v)
511       v = mul_test(b, a)
512       screen_progress(v)
513     end
514     (0..16).each do |i|
515       s_a = rand(2)-1
516       s_b = rand(2)-1
517       b_size = rand(length_b_B+1)
518       a = rand(256**length_a_B) * s_a
519       b = rand(256**b_size) * s_b
520       v = mul_test(a, b)
521       screen_progress(v)      
522       v = mul_test(b, a)
523       screen_progress(v)
524     end
525     length_a_B += 1
526     length_b_B += 1
527   end while length_a_B<4096/8
528 end
529
530 ################################################################################
531 # run_test_square                                                              #
532 ################################################################################
533
534 def run_test_square(skip=0)
535   length_a_B = skip+1
536   begin
537     $size = length_a_B
538     (0..16).each do |i|
539       a = rand(256**length_a_B)
540       v = square_test(a)
541       screen_progress(v)
542     end
543     length_a_B += 1
544   end while length_a_B<4096/8
545 end
546
547 ################################################################################
548 # run_test_reduce                                                              #
549 ################################################################################
550
551 def run_test_reduce(skip=0)
552   length_a_B = skip+1
553   length_b_B = skip+1
554   begin
555     $size = length_a_B
556     (0..16).each do |i|
557       a = rand(256**length_a_B)
558       b = rand(256**length_a_B)+1
559       v = reduce_test(a, b)
560       screen_progress(v)
561       end
562     (0..16).each do |i|
563       b_size = rand(length_b_B+1)
564       a = rand(256**length_a_B)
565       b = rand(256**b_size)+1 
566       v = reduce_test(a, b)
567       screen_progress(v)      
568       end
569     length_a_B += 1
570     length_b_B += 1
571   end while length_a_B<4096/8
572 end
573
574 ################################################################################
575 # run_test_expmod                                                              #
576 ################################################################################
577
578 def run_test_expmod(skip=0)
579   length_a_B = skip+1
580   length_b_B = skip+1
581   length_c_B = skip+1
582   begin
583     $size = length_a_B
584     (0..16).each do |i|
585       a = rand(256**length_a_B)
586       b = rand(256**length_b_B)+1
587       c = rand(256**length_c_B)+1
588       v = expmod_test(a, b, c)
589       screen_progress(v)
590       end
591     (0..16).each do |i|
592       b_size = rand(length_b_B+1)
593       a = rand(256**length_a_B)
594       b = rand(256**b_size)+1 
595       c = rand(256**b_size)+1
596       v = expmod_test(a, b, c)
597       screen_progress(v)      
598       end
599     length_a_B += 1
600     length_b_B += 1
601   end while length_a_B<4096/8
602 end
603
604 ################################################################################
605 # run_test_gcdext                                                              #
606 ################################################################################
607
608 def run_test_gcdext(skip=0)
609   length_a_B = skip+1
610   length_b_B = skip+1
611   begin
612     $size = length_a_B
613     (0..16).each do |i|
614       a = rand(256**length_a_B)
615       b = rand(256**length_a_B)+1
616       v = gcdext_test(a, b)
617       $logfile.flush()
618       screen_progress(v)
619       end
620     (0..16).each do |i|
621       b_size = rand(length_b_B+1)
622       a = rand(256**length_a_B)
623       b = rand(256**b_size)+1 
624       v = gcdext_test(a, b)
625       $logfile.flush()
626       screen_progress(v)      
627       end
628     length_a_B += 1
629     length_b_B += 1
630   end while length_a_B<4096/8
631 end
632
633 ################################################################################
634 # MAIN                                                                         #
635 ################################################################################
636
637 opts = Getopt::Std.getopts("s:f:i:a:hd")
638
639 conf = Hash.new
640 conf = readconfigfile("/etc/testport.conf", conf)
641 conf = readconfigfile("~/.testport.conf", conf)
642 conf = readconfigfile("testport.conf", conf)
643 conf = readconfigfile(opts["f"], conf) if opts["f"]
644
645 #puts conf.inspect
646
647 puts("serial port interface version: " + SerialPort::VERSION);
648 $linewidth = 64
649 $linepos = 0
650 $testno = 0
651 params = { "baud"       => conf["PORT"]["baud"].to_i,
652             "data_bits" => conf["PORT"]["databits"].to_i,
653             "stop_bits" => conf["PORT"]["stopbits"].to_i,
654             "parity"    => SerialPort::NONE }
655 params["paraty"] = SerialPort::ODD   if conf["PORT"]["paraty"].downcase == "odd"
656 params["paraty"] = SerialPort::EVEN  if conf["PORT"]["paraty"].downcase == "even"
657 params["paraty"] = SerialPort::MARK  if conf["PORT"]["paraty"].downcase == "mark"
658 params["paraty"] = SerialPort::SPACE if conf["PORT"]["paraty"].downcase == "space"
659
660 puts("\nPort: "+conf["PORT"]["port"]+"@"    +
661                 params["baud"].to_s      +
662                 " "                      +
663                 params["data_bits"].to_s +
664                 conf["PORT"]["paraty"][0,1].upcase +
665                 params["stop_bits"].to_s +
666                 "\n")
667
668 $sp = SerialPort.new(conf["PORT"]["port"], params)
669
670 $sp.read_timeout=1000; # 5 minutes
671 $sp.flow_control = SerialPort::SOFT
672
673 reset_system()
674
675 if opts['d']
676   $debug = true
677 end
678
679 logfilename = conf['PORT']['testlogbase']+'bigint.txt'
680 if File.exists?(logfilename)
681   i=1
682   begin
683     logfilename = sprintf('%s%04d%s', conf['PORT']['testlogbase']+'bigint_',i,'.txt')
684     i+=1
685   end while(File.exists?(logfilename))
686   while(i>2) do
687     File.move(sprintf('%s%04d%s', conf['PORT']['testlogbase']+'bigint_',i-2,'.txt'), 
688               sprintf('%s%04d%s', conf['PORT']['testlogbase']+'bigint_',i-1,'.txt'), true)
689     i-=1
690   end
691     File.move(sprintf('%s%s', conf['PORT']['testlogbase'],'bigint.txt'), 
692               sprintf('%s%04d%s', conf['PORT']['testlogbase']+'bigint_',1,'.txt'), true)
693   logfilename = conf['PORT']['testlogbase']+'bigint.txt' 
694 end
695 $logfile = File.open(logfilename, 'w')
696 printf("logfile: %s\n", logfilename)
697
698 $logfile.printf("bigint test from: %s\n", Time.now.to_s)
699 $logfile.printf("skip = %s\n", opts['s']) if opts['s']
700 $logfile.printf("seed = 0x%X\n", 0xdeadbeef)
701
702 tests = Hash.new
703 tests['a'] = proc {|x| run_test_add(x) }
704 tests['m'] = proc {|x| run_test_mul(x) }
705 tests['s'] = proc {|x| run_test_square(x) }
706 tests['r'] = proc {|x| run_test_reduce(x) }
707 tests['e'] = proc {|x| run_test_expmod(x) }
708 tests['g'] = proc {|x| run_test_gcdext(x) }
709 init_str = Hash.new
710 init_str['a'] = 'add-test'
711 init_str['m'] = 'mul-test'
712 init_str['s'] = 'square-test'
713 init_str['r'] = 'reduce-test'
714 init_str['e'] = 'expmod-test'
715 init_str['g'] = 'gcdext-test'
716
717 srand(0xdeadbeef)
718
719 if opts['a']
720   opts['a'].each_char do |x|
721     if tests[x]
722       puts init_str[x]
723       init_system(init_str[x])
724       tests[x].call(opts['s']?opts['s'].to_i():0) 
725     else
726       puts "no test defiened for '#{x}'"
727     end  
728   end
729 else
730   'amsre'.each_char do |x|
731     if tests[x]
732       puts init_str[x]
733       init_system(init_str[x])
734       tests[x].call(opts['s']?opts['s'].to_i():0) 
735     else
736       puts "no test defiened for '#{x}'"
737     end  
738   end
739 end
740
741
742 $logile.close()