It can be done with tox target 'gen':
```bash
-tox -e gen
+$ tox -e gen
```
## Running unit-tests
-Execute command from the project root dir:
+Download resources required to run unit tests by executing the script in the scripts folder:
+```
+$ python ./scripts/download_test_resources.py
+```
+
+The script will download an archive from the Linaro server and extract it. A folder `test/testdata/shared` will be created. Execute `pytest` from the project root dir:
```bash
-$ tox
+$ python -m pytest test/ -v
```
-or
+or run tox which will do both:
```bash
-$ pytest -v
+$ tox
```
## Build python distr
--- /dev/null
+"""Downloads and extracts resources for unit tests.
+
+It is mandatory to run this script prior to running unit tests. Resources are stored as a tar.gz or a tar.bz2 archive and
+extracted into the test/testdata/shared folder.
+"""
+
+import tarfile
+import requests
+import os
+import uuid
+
+SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__))
+EXTRACT_DIR = os.path.join(SCRIPTS_DIR, "..", "test")
+ARCHIVE_URL = "https://snapshots.linaro.org/components/pyarmnn-tests/pyarmnn_testdata_200500_20200415.tar.bz2"
+
+
+def download_resources(url, save_path):
+ # download archive - only support tar.gz or tar.bz2
+ print("Downloading '{}'".format(url))
+ temp_filename = str(uuid.uuid4())
+ if url.endswith(".tar.bz2"):
+ temp_filename += ".tar.bz2"
+ elif url.endswith(".tar.gz"):
+ temp_filename += ".tar.gz"
+ else:
+ raise RuntimeError("Unsupported file.")
+ try:
+ r = requests.get(url, stream=True)
+ except requests.exceptions.RequestException as e:
+ raise RuntimeError("Unable to download file: {}".format(e))
+ file_path = os.path.join(save_path, temp_filename)
+ with open(file_path, 'wb') as f:
+ f.write(r.content)
+
+ # extract and delete temp file
+ with tarfile.open(file_path, "r:bz2" if temp_filename.endswith(".tar.bz2") else "r:gz") as tar:
+ print("Extracting '{}'".format(file_path))
+ tar.extractall(save_path)
+ if os.path.exists(file_path):
+ print("Removing '{}'".format(file_path))
+ os.remove(file_path)
+
+
+download_resources(ARCHIVE_URL, EXTRACT_DIR)
--- /dev/null
+requests==2.23.0
+pdoc3==0.6.3
+pyarmnn>=19.8.0
+++ /dev/null
-This folder contains models and data needed for the testing of PyArmNN.
-
-All models and files found in this folder were created by ARM for the purpose
-of testing PyArmNN.
-
-All the contents of this folder are distributed with the following license.
-
-Copyright © 2020 Arm Ltd. All rights reserved.
-SPDX-License-Identifier: MIT
-
+++ /dev/null
-{
- "ArmNN": {
- "inference_measurements_#1": {
- "type": "Event",
- "Wall clock time_#1": {
- "type": "Measurement",
- "raw": [
- 1.1,
- 2.2,
- 3.3,
- 4.4,
- 5.5,
- 6.6
- ],
- "unit": "us"
- },
-
- "Execute_#2": {
- "type": "Event",
- "Wall clock time_#2": {
- "type": "Measurement",
- "raw": [
- 1.1,
- 2.2,
- 3.3,
- 4.4,
- 5.5,
- 6.6
- ],
- "unit": "us"
- },
- "Wall clock time (Start)_#2": {
- "type": "Measurement",
- "raw": [
- 1,
- 1,
- 1,
- 1,
- 1,
- 1
- ],
- "unit": "us"
- },
- "Wall clock time (Stop)_#2": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
-
- "RefSomeMock1dWorkload_Execute_#5": {
- "type": "Event",
- "Wall clock time_#5": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Start)_#5": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Stop)_#5": {
- "type": "Measurement",
- "raw": [
- 4,
- 4,
- 4,
- 4,
- 4,
- 4
- ],
- "unit": "us"
- }
- },
- "NeonSomeMock2Workload_Execute_#6": {
- "type": "Event",
- "Wall clock time_#6": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Start)_#6": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Stop)_#6": {
- "type": "Measurement",
- "raw": [
- 4,
- 4,
- 4,
- 4,
- 4,
- 4
- ],
- "unit": "us"
- }
- },
- "ClSomeMock3dWorkload_Execute_#7": {
- "type": "Event",
- "Wall clock time_#7": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Start)_#7": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Stop)_#7": {
- "type": "Measurement",
- "raw": [
- 4,
- 4,
- 4,
- 4,
- 4,
- 4
- ],
- "unit": "us"
- }
- },
- "EthosNSomeMock4dWorkload_Execute_#8": {
- "type": "Event",
- "Wall clock time_#8": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Start)_#8": {
- "type": "Measurement",
- "raw": [
- 2,
- 2,
- 2,
- 2,
- 2,
- 2
- ],
- "unit": "us"
- },
- "Wall clock time (Stop)_#8": {
- "type": "Measurement",
- "raw": [
- 4,
- 4,
- 4,
- 4,
- 4,
- 4
- ],
- "unit": "us"
- }
- }
- }
- }
- }
-}
setuptools==41.6.0
numpy==1.17.2
pillow==6.1.0
+ requests==2.23.0
recreate = True
whitelist_externals = /bin/sh
commands =
+ python ./scripts/download_test_resources.py
python -m pytest test/ -v {posargs} --junit-xml=test_report_junit-{envname}.xml --cov=pyarmnn --cov-report xml:coverage-{envname}.xml
[testenv:devenv]