-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial Jenkinsfile * Build examples and load xtagctl for tests * Examples produce different bin names and can be run from any dir * add xtagctl reset * Test has size passed from Jenkinsfile * Add analysis script on fail * Bump version * API update with limitation * Update changelog
- Loading branch information
Showing
13 changed files
with
291 additions
and
16 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,124 @@ | ||
@Library('[email protected]') _ | ||
|
||
getApproval() | ||
|
||
pipeline { | ||
agent { | ||
label 'xcore.ai-explorer' | ||
} | ||
parameters { | ||
string( | ||
name: 'TOOLS_VERSION', | ||
defaultValue: '15.0.5', | ||
description: 'The tools version to build with (check /projects/tools/ReleasesTools/)' | ||
) | ||
} | ||
environment { | ||
// '/XMOS/tools' from get_tools.py and rest from tools installers | ||
TOOLS_PATH = "/XMOS/tools/${params.TOOLS_VERSION}/XMOS/XTC/${params.TOOLS_VERSION}" | ||
} | ||
options { | ||
skipDefaultCheckout() | ||
} | ||
stages { | ||
stage('Checkout') { | ||
steps { | ||
checkout scm | ||
sh "git clone [email protected]:xmos-int/xtagctl.git" | ||
} | ||
} | ||
stage('Install Dependencies') { | ||
steps { | ||
sh '/XMOS/get_tools.py ' + params.TOOLS_VERSION | ||
toolsEnv(TOOLS_PATH) { | ||
installDependencies() | ||
} | ||
} | ||
} | ||
stage('Static analysis') { | ||
steps { | ||
withVenv() { | ||
sh "flake8 --exit-zero --output-file=flake8.xml xscope_fileio" | ||
recordIssues enabledForFailure: true, tool: flake8(pattern: 'flake8.xml') | ||
} | ||
} | ||
} | ||
stage('Build') { | ||
steps { | ||
toolsEnv(TOOLS_PATH) { // load xmos tools | ||
sh 'tree' | ||
sh 'cd examples/throughput_c && make' | ||
sh 'cd examples/fileio_features_xc && xmake' | ||
} | ||
} | ||
} | ||
stage('Cleanup xtagctl'){ | ||
steps { | ||
withVenv() { | ||
toolsEnv(TOOLS_PATH) { | ||
sh 'xtagctl reset_all XCORE-AI-EXPLORER' | ||
sh 'rm -f ~/.xtag/status.lock ~/.xtag/acquired' | ||
} | ||
} | ||
} | ||
} | ||
stage('Tests'){ | ||
failFast false | ||
parallel { | ||
stage('Hardware tests') { | ||
stages{ | ||
stage('Transfer test single large'){ | ||
steps { | ||
withVenv() { | ||
toolsEnv(TOOLS_PATH) { | ||
sh 'python tests/test_throughput.py 64' //Pass size in MB | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
stage('Hardware tests #2 (in parallel)') { | ||
stages{ | ||
stage('Transfer test multiple small'){ | ||
steps { | ||
withVenv() { | ||
toolsEnv(TOOLS_PATH) { | ||
sh 'python tests/test_throughput.py 5' //Pass size in MB | ||
sh 'python tests/test_throughput.py 5' //Pass size in MB | ||
sh 'python tests/test_throughput.py 5' //Pass size in MB | ||
sh 'python tests/test_throughput.py 5' //Pass size in MB | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
stage('xsim tests'){ | ||
stages{ | ||
stage('feature test'){ | ||
steps { | ||
withVenv() { | ||
toolsEnv(TOOLS_PATH) { | ||
sh 'python tests/test_features.py' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
success { | ||
println "Do some sort of promotion: viewfiles/submodules/branches/tags" | ||
} | ||
always { | ||
archiveArtifacts artifacts: "**/*.bin", fingerprint: true, allowEmptyArchive: true | ||
} | ||
cleanup { | ||
cleanWs() | ||
} | ||
} | ||
} |
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
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
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,13 @@ | ||
# python_version 3.7 | ||
|
||
# dependencies | ||
numpy | ||
flake8==3.8.3 | ||
pylint==2.5.3 | ||
pytest==6.0.0 | ||
pytest-xdist==1.34.0 | ||
|
||
# self-install | ||
-e ./ | ||
-e xtagctl/ | ||
|
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,38 @@ | ||
import numpy as np | ||
import sys | ||
|
||
|
||
|
||
def analyse_error_rate(ref, dut): | ||
assert ref.shape == dut.shape, f"Unequal sizes: {ref.shape} {dut.shape}" | ||
size = ref.shape[0] | ||
num_diff = np.count_nonzero(ref != dut) | ||
if num_diff == 0: | ||
print("Files identical") | ||
return | ||
bit_error_ppm = size / 1000000.0 * num_diff | ||
print(f"Total bytes: {size} ({size // (1024*1024)}MB), differing bytes: {num_diff}, Error PPM: {bit_error_ppm:.2f}") | ||
|
||
clusters = 0 | ||
total_cluster_size = 0 | ||
diff_counter = 0 | ||
cluster_size_threshold = 16 | ||
for idx in range(size): | ||
if ref[idx] != dut[idx]: | ||
if diff_counter == 0: | ||
clusters += 1 | ||
diff_counter = cluster_size_threshold | ||
total_cluster_size += 1 | ||
if diff_counter > 0: | ||
diff_counter -= 1 | ||
|
||
average_cluster_size = total_cluster_size / clusters | ||
print(f"clusters: {clusters}, minimum gap {cluster_size_threshold}, ave_cluster_size: {average_cluster_size}") | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 3: | ||
assert False, f"usage: {sys.argv[0]} <ref.bin> <dut.bin>" | ||
ref = np.fromfile(sys.argv[1], dtype=np.uint8) | ||
dut = np.fromfile(sys.argv[2], dtype=np.uint8) | ||
|
||
analyse_error_rate(ref, dut) |
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 @@ | ||
#We assume that the Xscope FileIO Python library has been installed via pip beforehand and is available to import. Please see readme for instuctions. | ||
import numpy as np | ||
import xscope_fileio | ||
import os, sys | ||
import xtagctl | ||
import contextlib | ||
import random, string | ||
|
||
|
||
@contextlib.contextmanager | ||
def cd(path): | ||
CWD = os.getcwd() | ||
os.mkdir(path) | ||
os.chdir(path) | ||
yield | ||
os.chdir(CWD) | ||
|
||
|
||
def run_features(): | ||
tmpdirname = 'tmp_features_' + ''.join(random.choices(string.ascii_uppercase + string.digits, k=8)) | ||
test_dir = os.path.dirname(os.path.realpath(__file__)) + "/" + tmpdirname | ||
with cd(test_dir): | ||
ref_text = b"Evolution is change in the heritable characteristics of biological populations over successive generations." + b"\x00"; | ||
with open("features_ref.bin", "wb") as ref_file: | ||
ref_file.write(ref_text) | ||
|
||
firmware_xe = test_dir + "/../../examples/fileio_features_xc/bin/fileio_features_xc.xe" | ||
xscope_fileio.run_on_target(None, firmware_xe, use_xsim=True) | ||
|
||
|
||
with open("features_dut.bin", "rb") as dut_file: | ||
dut_text = dut_file.read() | ||
|
||
with open("features_dut_mod.bin", "rb") as dut_mod_file: | ||
dut_mod_text = dut_mod_file.read() | ||
|
||
ref_mod_text = ref_text[0:10] + b"IS" + ref_text[12:] | ||
|
||
assert dut_text == ref_text | ||
print(dut_mod_text, ref_mod_text) | ||
assert dut_mod_text == ref_mod_text | ||
print("PASS") | ||
|
||
if __name__ == "__main__": | ||
run_features() |
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 @@ | ||
#We assume that the Xscope FileIO Python library has been installed via pip beforehand and is available to import. Please see readme for instuctions. | ||
import numpy as np | ||
import xscope_fileio | ||
import os, sys | ||
import xtagctl | ||
import contextlib | ||
import random, string | ||
from compare_bins import analyse_error_rate | ||
|
||
|
||
@contextlib.contextmanager | ||
def cd(path): | ||
CWD = os.getcwd() | ||
os.mkdir(path) | ||
os.chdir(path) | ||
yield | ||
os.chdir(CWD) | ||
|
||
|
||
def run_throughput(size_mb): | ||
tmpdirname = 'tmp_throughput_' + ''.join(random.choices(string.ascii_uppercase + string.digits, k=8)) | ||
test_dir = os.path.dirname(os.path.realpath(__file__)) + "/" + tmpdirname | ||
with cd(test_dir): | ||
ref = np.random.randint(256, size=(size_mb * 1024 * 1024)).astype(np.uint8) | ||
ref.tofile("throughput_ref.bin") | ||
|
||
with xtagctl.acquire("XCORE-AI-EXPLORER", timeout=10) as adapter_id: | ||
firmware_xe = test_dir + "/../../examples/throughput_c/fileio_test.xe" | ||
xscope_fileio.run_on_target(adapter_id, firmware_xe, use_xsim=False) | ||
|
||
dut = np.fromfile("throughput_dut.bin", dtype=np.uint8) | ||
|
||
equal = np.array_equal(ref, dut) | ||
if not equal: | ||
analyse_error_rate(ref, dut) | ||
assert 0 | ||
|
||
print("PASS") | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) > 1: | ||
size_mb = int(sys.argv[1]) | ||
else: | ||
size_mb = 30 | ||
run_throughput(size_mb) |
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
Oops, something went wrong.