9os

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

commit d21d161d7d0a4eb627e4bd4e51f9a8438028313a
parent e28b6823c049910a3b3172c9ac35196b4d11b3ae
Author: Dimitris Papastamos <dimitris.papastamos@arm.com>
Date:   Fri, 12 Oct 2018 14:26:44 +0100

[test] Add a simple test case to test the pack/unpack wrappers

This is very limited currently, we will need to revisit this once the
questions around the RSCB definition are resolved.

Change-Id: I19738b91d3ca12e1226631622dc61fcc1b9e19dd
Signed-off-by: Dimitris Papastamos <dimitris.papastamos@arm.com>

Diffstat:
Mtest/Makefile | 2+-
Atest/test3/Makefile | 13+++++++++++++
Atest/test3/test.c | 27+++++++++++++++++++++++++++
Atest/test3/test.sh | 5+++++
4 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/test/Makefile b/test/Makefile @@ -1,7 +1,7 @@ PROJECTDIR = .. include $(PROJECTDIR)/scripts/rules.mk -DIRS = test1 test2 +DIRS = test1 test2 test3 all: $(DIRS) diff --git a/test/test3/Makefile b/test/test3/Makefile @@ -0,0 +1,13 @@ +PROJECTDIR = ../.. +include $(PROJECTDIR)/scripts/rules.mk + +OBJS = $(ARCHDIR)/crt-$(SYS).o test.o +LIBS = -ltypes -lc +LIBDEP = $(LIBDIR)/libtypes.a $(LIBDIR)/libc.a + +TARGET = run + +all: $(TARGET) + +$(TARGET): $(OBJS) $(LIBDEP) + $(LD) $(RCODE_LDFLAGS) $(OBJS) $(LIBS) -o $@ diff --git a/test/test3/test.c b/test/test3/test.c @@ -0,0 +1,27 @@ +#include <assert.h> +#include <stdint.h> +#include <string.h> +#include <types.h> + +int +main(void) +{ + struct rscb_ctrl a = { 0 }, b = { 0 }; + uint64_t buf[128]; + + a.en = 0; + a.preg_lock = 1; + a.dbg = 1; + a.res0_0 = 0; + a.rmu_wlock = 1; + a.rot_wlock = 1; + a.rscb_lock = 0; + a.alive = 1; + a.res0_1 = 0; + + assert(pack_rscb_ctrl(buf, &a) != -1); + assert(unpack_rscb_ctrl(buf, &b) != -1); + assert(memcmp(&a, &b, sizeof(struct rscb_ctrl)) == 0); + + return 0; +} diff --git a/test/test3/test.sh b/test/test3/test.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -e + +$EMUCMD ./run