$conffile_check = Hash.new
$conffile_check.default = 0
+################################################################################
+# readconfigfile #
+################################################################################
+
def readconfigfile(fname, conf)
return conf if $conffile_check[fname]==1
$conffile_check[fname]=1
return conf
end
+################################################################################
+# reset_system #
+################################################################################
+
def reset_system
$sp.print("exit\r")
sleep 0.1
sleep 0.1
end
+################################################################################
+# scan_system #
+################################################################################
+
def scan_system
algos = Hash.new
$sp.print("shavs_list\r")
end
end
+################################################################################
+# init_system #
+################################################################################
+
def init_system(algo_select)
$sp.print("echo off \r")
print("DBG i: " + "echo off \r"+"\n") if $debug
sleep 1
$sp.print("shavs_set #{algo_select}\r")
- print("DBG i: " + "shavs_set #{$algo_select} \r"+"\n") # if $debug
+ print("DBG i: " + "shavs_set #{$algo_select} \r"+"\n") if $debug
sleep 1
$sp.print("shavs_test1 \r")
print("DBG i: " + "shavs_test1 \r"+"\n") if $debug
$buffer_size = m[1].to_i(16)
end
+################################################################################
+# get_md #
+################################################################################
+
def get_md
begin
line = $sp.gets()
return line
end
+################################################################################
+# send_md #
+################################################################################
+
def send_md(md_string)
$sp.print("Msg = ")
for i in 0..md_string.length-1
$sp.print(md_string[i].chr)
# print("DBG s: "+ md_string[i].chr) if $debug
- sleep(0.01)
+# sleep(0.001)
if((i%($buffer_size*2)==0)&&(i!=0))
begin
line=$sp.gets()
end
end
+################################################################################
+# run_test #
+################################################################################
+
def run_test(filename, skip=0)
nerrors = 0
line=1
until file.eof
begin
lb=file.gets()
- end while not (file.eof or (/[\s]*Len[\s]*=.*/.match(lb)))
- len = /[\s]*Len[\s]*=[\s]*([0-9]*)/.match(lb)[1].to_i
- puts("DBG sending: "+lb) if $debug
- return if file.eof
+# printf("DBG info: file read: %s", lb)
+ end while not (file.eof or (/[\s]*Len[\s]*=/.match(lb)))
+# puts("got ya")
+ if file.eof
+ file.close()
+ return nerrors
+ end
+ len = /[\s]*Len[\s]*=[\s]*([0-9]*)/.match(lb)[1].to_i
if(skip>0)
skip -= 1
redo
end
+ puts("DBG sending: "+lb) if $debug
$sp.print(lb.strip)
$sp.print("\r")
begin
else
putc('!')
# printf("<%d>",len)
- printf("\nError @%05d: %s \n != %s - ",len, a, b)
+ printf("\nError @%05d: %s [should]\n != %s [is]- ",len, a, b)
nerrors += 1
end
pos += 1
end
- return nerrors.to_i
+ file.close()
+ return nerrors
end
-opts = Getopt::Std.getopts("s:f:i:hdca")
+
+################################################################################
+# MAIN #
+################################################################################
+
+opts = Getopt::Std.getopts("s:f:i:j:hdca")
conf = Hash.new
conf = readconfigfile("/etc/testport.conf", conf)
algos=scan_system()
#puts algos.inspect
+if opts["d"]
+ $debug = true
+end
+
if opts["s"]
algos_rev = algos.invert
algo_tasks = Array.new
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}"]}")