Browse Source

integrated automatic testing scrips (1/2)

master
bg 14 years ago
parent
commit
dd02da3bd4
  1. 16
      Makefile
  2. 5
      avr-makefile.inc
  3. 98
      get_test.rb
  4. 8
      main-noekeon-test.c

16
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

5
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)

98
get_test.rb

@ -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);

8
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,

Loading…
Cancel
Save