cheriot: Added testbench make rules

- Added a new target, cheriot-testbench, to run the cheriot supplied testbench on a standalone cheriot configuration.
- Added a new variable CHERIOT_BOARD to specify the board being used, with default equal to $PLATFORM
- Modified CHERIOT_FIRMWARE_RELEASE target to be generic (by using CHERIOT_BOARD) so that different applications with different boards can be created using the same Make rule

Bypass-Presubmit-Reason: no sencha CI tests

Change-Id: I83659c50ef7f53bafd050b2d9c0ff70eaa448780
diff --git a/platforms/sencha/cheriot.mk b/platforms/sencha/cheriot.mk
index 40a8e2b..150fd32 100644
--- a/platforms/sencha/cheriot.mk
+++ b/platforms/sencha/cheriot.mk
@@ -30,11 +30,15 @@
 CHERIOT_OUT_DEBUG   := $(CHERIOT_OUT_DIR)/debug
 CHERIOT_OUT_RELEASE := $(CHERIOT_OUT_DIR)/release
 
+CHERIOT_BOARD := ${PLATFORM}
+
 CHERIOT_FIRMWARE_DEBUG   := $(CHERIOT_OUT_DEBUG)/cheriot/cheriot/release/${CHERIOT_FIRMWARE}-firmware
 # XXX debug builds don't work atm
 #CHERIOT_FIRMWARE_DEBUG   := $(CHERIOT_OUT_DEBUG)/cheriot/cheriot/debug/${CHERIOT_FIRMWARE}-firmware
 CHERIOT_FIRMWARE_RELEASE := $(CHERIOT_OUT_RELEASE)/cheriot/cheriot/release/${CHERIOT_FIRMWARE}-firmware
 
+CHERIOT_TEST := $(CHERIOT_OUT_RELEASE)/cheriot/cheriot/release/test-suite
+
 # TODO: add CHERIOT_FIRMWARE_SRC_DIR (not currently defined in time to use here)
 CHERIOT_SOURCES := $(shell find $(CHERIOT_SRC_DIR) \(\
 	-name \*.rs -or \
@@ -113,7 +117,7 @@
 		xmake config \
 			-o ${CHERIOT_OUT_DEBUG} \
 			--sdk=${ROOTDIR}/cache/cheriot-tools \
-			--board=${PLATFORM} \
+			--board=${CHERIOT_BOARD} \
 			${CHERIOT_DEBUG_CONFIG_OPTIONS} && \
 	xmake build
 
@@ -126,18 +130,27 @@
 		xmake config \
 			-o ${CHERIOT_OUT_RELEASE} \
 			--sdk=${ROOTDIR}/cache/cheriot-tools \
-			--board=${PLATFORM} \
+			--board=${CHERIOT_BOARD} \
 			${CHERIOT_RELEASE_CONFIG_OPTIONS} && \
 	xmake build
 
 ## Generates CHERIoT build artifacts setup for release
 cheriot-bundle-release: $(CHERIOT_FIRMWARE_RELEASE)
 
+## Generates CHERIoT provided test-suite binary
+cheriot-test:
+	${MAKE} \
+		CHERIOT_BOARD=sail \
+		CHERIOT_FIRMWARE_SRC_DIR=${CHERIOT_SRC_DIR}/tests \
+		CHERIOT_FIRMWARE_RELEASE=$(CHERIOT_TEST) \
+		${CHERIOT_TEST}
+
 ## Generates both debug & release CHERIoT build artifacts
 cheriot: cheriot-bundle-debug cheriot-bundle-release
 
 .PHONY:: cheriot cheriot_check cheriot-clean
 .PHONY:: cheriot-bundle-debug cheriot-bundle-release
+.PHONY:: cheriot-test
 .PHONY:: cheriot-builtins-debug cheriot-builtins-release
 .PHONY:: cheriot-gen-headers cheriot-clean-headers
 .PHONY:: cheriot-build-debug-prepare cheriot-build-release-prepare
diff --git a/platforms/sencha/sim.mk b/platforms/sencha/sim.mk
index c789e5b..2347e76 100644
--- a/platforms/sencha/sim.mk
+++ b/platforms/sencha/sim.mk
@@ -58,9 +58,16 @@
 # XXX the same for now
 SENCHA_RESC_DEBUG=sim/config/sencha.resc
 SENCHA_RESC_RELEASE=sim/config/sencha.resc
+CHERIOT_RESC_RELEASE=sim/config/cheriot.resc
 
 SENCHA_REPL=sim/config/platforms/sencha.repl
 
+## Run the testbench in standalone cheriot
+cheriot-testbench: renode cheriot_sim $(CHERIOT_TEST)
+	$(RENODE_CMD) -e "\
+    i @${CHERIOT_RESC_RELEASE}; \
+        start"
+
 ## Launches an end-to-end build of the system and starts Renode
 #
 # This top-level target triggers the `matcha_tock_release`, `cheriot`, `renode`,