From: bg Date: Fri, 18 Jul 2008 20:51:00 +0000 (+0000) Subject: integrated automatic testing scrips (1/2) X-Git-Url: https://git.cryptolib.org/?a=commitdiff_plain;h=dd02da3bd4b9c9a84f68150b5cba987b73fd29af;p=avr-crypto-lib.git integrated automatic testing scrips (1/2) --- diff --git a/Makefile b/Makefile index f2611af..efae2b4 100644 --- a/Makefile +++ b/Makefile @@ -158,12 +158,24 @@ $(1)_FLASH: $(2) @$(FLASHCMD)$(call first,$(2)) endef -#$(foreach algo, $(ALGORITHMS),$(eval $(call FLASH_TEMPLATE, $(algo), \ -# $(patsubst $(BIN_DIR)%.o,$(TESTBIN_DIR)%.hex,$(firstword $($(algo)_TEST_BIN)))) )) $(foreach algo, $(ALGORITHMS),$(eval $(call FLASH_TEMPLATE, $(algo), $(TESTBIN_DIR)main-$(call lc,$(algo))-test.hex) )) #------------------------------------------------------------------------------- +define TESTRUN_TEMPLATE +$(1)_TESTRUN: $(1)_FLASH + @echo "[test]: $(1)" + $(RUBY) get_test.rb $(TESTPORT) $(TESTPORTBAUDR) 8 1 nessie $(TESTLOG_DIR)$(TESTPREFIX) $(2) +endef + +$(foreach algo, $(ALGORITHMS),$(eval $(call TESTRUN_TEMPLATE, $(algo), $(call lc,$(algo)) ))) + +ALL_TESTRUN: $(foreach algo, $(ALGORITHMS), $(algo)_TESTRUN) + +#------------------------------------------------------------------------------- + + + .PHONY: clean clean: rm -rf $(BIN_DIR)*.o *.o $(TESTBIN_DIR)*.elf $(TESTBIN_DIR)* *.elf *.eps *.png *.pdf *.bak *_size.txt diff --git a/avr-makefile.inc b/avr-makefile.inc index 4d9555c..3585afe 100644 --- a/avr-makefile.inc +++ b/avr-makefile.inc @@ -9,7 +9,10 @@ BIN_DIR = bin/ TESTBIN_DIR = test_bin/ #uisp -dprog=bsd -dlpt=/dev/parport1 --upload if=$(PRG).hex ERASECMD = - +TESTPORT = /dev/ttyUSB1 +TESTPORTBAUDR = 9600 +TESTLOG_DIR = testlog/ +TESTPREFIX = nessie- CC = avr-gcc override CFLAGS = -MMD -MF$(DEP_DIR)$(patsubst %.c,%.d,$<) -pedantic -std=c99 -Wall -Wstrict-prototypes $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) diff --git a/get_test.rb b/get_test.rb new file mode 100644 index 0000000..a2a5163 --- /dev/null +++ b/get_test.rb @@ -0,0 +1,98 @@ +#!/usr/bin/ruby + +require "serialport.so" + +if ARGV.size < 5 + STDERR.print <=6)?ARGV[5]:""; +param=(ARGV.size>=7)?ARGV[6]:""; + +puts("\nPort: "+ARGV[0]+ "@"+ARGV[1]+" "+ARGV[2]+"N"+ARGV[3]+"\n"); +$linewidth = 16 +$sp = SerialPort.new(ARGV[0], ARGV[1].to_i, ARGV[2].to_i, ARGV[3].to_i, SerialPort::NONE); +$sp.read_timeout=5000; # 5 seconds +$sp.write(command); + +def readTestVector(param) + fname=$dir; + lb=""; + buffer=""; + set=0; + vector=0; + begin + lb=$sp.gets(); + if (m=/unknown command/.match(lb) || m=/[Ee][Rr]{2}[Oo][Rr]/.match(lb)) + puts("ERROR: "+lb); + exit(2); + end + if(lb==nil) + return false; + end + end while(m=/\*+/.match(lb)); + + buffer += lb; + begin + lb=$sp.gets(); + if(lb==nil) + return false; + end + buffer+=lb; + end while(m=/\*.*/.match(lb)); + + while(!(m=/Test vectors/.match(lb))) + m=/[^:]*:[\s]([A-Za-z0-9_-]*)/.match(lb); + if(m) + fname+=m[1]+"."; + end + buffer+=lb; + lb = $sp.gets(); + end + if(param!="") + fname+=param+"."; + end + puts("-> "+fname+"txt"); + file=File.new(fname+"txt", "w"); + buffer+=lb; + file.write(buffer); + begin + if (m=/Test\ vectors\ \-\-\ set[\s]+([0-9]+)/.match(lb)) + set=m[1].to_i; + print("\nSet "+m[1]+":"); + end + if (m=/Set [0-9]*, vector#[\s]*([0-9]+):/.match(lb)) + vector=m[1].to_i; + #print(" "+m[1]); + if(vector!=0 && vector % $linewidth==0) + print("\n ") + end + printf(" %3u", vector); + end + lb=$sp.gets(); + if(lb==nil) + file.close(); + return false; + end + file.write(lb); + end while(!m=/End of test vectors/.match(lb)); + puts("\n"); + file.close(); + return true +end + +if(readTestVector(param)==false) + puts("ERROR: test seem not to be implemented"); + exit(3); +end + +while(readTestVector(param)) +end + +exit(0); + + diff --git a/main-noekeon-test.c b/main-noekeon-test.c index 9ba191e..851c7bc 100644 --- a/main-noekeon-test.c +++ b/main-noekeon-test.c @@ -80,6 +80,12 @@ void testrun_nessie_noekeon_direct(void){ nessie_bc_run(); } +void testrun_nessie_noekeon(void){ + testrun_nessie_noekeon_direct(); + testrun_nessie_noekeon_indirect(); +} + + void testrun_stdtest_rundirect(void* data, void* key){ uart_putstr_P(PSTR("\r\n ")); uart_putstr_P(PSTR("k = ")); @@ -215,7 +221,7 @@ int main (void){ uart_putstr_P(PSTR(")\r\nloaded and running\r\n")); PGM_P u = PSTR("nessie\0test\0direct\0indirect\0performance\0"); - void_fpt v[] = {testrun_nessie_noekeon_direct, + void_fpt v[] = {testrun_nessie_noekeon, testrun_stdtest_noekeon, testrun_nessie_noekeon_direct, testrun_nessie_noekeon_indirect,