9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 244bf0ba8a407b3dcc613323a920dd9278a097cb
parent 9592390e35a3cef34b896594ff555ecdb9ef1caa
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 11 Jul 2020 22:30:06 +0200

tests: Remove unit/0001

Change-Id: I3af4290bd912db2d6c009dc214d67f55697ae1a1

Diffstat:
Dtest/unit/001/.gitignore | 4----
Mtest/unit/001/Makefile | 107+++++++------------------------------------------------------------------------
Mtest/unit/001/descr | 2+-
Dtest/unit/001/mkrmu | 88-------------------------------------------------------------------------------
Mtest/unit/001/test.c | 24++++++++++--------------
Mtest/unit/001/test.sh | 28+---------------------------
Mtest/unit/002/descr | 2+-
Mtest/unit/002/test.c | 42++++++++++++++++++++++++++++--------------
Rtest/unit/003/test.exp -> test/unit/002/test.exp | 0
Mtest/unit/002/test.sh | 6+++++-
Dtest/unit/003/Makefile | 17-----------------
Dtest/unit/003/descr | 1-
Dtest/unit/003/test.c | 40----------------------------------------
Dtest/unit/003/test.sh | 9---------
Mtest/unit/Makefile | 2+-
15 files changed, 56 insertions(+), 316 deletions(-)

diff --git a/test/unit/001/.gitignore b/test/unit/001/.gitignore @@ -1,4 +0,0 @@ -hdl_*.c -ramfw -romfw -rmu diff --git a/test/unit/001/Makefile b/test/unit/001/Makefile @@ -3,104 +3,15 @@ PROJECTDIR = ../../.. include $(PROJECTDIR)/scripts/rules.mk include ../rules.mk -LIBOBJ = hdl_RMU_System_InterfaceVersion.o \ - hdl_RMU_System_Status.o \ - hdl_RMU_System_Enable.o \ - hdl_RMU_Local_Status.o \ - hdl_RMU_Local_Load.o \ - hdl_RMU_Local_Validate.o \ - hdl_RMU_Crypto_Random.o \ - hdl_RMU_Realm_Register.o \ - hdl_RMU_Realm_Release.o \ - hdl_RMU_Realm_InvalidateCurrent.o \ - hdl_RMU_Realm_Invalidate.o \ - hdl_RMU_Realm_GetParameterValue.o \ - hdl_RMU_Realm_SetParameterValue.o \ - hdl_RMU_Realm_GetParameterInheritance.o \ - hdl_RMU_Realm_SetParameterInheritance.o \ - hdl_RMU_Realm_Initialize.o \ - hdl_RMU_Realm_Prepare.o \ - hdl_RMU_Realm_Populate.o \ - hdl_RMU_Realm_Activate.o \ - hdl_RMU_Realm_Info.o \ - hdl_RMU_Realm_ReadMemory.o \ - hdl_RMU_Realm_WriteMemory.o \ - hdl_RMU_Realm_SetMetadata.o \ - hdl_RMU_Realm_GetMetadata.o \ - hdl_RMU_Realm_CreateZeroMetadata.o \ - hdl_RMU_Realm_SetCommandTrap.o \ - hdl_RMU_Realm_AttestationReportSize.o \ - hdl_RMU_Realm_AttestationReportInit.o \ - hdl_RMU_Realm_AttestationReport.o \ - hdl_RMU_Realm_ExtendBindingKeySeedValue.o \ - hdl_RMU_Realm_SetBindingKeySeedLock.o \ - hdl_RMU_Realm_DeriveBindingKey.o \ - hdl_RMU_Realm_GetBindingKeySeedValue.o \ - hdl_RMU_REC_Size.o \ - hdl_RMU_REC_Register.o \ - hdl_RMU_REC_Prepare.o \ - hdl_RMU_REC_Release.o \ - hdl_RMU_REC_ReadGeneralPurposeRegister.o \ - hdl_RMU_REC_WriteGeneralPurposeRegister.o \ - hdl_RMU_REC_ReadVectorRegister.o \ - hdl_RMU_REC_WriteVectorRegister.o \ - hdl_RMU_REC_ReadSystemRegister.o \ - hdl_RMU_REC_WriteSystemRegister.o \ - hdl_RMU_MDT_BufferSize.o \ - hdl_RMU_MDT_Register.o \ - hdl_RMU_MDT_Release.o \ - hdl_RMU_MDT_Info.o \ - hdl_RMU_MDT_WriteStorage.o \ - hdl_RMU_MDT_ReadStorage.o \ - hdl_RMU_MDT_Move.o \ - hdl_RMU_Granule_Invalidate.o \ - hdl_RMU_Granule_Clean.o \ - hdl_RMU_Granule_Info.o \ - hdl_RMU_Granule_Detail.o \ - hdl_RMU_Granule_SetPermissions.o \ - hdl_RMU_Granule_Sync.o \ - hdl_RMU_Granule_Claim.o \ - hdl_RMU_Granule_Release.o \ - hdl_RMU_Granule_AddInit.o \ - hdl_RMU_Granule_Add.o \ - hdl_RMU_Granule_Reclaim.o \ - hdl_RMU_Granule_Fuse.o \ - hdl_RMU_Granule_Shatter.o \ - hdl_RMU_Granule_SetGlobalVisibility.o \ - hdl_RMU_Granule_ExportInit.o \ - hdl_RMU_Granule_Export.o \ - hdl_RMU_Granule_ImportInit.o \ - hdl_RMU_Granule_Import.o \ +OBJS = $(LIBDIR)/crt.o \ + $(TARGETDIR)/arch.o \ + $(SRCDIR)/romfw/builtin.o \ + $(DRVDIR)/builtin.o \ + test.o \ -ROMOBJS = $(LIBDIR)/crt.o \ - $(TARGETDIR)/arch.o \ - $(SRCDIR)/romfw/builtin.o \ - test.o \ +TARGET = run -RAMOBJS = $(LIBDIR)/crt.o \ - $(TARGETDIR)/arch.o \ - $(SRCDIR)/ramfw/builtin.o \ - test.o \ +all: $(TARGET) -TARGET = romfw ramfw - -all: rmu - $(MAKE) run - -run: $(TARGET) - -romfw: $(ROMOBJS) $(LIBDEP) libhdl.a - $(LD) -L. $(PROJ_LDFLAGS) $(ROMOBJS) $(PROJ_LDLIBS) -o $@ - -ramfw: $(RAMOBJS) $(LIBDEP) libhdl.a - $(LD) -L. $(PROJ_LDFLAGS) $(RAMOBJS) $(PROJ_LDLIBS) -o $@ - -libhdl.a: $(LIBOBJ) - $(AR) $(ARFLAGS) $@ $? - $(RL) $(RANLIBFLAGS) $@ - -rmu: - mkrmu - touch $@ -clean: - rm -f $(LIBOBJ:.o=.c) *.a +$(TARGET): $(OBJS) $(LIBDEP) + $(LD) $(PROJ_LDFLAGS) $(OBJS) $(PROJ_LDLIBS) -o $@ diff --git a/test/unit/001/descr b/test/unit/001/descr @@ -1 +1 @@ -Test dispatcher by feeding into it all possible 16-bit RMC encodings +Test RMU_System_InterfaceVersion() diff --git a/test/unit/001/mkrmu b/test/unit/001/mkrmu @@ -1,88 +0,0 @@ -#!/bin/sh - -genfile() -{ - cat <<FILE >$i.c -#include <stdio.h> - -#include <rcode.h> - -void -$1(void) -{ - puts("$1"); -} -FILE -} - - -cat <<EOF | while read i; do genfile $i; done -hdl_RMU_System_InterfaceVersion -hdl_RMU_System_Status -hdl_RMU_System_Enable -hdl_RMU_Local_Status -hdl_RMU_Local_Load -hdl_RMU_Local_Validate -hdl_RMU_Crypto_Random -hdl_RMU_Realm_Register -hdl_RMU_Realm_Release -hdl_RMU_Realm_InvalidateCurrent -hdl_RMU_Realm_Invalidate -hdl_RMU_Realm_GetParameterValue -hdl_RMU_Realm_SetParameterValue -hdl_RMU_Realm_GetParameterInheritance -hdl_RMU_Realm_SetParameterInheritance -hdl_RMU_Realm_Initialize -hdl_RMU_Realm_Prepare -hdl_RMU_Realm_Populate -hdl_RMU_Realm_Activate -hdl_RMU_Realm_Info -hdl_RMU_Realm_ReadMemory -hdl_RMU_Realm_WriteMemory -hdl_RMU_Realm_SetMetadata -hdl_RMU_Realm_GetMetadata -hdl_RMU_Realm_CreateZeroMetadata -hdl_RMU_Realm_SetCommandTrap -hdl_RMU_Realm_AttestationReportSize -hdl_RMU_Realm_AttestationReportInit -hdl_RMU_Realm_AttestationReport -hdl_RMU_Realm_ExtendBindingKeySeedValue -hdl_RMU_Realm_SetBindingKeySeedLock -hdl_RMU_Realm_DeriveBindingKey -hdl_RMU_Realm_GetBindingKeySeedValue -hdl_RMU_REC_Size -hdl_RMU_REC_Register -hdl_RMU_REC_Prepare -hdl_RMU_REC_Release -hdl_RMU_REC_ReadGeneralPurposeRegister -hdl_RMU_REC_WriteGeneralPurposeRegister -hdl_RMU_REC_ReadVectorRegister -hdl_RMU_REC_WriteVectorRegister -hdl_RMU_REC_ReadSystemRegister -hdl_RMU_REC_WriteSystemRegister -hdl_RMU_MDT_BufferSize -hdl_RMU_MDT_Register -hdl_RMU_MDT_Release -hdl_RMU_MDT_Info -hdl_RMU_MDT_WriteStorage -hdl_RMU_MDT_ReadStorage -hdl_RMU_MDT_Move -hdl_RMU_Granule_Invalidate -hdl_RMU_Granule_Clean -hdl_RMU_Granule_Info -hdl_RMU_Granule_Detail -hdl_RMU_Granule_SetPermissions -hdl_RMU_Granule_Sync -hdl_RMU_Granule_Claim -hdl_RMU_Granule_Release -hdl_RMU_Granule_AddInit -hdl_RMU_Granule_Add -hdl_RMU_Granule_Reclaim -hdl_RMU_Granule_Fuse -hdl_RMU_Granule_Shatter -hdl_RMU_Granule_SetGlobalVisibility -hdl_RMU_Granule_ExportInit -hdl_RMU_Granule_Export -hdl_RMU_Granule_ImportInit -hdl_RMU_Granule_Import -EOF diff --git a/test/unit/001/test.c b/test/unit/001/test.c @@ -3,28 +3,24 @@ #include <stdio.h> #include <stdlib.h> -#include <libk.h> #include <rcode/rcode.h> +#include "../../../src/romfw/ec.h" #include "../../../target/hosted/hosted.h" struct trapframe frame; int -main(int argc, char *argv[]) +main(void) { - unsigned i, j; - Rmucmd cmd; + frame.r[ESR] = RMC << 26; /* class = func = 0 */ + + if (!setjmp(recover)) + trap(&frame); + + assert(frame.r[X0] == 0); + assert(frame.r[X1] == 0); + assert(frame.r[X2] == 1); - for (i = 0; i < 256; i++) { - for (j = 0; j < 256; j++) { - cmd.fp = &frame; - cmd.class = i; - cmd.func = j; - dbg(kout, "%u\t%u\t", i, j); - if (!setjmp(recover)) - rmc(&cmd); - } - } return 0; } diff --git a/test/unit/001/test.sh b/test/unit/001/test.sh @@ -2,30 +2,4 @@ set -e -tmp1=tmp1.$$ -tmp2=tmp2.$$ -trap 'r=$?;rm -f $tmp1 $tmp2;exit $r' EXIT HUP INT QUIT TERM - -tst() { -$EMUCMD $cmd | grep -v 'bad RMC' | sed 's/hdl_//' > $tmp1 -awk -v type=$1 '$0 ~ type {print $1 "\t" $2 "\t" $3}' < $SCRIPTDIR/rmu.cmd | -sed -e 's/\./_/g' > $tmp2 - -diff -u $tmp1 $tmp2 - -$EMUCMD $cmd | awk ' -/[0-9]+ [0-9]+/ {rmc[$1, $2] = 1} -END { - for (i = 0; i < 256; i++) { - for (j = 0; j < 256; j++) { - if (!rmc[i, j]) { - print "fail", i, j - exit 1 - } - } - } -}' -} - -cmd=./romfw tst rom -cmd=./ramfw tst ram +$EMUCMD ./run diff --git a/test/unit/002/descr b/test/unit/002/descr @@ -1 +1 @@ -Test RMU_System_InterfaceVersion() +Test panic() diff --git a/test/unit/002/test.c b/test/unit/002/test.c @@ -1,26 +1,40 @@ -#include <assert.h> -#include <setjmp.h> -#include <stdio.h> +#include <signal.h> #include <stdlib.h> - #include <rcode/rcode.h> -#include "../../../src/romfw/ec.h" #include "../../../target/hosted/hosted.h" -struct trapframe frame; +void +cleanup(int signum) +{ + extern int halted; -int -main(void) + if (halted) + exit(0); +} + +static struct trapframe * +mockframe(void) { - frame.r[ESR] = RMC << 26; /* class = func = 0 */ + int i; + static struct trapframe frame; - if (!setjmp(recover)) - trap(&frame); + for (i = 0; i < NR_REGS; i++) + frame.r[i] = i; + frame.r[ELR] = 0xdeadbeef; + frame.r[SP] = 0xdeadbabe; - assert(frame.r[X0] == 0); - assert(frame.r[X1] == 0); - assert(frame.r[X2] == 1); + return &frame; +} + +int +main(void) +{ + if (setjmp(recover)) + return -1; + signal(SIGABRT, cleanup); + getframe = mockframe; + panic("oops"); return 0; } diff --git a/test/unit/003/test.exp b/test/unit/002/test.exp diff --git a/test/unit/002/test.sh b/test/unit/002/test.sh @@ -2,4 +2,8 @@ set -e -$EMUCMD ./run +tmp1=tmp.$$ +trap 'r=$?;rm -f $tmp1;exit $r' EXIT HUP INT QUIT TERM + +$EMUCMD ./run > $tmp1 +diff -u $tmp1 test.exp diff --git a/test/unit/003/Makefile b/test/unit/003/Makefile @@ -1,17 +0,0 @@ -.POSIX: -PROJECTDIR = ../../.. -include $(PROJECTDIR)/scripts/rules.mk -include ../rules.mk - -OBJS = $(LIBDIR)/crt.o \ - $(TARGETDIR)/arch.o \ - $(SRCDIR)/romfw/builtin.o \ - $(DRVDIR)/builtin.o \ - test.o \ - -TARGET = run - -all: $(TARGET) - -$(TARGET): $(OBJS) $(LIBDEP) - $(LD) $(PROJ_LDFLAGS) $(OBJS) $(PROJ_LDLIBS) -o $@ diff --git a/test/unit/003/descr b/test/unit/003/descr @@ -1 +0,0 @@ -Test panic() diff --git a/test/unit/003/test.c b/test/unit/003/test.c @@ -1,40 +0,0 @@ -#include <signal.h> -#include <stdlib.h> -#include <rcode/rcode.h> - -#include "../../../target/hosted/hosted.h" - -void -cleanup(int signum) -{ - extern int halted; - - if (halted) - exit(0); -} - -static struct trapframe * -mockframe(void) -{ - int i; - static struct trapframe frame; - - for (i = 0; i < NR_REGS; i++) - frame.r[i] = i; - frame.r[ELR] = 0xdeadbeef; - frame.r[SP] = 0xdeadbabe; - - return &frame; -} - -int -main(void) -{ - if (setjmp(recover)) - return -1; - signal(SIGABRT, cleanup); - getframe = mockframe; - - panic("oops"); - return 0; -} diff --git a/test/unit/003/test.sh b/test/unit/003/test.sh @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e - -tmp1=tmp.$$ -trap 'r=$?;rm -f $tmp1;exit $r' EXIT HUP INT QUIT TERM - -$EMUCMD ./run > $tmp1 -diff -u $tmp1 test.exp diff --git a/test/unit/Makefile b/test/unit/Makefile @@ -2,7 +2,7 @@ PROJECTDIR = ../.. include $(PROJECTDIR)/scripts/rules.mk -DIRS = 001 002 003 +DIRS = 001 002 all: $(DIRS)