X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=host%2Fshavs_test2.rb;h=3c06e2f966f8bd0ab4f42786c11845b75668c551;hb=fb928c1c4c392b9e987631f84f1027af94e05beb;hp=4d411cbc741705a7b440afe8c13e506d3a28006b;hpb=f59c19cdaa2b415ea72a30083ee7df085c2a6ae9;p=arm-crypto-lib.git diff --git a/host/shavs_test2.rb b/host/shavs_test2.rb index 4d411cb..3c06e2f 100644 --- a/host/shavs_test2.rb +++ b/host/shavs_test2.rb @@ -1,7 +1,7 @@ #!/usr/bin/ruby # shavs_test.rb =begin - This file is part of the AVR-Crypto-Lib. + This file is part of the ARM-Crypto-Lib. Copyright (C) 2008, 2009 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ require 'rubygems' require 'serialport' require 'getopt/std' -$buffer_size = 0 +$buffer_size = 0 # set automatically in init_system $conffile_check = Hash.new $conffile_check.default = 0 @@ -48,7 +48,7 @@ def readconfigfile(fname, conf) conf[m[1]] = Hash.new next end - next if not /=/.match(line) + next if ! /=/.match(line) m=/[\s]*([^\s]*)[\s]*=[\s]*([^\s]*)/.match(line) if m[1]=="include" Dir.glob(m[2]){ |fn| conf = readconfigfile(fn, conf) } @@ -104,6 +104,7 @@ def init_system(algo_select) line=$sp.gets() end while not m=/buffer_size[\s]*=[\s]*0x([0-9A-Fa-f]*)/.match(line) $buffer_size = m[1].to_i(16) + printf("buffer_size = %d\n", $buffer_size) end ################################################################################ @@ -113,8 +114,9 @@ end def get_md begin line = $sp.gets() + puts("DBG got: " + line.inspect) if $debug line = "" if line==nil - puts("DBG got: "+line) if $debug + # puts("DBG got: "+line) if $debug end while not /[\s]*MD[\s]*=.*/.match(line) return line end @@ -139,17 +141,27 @@ def send_md(md_string) # puts 'DBG: send_md; md_string.length = '+md_string.length.to_s+'; buffer_size = '+$buffer_size.to_s bs = $buffer_size*2 $sp.print("Msg = ") - for i in 0..((md_string.length-1)/bs) + $sp.print(md_string[0]) + md_string = md_string[1..-1] + for i in 0..((md_string.length)/bs) # puts 'DBG bulk send' - if(md_string.length-i*bs also read config from +# -i skip until test nr. +# -j start with testfile +# -o use just one testfile +# -h ??? +# -d enable debug mode +# -c ??? +# -a ??? + +opts = Getopt::Std.getopts("s:f:i:j:hdcao") conf = Hash.new conf = readconfigfile("/etc/testport.conf", conf) @@ -282,16 +307,16 @@ algo_tasks.each do |algoa| puts("No test-set defined for #{algo} \r\n") next else - i=0 - i = opts["j"] if opts["j"] - logfile=File.open(conf["PORT"]["testlogbase"]+algo+".txt", "a") - while conf[algo]["file_#{i}"] != nil - puts("Testing #{algo} with #{conf[algo]["file_#{i}"]}") - reset_system() - init_system(algoa[1]) - skip=0 - skip=opts["i"].to_i if opts["i"] - nerrors=run_test(conf[algo]["file_#{i}"], skip) + i=0 + i = opts["j"].to_i if opts["j"] + logfile=File.open(conf["PORT"]["testlogbase"]+algo+".txt", "a") + while conf[algo]["file_#{i}"] != nil + puts("Testing #{algo} with #{conf[algo]["file_#{i}"]}") + reset_system() + init_system(algoa[1]) + skip=0 + skip=opts["i"].to_i if opts["i"] + nerrors=run_test(conf[algo]["file_#{i}"], skip) if nerrors == 0 puts("\n[ok]") logfile.puts("[ok] "+conf[algo]["file_#{i}"]+ " ("+Time.now.to_s()+")") @@ -299,7 +324,8 @@ algo_tasks.each do |algoa| puts("\n[errors: "+ nerrors.to_s() +"]") logfile.puts("[error] "+nerrors.to_s+" "+conf[algo]["file_#{i}"]+ " ("+Time.now.to_s()+")") end - i += 1 + i = i+1 + break if opts["o"] end logfile.close() end