From a5f4e0791be63315e345ab6dcd223736b1bc5826 Mon Sep 17 00:00:00 2001
From: Armin Luntzer <armin.luntzer@univie.ac.at>
Date: Wed, 24 May 2017 13:29:53 +0200
Subject: [PATCH] * add system-level test script for Xentium processing network
 * adjust Xentium processing demo so it exits after tasks were processed

---
 init/xentium_demo.c                           |  48 ++++++++++-
 .../hwtests/xen_proc_net/.run_test.sh.swp     | Bin 0 -> 12288 bytes
 tools/testing/hwtests/xen_proc_net/README     |  35 ++++++++
 tools/testing/hwtests/xen_proc_net/config     |  78 ++++++++++++++++++
 .../testing/hwtests/xen_proc_net/run_test.sh  |  27 ++++++
 5 files changed, 184 insertions(+), 4 deletions(-)
 create mode 100644 tools/testing/hwtests/xen_proc_net/.run_test.sh.swp
 create mode 100644 tools/testing/hwtests/xen_proc_net/README
 create mode 100644 tools/testing/hwtests/xen_proc_net/config
 create mode 100755 tools/testing/hwtests/xen_proc_net/run_test.sh

diff --git a/init/xentium_demo.c b/init/xentium_demo.c
index fec43a8..96364a4 100644
--- a/init/xentium_demo.c
+++ b/init/xentium_demo.c
@@ -1,6 +1,6 @@
 /**
  * @file init/xentium_demo.c
- * 
+ *
  * @ingroup xen_demo
  * @defgroup xen_demo Xentium Demonstrator
  *
@@ -20,6 +20,38 @@
 #include <xentium_demo.h>
 
 
+/** we use this to detect when we're done with the demo */
+static int xen_active_tasks;
+
+
+/**
+ * @brief increment active task counter
+ */
+
+static void xen_tasks_inc(void)
+{
+	xen_active_tasks++;
+}
+
+/**
+ * @brief decrement active task counter if > 0
+ */
+static void xen_tasks_dec(void)
+{
+	if (xen_active_tasks)
+		xen_active_tasks--;
+}
+
+/**
+ * @brief get active task count
+ *
+ * @returns number of active tasks;
+ */
+static int xen_tasks_get(void)
+{
+	return xen_active_tasks;
+}
+
 
 /**
  * @brief the output function of the xentium processing network
@@ -55,6 +87,9 @@ static int xen_op_output(unsigned long op_code, struct proc_task *t)
 
 	pt_destroy(t);
 
+	/* decrement task counter */
+	xen_tasks_dec();
+
 	return PN_TASK_SUCCESS;
 }
 
@@ -82,6 +117,8 @@ static void xen_new_input_task(size_t n)
 	struct stack_op_info *stack_nfo;
 	struct ramp_op_info *ramp_nfo;
 
+	/* increment task counter */
+	xen_tasks_inc();
 
 	/* Kernels may need information on how to process an item. We allocate
 	 * these structures below
@@ -149,7 +186,8 @@ static void xen_new_input_task(size_t n)
 
 	/* add task top processing network */
 	while (xentium_input_task(t) < 0)
-		printk("Xenitium input busy!\n");
+		printk("Xentium input busy!\n");
+
 }
 
 
@@ -186,13 +224,15 @@ void xen_demo(void)
 	xen_new_input_task(64);
 
 
-	/* Process the network outputs in an infinite loop. Since we have
+	/* Process the network outputs until all tasks are done. Since we have
 	 * 12 inputs, a stacking of 4 and a ramp length of 32, we will
 	 * get 1 data point output for inputs of 32 items and 2 for inputs
 	 * of 64 items, i.e. 5 in total.
 	 */
 
-	while (1)
+	while (xen_tasks_get())
 		xentium_output_tasks();
 
+
+	printk("Xentium demo SUCCESSFUL\n");
 }
diff --git a/tools/testing/hwtests/xen_proc_net/.run_test.sh.swp b/tools/testing/hwtests/xen_proc_net/.run_test.sh.swp
new file mode 100644
index 0000000000000000000000000000000000000000..6336c7ea0b8a8162f80d0c701f1df316ccbfb101
GIT binary patch
literal 12288
zcmYc?2=nw+u+TGLU|?VnU|=|vqZ(Pv#lo`Co`E5;C^s_?Bu)S)XQbvA6cbRyz`#%k
zHc&r3vqaw~H8IaWSidAcKc`r~B(=CCGcR2~qa4I4)~`s-i!Uh3Pma$^EzvJ3&5H*K
z>lJ4ZwqaDoXb6mk0M-yFElJb0;AJp2G6ZLJWhF%gVWCj0N=F4pLtr!nMnhmU1V%$(
zGz3ONU^E0qLtr!nhGz(r6fiQ>GcYhPLA@spr5Vv^D0h?^4S~@R7!85Z5Eu=C(GVC7
zfzc2c4S~@R7!85Z5Eu=C(GVDdA&{8Dz;KY4fx(jxGXD?j|9|0UV7SfCz;KJ7f#DcG
z1H(~%28Q|k3=H%585r9685r9585j!r85j!q85k1z85k1y85rXE85lhI85orK85n-^
zF)-ZbV_?|M$H1_GkAY!59|J=T9|J=Y9|J=K9|J=u9|J=$AH-f)J_ZJ7J_ZI0J_ZI;
zJ_ZI2J_ZJEJ_ZIZJ_d$wybKH{co`Vx@G>yG;$>iX#LK{NmzRNIIWGglJl-J~;G<3+
z4S~@R7!85Z5Eu=C(GVC7fzc2c4S~@R7!3i;5J*j}$ShG%NzPA6W#D8;%VgjL3m6)i
zGGwMHM1whSSyUdnT8JqMx~YW<hDIg|vDj4Ow+=-|YDFf3p9%$F#}=iQU~{X2N>OSF
z!g_0kl8n?m24#iJG==h1g_6wN)D(sM(h?no#FVVk;t~b0=^&3Qq~#YWq-T~WBxM$-
zCYLZU6s4Bfs@O9qKmeygdQobDLU5?Fvukj$f|{LzeoAVYeqL!#juJvmNop!YyriU3
zL4lK#Q$azYCWZl|IX6E~K{qEgKhH=(w^Tv5G_j}zt~A&HqD-lvC^N4lO(8}pCqFSo
zAtyC4FTXe@uc$OHCa<tGvm{0dWE#j5`K2WahDHVoNr}Z73cAS(F$@e0xry1S3N<wl
zFBwAl$sj|JMUzt$RH}=Ml2bB^YEi@s6q57v(lXN#()xN(5hOz)I&Jmz^x=qsL0KWa
h2;{$9P>3d_DrDv<6eN~pC^9H3>L+F9>4RL!008M1_+$V8

literal 0
HcmV?d00001

diff --git a/tools/testing/hwtests/xen_proc_net/README b/tools/testing/hwtests/xen_proc_net/README
new file mode 100644
index 0000000..4bbc3f8
--- /dev/null
+++ b/tools/testing/hwtests/xen_proc_net/README
@@ -0,0 +1,35 @@
+
+Description:
+============
+
+This test configures and executes the  Xentium Processing Network Demonstrator
+and evaluates success or failure.
+The supplied shell script can be used in conjunction with git bisect run <...>
+
+Pass/Fail Criterea:
+===================
+
+The demonstrator will print a line containing SUCCESS if the test passes
+successfully, all other conditions are considered a failure.
+
+The shell script will also fail the test if its execution lasts for more
+than 120 seconds. This is done to detect situations where the grmon or
+the hardware platform becomes stuck. In such a situation, the exit code
+returned will be 125, as to indicate to git bisect, that the current
+configuration can not be tested.
+
+
+Prerequisites:
+==============
+
+	* MPPB v2.x
+	* DEBUG UART connected to /dev/ttyS0
+	* grmon v1.1.x
+
+
+Notes:
+======
+
+The current .config of LeanOS will be overwritten and the image will
+be rebuilt.
+
diff --git a/tools/testing/hwtests/xen_proc_net/config b/tools/testing/hwtests/xen_proc_net/config
new file mode 100644
index 0000000..bc04635
--- /dev/null
+++ b/tools/testing/hwtests/xen_proc_net/config
@@ -0,0 +1,78 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# LeanOS Configuration
+#
+
+#
+# SPARC Configuration
+#
+CONFIG_LEON2=y
+# CONFIG_LEON3 is not set
+# CONFIG_MMU is not set
+CONFIG_EXTRA_SPARC_PHYS_BANKS=1
+
+#
+# Memory Management Settings
+#
+CONFIG_SPARC_MM_BLOCK_ORDER_MAX=29
+CONFIG_SPARC_MM_BLOCK_ORDER_MIN=12
+CONFIG_SPARC_INIT_PAGE_MAP_MAX_ENTRIES=8
+CONFIG_SPARC_BOOTMEM_RESERVE_CHUNK_ORDER=20
+CONFIG_SPARC_BOOTMEM_REQUEST_NEW_ON_DEMAND=y
+
+#
+# General Setup
+#
+CONFIG_KALLSYMS=y
+CONFIG_CROSS_PLATFORM_TARGET=y
+CONFIG_CROSS_COMPILE="sparc-elf-"
+CONFIG_TARGET_COMPILER_BOOT_CODE=y
+CONFIG_MODULES=y
+CONFIG_EMBED_MODULES_IMAGE=y
+CONFIG_BUILD_XEN_KERNELS=y
+CONFIG_XENTIUM_PROC_DEMO=y
+
+#
+# Compile-time checks and compiler options
+#
+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+# CONFIG_CC_OPTIMIZE_NONE is not set
+# CONFIG_DEBUG_INFO is not set
+CONFIG_KERNEL_PRINTK=y
+CONFIG_KERNEL_LEVEL=6
+CONFIG_SOC=y
+CONFIG_MPPB=y
+
+#
+# System-on-Chip drivers
+#
+CONFIG_NOC_DMA=y
+CONFIG_NOC_DMA_TRANSFER_QUEUE_SIZE=32
+CONFIG_NOC_DMA_SAME_MASTER_TRANSFER_WORKAROUND=y
+CONFIG_XENTIUM=y
+
+#
+# Core Components
+#
+# CONFIG_SYSCTL is not set
+CONFIG_MM=y
+
+#
+# Memory Management Debug Options
+#
+# CONFIG_MM_DEBUG_DUMP is not set
+CONFIG_PAGE_MAP=y
+
+#
+# Page Map Options
+#
+# CONFIG_PAGE_MAP_CHECK_PAGE_ALIGNMENT is not set
+CONFIG_PAGE_MAP_MOVE_NODE_AVAIL_THRESH=1
+CONFIG_CHUNK=y
+CONFIG_AR=y
+CONFIG_SAMPLES=y
+# CONFIG_SAMPLE_MM is not set
+# CONFIG_SAMPLE_CHUNK is not set
+CONFIG_SAMPLE_PROC_CHAIN=y
+CONFIG_SAMPLE_NOC_DMA=y
diff --git a/tools/testing/hwtests/xen_proc_net/run_test.sh b/tools/testing/hwtests/xen_proc_net/run_test.sh
new file mode 100755
index 0000000..dd8b4e4
--- /dev/null
+++ b/tools/testing/hwtests/xen_proc_net/run_test.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# grmon must be in path!
+
+srcdir=../../../../
+
+cp config ${srcdir}/.config || exit 1
+
+cd ${srcdir} || exit 1
+
+make clean || exit 1
+
+make || exit 1
+
+
+timeout 120 bash -c \
+	"printf \"load leanos\nrun\nquit\" |\
+	 grmon -leon2 -u -uart /dev/ttyS0  |\
+       	 tee /dev/tty  			   |\
+       	 grep SUCCESS &> /dev/null"
+ret=$?
+
+# if we timed out, adjust exit code for git bisect
+if [ $ret -eq 124 ]; then
+	exit 125
+fi
+	
+exit $ret
-- 
GitLab