-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Auto formatter trigger on pr and push * Added ability to exclude files from coverage * Added example showing how to use xcoverage
- Loading branch information
1 parent
f637592
commit 011cd8d
Showing
7 changed files
with
324 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# The APP_NAME variable determines the name of the final .xe file. It should | ||
# not include the .xe postfix. If left blank the name will default to | ||
# the project name | ||
|
||
APP_NAME = | ||
|
||
# The flags passed to xcc when building the application | ||
# You can also set the following to override flags for a particular language: | ||
# | ||
# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS | ||
# | ||
# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to | ||
# xcc for the final link (mapping) stage. | ||
|
||
# SHARED_CODE = ../../shared_src | ||
|
||
COMMON_FLAGS = -DDEBUG_PRINT_ENABLE \ | ||
-O0 \ | ||
-g \ | ||
-save-temps \ | ||
# -I$(SHARED_CODE) \ | ||
# -DUSB_TILE=tile[0] \ | ||
# -DXUD_SIM_XSIM=1 \ | ||
# -DXUD_TEST_SPEED_HS=1 \ | ||
$(CFLAGS) | ||
TEST_DEMO = demo | ||
|
||
XCC_FLAGS_$(TEST_DEMO)= $(COMMON_FLAGS) | ||
|
||
# The TARGET variable determines what target system the application is | ||
# compiled for. It either refers to an XN file in the source directories | ||
# or a valid argument for the --target option when compiling. | ||
|
||
TARGET = XK_XVF3510_L71.xn | ||
|
||
# The USED_MODULES variable lists other module used by the application. | ||
USED_MODULES = | ||
|
||
|
||
#============================================================================= | ||
# The following part of the Makefile includes the common build infrastructure | ||
# for compiling XMOS applications. You should not need to edit below here. | ||
|
||
XMOS_MAKE_PATH ?= ../.. | ||
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Code Coverage Example | ||
===================== | ||
Run by: | ||
|
||
python code_coverage.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2022 XMOS LIMITED. | ||
# This Software is subject to the terms of the XMOS Public Licence: Version 1. | ||
from xcoverage.xcov import * | ||
import subprocess as ps | ||
import pytest | ||
import sys | ||
import os | ||
|
||
def build_xe(xe, clean=False): | ||
build_config = xe | ||
cmd = "xmake " | ||
if clean: | ||
cmd += "clean " | ||
cmd += "CONFIG=%s " % build_config | ||
ps.run(cmd, shell=True, check=True) | ||
|
||
def code_coverage(): | ||
|
||
#define xcov_combine and combine_proccess | ||
xcov_comb = xcov_combine() | ||
combine_test = combine_process(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
testname = os.path.basename(__file__).split(".")[0] | ||
xe_bin = testname + "_demo" | ||
binary = f"bin/demo/{xe_bin}.xe" | ||
split_dir = f"bin/demo" | ||
disasm = f"bin/demo/{xe_bin}.dump" | ||
tracefile = f"bin/demo/trace.txt" | ||
|
||
#build xe and generate disassembly file | ||
build_xe("demo", clean=False) | ||
print(binary) | ||
print(split_dir) | ||
print(disasm) | ||
generate_elf_disasm(binary, split_dir, disasm) | ||
|
||
#run xsim | ||
ps.run("xsim --trace-to %s %s" % (tracefile, binary), shell=True) | ||
|
||
#run code coverage calculation | ||
coverage = xcov_process(disasm, tracefile, split_dir) | ||
#run coverage result combine for each source file | ||
xcov_comb.run_combine(split_dir) | ||
#merge cobined result over different process | ||
coverage = combine_test.do_combine_test() | ||
combine_test.generate_merge_src() | ||
# teardowm - remove tmp file | ||
combine_test.remove_tmp_testresult(combine_test.tpath) | ||
|
||
if __name__ == "__main__": | ||
code_coverage() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Network xmlns="http://www.xmos.com" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com"> | ||
<Type>Device</Type> | ||
<Name>XVF3510 Device</Name> | ||
|
||
<Declarations> | ||
<Declaration>tileref tile[2]</Declaration> | ||
<Declaration>tileref usb_tile</Declaration> | ||
</Declarations> | ||
|
||
<Packages> | ||
<Package id="0" Type="XS2-UFnA-512-FB236"> | ||
<Nodes> | ||
<Node Id="0" InPackageId="0" Type="XS2-L16A-512" SystemFrequency="500MHz" OscillatorSrc="1"> | ||
<Boot> | ||
<Source Location="bootFlash0"/> | ||
</Boot> | ||
<Tile Number="0" Reference="tile[0]"> | ||
<!-- QSPI ports --> | ||
<Port Location="XS1_PORT_1B" Name="PORT_SQI_CS_0"/> | ||
<Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK_0"/> | ||
<Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO_0"/> | ||
|
||
<!-- Mic related ports --> | ||
<Port Location="XS1_PORT_1L" Name="PORT_PDM_CLK"/> | ||
<Port Location="XS1_PORT_1F" Name="PORT_PDM_DATA"/> | ||
<Port Location="XS1_PORT_1K" Name="PORT_MCLK_IN"/> | ||
|
||
<!-- Spare ports --> | ||
<Port Location="XS1_PORT_1H" Name="PORT_NOT_IN_PACKAGE_1"/> | ||
<Port Location="XS1_PORT_1I" Name="PORT_NOT_IN_PACKAGE_2"/> | ||
<Port Location="XS1_PORT_1J" Name="PORT_NOT_IN_PACKAGE_3"/> | ||
|
||
<!-- Audio ports --> | ||
<Port Location="XS1_PORT_1O" Name="PORT_I2S_LRCLK"/> | ||
<Port Location="XS1_PORT_1P" Name="PORT_I2S_BCLK"/> | ||
<Port Location="XS1_PORT_1N" Name="I2S_DATA_IN"/> | ||
|
||
<!-- connected to DAC --> | ||
<Port Location="XS1_PORT_4F" Name="PORT_TP_20_21_22_23"/> | ||
|
||
<!-- External engine ports --> | ||
<Port Location="XS1_PORT_1A" Name="PORT_SSB"/> | ||
<Port Location="XS1_PORT_1D" Name="PORT_SPI_MOSI"/> | ||
<Port Location="XS1_PORT_1E" Name="PORT_SPI_MISO"/> | ||
<Port Location="XS1_PORT_1M" Name="I2S_MIC_DATA"/> | ||
<Port Location="XS1_PORT_4D" Name="PORT_MUTE"/> | ||
|
||
</Tile> | ||
<Tile Number="1" Reference="tile[1]"> | ||
|
||
<Port Location="XS1_PORT_1A" Name="PORT_MCLK_OUT"/> | ||
<Port Location="XS1_PORT_1C" Name="PORT_I2C_SCL"/> | ||
<Port Location="XS1_PORT_1D" Name="PORT_I2C_SDA"/> | ||
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT"/> | ||
|
||
|
||
</Tile> | ||
|
||
</Node> | ||
<Node Id="1" InPackageId="1" Type="periph:XS1-SU" Reference="usb_tile" Oscillator="24MHz"> | ||
</Node> | ||
</Nodes> | ||
<Links> | ||
<Link Encoding="5wire"> | ||
<LinkEndpoint NodeId="0" Link="8" Delays="52clk,52clk"/> | ||
<LinkEndpoint NodeId="1" Link="XL0" Delays="1clk,1clk"/> | ||
</Link> | ||
</Links> | ||
</Package> | ||
</Packages> | ||
|
||
<Nodes> | ||
<Node Id="3" Type="device:" RoutingId="0x8000"> | ||
<Service Id="0" Proto="xscope_host_data(chanend c);"> | ||
<Chanend Identifier="c" end="3"/> | ||
</Service> | ||
</Node> | ||
</Nodes> | ||
|
||
<Links> | ||
<Link Encoding="2wire" Delays="4,4" Flags="XSCOPE"> | ||
<LinkEndpoint NodeId="0" Link="XL0"/> | ||
<LinkEndpoint NodeId="3" Chanend="1"/> | ||
</Link> | ||
</Links> | ||
|
||
<ExternalDevices> | ||
<Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash0" Type="0" PageSize="256" SectorSize="4096" NumPages="8192"> | ||
<Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS_0"/> | ||
<Attribute Name="PORT_SQI_SCLK" Value="PORT_SQI_SCLK_0"/> | ||
<Attribute Name="PORT_SQI_SIO" Value="PORT_SQI_SIO_0"/> | ||
<Attribute Name="QE_REGISTER" Value="flash_qe_location_status_reg_1"/> | ||
<Attribute Name="QE_BIT" Value="flash_qe_bit_1"/> | ||
</Device> | ||
</ExternalDevices> | ||
|
||
<JTAGChain> | ||
<JTAGDevice NodeId="0"/> | ||
</JTAGChain> | ||
|
||
</Network> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright 2016-2022 XMOS LIMITED. | ||
// This Software is subject to the terms of the XMOS Public Licence: Version 1. | ||
#include <platform.h> | ||
#include <print.h> | ||
#include <xs1.h> | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
|
||
void test_chan_1 ( chanend c, int x ) { | ||
c <: 5; | ||
} | ||
|
||
void test_chan_2 ( chanend c ) { | ||
for (int i=0; i<10; i++){ | ||
select { | ||
case c :> int x : | ||
break ; | ||
} | ||
} | ||
} | ||
|
||
void test_for_loop(chanend c){ | ||
for(int i = 0; i<10; i++){ | ||
test_chan_1(c,i); | ||
} | ||
} | ||
|
||
interface my_interface { | ||
void fA ( int x , int y ) ; | ||
void fB ( float x ) ; | ||
}; | ||
|
||
void test_interface_1 ( client interface my_interface i ){ | ||
// 'i ' is the client end of the connection , | ||
// let ' s communicate with the other end . | ||
i . fA (5 , 10) ; | ||
// i . fB (10.2); | ||
} | ||
|
||
void test_interface_2 ( server interface my_interface i ) | ||
{ | ||
// wait for either fA or fB over connection 'i '. | ||
select { | ||
case i . fA ( int x , int y ) : | ||
x = x + y ; | ||
break ; | ||
case i . fB ( float x ) : | ||
x += 2.22; | ||
break ; | ||
} | ||
} | ||
|
||
void rx_chan(chanend d){ | ||
select{ | ||
case d :> int s: | ||
break; | ||
} | ||
} | ||
|
||
void dummy_fn(chanend d){ | ||
d <: 10; | ||
} | ||
|
||
void simple_chan_tx(int t, chanend d){ | ||
if (t == 1){ | ||
d <: t; | ||
} | ||
else if (t == 2){ | ||
dummy_fn(d); | ||
} | ||
} | ||
|
||
|
||
int main() | ||
{ | ||
interface my_interface i ; | ||
chan c, d; | ||
|
||
par{ | ||
on tile[0]: test_interface_1(i); | ||
on tile[0]: test_interface_2(i); | ||
on tile[0]: simple_chan_tx(1, d); | ||
on tile[1]: rx_chan(d); | ||
on tile[1]: test_for_loop(c); | ||
on tile[1]: test_chan_2(c); | ||
} | ||
return 0; | ||
} |
Oops, something went wrong.