Compare commits

...

6 Commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
c895d1d033 Bluetooth: controller: Add explicit opcode check in unknown rsp PDU
Add explicit opcode check when handling received unknown
response PDU.

Without this, for example, an in progress Data Length Update
procedure state was reset when receiving an unknown response
to slave initiated feature request.

Fixes #26252.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-15 16:45:36 +03:00
Kumar Gala
e034bb3641 buildkite: Handle case of sanitycheck doing nothing
The junit-annotate step will fail if there are no sanitycheck-*.xml
files to be found which can happen if sanitycheck is run and does
nothing (for example an update to .editorconfig).

Try and create an empty sanitycheck.xml in such a case.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-23 11:05:47 -04:00
Anas Nashif
b57fc3c3ec codeowner: add scripts/ci
Fix codeowner for scripts/ci

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-06-22 15:22:02 -04:00
Anas Nashif
51e1085494 ci: add compliance checking via GH actions
Move check_compliance script to main tree and adapt/use with GH actions.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-06-22 15:22:02 -04:00
Kumar Gala
0fadaa2cc2 ci: Add initial buildkite ci setup
Add setup to utilize buildkite for CI purposes:

1. .buildkite/hooks/pre-command:
   * Handles getting git checkout setup against upstream repo
   * Setup some west module cache (dirs, clean out files & locks)
   * init dir for ccache

2. .buildkite/hooks/post-command:
   * Report disk usage (meant for possible debugging)

3. .buildkite/pipeline.yml [uses to determine what to do]:
   * setup zephyr env vars
   * set which docker container to use
     (export some local disk caches for git, west modules, and ccache)
   * uses plug to general build annotation on failure (junit-annotate)

4. .buildkite/run.sh [ buildkite wrapper to invoke scripts/ci/run.sh ]

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-22 14:20:27 -04:00
Kumar Gala
7330de0a6e ci: Update for buildkite environment
* Tweak west_setup:
  - log `west update` to a file to reduce noise in log
  - use `west forall` + `git reset` to make sure files are checked out
    (this is to handle a possible module cache)
* Output when we start sanity_check.  Add a banner for when we run
  sanity_check so it's a bit easier to find in console logs

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-22 14:20:27 -04:00
10 changed files with 1628 additions and 9 deletions

8
.buildkite/hooks/post-command Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
# Copyright (c) 2020 Linaro Limited
#
# SPDX-License-Identifier: Apache-2.0
# report disk usage:
echo "--- $0 disk usage"
df -h

38
.buildkite/hooks/pre-command Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# Copyright (c) 2020 Linaro Limited
#
# SPDX-License-Identifier: Apache-2.0
# Save off where we started so we can go back there
WORKDIR=${PWD}
if [ -n "${BUILDKITE_PULL_REQUEST_BASE_BRANCH}" ]; then
git fetch -v origin ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}
git checkout FETCH_HEAD
git config --local user.email "builds@zephyrproject.org"
git config --local user.name "Zephyr CI"
git merge --no-edit "${BUILDKITE_COMMIT}" || {
local merge_result=$?
echo "Merge failed: ${merge_result}"
git merge --abort
exit $merge_result
}
fi
mkdir -p /var/lib/buildkite-agent/zephyr-ccache/
# create cache dirs, no-op if they already exist
mkdir -p /var/lib/buildkite-agent/zephyr-module-cache/modules
mkdir -p /var/lib/buildkite-agent/zephyr-module-cache/tools
mkdir -p /var/lib/buildkite-agent/zephyr-module-cache/bootloader
# Clean cache - if it already exists
cd /var/lib/buildkite-agent/zephyr-module-cache
find -type f -not -path "*/.git/*" -not -name ".git" -delete
# Remove any stale locks
find -name index.lock -delete
# return from where we started so we can find pipeline files from
# git repo
cd ${WORKDIR}

28
.buildkite/pipeline.yml Normal file
View File

@@ -0,0 +1,28 @@
steps:
- command:
- .buildkite/run.sh
env:
ZEPHYR_TOOLCHAIN_VARIANT: "zephyr"
ZEPHYR_SDK_INSTALL_DIR: "/opt/sdk/zephyr-sdk-0.11.3"
parallelism: 20
timeout_in_minutes: 120
retry:
manual: true
plugins:
- docker#v3.5.0:
image: "zephyrprojectrtos/ci:v0.11.8"
propagate-environment: true
volumes:
- "/var/lib/buildkite-agent/git-mirrors:/var/lib/buildkite-agent/git-mirrors"
- "/var/lib/buildkite-agent/zephyr-module-cache:/var/lib/buildkite-agent/zephyr-module-cache"
- "/var/lib/buildkite-agent/zephyr-ccache:/root/.ccache"
workdir: "/workdir/zephyr"
agents:
- "queue=default"
- wait: ~
continue_on_failure: true
- plugins:
- junit-annotate#v1.7.0:
artifacts: sanitycheck-*.xml

50
.buildkite/run.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
# Copyright (c) 2020 Linaro Limited
#
# SPDX-License-Identifier: Apache-2.0
echo "--- run $0"
git log -n 5 --oneline --decorate --abbrev=12
# Setup module cache
cd /workdir
ln -s /var/lib/buildkite-agent/zephyr-module-cache/modules
ln -s /var/lib/buildkite-agent/zephyr-module-cache/tools
ln -s /var/lib/buildkite-agent/zephyr-module-cache/bootloader
cd /workdir/zephyr
export JOB_NUM=$((${BUILDKITE_PARALLEL_JOB}+1))
# ccache stats
echo ""
echo "--- ccache stats at start"
ccache -s
if [ -n "${BUILDKITE_PULL_REQUEST_BASE_BRANCH}" ]; then
./scripts/ci/run_ci.sh -c -b ${BUILDKITE_PULL_REQUEST_BASE_BRANCH} -r origin \
-m ${JOB_NUM} -M ${BUILDKITE_PARALLEL_JOB_COUNT} -p ${BUILDKITE_PULL_REQUEST}
else
./scripts/ci/run_ci.sh -c -b ${BUILDKITE_BRANCH} -r origin \
-m ${JOB_NUM} -M ${BUILDKITE_PARALLEL_JOB_COUNT};
fi;
SANITY_EXIT_STATUS=$?
# Rename sanitycheck junit xml for use with junit-annotate-buildkite-plugin
# create dummy file if sanitycheck did nothing
if [ ! -f sanity-out/sanitycheck.xml ]; then
touch sanity-out/sanitycheck.xml
fi
mv sanity-out/sanitycheck.xml sanitycheck-${BUILDKITE_JOB_ID}.xml
buildkite-agent artifact upload sanitycheck-${BUILDKITE_JOB_ID}.xml
# ccache stats
echo "--- ccache stats at finish"
ccache -s
# disk usage
echo "--- disk usage at finish"
df -h
exit ${SANITY_EXIT_STATUS}

114
.github/workflows/compliance.yml vendored Normal file
View File

@@ -0,0 +1,114 @@
name: Compliance
on: pull_request
jobs:
compliance_job:
runs-on: ubuntu-latest
name: Run compliance checks on patch series (PR)
steps:
- name: Checkout the code
uses: actions/checkout@v1
- name: cache-pip
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-doc-pip
- name: Install python dependencies
run: |
pip3 install setuptools
pip3 install wheel
pip3 install python-magic junitparser gitlint pylint pykwalify
pip3 install west
- name: Run Compliance Tests
id: compliance
env:
BASE_REF: ${{ github.base_ref }}
run: |
export PATH=$PATH:~/.local/bin
export ZEPHYR_BASE=$PWD
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git rebase origin/${BASE_REF}
./scripts/ci/check_compliance.py -m Codeowners -m Devicetree -m Gitlint -m Identity -m Nits -m pylint -m checkpatch -m Kconfig -c origin/${BASE_REF}.. || true
- name: upload-results
uses: actions/upload-artifact@master
continue-on-error: True
with:
name: compliance.xml
path: compliance.xml
- name: check-warns
run: |
if [ -s Nits.txt ]; then
errors=$(cat Nits.txt)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=Nits.txt::$errors"
exit=1
fi
if [ -s checkpatch.txt ]; then
errors=$(cat checkpatch.txt)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=Checkpatch.txt::$errors"
exit=1
fi
if [ -s Identity.txt ]; then
errors=$(cat Identity.txt)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=Identity.txt::$errors"
exit=1
fi
if [ -s Gitlint.txt ]; then
errors=$(cat Gitlint.txt)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=Gitlint.txt::$errors"
exit=1
fi
if [ -s pylint.txt ]; then
errors=$(cat pylint.txt)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=pylint.txt::$errors"
exit=1
fi
if [ -s Devicetree.txt ]; then
errors=$(cat Devicetree.txt)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=Devicetree.txt::$errors"
exit=1
fi
if [ -s Kconfig.txt ]; then
errors=$(cat Kconfig.txt)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=Kconfig.txt::$errors"
exit=1
fi
if [ -s Codeowners.txt ]; then
errors=$(cat Codeowners.txt)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=Codeowners.txt::$errors"
exit=1
fi
if [ ${exit} == 1 ]; then
exit 1;
fi

View File

@@ -16,6 +16,7 @@
/.known-issues/ @nashif
/.github/ @nashif
/.github/workflows/ @galak @nashif
/.buildkite/ @galak
/arch/arc/ @vonhust @ruuddw
/arch/arm/ @MaureenHelm @galak @ioannisg
/arch/arm/core/aarch32/cortex_m/cmse/ @ioannisg
@@ -369,6 +370,7 @@
/samples/subsys/usb/ @jfischer-phytec-iot @finikorg
/samples/subsys/power/ @wentongwu @pabigot
/samples/userspace/ @andrewboie
/scripts/ci/ @nashif @galak
/scripts/coccicheck @himanshujha199640 @JuliaLawall
/scripts/coccinelle/ @himanshujha199640 @JuliaLawall
/scripts/kconfig/ @ulfalizer

1123
scripts/ci/check_compliance.py Executable file

File diff suppressed because it is too large Load Diff

249
scripts/ci/pylintrc Normal file
View File

@@ -0,0 +1,249 @@
# Copyright (c) 2019, Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
# pylint configuration for the PyLint check in check_compliance.py.
#
# To run pylint manually with this configuration from the Zephyr repo, do
#
# pylint3 --rcfile=ci-tools/scripts/pylintrc <Python file>
#
# This command will check all scripts:
#
# pylint3 --rcfile=ci-tools/scripts/pylintrc $(git ls-files '*.py')
[MASTER]
# Use multiple processes
jobs=0
# Do not pickle collected data for comparisons
persistent=no
[REPORTS]
# Only show messages, not full report
reports=no
# Disable score
score=no
[MESSAGES CONTROL]
# Only enable specific (hopefully) uncontroversial warnings. Use
# 'pylint3 --list-msgs' to list messages and their IDs.
#
# These might be nice to check too, but currently trigger false positives:
#
# no-member
# arguments-differ
# redefine-in-handler
# abstract-method
#
# These might be too controversial:
#
# no-else-return
# consider-using-get
# redefined-builtin
#
# These tell you to use logger.warning("foo %d bar", 3) instead of e.g.
# logger.warning("foo {} bar".format(3)), but it's not a clear win in all
# cases. f-strings would be nicer too, and it's easier to convert from format()
# to those.
#
# logging-not-lazy
# logging-format-interpolation
# logging-fstring-interpolation
disable=all
# Identifiers are in the same order as in 'pylint3 --list-msgs'. Entire
# message "types" (~= severities) like F(atal), E(error),... are listed
# first.
enable=
F, # atal
empty-docstring,
unneeded-not,
singleton-comparison,
misplaced-comparison-constant,
unidiomatic-typecheck,
consider-using-enumerate,
consider-iterating-dictionary,
bad-classmethod-argument,
bad-mcs-method-argument,
bad-mcs-classmethod-argument,
single-string-used-for-slots,
trailing-newlines,
trailing-whitespace,
missing-final-newline,
superfluous-parens,
mixed-line-endings,
unexpected-line-ending-format,
invalid-characters-in-docstring,
useless-import-alias,
len-as-condition,
syntax-error,
init-is-generator,
return-in-init,
function-redefined,
not-in-loop,
return-outside-function,
yield-outside-function,
nonexistent-operator,
duplicate-argument-name,
abstract-class-instantiated,
bad-reversed-sequence,
too-many-star-expressions,
invalid-star-assignment-target,
star-needs-assignment-target,
nonlocal-and-global,
continue-in-finally,
nonlocal-without-binding,
misplaced-format-function,
method-hidden,
access-member-before-definition,
no-method-argument,
no-self-argument,
invalid-slots-object,
assigning-non-slot,
invalid-slots,
inherit-non-class,
inconsistent-mro,
duplicate-bases,
non-iterator-returned,
unexpected-special-method-signature,
invalid-length-returned,
relative-beyond-top-level,
used-before-assignment,
undefined-variable,
undefined-all-variable,
invalid-all-object,
no-name-in-module,
unpacking-non-sequence,
bad-except-order,
raising-bad-type,
bad-exception-context,
misplaced-bare-raise,
raising-non-exception,
notimplemented-raised,
catching-non-exception,
bad-super-call,
not-callable,
assignment-from-no-return,
no-value-for-parameter,
too-many-function-args,
unexpected-keyword-arg,
redundant-keyword-arg,
missing-kwoa,
invalid-sequence-index,
invalid-slice-index,
assignment-from-none,
not-context-manager,
invalid-unary-operand-type,
unsupported-binary-operation,
repeated-keyword,
not-an-iterable,
not-a-mapping,
unsupported-membership-test,
unsubscriptable-object,
unsupported-assignment-operation,
unsupported-delete-operation,
invalid-metaclass,
unhashable-dict-key,
logging-unsupported-format,
logging-format-truncated,
logging-too-many-args,
logging-too-few-args,
bad-format-character,
truncated-format-string,
mixed-format-string,
format-needs-mapping,
missing-format-string-key,
too-many-format-args,
too-few-format-args,
bad-string-format-type,
bad-str-strip-call,
invalid-envvar-value,
yield-inside-async-function,
not-async-context-manager,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
literal-comparison,
comparison-with-itself,
no-self-use,
no-classmethod-decorator,
no-staticmethod-decorator,
cyclic-import,
duplicate-code,
consider-merging-isinstance,
simplifiable-if-statement,
redefined-argument-from-local,
trailing-comma-tuple,
stop-iteration-return,
useless-return,
consider-swap-variables,
consider-using-join,
consider-using-in,
chained-comparison,
consider-using-dict-comprehension,
consider-using-set-comprehension,
simplifiable-if-expression,
unreachable,
pointless-statement,
pointless-string-statement,
expression-not-assigned,
unnecessary-pass,
unnecessary-lambda,
duplicate-key,
assign-to-new-keyword,
useless-else-on-loop,
confusing-with-statement,
using-constant-test,
comparison-with-callable,
lost-exception,
assert-on-tuple,
bad-staticmethod-argument,
super-init-not-called,
non-parent-init-called,
useless-super-delegation,
unnecessary-semicolon,
bad-indentation,
mixed-indentation,
deprecated-module,
reimported,
import-self,
misplaced-future,
global-variable-not-assigned,
unused-import,
unused-variable,
undefined-loop-variable,
unbalanced-tuple-unpacking,
possibly-unused-variable,
self-cls-assignment,
bare-except,
duplicate-except,
try-except-raise,
binary-op-exception,
raising-format-tuple,
wrong-exception-operation,
keyword-arg-before-vararg,
bad-format-string-key,
unused-format-string-key,
bad-format-string,
unused-format-string-argument,
format-combined-specification,
missing-format-attribute,
invalid-format-index,
anomalous-backslash-in-string,
anomalous-unicode-escape-in-string,
bad-open-mode,
redundant-unittest-assert,
deprecated-method,
bad-thread-instantiation,
shallow-copy-environ,
invalid-envvar-default,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,

View File

@@ -146,7 +146,8 @@ function west_setup() {
pushd ..
if [ ! -d .west ]; then
west init -l ${git_dir}
west update
west update 1> west.update.log
west forall -c 'git reset --hard HEAD'
fi
popd
}
@@ -253,6 +254,8 @@ if [ -n "$main_ci" ]; then
${sanitycheck} ${sanitycheck_options} --save-tests test_file_3.txt || exit 1
cat test_file_1.txt test_file_2.txt test_file_3.txt > test_file.txt
echo "+++ run sanitycheck"
# Run a subset of tests based on matrix size
${sanitycheck} ${sanitycheck_options} --load-tests test_file.txt \
--subset ${matrix}/${matrix_builds} --retry-failed 3

View File

@@ -5859,10 +5859,14 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
goto ull_conn_rx_unknown_rsp_send;
}
struct pdu_data_llctrl *llctrl = (void *)&pdu_rx->llctrl;
if (0) {
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
} else if (conn->llcp_conn_param.ack !=
conn->llcp_conn_param.req) {
} else if ((conn->llcp_conn_param.ack !=
conn->llcp_conn_param.req) &&
(llctrl->unknown_rsp.type ==
PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ)) {
struct lll_conn *lll = &conn->lll;
struct node_rx_cu *cu;
@@ -5924,7 +5928,9 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
#endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
} else if (conn->llcp_length.req != conn->llcp_length.ack) {
} else if ((conn->llcp_length.req != conn->llcp_length.ack) &&
(llctrl->unknown_rsp.type ==
PDU_DATA_LLCTRL_TYPE_LENGTH_REQ)) {
/* Procedure complete */
conn->llcp_length.ack = conn->llcp_length.req;
@@ -5934,8 +5940,9 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
#if defined(CONFIG_BT_CTLR_PHY)
} else if (conn->llcp_phy.req !=
conn->llcp_phy.ack) {
} else if ((conn->llcp_phy.req != conn->llcp_phy.ack) &&
(llctrl->unknown_rsp.type ==
PDU_DATA_LLCTRL_TYPE_PHY_REQ)) {
struct lll_conn *lll = &conn->lll;
/* Procedure complete */
@@ -5963,9 +5970,6 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
#endif /* CONFIG_BT_CTLR_PHY */
} else {
struct pdu_data_llctrl *llctrl;
llctrl = (void *)&pdu_rx->llctrl;
switch (llctrl->unknown_rsp.type) {
#if defined(CONFIG_BT_CTLR_LE_PING)