Skip to content

Commit 7dcc587

Browse files
Merge branch 'master' into feature/adds-psa-crypto-support
2 parents 77ea172 + 8b905ab commit 7dcc587

File tree

138 files changed

+2242
-835
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+2242
-835
lines changed

credentials/generate-revocation-set.py

+28-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from click_option_group import RequiredMutuallyExclusiveOptionGroup, optgroup
3333
from cryptography import x509
3434
from cryptography.hazmat.primitives.asymmetric import ec
35+
from cryptography.x509.oid import NameOID
3536

3637
# Supported log levels, mapping string values required for argument
3738
# parsing into logging constants
@@ -64,6 +65,32 @@ def extract_single_integer_attribute(subject, oid):
6465
return None
6566

6667

68+
def extract_fallback_tag_from_common_name(cn, marker):
69+
val_len = 4
70+
start_idx = cn.find(marker)
71+
72+
if start_idx != -1:
73+
val_start_idx = start_idx + len(marker)
74+
val = cn[val_start_idx:val_start_idx + val_len]
75+
return int(val, 16) if len(val) == 4 else None
76+
77+
return None
78+
79+
80+
def parse_vid_pid_from_distinguished_name(distinguished_name):
81+
# VID/PID encoded using Matter specific RDNs
82+
vid = extract_single_integer_attribute(distinguished_name, OID_VENDOR_ID)
83+
pid = extract_single_integer_attribute(distinguished_name, OID_PRODUCT_ID)
84+
85+
# Fallback method to get the VID/PID, encoded in CN as "Mvid:FFFF Mpid:1234"
86+
if vid is None and pid is None:
87+
cn = distinguished_name.get_attributes_for_oid(NameOID.COMMON_NAME)[0].value
88+
vid = extract_fallback_tag_from_common_name(cn, 'Mvid:')
89+
pid = extract_fallback_tag_from_common_name(cn, 'Mpid:')
90+
91+
return vid, pid
92+
93+
6794
class DCLDClient:
6895
'''
6996
A client for interacting with DCLD using either the REST API or command line interface (CLI).
@@ -248,14 +275,11 @@ def main(use_main_net_dcld: str, use_test_net_dcld: str, use_main_net_http: bool
248275
is_paa = revocation_point["isPAA"]
249276

250277
# 3. && 4. Validate VID/PID
251-
# TODO: Need to support alternate representation of VID/PID (see spec "6.2.2.2. Encoding of Vendor ID and Product ID in subject and issuer fields")
252-
crl_vid = extract_single_integer_attribute(crl_signer_certificate.subject, OID_VENDOR_ID)
253-
crl_pid = extract_single_integer_attribute(crl_signer_certificate.subject, OID_PRODUCT_ID)
278+
crl_vid, crl_pid = parse_vid_pid_from_distinguished_name(crl_signer_certificate.subject)
254279

255280
if is_paa:
256281
if crl_vid is not None:
257282
if vid != crl_vid:
258-
# TODO: Need to log all situations where a continue is called
259283
logging.warning("VID is not CRL VID, continue...")
260284
continue
261285
else:

docs/guides/simulated_device_linux.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Now that the building is completed there is a `chip-app1` binary created. This
6161
binary can be executed on a linux os with test commands.
6262
6363
```
64-
./scripts/tests/yaml/runner.py [TEST NAME] app1
64+
./scripts/tests/chipyaml/runner.py [TEST NAME] app1
6565
```
6666
6767
## Interacting with the simulated app

docs/testing/yaml.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,12 @@ Compile chip-tool:
347347

348348
NOTE: use the target appropriate to your system
349349

350-
[chiptool.py](https://github.com/project-chip/connectedhomeip/blob/master/scripts/tests/yaml/chiptool.py)
350+
[chiptool.py](https://github.com/project-chip/connectedhomeip/blob/master/scripts/tests/chipyaml/chiptool.py)
351351
can be used to run tests against a commissioned DUT (commissioned by chip-tool).
352352
This will start an interactive instance of chip-tool automatically.
353353

354354
```
355-
./scripts/tests/yaml/chiptool.py tests Test_TC_OO_2_1 --server_path ./out/linux-x64-chip-tool/chip-tool
355+
./scripts/tests/chipyaml/chiptool.py tests Test_TC_OO_2_1 --server_path ./out/linux-x64-chip-tool/chip-tool
356356
357357
```
358358

@@ -361,14 +361,14 @@ NOTE: substitute the appropriate test name and chip-tool path as appropriate.
361361
A list of available tests can be generated using:
362362

363363
```
364-
./scripts/tests/yaml/chiptool.py list
364+
./scripts/tests/chipyaml/chiptool.py list
365365
```
366366

367367
Config variables can be passed to chiptool.py after the script by separating
368368
with --
369369

370370
```
371-
./scripts/tests/yaml/chiptool.py tests Test_TC_OO_2_1 --server_path ./out/linux-x64-chip-tool/chip-tool -- nodeId 0x12344321
371+
./scripts/tests/chipyaml/chiptool.py tests Test_TC_OO_2_1 --server_path ./out/linux-x64-chip-tool/chip-tool -- nodeId 0x12344321
372372
373373
```
374374

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+1
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,7 @@ cluster Switch = 59 {
22572257
kMomentarySwitchRelease = 0x4;
22582258
kMomentarySwitchLongPress = 0x8;
22592259
kMomentarySwitchMultiPress = 0x10;
2260+
kActionSwitch = 0x20;
22602261
}
22612262

22622263
info event SwitchLatched = 0 {

examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter

+1
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,7 @@ cluster Switch = 59 {
19891989
kMomentarySwitchRelease = 0x4;
19901990
kMomentarySwitchLongPress = 0x8;
19911991
kMomentarySwitchMultiPress = 0x10;
1992+
kActionSwitch = 0x20;
19921993
}
19931994

19941995
info event SwitchLatched = 0 {

examples/android/CHIPTest/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ shared_library("jni") {
3333
"${chip_root}/src/lib/support",
3434
"${chip_root}/src/lib/support:pw_tests_wrapper",
3535
"${chip_root}/src/lib/support:test_utils",
36-
"${chip_root}/src/lib/support:testing_nlunit",
3736
"${chip_root}/src/lib/support/jsontlv",
3837
"${chip_root}/src/platform",
3938
"${chip_root}/src/platform/android",

examples/android/CHIPTest/app/src/main/cpp/CHIPTest-JNI.cpp

+47-44
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
#include <lib/support/CHIPJNIError.h>
3030
#include <lib/support/CodeUtils.h>
3131
#include <lib/support/JniReferences.h>
32-
#include <lib/support/UnitTest.h>
33-
#include <lib/support/UnitTestRegistration.h>
3432
#include <platform/CHIPDeviceLayer.h>
3533
#include <platform/android/AndroidChipPlatform-JNI.h>
3634

37-
#include <nlunit-test.h>
35+
#include "pw_unit_test/framework.h"
36+
#include "pw_unit_test/googletest_style_event_handler.h"
37+
#include "pw_unit_test/logging_event_handler.h"
3838

3939
using namespace chip;
4040

@@ -146,57 +146,60 @@ static void onLog(const char * fmt, ...)
146146
VerifyOrReturn(err != CHIP_NO_ERROR, ReportError(env, err, __FUNCTION__));
147147
}
148148

149-
static void jni_log_name(struct _nlTestSuite * inSuite)
150-
{
151-
onLog("[ %s ]\n", inSuite->name);
152-
}
149+
namespace pw::unit_test {
153150

154-
static void jni_log_initialize(struct _nlTestSuite * inSuite, int inResult, int inWidth)
151+
class AndroidLoggingEventHandler : public pw::unit_test::LoggingEventHandler
155152
{
156-
onLog("[ %s : %-*s ] : %s\n", inSuite->name, inWidth, "Initialize", inResult == FAILURE ? "FAILED" : "PASSED");
157-
}
158-
static void jni_log_terminate(struct _nlTestSuite * inSuite, int inResult, int inWidth)
159-
{
160-
onLog("[ %s : %-*s ] : %s\n", inSuite->name, inWidth, "Terminate", inResult == FAILURE ? "FAILED" : "PASSED");
161-
}
153+
public:
154+
void RunAllTestsStart() override { onLog(PW_UNIT_TEST_GOOGLETEST_RUN_ALL_TESTS_START); }
162155

163-
static void jni_log_setup(struct _nlTestSuite * inSuite, int inResult, int inWidth)
164-
{
165-
onLog("[ %s : %-*s ] : %s\n", inSuite->name, inWidth, "Setup", inResult == FAILURE ? "FAILED" : "PASSED");
166-
}
167-
168-
static void jni_log_test(struct _nlTestSuite * inSuite, int inWidth, int inIndex)
169-
{
170-
onLog("[ %s : %-*s ] : %s\n", inSuite->name, inWidth, inSuite->tests[inIndex].name, inSuite->flagError ? "FAILED" : "PASSED");
171-
}
172-
173-
static void jni_log_teardown(struct _nlTestSuite * inSuite, int inResult, int inWidth)
174-
{
175-
onLog("[ %s : %-*s ] : %s\n", inSuite->name, inWidth, "TearDown", inResult == FAILURE ? "FAILED" : "PASSED");
176-
}
177-
178-
static void jni_log_statTest(struct _nlTestSuite * inSuite)
179-
{
180-
onLog("Failed Tests: %d / %d\n", inSuite->failedTests, inSuite->runTests);
181-
}
156+
void RunAllTestsEnd(const RunTestsSummary & run_tests_summary) override
157+
{
158+
onLog(PW_UNIT_TEST_GOOGLETEST_RUN_ALL_TESTS_END);
159+
onLog(PW_UNIT_TEST_GOOGLETEST_PASSED_SUMMARY, run_tests_summary.passed_tests);
160+
if (run_tests_summary.skipped_tests)
161+
{
162+
onLog(PW_UNIT_TEST_GOOGLETEST_DISABLED_SUMMARY, run_tests_summary.skipped_tests);
163+
}
164+
if (run_tests_summary.failed_tests)
165+
{
166+
onLog(PW_UNIT_TEST_GOOGLETEST_FAILED_SUMMARY, run_tests_summary.failed_tests);
167+
}
168+
}
182169

183-
static void jni_log_statAssert(struct _nlTestSuite * inSuite)
184-
{
185-
onLog("Failed Asserts: %d / %d\n", inSuite->failedAssertions, inSuite->performedAssertions);
186-
}
170+
void TestCaseStart(const TestCase & test_case) override
171+
{
172+
onLog(PW_UNIT_TEST_GOOGLETEST_CASE_START, test_case.suite_name, test_case.test_name);
173+
}
187174

188-
static nl_test_output_logger_t jni_test_logger = {
189-
jni_log_name, jni_log_initialize, jni_log_terminate, jni_log_setup,
190-
jni_log_test, jni_log_teardown, jni_log_statTest, jni_log_statAssert,
175+
void TestCaseEnd(const TestCase & test_case, TestResult result) override
176+
{
177+
// Use a switch with no default to detect changes in the test result enum.
178+
switch (result)
179+
{
180+
case TestResult::kSuccess:
181+
onLog(PW_UNIT_TEST_GOOGLETEST_CASE_OK, test_case.suite_name, test_case.test_name);
182+
break;
183+
case TestResult::kFailure:
184+
onLog(PW_UNIT_TEST_GOOGLETEST_CASE_FAILED, test_case.suite_name, test_case.test_name);
185+
break;
186+
case TestResult::kSkipped:
187+
onLog(PW_UNIT_TEST_GOOGLETEST_CASE_DISABLED, test_case.suite_name, test_case.test_name);
188+
break;
189+
}
190+
}
191191
};
192+
}; // namespace pw::unit_test
192193

193194
extern "C" JNIEXPORT jint Java_com_tcl_chip_chiptest_TestEngine_runTest(JNIEnv * env, jclass clazz)
194195
{
195-
nlTestSetLogger(&jni_test_logger);
196196
chip::DeviceLayer::StackLock lock;
197-
// TODO [PW_MIGRATION] Remove NLUnit tests call after migration
198-
jint ret = RunRegisteredUnitTests();
199-
ret += chip::test::RunAllTests();
197+
198+
// Running Pigweed Tests
199+
testing::InitGoogleTest(nullptr, static_cast<char **>(nullptr));
200+
pw::unit_test::AndroidLoggingEventHandler handler;
201+
pw::unit_test::RegisterEventHandler(&handler);
202+
jint ret = RUN_ALL_TESTS();
200203

201204
return ret;
202205
}

examples/bridge-app/bridge-common/bridge-app.matter

+1
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,7 @@ cluster Switch = 59 {
15741574
kMomentarySwitchRelease = 0x4;
15751575
kMomentarySwitchLongPress = 0x8;
15761576
kMomentarySwitchMultiPress = 0x10;
1577+
kActionSwitch = 0x20;
15771578
}
15781579

15791580
info event SwitchLatched = 0 {

0 commit comments

Comments
 (0)