Skip to content

Commit

Permalink
Create Tests workflow, will house certification tests (#7381)
Browse files Browse the repository at this point in the history
* Initial stab

* Adding test runs

* Removing this

* Making this +x

* Oops

* Running all tests

* Delete storage just inc ase

* Trying to run this in darwin too

* Moving darwin into tests

* Testing out mbedtls

* Fixing gStorage

* Fixing quoting

* Wait for pairing

* next

* Trying 0.0.0.0

* ::1

* Testing cache

* Removing cache

* IPv6 localhost for today

* IPv6 localhost

* Moving to this pin code

* check validity of mTransportMgr

* collect core dump

* remove controller shutdown

* delay controller shutdown in the test

* restyled

* Removing this, not needed anymore

* Empty defines

* Update scripts/tests/test_suites.sh

Co-authored-by: Boris Zbarsky <[email protected]>

* Adding todos

Co-authored-by: Pankaj Garg <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
3 people authored Jun 4, 2021
1 parent 2d832bf commit 8402293
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 11 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,9 @@ jobs:
- name: Delete Defaults
run: defaults delete com.apple.dt.xctest.tool
continue-on-error: true
- name: Run Tests
- name: Run Framework Tests
timeout-minutes: 5
run: |
../../../out/debug/chip-all-clusters-app &
xcodebuild test -target "CHIP" -scheme "CHIP Framework Tests" -sdk macosx
working-directory: src/darwin/Framework
- name: Delete Defaults
run: defaults delete com.apple.dt.xctest.tool
continue-on-error: true
92 changes: 92 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright (c) 2020-2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Tests

on:
push:
pull_request:

jobs:
test_suites_linux:
name: Test Suites - Linux
timeout-minutes: 60

if: github.actor != 'restyled-io[bot]'
runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build:latest
options:
--privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0
net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Bootstrap
timeout-minutes: 3
run: scripts/build/gn_bootstrap.sh
- name: Build all clusters app
timeout-minutes: 5
run: |
scripts/examples/gn_build_example.sh examples/all-clusters-app/linux out/debug chip_config_network_layer_ble=false
- name: Build chip-tool
timeout-minutes: 5
run: |
scripts/examples/gn_build_example.sh examples/chip-tool out/debug/standalone/
- name: Run Tests
timeout-minutes: 5
run: |
ifconfig -a
scripts/tests/test_suites.sh
test_suites_darwin:
name: Test Suites - Darwin
timeout-minutes: 60

if: github.actor != 'restyled-io[bot]'
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Setup Environment
run: brew install openssl pkg-config
- name: Fix pkgconfig link
working-directory: /usr/local/lib/pkgconfig
run: |
pwd
ls -la /usr/local/Cellar/
ls -la /usr/local/Cellar/[email protected]
OPEN_SSL_VERSION=`ls -la /usr/local/Cellar/[email protected] | cat | tail -n1 | awk '{print $NF}'`
ln -s /usr/local/Cellar/[email protected]/$OPEN_SSL_VERSION/lib/pkgconfig/* .
- name: Bootstrap
timeout-minutes: 3
run: scripts/build/gn_bootstrap.sh
- name: Run Build Test Server
timeout-minutes: 5
run: |
scripts/examples/gn_build_example.sh examples/all-clusters-app/linux out/debug chip_config_network_layer_ble=false
- name: Build chip-tool
timeout-minutes: 5
run: |
scripts/examples/gn_build_example.sh examples/chip-tool out/debug/standalone/
- name: Run Test Suites
timeout-minutes: 5
run: |
scripts/tests/test_suites.sh
9 changes: 5 additions & 4 deletions examples/chip-tool/commands/common/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ void Commands::Register(const char * clusterName, commands_list commandsList)
}
}

// TODO: Remove this work around due to crashes when storage is accessed from multiple threads and passed around
static PersistentStorage gStorage;
int Commands::Run(NodeId localId, NodeId remoteId, int argc, char ** argv)
{
CHIP_ERROR err = CHIP_NO_ERROR;
PersistentStorage storage;

err = chip::Platform::MemoryInit();
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init Memory failure: %s", chip::ErrorStr(err)));
Expand All @@ -51,12 +52,12 @@ int Commands::Run(NodeId localId, NodeId remoteId, int argc, char ** argv)
SuccessOrExit(err = chip::DeviceLayer::Internal::BLEMgrImpl().ConfigureBle(/* BLE adapter ID */ 0, /* BLE central */ true));
#endif

err = storage.Init();
err = gStorage.Init();
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init Storage failure: %s", chip::ErrorStr(err)));

chip::Logging::SetLogFilter(storage.GetLoggingLevel());
chip::Logging::SetLogFilter(gStorage.GetLoggingLevel());

err = RunCommand(storage, localId, remoteId, argc, argv);
err = RunCommand(gStorage, localId, remoteId, argc, argv);
SuccessOrExit(err);

exit:
Expand Down
19 changes: 19 additions & 0 deletions examples/chip-tool/commands/tests/TestCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,22 @@

constexpr uint16_t kWaitDurationInSeconds = 30;

static void test_os_sleep_ms(uint64_t millisecs)
{
struct timespec sleep_time;
uint64_t s = millisecs / 1000;

millisecs -= s * 1000;
sleep_time.tv_sec = static_cast<time_t>(s);
sleep_time.tv_nsec = static_cast<long>(millisecs * 1000000);

nanosleep(&sleep_time, nullptr);
}

CHIP_ERROR TestCommand::Run(PersistentStorage & storage, NodeId localId, NodeId remoteId)
{
ReturnErrorOnFailure(mOpCredsIssuer.Initialize(storage));

chip::Controller::CommissionerInitParams params;

params.storageDelegate = &storage;
Expand All @@ -38,6 +52,11 @@ CHIP_ERROR TestCommand::Run(PersistentStorage & storage, NodeId localId, NodeId
WaitForResponse(kWaitDurationInSeconds);

mCommissioner.ServiceEventSignal();

// Give some time for all the pending messages to flush before shutting down
// Note: This is working around racy code in message queues during shutdown
// TODO: Remove this workaround once we understand the message queue and shutdown race
test_os_sleep_ms(1000);
mCommissioner.Shutdown();

VerifyOrReturnError(GetCommandExitStatus(), CHIP_ERROR_INTERNAL);
Expand Down
46 changes: 46 additions & 0 deletions scripts/tests/test_suites.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

#
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -e

declare -a test_array="($(find src/app/tests/suites -type f -name "*.yaml" -exec basename {} .yaml \;))"

echo "Found tests:"
for i in "${test_array[@]}"; do
echo " $i"
done
echo ""
echo ""

for i in "${test_array[@]}"; do
echo " ===== Running test: $i"
echo " * Starting cluster server"
rm -rf /tmp/chip_tool_config.ini
sleep 1
out/debug/chip-all-clusters-app &
background_pid=$!
sleep 1
echo " * Pairing to device"
out/debug/standalone/chip-tool pairing onnetwork 1 20202021 3840 ::1 11097
sleep 1
echo " * Starting test run: $i"
out/debug/standalone/chip-tool tests "$i"
kill -9 "$background_pid" || true
echo " ===== Test complete: $i"
sleep 2
done
4 changes: 2 additions & 2 deletions src/transport/AdminPairingTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ class DLL_EXPORT AdminPairingInfo
uint64_t mFabricId; /* This field is serialized in LittleEndian byte order */
uint16_t mVendorId; /* This field is serialized in LittleEndian byte order */

char mFabricLabel[kFabricLabelMaxLengthInBytes + 1] = { '\0' };

uint16_t mRootCertLen; /* This field is serialized in LittleEndian byte order */
uint16_t mOpCertLen; /* This field is serialized in LittleEndian byte order */

Crypto::P256SerializedKeypair mOperationalKey;
uint8_t mRootCert[kMaxChipCertSize];
uint8_t mOperationalCert[kMaxChipCertSize];

char mFabricLabel[kFabricLabelMaxLengthInBytes + 1] = { '\0' };
};
};

Expand Down
7 changes: 6 additions & 1 deletion src/transport/SecureSessionMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,16 @@ CHIP_ERROR SecureSessionMgr::SendMessage(SecureSessionHandle session, PayloadHea
ChipLogProgress(Inet, "Sending secure msg on connection specific transport");
err = state->GetTransport()->SendMessage(state->GetPeerAddress(), std::move(msgBuf));
}
else
else if (mTransportMgr != nullptr)
{
ChipLogProgress(Inet, "Sending secure msg on generic transport");
err = mTransportMgr->SendMessage(state->GetPeerAddress(), std::move(msgBuf));
}
else
{
ChipLogError(Inet, "The transport manager is not initialized. Unable to send the message");
err = CHIP_ERROR_INCORRECT_STATE;
}
ChipLogProgress(Inet, "Secure msg send status %s", ErrorStr(err));
SuccessOrExit(err);

Expand Down

0 comments on commit 8402293

Please sign in to comment.