You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/09/17 12:20:54 UTC
[mynewt-nimble] 01/01: test
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch travis-dev
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit effe92318bbe45b604a7613be4e2b9101e41224d
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Wed Sep 14 08:22:36 2022 +0200
test
---
.travis.yml | 186 ++++++++++----------------------
tests/project.yml | 38 +++++++
tests/scripts/build_targets.sh | 6 ++
tests/scripts/check_style.py | 110 +++++++++++++++++++
tests/targets/ll/cmac/pkg.yml | 4 +
tests/targets/ll/cmac/syscfg.yml | 18 ++++
tests/targets/ll/cmac/target.yml | 3 +
tests/targets/ll/nrf52840/pkg.yml | 4 +
tests/targets/ll/nrf52840/syscfg.yml | 0
tests/targets/ll/nrf52840/target.yml | 5 +
tests/targets/ll/nrf5340_net/pkg.yml | 4 +
tests/targets/ll/nrf5340_net/syscfg.yml | 0
tests/targets/ll/nrf5340_net/target.yml | 3 +
tests/targets/ll/pkg.yml | 2 +
tests/targets/ll/syscfg.yml | 31 ++++++
uncrustify.cfg | 3 -
16 files changed, 285 insertions(+), 132 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index d3dd9742..8f0def89 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,142 +15,70 @@
# specific language governing permissions and limitations
# under the License.
-language: go
-
-dist: bionic
-
-_addons: &addon_conf
- apt:
- sources:
- - ubuntu-toolchain-r-test
- packages:
- - gcc-multilib
- - gcc-7-multilib
- - g++-multilib
-
-go:
- - "1.16"
+os: linux
+dist: jammy
+language: shell
git:
- depth: false
-
-matrix:
- allow_failures:
- - env:
- - TEST=BUILD_PORTS
- - VM_AMOUNT=1
- - TARGET_SET=1
- include:
- # Style checking
- - os: linux
- language: python
- python:
- - "3.5"
- addons:
- apt:
- packages:
- - "python3-pip"
- env:
- - TEST=STYLE
- - DEBUG=1
-
- # newt build <targets>
- - os: linux
- addons: *addon_conf
- env:
- - TEST=BUILD_TARGETS
- - VM_AMOUNT=4
- - TARGET_SET=1
- - os: linux
- addons: *addon_conf
- env:
- - TEST=BUILD_TARGETS
- - VM_AMOUNT=4
- - TARGET_SET=2
- - os: linux
- addons: *addon_conf
- env:
- - TEST=BUILD_TARGETS
- - VM_AMOUNT=4
- - TARGET_SET=3
- - os: linux
- addons: *addon_conf
- env:
- - TEST=BUILD_TARGETS
- - VM_AMOUNT=4
- - TARGET_SET=4
-
- # newt test all (Linux)
- - os: linux
- addons: *addon_conf
- env:
- - TEST=TEST_ALL
- - VM_AMOUNT=2
- - TARGET_SET=1
- - os: linux
- addons: *addon_conf
- env:
- - TEST=TEST_ALL
- - VM_AMOUNT=2
- - TARGET_SET=2
+ # do not clone to default location, we'll clone into project dir
+ clone: false
- # ports
- - os: linux
- addons: *addon_conf
- env:
- - TEST=BUILD_PORTS
- - VM_AMOUNT=1
- - TARGET_SET=1
+cache:
+ ccache: true
+ directories:
+ - $HOME/.ccache
- - os: windows
- env:
- - TEST=BUILD_TARGETS_WINDOWS
- - VM_AMOUNT=1
- - TARGET_SET=1
+_style-before_script: &style-before_script
+ # prepare project
+ - mkdir -p ~/mynewt-ci && cd ~/mynewt-ci
+ - git clone --single-branch https://github.com/apache/mynewt-nimble.git
+ - cd mynewt-nimble
+ - git fetch origin refs/pull/$TRAVIS_PULL_REQUEST/head
+ - git checkout -q FETCH_HEAD
-before_install:
- - printenv
- - export GOPATH=$HOME/gopath
+_build-install: &build-install
+ # install newt
+ - eval "$(gimme 1.16)"
- go version
+ - go get mynewt.apache.org/newt/newt@latest
+ - newt version
+ # install toolchain
+ - mkdir ~/gcc-arm-none-eabi
+ - wget -qO- "https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi.tar.xz" | tar xvJ --strip 1 -C ~/gcc-arm-none-eabi
+ - for t in ~/gcc-arm-none-eabi/bin/arm-none-eabi-*; do ln -sf $(which ccache) ~/bin/$(basename "$t"); done
+ - export PATH=$PATH:~/gcc-arm-none-eabi/bin
+
+_build-before_script: &build-before_script
+ # prepare project
+ - mkdir -p ~/mynewt-ci && cd ~/mynewt-ci
+ - git clone --depth=1 https://github.com/apache/mynewt-core.git repos/apache-mynewt-core
+ - git clone --depth=1 https://github.com/apache/mynewt-nimble.git repos/apache-mynewt-nimble
+ - git clone --depth=1 https://github.com/apache/mynewt-mcumgr.git repos/apache-mynewt-mcumgr
+ - git clone --depth=1 https://github.com/mcu-tools/mcuboot.git repos/mcuboot
+ - git clone --depth=1 https://github.com/hathach/tinyusb.git repos/tinyusb
+ - cd repos/apache-mynewt-nimble
+ - git fetch origin "$TRAVIS_COMMIT"
+ - git checkout -q FETCH_HEAD
+ - cp tests/project.yml ../..
-install:
- - git clone https://github.com/JuulLabs-OSS/mynewt-travis-ci $HOME/ci
- - chmod +x $HOME/ci/*.sh
- - |
- if [ "${TEST}" == "STYLE" ]; then
- pip3 install requests
- else
- $HOME/ci/${TRAVIS_OS_NAME}_travis_install.sh
- fi
+jobs:
+ include:
+ - name: Style check
+ if: type IN (pull_request)
+ install: sudo apt update && sudo apt -y install uncrustify
+ before_script: *style-before_script
+ script: ./tests/scripts/check_style.py FETCH_HEAD
-before_script:
- - |
- if [ "${TEST}" == "STYLE" ]; then
- $HOME/ci/install_uncrustify.sh
- else
- newt version
- gcc --version
- if [ "${TEST}" != "TEST_ALL" ]; then arm-none-eabi-gcc --version; fi
- cp -R $HOME/ci/mynewt-nimble-project.yml project.yml
- mkdir -p targets
- cp -R $HOME/ci/mynewt-nimble-targets targets
- $HOME/ci/prepare_test.sh $VM_AMOUNT
- mkdir -p repos && pushd repos/
- git clone --depth=1 https://github.com/apache/mynewt-core apache-mynewt-core
- git clone --depth=1 https://github.com/JuulLabs-OSS/mcuboot mcuboot
- git clone --depth=1 https://github.com/apache/mynewt-mcumgr apache-mynewt-mcumgr
- popd
- fi
+ - name: Build targets (LL)
+ install: *build-install
+ before_script: *build-before_script
+ script: ./tests/scripts/build_targets.sh tests/targets/ll/
-script:
- - |
- if [ "${TEST}" == "STYLE" ]; then
- python3 $HOME/ci/check_style.py
- else
- $HOME/ci/run_test.sh
- fi
+ - name: Build targets (other)
+ install: *build-install
+ before_script: *build-before_script
+ script: ./tests/scripts/build_targets.sh targets/
-cache:
- directories:
- - $HOME/TOOLCHAIN
- - $HOME/Library/Caches/Homebrew
+after_script:
+ - ccache -s
+ - ccache -p
diff --git a/tests/project.yml b/tests/project.yml
new file mode 100644
index 00000000..84daaa5e
--- /dev/null
+++ b/tests/project.yml
@@ -0,0 +1,38 @@
+project.name: "apache-mynewt-nimble"
+
+project.repositories:
+ - apache-mynewt-core
+ - apache-mynewt-nimble
+ - apache-mynewt-mcumgr
+ - mcuboot
+ - tinyusb
+
+repository.apache-mynewt-core:
+ type: github
+ vers: 0.0.0
+ user: apache
+ repo: mynewt-core
+
+repository.apache-mynewt-nimble:
+ type: github
+ vers: 0.0.0
+ user: apache
+ repo: mynewt-nimble
+
+repository.apache-mynewt-mcumgr:
+ type: github
+ vers: 0.0.0
+ user: apache
+ repo: mynewt-mcumgr
+
+repository.mcuboot:
+ type: github
+ vers: 0.0.0
+ user: mcu-tools
+ repo: mcuboot
+
+repository.tinyusb:
+ type: github
+ vers: 0.0.0
+ user: hathach
+ repo: tinyusb
diff --git a/tests/scripts/build_targets.sh b/tests/scripts/build_targets.sh
new file mode 100755
index 00000000..0d93c362
--- /dev/null
+++ b/tests/scripts/build_targets.sh
@@ -0,0 +1,6 @@
+#!/bin/bash -xe
+
+TARGETS=$(newt target list -a | grep -E "^@apache-mynewt-nimble/${1:-tests/targets/}")
+for t in $TARGETS; do
+ newt build "$t" 1> /dev/null
+done
diff --git a/tests/scripts/check_style.py b/tests/scripts/check_style.py
new file mode 100755
index 00000000..70c3391f
--- /dev/null
+++ b/tests/scripts/check_style.py
@@ -0,0 +1,110 @@
+#!/usr/bin/python
+
+import os.path
+import re
+import subprocess
+import tempfile
+import sys
+
+
+def get_lines_range(m: re.Match) -> range:
+ first = int(m.group(1))
+
+ if m.group(2) is not None:
+ last = first + int(m.group(2))
+ else:
+ last = first + 1
+
+ return range(first, last)
+
+
+def run_cmd(cmd: str) -> list[str]:
+ out = subprocess.check_output(cmd, text=True, shell=True)
+ return out.splitlines()
+
+
+def check_file(fname: str, commit: str, upstream: str) -> list[str]:
+ ret = []
+
+ diff_lines = set()
+ for s in run_cmd(f"git diff -U0 {upstream} {commit} -- {fname}"):
+ m = re.match(r"^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@", s)
+ if not m:
+ continue
+ diff_lines.update(get_lines_range(m))
+
+ with tempfile.NamedTemporaryFile(suffix=os.path.basename(fname)) as tmpf:
+ lines = subprocess.check_output(f"git show {commit}:{fname}",
+ shell=True)
+ tmpf.write(lines)
+
+ in_chunk = False
+
+ for s in run_cmd(f"uncrustify -q -c uncrustify.cfg -f {tmpf.name} | "
+ f"diff -u0 -p {tmpf.name} - || true"):
+ m = re.match(r"^@@ -(\d+)(?:,(\d+))? \+\d+(?:,\d+)? @@", s)
+ if not m:
+ if in_chunk:
+ ret.append(s)
+ continue
+
+ in_chunk = len(diff_lines & set(get_lines_range(m))) != 0
+
+ if in_chunk:
+ ret.append(s)
+
+ return ret
+
+
+def is_ignored(fname: str, ign_dirs: list[str]) -> bool:
+ if not re.search(r"\.(c|cpp|h|hpp)$", fname):
+ return True
+
+ for d in ign_dirs:
+ if fname.startswith(d):
+ return True
+
+ return False
+
+
+def main() -> bool:
+ if len(sys.argv) > 1:
+ commit = sys.argv[1]
+ else:
+ commit = "HEAD"
+ if len(sys.argv) > 2:
+ upstream = sys.argv[2]
+ else:
+ upstream = "origin/master"
+
+ mb = run_cmd(f"git merge-base {upstream} {commit}")
+ upstream = mb[0]
+
+ has_error = False
+
+ with open(".style_ignored_dirs", "r") as x:
+ ign_dirs = [s.strip() for s in x.readlines() if
+ s.strip() and not s.startswith("#")]
+
+ files = run_cmd(f"git diff --diff-filter=AM --name-only {upstream} {commit}")
+ for fname in files:
+ if is_ignored(fname, ign_dirs):
+ print(f"\033[90m- {fname}\033[0m")
+ continue
+
+ diff = check_file(fname, commit, upstream)
+ if len(diff) > 0:
+ print(f"\033[31m! {fname}\033[0m")
+ print()
+ print("\n".join(diff))
+ print()
+ has_error = True
+ else:
+ print(f"+ {fname}")
+
+ return not has_error
+
+
+if __name__ == "__main__":
+ if not main():
+ sys.exit(1)
diff --git a/tests/targets/ll/cmac/pkg.yml b/tests/targets/ll/cmac/pkg.yml
new file mode 100644
index 00000000..5bc957cd
--- /dev/null
+++ b/tests/targets/ll/cmac/pkg.yml
@@ -0,0 +1,4 @@
+pkg.name: tests/targets/ll/cmac
+pkg.type: target
+pkg.deps:
+ - tests/targets/ll
diff --git a/tests/targets/ll/cmac/syscfg.yml b/tests/targets/ll/cmac/syscfg.yml
new file mode 100644
index 00000000..8e499b3f
--- /dev/null
+++ b/tests/targets/ll/cmac/syscfg.yml
@@ -0,0 +1,18 @@
+syscfg.vals:
+ MCU_SLP_TIMER: 1
+ MCU_SLP_TIMER_32K_ONLY: 1
+ MCU_DEEP_SLEEP: 1
+ MCU_DEBUG_HCI_EVENT_ON_FAULT: 1
+ MCU_DEBUG_HCI_EVENT_ON_ASSERT: 1
+ MCU_DEBUG_DSER_HAL_OS_TICK: 0
+ MCU_DEBUG_DSER_CMAC_SHARED: 0
+ MCU_DEBUG_DSER_CMAC_SLEEP: 0
+ MCU_DEBUG_DSER_BLE_HCI_CMAC_LL: 0
+
+ BLE_LL_PUBLIC_DEV_ADDR: 0xc0dec000c3ac
+ BLE_LL_CONN_INIT_MIN_WIN_OFFSET: 4
+ BLE_LL_SCHED_AUX_MAFS_DELAY: 200
+ BLE_LL_SCHED_AUX_CHAIN_MAFS_DELAY: 150
+ BLE_LL_RFMGMT_ENABLE_TIME: 20
+ BLE_LL_HCI_VS_EVENT_ON_ASSERT: 0
+ BLE_LL_CFG_FEAT_LE_CODED_PHY: 0
diff --git a/tests/targets/ll/cmac/target.yml b/tests/targets/ll/cmac/target.yml
new file mode 100644
index 00000000..e3ca85cd
--- /dev/null
+++ b/tests/targets/ll/cmac/target.yml
@@ -0,0 +1,3 @@
+target.app: "@apache-mynewt-nimble/apps/blehci"
+target.bsp: "@apache-mynewt-core/hw/bsp/dialog_cmac"
+target.build_profile: speed
diff --git a/tests/targets/ll/nrf52840/pkg.yml b/tests/targets/ll/nrf52840/pkg.yml
new file mode 100644
index 00000000..f7d4b994
--- /dev/null
+++ b/tests/targets/ll/nrf52840/pkg.yml
@@ -0,0 +1,4 @@
+pkg.name: tests/targets/ll/nrf52840
+pkg.type: target
+pkg.deps:
+ - tests/targets/ll
diff --git a/tests/targets/ll/nrf52840/syscfg.yml b/tests/targets/ll/nrf52840/syscfg.yml
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/targets/ll/nrf52840/target.yml b/tests/targets/ll/nrf52840/target.yml
new file mode 100644
index 00000000..a01c8322
--- /dev/null
+++ b/tests/targets/ll/nrf52840/target.yml
@@ -0,0 +1,5 @@
+target.app: "@apache-mynewt-nimble/apps/blehci"
+target.bsp: "@apache-mynewt-core/hw/bsp/nordic_pca10056"
+target.build_profile: debug
+#target.build_profile: optimized
+#target.build_profile: speed
diff --git a/tests/targets/ll/nrf5340_net/pkg.yml b/tests/targets/ll/nrf5340_net/pkg.yml
new file mode 100644
index 00000000..8a928aa1
--- /dev/null
+++ b/tests/targets/ll/nrf5340_net/pkg.yml
@@ -0,0 +1,4 @@
+pkg.name: tests/targets/ll/nrf5340_net
+pkg.type: target
+pkg.deps:
+ - tests/targets/ll
diff --git a/tests/targets/ll/nrf5340_net/syscfg.yml b/tests/targets/ll/nrf5340_net/syscfg.yml
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/targets/ll/nrf5340_net/target.yml b/tests/targets/ll/nrf5340_net/target.yml
new file mode 100644
index 00000000..9064063c
--- /dev/null
+++ b/tests/targets/ll/nrf5340_net/target.yml
@@ -0,0 +1,3 @@
+target.app: "@apache-mynewt-nimble/apps/blehci"
+target.bsp: "@apache-mynewt-core/hw/bsp/nordic_pca10095_net"
+target.build_profile: debug
diff --git a/tests/targets/ll/pkg.yml b/tests/targets/ll/pkg.yml
new file mode 100644
index 00000000..6ddafd56
--- /dev/null
+++ b/tests/targets/ll/pkg.yml
@@ -0,0 +1,2 @@
+pkg.name: tests/targets/ll
+pkg.type: config
diff --git a/tests/targets/ll/syscfg.yml b/tests/targets/ll/syscfg.yml
new file mode 100644
index 00000000..9fd6545b
--- /dev/null
+++ b/tests/targets/ll/syscfg.yml
@@ -0,0 +1,31 @@
+syscfg.vals:
+ OS_CRASH_FILE_LINE: 1
+ MSYS_1_BLOCK_SIZE: 308
+
+ BLE_VERSION: 53
+ BLE_EXT_ADV: 1
+ BLE_EXT_ADV_MAX_SIZE: 1650
+ BLE_PERIODIC_ADV: 1
+ BLE_PERIODIC_ADV_SYNC_TRANSFER: 1
+ BLE_MULTI_ADV_INSTANCES: 4
+ BLE_MAX_PERIODIC_SYNCS: 4
+ BLE_MAX_CONNECTIONS: 4
+
+ BLE_TRANSPORT_ACL_COUNT: 32
+ BLE_TRANSPORT_ACL_SIZE: 255
+ BLE_TRANSPORT_EVT_DISCARDABLE_COUNT: 64
+
+syscfg.vals.BLE_CONTROLLER:
+ BLE_LL_STACK_SIZE: 200
+ BLE_LL_CFG_FEAT_DATA_LEN_EXT: 1
+ BLE_LL_CFG_FEAT_LE_2M_PHY: 1
+ BLE_LL_CFG_FEAT_LE_CODED_PHY: 1
+ BLE_LL_CFG_FEAT_LL_PRIVACY: 1
+ BLE_LL_CFG_FEAT_LL_SCA_UPDATE: 1
+ BLE_LL_CFG_FEAT_LL_ENHANCED_CONN_UPDATE: 1
+ BLE_LL_CFG_FEAT_CTRL_TO_HOST_FLOW_CONTROL: 1
+ BLE_LL_CONN_INIT_SLOTS: 1
+ BLE_LL_DTM: 1
+ BLE_LL_HCI_VS_EVENT_ON_ASSERT: 1
+ BLE_LL_SCAN_AUX_SEGMENT_CNT: 16
+ BLE_LL_NUM_SCAN_DUP_ADVS: 64
diff --git a/uncrustify.cfg b/uncrustify.cfg
index 481a62ab..d5f85763 100644
--- a/uncrustify.cfg
+++ b/uncrustify.cfg
@@ -677,9 +677,6 @@ sp_try_brace = ignore # ignore/add/remove/force
# Add or remove space between get/set and '{' if on the same line
sp_getset_brace = ignore # ignore/add/remove/force
-# Add or remove space between a variable and '{' for C++ uniform initialization. Default=Add
-sp_word_brace = add # ignore/add/remove/force
-
# Add or remove space between a variable and '{' for a namespace. Default=Add
sp_word_brace_ns = add # ignore/add/remove/force