include $(ROOT)/usr/include/make/SCdefs

VPATH = ../../../../common/os/tests/iosc/
include $(VPATH)/Make.common

TARGETS = $(CFILES:.c=.elf)

default: $(TARGETS)

LCOPTS += -DPERF 
LLDLIBS +=  -lbsl -lcsl -liosc -lios   -lioslibc -lvio 
LLDOPTS += -Ttext $(MK_APP_START) -T $(SDRAM_LINK) -L$(ROOT)/usr/lib/sc

LDIRT += *.mrg
%.elf: $(CRT0)  %.o
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)

include $(COMMONRULES)


%app.mrg: %test.elf $(ROOT)/usr/bin/sc/sk.elf 
	$(MERGE) -k $(ROOT)/usr/bin/sc/sk.elf -s $(MK_SHARED_START) -z 0x80000 -e $< -o $@


not_ownersapp.mrg: ownerstest.elf $(ROOT)/usr/bin/sc/sk.elf 
	$(MERGE) -k $(ROOT)/usr/bin/sc/sk.elf -s $(MK_SHARED_START) -z 0x80000 -f $< -o $@


ownersapp.mrg: ownerstest.elf $(ROOT)/usr/bin/sc/sk.elf 
	$(MERGE) -k $(ROOT)/usr/bin/sc/sk.elf -s $(MK_SHARED_START) -z 0x80000 -e $< -o $@


fs_versionapp.mrg: versiontest.elf $(ROOT)/usr/bin/sc/sk.elf 
	$(MERGE) -k $(ROOT)/usr/bin/sc/sk.elf -s $(MK_SHARED_START) -z 0x80000 -f $< -o $@


versionapp.mrg: versiontest.elf $(ROOT)/usr/bin/sc/sk.elf 
	$(MERGE) -k $(ROOT)/usr/bin/sc/sk.elf -s $(MK_SHARED_START) -z 0x80000 -e $< -o $@

memcheckesapp.mrg: memchecktest.elf $(ROOT)/usr/bin/sc/sk.elf
	$(MERGE) -k $(ROOT)/usr/bin/sc/sk.elf -s $(MK_SHARED_START) -z 0x80000 -e $< -o $@

runtests: $(TARGETS) hashapp.mrg hmacapp.mrg handleapp.mrg ownersapp.mrg not_ownersapp.mrg protapp.mrg randapp.mrg 
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o hashapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o hmacapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o ownersapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o not_ownersapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o protapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o handleapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o randapp.mrg

regression: $(TARGETS) hashapp.mrg hmacapp.mrg handleapp.mrg ownersapp.mrg not_ownersapp.mrg protapp.mrg randapp.mrg keygenapp.mrg signverapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o hashapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o hmacapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o ownersapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o not_ownersapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o protapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o handleapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o randapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o keygenapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o signverapp.mrg

memcheckestest: $(TARGETS) memcheckesapp.mrg 
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o memcheckesapp.mrg

not_ownerstest: $(TARGETS) not_ownersapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o not_ownersapp.mrg

ownerstest: $(TARGETS) ownersapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o ownersapp.mrg

prottest: $(TARGETS) protapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o protapp.mrg


eccreftest: $(TARGETS) eccrefapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o eccrefapp.mrg

handletest: $(TARGETS) handleapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o handleapp.mrg

fs_versiontest: $(TARGETS) fs_versionapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o fs_versionapp.mrg

versiontest: $(TARGETS) versionapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o versionapp.mrg

keygentest: $(TARGETS) keygenapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o keygenapp.mrg

hashtest: $(TARGETS) hashapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o hashapp.mrg

hmactest: $(TARGETS) hmacapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o hmacapp.mrg

signvertest: $(TARGETS) signverapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o signverapp.mrg

rsavertest: $(TARGETS) rsaverapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o rsaverapp.mrg

certtest: $(TARGETS) certapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o certapp.mrg

randtest: $(TARGETS) randapp.mrg
	$(ROOT)/usr/bin/x86/sce -t 0x1ff -f -o randapp.mrg
