]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
integrated automatic testing scrips (1/2)
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Fri, 18 Jul 2008 20:51:00 +0000 (20:51 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Fri, 18 Jul 2008 20:51:00 +0000 (20:51 +0000)
Makefile
avr-makefile.inc
get_test.rb [new file with mode: 0644]
main-noekeon-test.c

index f2611af072f7fa8ffcaa0a8b5f407f629e299144..efae2b4f89b3acd85a4830ffc2998362bf2fc6e4 100644 (file)
--- 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
index 4d9555ca6385158cec223a2e68f21b02690ccd69..3585afe3578eb8910393ec23b9abb961576a9274 100644 (file)
@@ -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 (file)
index 0000000..a2a5163
--- /dev/null
@@ -0,0 +1,98 @@
+#!/usr/bin/ruby 
+
+require "serialport.so"
+
+if ARGV.size < 5
+  STDERR.print <<EOF
+  Usage: ruby #{$0} port bps nbits stopb command [target_dir] [additional specifier]
+EOF
+  exit(1)
+end
+
+command=ARGV[4]+" ";
+$dir=(ARGV.size>=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);
+
+
index 9ba191e7260455ddfb710dc7eba82d8e635cbf07..851c7bc663009bd4eabca77ed13a1b77575dac03 100644 (file)
@@ -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,