Skip to content

Commit

Permalink
Added github action to test CPP API
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe0606 committed Jun 25, 2024
1 parent fd088ac commit 45bb6c8
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 27 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/runcpptest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Compile and Run
on:
workflow_dispatch:
pull_request:
branches: [main]
push:
branches: [main]

permissions:
actions: read
security-events: write

jobs:
CI_test_run:
strategy:
fail-fast: false
matrix:
compiler: [AC6, CLANG, GCC]
core: [M0, M4, M55]
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install system packages
run: |
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get install libpython3.9 libtinfo5
- name: Activate vcpkg
uses: ARM-software/cmsis-actions/vcpkg@v1
with:
cache: "-${{ matrix.compiler }}-${{ matrix.core }}"

- name: Activate Arm tool license
uses: ARM-software/cmsis-actions/armlm@v1

- name: Prepare framework
run: |
cd dsppp
echo "Create missing folders"
mkdir AC6_results
mkdir CLANG_results
mkdir GCC_results
echo "Install missing python packages"
pip install -r ../Testing/requirements.txt
echo "Load missing pack"
csolution list packs -s test.csolution.yml -m > required_packs.txt
cat required_packs.txt
cpackget add -a -f required_packs.txt
- name: Execute
run: |
cd dsppp
echo "Running tests"
python runall.py -t -g ${{ matrix.compiler }} -c ${{ matrix.core }} -avh $AVH_FVP_PLUGINS/../bin
- name: Upload test report
uses: actions/upload-artifact@v4
with:
name: test-report_${{ matrix.compiler }}_${{ matrix.core }}
path: ${{ matrix.compiler }}_results/errors_${{ matrix.compiler }}.txt


- name: Check error
run: |
cd dsppp
echo "Checking output..."
test "$(cat ${{ matrix.compiler }}_results/errors_${{ matrix.compiler }}.txt | wc -l)" -eq 0
3 changes: 3 additions & 0 deletions dsppp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ run_*.bat
ac6_results/
gcc_results/
clang_results/
AC6_results/
GCC_results/
CLANG_results/
2 changes: 1 addition & 1 deletion dsppp/RTE/_Release_VHT-Corstone-300/RTE_Components.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* CSOLUTION generated file: DO NOT EDIT!
* Generated by: csolution version 2.2.1
* Generated by: csolution version 2.4.0
*
* Project: 'test.Release+VHT-Corstone-300'
* Target: 'Release+VHT-Corstone-300'
Expand Down
3 changes: 3 additions & 0 deletions dsppp/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@


// Allocator for temporaries
// But when in test mode (like in github action), malloc allocator is used instead
#if !defined(TESTMODE)
#if defined(POOL_ALLOCATOR)
#define TMP_ALLOC pool_allocator
#else
#define TMP_ALLOC stat_allocator
#endif
#endif

#include <dsppp/memory_pool.hpp>

Expand Down
68 changes: 50 additions & 18 deletions dsppp/run_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import sys
import mps3run
from os import environ

from colorama import init,Fore, Back, Style

Expand Down Expand Up @@ -91,9 +92,16 @@ def run(args,mustPrint=False,dumpStdErr=True,timeout=20,printCmd=False):
parser.add_argument('-d', action='store_true', help="Dry run")
parser.add_argument('-g', nargs='?',type = str, default="AC6",help="AC6 / CLANG / GCC")
parser.add_argument('-u', nargs='?',type = str, default="L85986697A",help="Debug UUID")
parser.add_argument('-t', action='store_true', help="Enable test mode")
parser.add_argument('-avh', nargs='?',type = str, default="C:/Keil_v5/ARM/avh-fvp/bin/models", help="AVH folder")

args = parser.parse_args()

GHACTION = False

if "AVH_FVP_PLUGINS" in os.environ:
GHACTION = True

init()

if args.a:
Expand All @@ -111,13 +119,13 @@ def run(args,mustPrint=False,dumpStdErr=True,timeout=20,printCmd=False):

def results():
if args.g == "AC6":
return("ac6_results")
return("AC6_results")

if args.g == "GCC":
return("gcc_results")
return("GCC_results")

if args.g == "CLANG":
return("clang_results")
return("CLANG_results")

print(f"Compiler {args.g} not known")
exit(1)
Expand All @@ -144,9 +152,15 @@ def cmd_args():
else:
ext = ".elf"

fvp = {"M55":"C:\\Keil_v5\\ARM\\VHT\\VHT_Corstone_SSE-300_Ethos-U55.exe",
"M4":"C:\\Keil_v5\\ARM\\VHT\\VHT_MPS2_Cortex-M4.exe",
"M0":"C:\\Keil_v5\\ARM\\VHT\\VHT_MPS2_Cortex-M0plus.exe"}
fvpWin = {"M55":"FVP_Corstone_SSE-300_Ethos-U55.exe",
"M4":"FVP_MPS2_Cortex-M4.exe",
"M0":"FVP_MPS2_Cortex-M0plus.exe"}

fvpUnix = {"M55":"FVP_Corstone_SSE-300_Ethos-U55",
"M4":"FVP_MPS2_Cortex-M4",
"M0":"FVP_MPS2_Cortex-M0plus"}

AVHROOT = args.avh

TESTS=["DOT_TEST",
"VECTOR_TEST",
Expand Down Expand Up @@ -184,15 +198,19 @@ def is_only_test(n,i):
]

# Restricted tests for debugging
#TESTS=["DOT_TEST","VECTOR_TEST"]
#DATATYPES=["F32_DT"]
#MODE = ["STATIC_TEST"]
TESTS=["DOT_TEST","VECTOR_TEST"]
DATATYPES=["F32_DT"]
MODE = ["STATIC_TEST"]

all_tests = list(itertools.product(TESTS,DATATYPES,MODE))



ALLOC = "#define POOL_ALLOCATOR"
TESTMODE = ""
if args.t:
TESTMODE = "#define TESTMODE"

if args.a:
# Stat allocator enabled and we do stats on VHT CS300 only
ALLOC = "//#define POOL_ALLOCATOR"
Expand All @@ -206,6 +224,7 @@ def is_only_test(n,i):
HEADER = f"""#ifndef TEST_CONFIG_H
#define TEST_CONFIG_H
{TESTMODE}
{ALLOC}
{BENCH}
Expand Down Expand Up @@ -295,7 +314,19 @@ def runVHT(test_name,test,err,subtest):
exe = "cpu0=" + out_path()
else:
exe = out_path()
res=run([fvp[core],"-f",config,"-a",exe])

if AVHROOT:
avhAttempt = os.path.join(AVHROOT,fvpWin[core])
if os.path.exists(avhAttempt):
avh = avhAttempt

avhAttempt = os.path.join(AVHROOT,fvpUnix[core])
if os.path.exists(avhAttempt):
avh = avhAttempt
else:
avh = avhUnixExe[core]

res=run([avh,"-f",config,"-a",exe])
if not is_error(res,test_name,err):
process_result(test_name,test,res.msg,subtest)

Expand Down Expand Up @@ -340,7 +371,7 @@ def runATest(test,file_err,nb,NB_MAX,current_nb_axf,nb_axf,first=True,subtest=No
nb_axf = nb_axf + 1
print(f"Number of axf to test = {nb_axf}")

with open(os.path.join(results(),"errors.txt"),"w") as err:
with open(os.path.join(results(),f"errors_{args.c}.txt"),"w") as err:
# Generate include for allocations
if args.a or args.i:
with open(os.path.join("allocation","all.h"),"w") as fh:
Expand Down Expand Up @@ -382,10 +413,11 @@ def runATest(test,file_err,nb,NB_MAX,current_nb_axf,nb_axf,first=True,subtest=No
nb = nb + 1


if ERROR_OCCURED:
printError("Error in tests:")
for n in all_errors:
printError(n)
sys.exit("Error occurred")
else:
sys.exit(0)
if not GHACTION:
if ERROR_OCCURED:
printError("Error in tests:")
for n in all_errors:
printError(n)
sys.exit("Error occurred")
else:
sys.exit(0)
10 changes: 5 additions & 5 deletions dsppp/test.cbuild-pack.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::CMSIS@6.0.0
selected-by:
selected-by-pack:
- ARM::CMSIS@6.0.0
- resolved-pack: ARM::CMSIS-Compiler@2.0.0
selected-by:
selected-by-pack:
- ARM::CMSIS-Compiler@2.0.0
- resolved-pack: ARM::CMSIS-DSP@1.15.0
selected-by:
selected-by-pack:
- ARM::CMSIS-DSP@1.15.0
- resolved-pack: ARM::Cortex_DFP@1.0.0
selected-by:
selected-by-pack:
- ARM::Cortex_DFP@1.0.0
- resolved-pack: ARM::V2M_MPS3_SSE_300_BSP@1.4.0
selected-by:
selected-by-pack:
- ARM::V2M_MPS3_SSE_300_BSP@1.4.0
1 change: 1 addition & 0 deletions dsppp/test_config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef TEST_CONFIG_H
#define TEST_CONFIG_H


#define POOL_ALLOCATOR
//#define ONLY_BENCHMARKS

Expand Down
10 changes: 7 additions & 3 deletions dsppp/tests/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ extern uint32_t start_time;
extern uint32_t stop_time;
extern uint32_t cycle_count;

#if defined(HOST)
#if defined(HOST) || defined(TESTMODE)
#define INIT_SYSTICK
#define START_CYCLE_MEASUREMENT
#define STOP_CYCLE_MEASUREMENT
#define START_CYCLE_MEASUREMENT \
start_time = 0;
#define STOP_CYCLE_MEASUREMENT \
stop_time = 0; \
cycle_count = start_time - stop_time; \
printf ("Cycle count = %d\r\n",(int)cycle_count);
#else
#define INIT_SYSTICK \
SysTick->CTRL=0; \
Expand Down

0 comments on commit 45bb6c8

Please sign in to comment.