@matter/testing 0.18.0 → 0.18.1-alpha.0-20261111-b89790712
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chip/app-reference.d.ts +41 -0
- package/dist/cjs/chip/app-reference.d.ts.map +1 -0
- package/dist/cjs/chip/app-reference.js +83 -0
- package/dist/cjs/chip/app-reference.js.map +6 -0
- package/dist/cjs/chip/cert/cert-context.d.ts +4 -2
- package/dist/cjs/chip/cert/cert-context.d.ts.map +1 -1
- package/dist/cjs/chip/cert/cert-context.js.map +1 -1
- package/dist/cjs/chip/cert/cert-dsl.d.ts +7 -1
- package/dist/cjs/chip/cert/cert-dsl.d.ts.map +1 -1
- package/dist/cjs/chip/cert/cert-dsl.js +4 -1
- package/dist/cjs/chip/cert/cert-dsl.js.map +1 -1
- package/dist/cjs/chip/cert/cert-test.d.ts.map +1 -1
- package/dist/cjs/chip/cert/cert-test.js +5 -18
- package/dist/cjs/chip/cert/cert-test.js.map +1 -1
- package/dist/cjs/chip/cert/chip-app-subject.d.ts.map +1 -1
- package/dist/cjs/chip/cert/chip-app-subject.js +23 -7
- package/dist/cjs/chip/cert/chip-app-subject.js.map +1 -1
- package/dist/cjs/chip/cert/controller-adapter.d.ts +71 -18
- package/dist/cjs/chip/cert/controller-adapter.d.ts.map +1 -1
- package/dist/cjs/chip/cert/controller-adapter.js +1 -3
- package/dist/cjs/chip/cert/controller-adapter.js.map +1 -1
- package/dist/cjs/chip/cert/evidence.d.ts +3 -3
- package/dist/cjs/chip/cert/evidence.js +1 -1
- package/dist/cjs/chip/cert/log-follower.d.ts +10 -0
- package/dist/cjs/chip/cert/log-follower.d.ts.map +1 -1
- package/dist/cjs/chip/cert/log-follower.js +48 -21
- package/dist/cjs/chip/cert/log-follower.js.map +1 -1
- package/dist/cjs/chip/cert/prompt-driven-python-test.js +1 -1
- package/dist/cjs/chip/cert/prompt-driven-python-test.js.map +1 -1
- package/dist/cjs/chip/cert/step-actions.d.ts +2 -3
- package/dist/cjs/chip/cert/step-actions.d.ts.map +1 -1
- package/dist/cjs/chip/cert/step-actions.js +2 -27
- package/dist/cjs/chip/cert/step-actions.js.map +1 -1
- package/dist/cjs/chip/index.d.ts +2 -1
- package/dist/cjs/chip/index.d.ts.map +1 -1
- package/dist/cjs/chip/index.js +2 -0
- package/dist/cjs/chip/index.js.map +1 -1
- package/dist/cjs/chip/python-test.d.ts +5 -0
- package/dist/cjs/chip/python-test.d.ts.map +1 -1
- package/dist/cjs/chip/python-test.js +12 -1
- package/dist/cjs/chip/python-test.js.map +1 -1
- package/dist/cjs/chip/state.d.ts.map +1 -1
- package/dist/cjs/chip/state.js +4 -1
- package/dist/cjs/chip/state.js.map +1 -1
- package/dist/cjs/device/backchannel.d.ts +10 -1
- package/dist/cjs/device/backchannel.d.ts.map +1 -1
- package/dist/cjs/test-descriptor.d.ts +4 -1
- package/dist/cjs/test-descriptor.d.ts.map +1 -1
- package/dist/cjs/test-descriptor.js.map +1 -1
- package/dist/cjs/util/async.d.ts +1 -0
- package/dist/cjs/util/async.d.ts.map +1 -1
- package/dist/cjs/util/async.js +1 -0
- package/dist/cjs/util/async.js.map +1 -1
- package/dist/esm/chip/app-reference.d.ts +41 -0
- package/dist/esm/chip/app-reference.d.ts.map +1 -0
- package/dist/esm/chip/app-reference.js +63 -0
- package/dist/esm/chip/app-reference.js.map +6 -0
- package/dist/esm/chip/cert/cert-context.d.ts +4 -2
- package/dist/esm/chip/cert/cert-context.d.ts.map +1 -1
- package/dist/esm/chip/cert/cert-context.js.map +1 -1
- package/dist/esm/chip/cert/cert-dsl.d.ts +7 -1
- package/dist/esm/chip/cert/cert-dsl.d.ts.map +1 -1
- package/dist/esm/chip/cert/cert-dsl.js +4 -1
- package/dist/esm/chip/cert/cert-dsl.js.map +1 -1
- package/dist/esm/chip/cert/cert-test.d.ts.map +1 -1
- package/dist/esm/chip/cert/cert-test.js +5 -18
- package/dist/esm/chip/cert/cert-test.js.map +1 -1
- package/dist/esm/chip/cert/chip-app-subject.d.ts.map +1 -1
- package/dist/esm/chip/cert/chip-app-subject.js +23 -7
- package/dist/esm/chip/cert/chip-app-subject.js.map +1 -1
- package/dist/esm/chip/cert/controller-adapter.d.ts +71 -18
- package/dist/esm/chip/cert/controller-adapter.d.ts.map +1 -1
- package/dist/esm/chip/cert/controller-adapter.js +1 -3
- package/dist/esm/chip/cert/controller-adapter.js.map +1 -1
- package/dist/esm/chip/cert/evidence.d.ts +3 -3
- package/dist/esm/chip/cert/evidence.js +1 -1
- package/dist/esm/chip/cert/log-follower.d.ts +10 -0
- package/dist/esm/chip/cert/log-follower.d.ts.map +1 -1
- package/dist/esm/chip/cert/log-follower.js +49 -22
- package/dist/esm/chip/cert/log-follower.js.map +1 -1
- package/dist/esm/chip/cert/prompt-driven-python-test.js +1 -1
- package/dist/esm/chip/cert/prompt-driven-python-test.js.map +1 -1
- package/dist/esm/chip/cert/step-actions.d.ts +2 -3
- package/dist/esm/chip/cert/step-actions.d.ts.map +1 -1
- package/dist/esm/chip/cert/step-actions.js +2 -29
- package/dist/esm/chip/cert/step-actions.js.map +1 -1
- package/dist/esm/chip/index.d.ts +2 -1
- package/dist/esm/chip/index.d.ts.map +1 -1
- package/dist/esm/chip/index.js +2 -0
- package/dist/esm/chip/index.js.map +1 -1
- package/dist/esm/chip/python-test.d.ts +5 -0
- package/dist/esm/chip/python-test.d.ts.map +1 -1
- package/dist/esm/chip/python-test.js +12 -1
- package/dist/esm/chip/python-test.js.map +1 -1
- package/dist/esm/chip/state.d.ts.map +1 -1
- package/dist/esm/chip/state.js +4 -1
- package/dist/esm/chip/state.js.map +1 -1
- package/dist/esm/device/backchannel.d.ts +10 -1
- package/dist/esm/device/backchannel.d.ts.map +1 -1
- package/dist/esm/test-descriptor.d.ts +4 -1
- package/dist/esm/test-descriptor.d.ts.map +1 -1
- package/dist/esm/test-descriptor.js.map +1 -1
- package/dist/esm/util/async.d.ts +1 -0
- package/dist/esm/util/async.d.ts.map +1 -1
- package/dist/esm/util/async.js +1 -0
- package/dist/esm/util/async.js.map +1 -1
- package/package.json +5 -5
- package/src/chip/app-reference.ts +91 -0
- package/src/chip/cert/cert-context.ts +4 -2
- package/src/chip/cert/cert-dsl.ts +16 -4
- package/src/chip/cert/cert-test.ts +7 -33
- package/src/chip/cert/chip-app-subject.ts +35 -10
- package/src/chip/cert/controller-adapter.ts +82 -21
- package/src/chip/cert/evidence.ts +3 -3
- package/src/chip/cert/log-follower.ts +58 -23
- package/src/chip/cert/prompt-driven-python-test.ts +1 -1
- package/src/chip/cert/step-actions.ts +4 -32
- package/src/chip/index.ts +3 -0
- package/src/chip/python-test.ts +18 -1
- package/src/chip/state.ts +6 -2
- package/src/device/backchannel.ts +11 -0
- package/src/test-descriptor.ts +4 -1
- package/src/util/async.ts +1 -1
- package/test/chip/AppReferenceTest.ts +113 -0
|
@@ -156,8 +156,8 @@ export interface StepRecorder {
|
|
|
156
156
|
*/
|
|
157
157
|
runHeaderLines?(): string[];
|
|
158
158
|
/**
|
|
159
|
-
* Records how many steps were skipped because the controller under test
|
|
160
|
-
*
|
|
159
|
+
* Records how many steps were skipped because the controller under test lacks a capability they
|
|
160
|
+
* declare. A run with such a step proved less than its plan, so it settles as
|
|
161
161
|
* `"controller-gap"` rather than `"pass"` (see `EvidenceRecorder`), and the count says how much less.
|
|
162
162
|
*/
|
|
163
163
|
recordControllerUnsupportedSkips?(count: number): void;
|
|
@@ -346,6 +346,8 @@ export interface CertTestDefinition {
|
|
|
346
346
|
* here; every other test keeps the transport its evidence and timing were written against.
|
|
347
347
|
*/
|
|
348
348
|
transport?: ControllerTransport;
|
|
349
|
+
/** Whether the test's controllers judge device attestation (see `cert-dsl.ts`'s `CertTestOptions`). */
|
|
350
|
+
attestation?: boolean;
|
|
349
351
|
/** Role name → controller kind (see `cert-dsl.ts`'s `CertTestOptions`). */
|
|
350
352
|
controllers: Readonly<Record<string, ControllerRoleKind>>;
|
|
351
353
|
/** What every step of this test needs of its controllers (see `cert-dsl.ts`'s `CertTestOptions`). */
|
|
@@ -136,6 +136,13 @@ export interface CertTestOptions {
|
|
|
136
136
|
*/
|
|
137
137
|
transport?: ControllerTransport;
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Has the test's controllers judge device attestation against the chip test roots
|
|
141
|
+
* (`ControllerAdapterOptions.attestation`), for a case about which attestations a commissioner accepts or refuses.
|
|
142
|
+
* Implies the `attestation` capability, so a case with a controller that cannot judge attestation is skipped.
|
|
143
|
+
*/
|
|
144
|
+
attestation?: boolean;
|
|
145
|
+
|
|
139
146
|
/**
|
|
140
147
|
* What the whole test needs of its controllers beyond the {@link ControllerAdapter} interface. Where a
|
|
141
148
|
* controller filling one of its roles lacks one, the test is skipped before any device starts. Declare it here
|
|
@@ -343,6 +350,7 @@ export function certTest(tc: string, options: CertTestOptions): CertTestBuilder
|
|
|
343
350
|
flavors: options.flavors,
|
|
344
351
|
chipBinsSources: options.chipBinsSources,
|
|
345
352
|
transport: options.transport,
|
|
353
|
+
attestation: options.attestation,
|
|
346
354
|
controllers: controllerRoles,
|
|
347
355
|
controllerCapabilities: options.controllerCapabilities,
|
|
348
356
|
controllerGroups: options.controllerGroups,
|
|
@@ -646,14 +654,17 @@ export function unmetTestPics(definition: CertTestDefinition, pics = certPicsFil
|
|
|
646
654
|
* one can: the capabilities it declares, and those its adapter options imply.
|
|
647
655
|
*/
|
|
648
656
|
export function unmetControllerCapabilities(
|
|
649
|
-
definition: Pick<CertTestDefinition, "controllers" | "controllerCapabilities" | "transport">,
|
|
657
|
+
definition: Pick<CertTestDefinition, "controllers" | "controllerCapabilities" | "transport" | "attestation">,
|
|
650
658
|
selection: ControllerSelection = resolveControllerSelection(),
|
|
651
659
|
): string | undefined {
|
|
652
660
|
return controllerCapabilityGap(requiredCapabilities(definition), Object.values(definition.controllers), selection);
|
|
653
661
|
}
|
|
654
662
|
|
|
655
|
-
function requiredCapabilities(
|
|
656
|
-
|
|
663
|
+
function requiredCapabilities(
|
|
664
|
+
definition: Pick<CertTestDefinition, "controllerCapabilities" | "transport" | "attestation">,
|
|
665
|
+
) {
|
|
666
|
+
const { transport, attestation } = definition;
|
|
667
|
+
return [...(definition.controllerCapabilities ?? []), ...capabilitiesFor({ transport, attestation })];
|
|
657
668
|
}
|
|
658
669
|
|
|
659
670
|
/**
|
|
@@ -675,7 +686,7 @@ function controllerNotApplicable(
|
|
|
675
686
|
* (see {@link controllerCapabilityOutOfScope}).
|
|
676
687
|
*/
|
|
677
688
|
function outOfControllerScope(
|
|
678
|
-
definition: Pick<CertTestDefinition, "controllers" | "controllerCapabilities" | "transport">,
|
|
689
|
+
definition: Pick<CertTestDefinition, "controllers" | "controllerCapabilities" | "transport" | "attestation">,
|
|
679
690
|
selection: ControllerSelection,
|
|
680
691
|
): string | undefined {
|
|
681
692
|
return controllerCapabilityOutOfScope(
|
|
@@ -1034,6 +1045,7 @@ class WiredCertTest extends CertTest {
|
|
|
1034
1045
|
name,
|
|
1035
1046
|
{
|
|
1036
1047
|
transport: this.definition.transport,
|
|
1048
|
+
attestation: this.definition.attestation,
|
|
1037
1049
|
groups: kind === "dut" ? this.#controllerGroups() : undefined,
|
|
1038
1050
|
},
|
|
1039
1051
|
kind,
|
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
} from "./cert-context.js";
|
|
29
29
|
import {
|
|
30
30
|
capabilitiesFor,
|
|
31
|
-
type ControllerCapability,
|
|
32
31
|
controllerCapabilityGap,
|
|
33
32
|
controllerCapabilityOutOfScope,
|
|
34
33
|
type ControllerSelection,
|
|
@@ -101,8 +100,8 @@ export class CertTest extends BaseTest {
|
|
|
101
100
|
const { devices } = cx;
|
|
102
101
|
|
|
103
102
|
// A step's own checks are how the suite defines "something was observed", and a step that ran
|
|
104
|
-
// without recording one ends unverified.
|
|
105
|
-
//
|
|
103
|
+
// without recording one ends unverified. Together with the actions below, the count also decides
|
|
104
|
+
// whether a step may still skip itself (CertStepNotApplicableError, the notApplicableAtRun probe).
|
|
106
105
|
let observedThisStep = 0;
|
|
107
106
|
// Checks alone miss a step that changed the device before it recorded anything
|
|
108
107
|
const actions = new StepActions();
|
|
@@ -358,7 +357,7 @@ export class CertTest extends BaseTest {
|
|
|
358
357
|
await raceAgainstDeviceExit(stepDef.run(cx), deviceExitWatch.exit, tc, stepDef.number);
|
|
359
358
|
} catch (e) {
|
|
360
359
|
if (e instanceof CertStepNotApplicableError) {
|
|
361
|
-
//
|
|
360
|
+
// "skipped" claims nothing was evaluated, which a step that recorded evidence or acted cannot
|
|
362
361
|
if (observedThisStep === 0 && actions.count === 0) {
|
|
363
362
|
planConditionSkips++;
|
|
364
363
|
report(stepDef, "skipped", e.message);
|
|
@@ -377,40 +376,15 @@ export class CertTest extends BaseTest {
|
|
|
377
376
|
continue;
|
|
378
377
|
}
|
|
379
378
|
|
|
380
|
-
if (e instanceof UnsupportedByControllerError
|
|
379
|
+
if (e instanceof UnsupportedByControllerError) {
|
|
381
380
|
aborted = true;
|
|
382
381
|
failed = true;
|
|
383
382
|
frameworkError = true;
|
|
384
|
-
failure = undeclaredRefusal(tc, stepDef, this.#definition, e
|
|
383
|
+
failure = undeclaredRefusal(tc, stepDef, this.#definition, e);
|
|
385
384
|
report(stepDef, "error");
|
|
386
385
|
continue;
|
|
387
386
|
}
|
|
388
387
|
|
|
389
|
-
if (e instanceof UnsupportedByControllerError) {
|
|
390
|
-
// "skipped" claims nothing was evaluated. A step that already recorded
|
|
391
|
-
// evidence or acted did act, so every later step would rest on a device state
|
|
392
|
-
// nobody declared — that is the run's outcome, not a skip.
|
|
393
|
-
if (observedThisStep === 0 && actions.count === 0) {
|
|
394
|
-
controllerUnsupportedSkips++;
|
|
395
|
-
report(stepDef, "skipped", e.message);
|
|
396
|
-
continue;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
aborted = true;
|
|
400
|
-
failed = true;
|
|
401
|
-
failure = new Error(
|
|
402
|
-
`Cert test ${tc} step ${stepDef.number}: the controller refused "${e.operation}" after ` +
|
|
403
|
-
`the step had already recorded ${observedThisStep} check(s) and made ${actions.count} ` +
|
|
404
|
-
`controller call(s) that may change the device, so the device ` +
|
|
405
|
-
`is in a state this run cannot describe. Declare the limitation as a capability gap ` +
|
|
406
|
-
`of the controller, or in its own PICS, so the step is skipped before it acts. ` +
|
|
407
|
-
`Refusal: ${e.message}`,
|
|
408
|
-
);
|
|
409
|
-
|
|
410
|
-
report(stepDef, "fail");
|
|
411
|
-
continue;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
388
|
aborted = true;
|
|
415
389
|
failed = true;
|
|
416
390
|
failure = e;
|
|
@@ -791,12 +765,12 @@ function undeclaredRefusal(
|
|
|
791
765
|
stepDef: CertStepDefinition,
|
|
792
766
|
definition: CertTestDefinition,
|
|
793
767
|
refusal: UnsupportedByControllerError,
|
|
794
|
-
capability: ControllerCapability,
|
|
795
768
|
): CertFrameworkError {
|
|
769
|
+
const { capability } = refusal;
|
|
796
770
|
const declared =
|
|
797
771
|
stepDef.controllerCapabilities?.includes(capability) ||
|
|
798
772
|
definition.controllerCapabilities?.includes(capability) ||
|
|
799
|
-
capabilitiesFor({ transport: definition.transport }).includes(capability);
|
|
773
|
+
capabilitiesFor({ transport: definition.transport, attestation: definition.attestation }).includes(capability);
|
|
800
774
|
const cause = declared
|
|
801
775
|
? `controller "${refusal.controller}" refused ${capability}, which its registration declares neither as a gap nor out of scope`
|
|
802
776
|
: `the step needs ${capability} and neither it nor its test case declares it`;
|
|
@@ -139,6 +139,18 @@ function hasStdinCommands(app: string) {
|
|
|
139
139
|
return STDIN_COMMANDS[app] !== undefined;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
/**
|
|
143
|
+
* The apps CHIP's own builds, chip-cert-bins among them, compile with the interactive shell (`chip_build_libshell` in the
|
|
144
|
+
* app's `args.gni`). The shell reads standard input and stops the app at end of input, so such an app needs a standard
|
|
145
|
+
* input that stays open. This project's image builds every app without the shell.
|
|
146
|
+
*/
|
|
147
|
+
const SHELL_APPS = new Set(["tv"]);
|
|
148
|
+
|
|
149
|
+
/** Whether `app` needs a standard input pipe: for its simulation commands, or to keep its shell from ending it. */
|
|
150
|
+
function needsStdin(app: string) {
|
|
151
|
+
return hasStdinCommands(app) || SHELL_APPS.has(app);
|
|
152
|
+
}
|
|
153
|
+
|
|
142
154
|
/** The character `app` reads for `command`, or `undefined` for a command it does not take that way. */
|
|
143
155
|
function stdinCommandFor(app: string, command: BackchannelCommand): string | undefined {
|
|
144
156
|
return STDIN_COMMANDS[app]?.get(command.name);
|
|
@@ -397,6 +409,8 @@ class ChipLocalDevice implements CertDevice {
|
|
|
397
409
|
readonly commissioning: Subject.CommissioningParameters;
|
|
398
410
|
readonly log: LogFollower;
|
|
399
411
|
|
|
412
|
+
/** The arguments that name the ports of this device's identity, which every start passes. */
|
|
413
|
+
#portArgs: string[];
|
|
400
414
|
#appArgs: string[];
|
|
401
415
|
|
|
402
416
|
/** What the app was last spawned with, which is what the evidence bundle reports. */
|
|
@@ -420,7 +434,8 @@ class ChipLocalDevice implements CertDevice {
|
|
|
420
434
|
this.id = domain;
|
|
421
435
|
this.commissioning = commissioningFor(options?.identity);
|
|
422
436
|
this.log = new LogFollower(this.#hub.follow(), domain);
|
|
423
|
-
this.#
|
|
437
|
+
this.#portArgs = portArgs(options?.identity);
|
|
438
|
+
this.#appArgs = [...this.#portArgs, ...(options?.appArgs ?? [])];
|
|
424
439
|
}
|
|
425
440
|
|
|
426
441
|
/**
|
|
@@ -494,7 +509,7 @@ class ChipLocalDevice implements CertDevice {
|
|
|
494
509
|
|
|
495
510
|
let generation: LocalGeneration | undefined;
|
|
496
511
|
const app = ManagedChildProcess.spawn(binPath, args, {
|
|
497
|
-
stdin:
|
|
512
|
+
stdin: needsStdin(this.app) ? "pipe" : "ignore",
|
|
498
513
|
onExit: exit => {
|
|
499
514
|
if (generation !== undefined) {
|
|
500
515
|
this.#ended(generation, exit);
|
|
@@ -762,18 +777,28 @@ class ChipLocalDevice implements CertDevice {
|
|
|
762
777
|
}
|
|
763
778
|
}
|
|
764
779
|
|
|
780
|
+
/** Stops the app and drops its key-value store, so the next start() is factory-new. */
|
|
781
|
+
async #factoryReset() {
|
|
782
|
+
await this.stop();
|
|
783
|
+
|
|
784
|
+
// A chip app is factory-new only once its key-value store is gone. Dropping the whole storage directory keeps
|
|
785
|
+
// this independent of the file layout the app's KVS implementation chooses; start() creates a fresh one.
|
|
786
|
+
if (this.#storageDir !== undefined) {
|
|
787
|
+
await rm(this.#storageDir, { recursive: true, force: true });
|
|
788
|
+
this.#storageDir = undefined;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
765
792
|
async backchannel(command: BackchannelCommand): Promise<void> {
|
|
766
793
|
switch (command.name) {
|
|
767
794
|
case "factoryReset":
|
|
768
|
-
await this
|
|
795
|
+
await this.#factoryReset();
|
|
796
|
+
await startForBackchannel(this, command.name);
|
|
797
|
+
break;
|
|
769
798
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
if (this.#storageDir !== undefined) {
|
|
774
|
-
await rm(this.#storageDir, { recursive: true, force: true });
|
|
775
|
-
this.#storageDir = undefined;
|
|
776
|
-
}
|
|
799
|
+
case "factoryResetWithAppArgs":
|
|
800
|
+
await this.#factoryReset();
|
|
801
|
+
this.#appArgs = [...this.#portArgs, ...command.appArgs];
|
|
777
802
|
await startForBackchannel(this, command.name);
|
|
778
803
|
break;
|
|
779
804
|
|
|
@@ -65,6 +65,7 @@ export interface CommissioningTarget {
|
|
|
65
65
|
* `writeAttribute`, `subscribe` and `decommission`. The controller's copy of the peer starts empty and holds
|
|
66
66
|
* only what direct calls read, so the calls that answer from it — `clientEndpoints`, `clientAttribute`, event
|
|
67
67
|
* observation, `openCommissioningWindow`, the ICD and OTA helpers — answer wrongly or fail.
|
|
68
|
+
* `openCommissioningWindow` works once the caller has read the node's root endpoint (endpoint 0, every cluster).
|
|
68
69
|
*
|
|
69
70
|
* Advisory. An adapter whose controller holds no such subscription has nothing to do.
|
|
70
71
|
*/
|
|
@@ -300,7 +301,7 @@ export interface ReadAttributeOptions {
|
|
|
300
301
|
* session over TCP (Matter Core § 4.15.1).
|
|
301
302
|
*
|
|
302
303
|
* A hard requirement, not a preference: a controller that cannot establish such a session fails
|
|
303
|
-
* the read, or refuses it
|
|
304
|
+
* the read, or refuses it naming `tcp-transport`, rather than reading over MRP
|
|
304
305
|
* — so a step asking for one cannot pass on a transport it did not use. A broad read is the case
|
|
305
306
|
* for it: the peer answers in a single report where MRP would have made it chunk.
|
|
306
307
|
*/
|
|
@@ -667,7 +668,12 @@ export interface OtaAnnouncementRecord {
|
|
|
667
668
|
/** `ProviderNodeID`, in the form {@link ControllerAdapter.commission} answers with. */
|
|
668
669
|
providerNodeId: CertNodeRef;
|
|
669
670
|
|
|
670
|
-
/**
|
|
671
|
+
/**
|
|
672
|
+
* `VendorID`: the announcing controller's vendor id as it would appear in its Basic Information cluster. A
|
|
673
|
+
* controller without that cluster sends its commissioner (admin) vendor id.
|
|
674
|
+
*
|
|
675
|
+
* @see {@link MatterSpecification.v161.Core} § 11.20.7.6.1.2
|
|
676
|
+
*/
|
|
671
677
|
vendorId: number;
|
|
672
678
|
|
|
673
679
|
/** `AnnouncementReason`: 0 SimpleAnnouncement, 1 UpdateAvailable, 2 UrgentUpdateAvailable. */
|
|
@@ -868,8 +874,8 @@ export interface CertIcdClientApi {
|
|
|
868
874
|
*
|
|
869
875
|
* A method whose controller cannot express the requested operation throws
|
|
870
876
|
* {@link UnsupportedByControllerError} rather than performing part of the interaction and returning
|
|
871
|
-
* a partial result; a step that needs the capability declares
|
|
872
|
-
*
|
|
877
|
+
* a partial result; a step that needs the capability declares it (see {@link ControllerCapability}), so it is
|
|
878
|
+
* skipped before it runs where the controller lacks it.
|
|
873
879
|
*/
|
|
874
880
|
export interface CertNodeApi {
|
|
875
881
|
invoke(
|
|
@@ -894,8 +900,8 @@ export interface CertNodeApi {
|
|
|
894
900
|
* {@link invoke}, a failure status is reported rather than thrown — the whole point of the batch is
|
|
895
901
|
* that its commands fail independently.
|
|
896
902
|
*
|
|
897
|
-
* A controller with no batch-invoke support throws {@link UnsupportedByControllerError}
|
|
898
|
-
* {@link CertNodeApi}'s own doc for the general contract).
|
|
903
|
+
* A controller with no batch-invoke support lacks `batch-invoke` and throws {@link UnsupportedByControllerError}
|
|
904
|
+
* (see {@link CertNodeApi}'s own doc for the general contract).
|
|
899
905
|
*
|
|
900
906
|
* @see {@link MatterSpecification.v161.Core} § 8.8.2
|
|
901
907
|
*/
|
|
@@ -928,8 +934,9 @@ export interface CertNodeApi {
|
|
|
928
934
|
* result was therefore not written — it is not a protocol failure, and a step that needs to know an attribute
|
|
929
935
|
* changed reads it back.
|
|
930
936
|
*
|
|
931
|
-
* An adapter whose controller cannot express
|
|
932
|
-
*
|
|
937
|
+
* An adapter whose controller cannot express the write throws {@link UnsupportedByControllerError} naming the
|
|
938
|
+
* capability it lacks or does not offer, among them `multi-path-write`, `mixed-version-write`,
|
|
939
|
+
* `typed-list-write-with-others` and `many-paths-per-request` (see {@link CertNodeApi}'s own doc for the general
|
|
933
940
|
* contract).
|
|
934
941
|
*
|
|
935
942
|
* @see {@link MatterSpecification.v161.Core} § 8.9.2.7, § 8.7.3.2
|
|
@@ -1122,26 +1129,22 @@ export interface CertNodeApi {
|
|
|
1122
1129
|
* Raise this before the operation has any observable effect (a commission, a write, a recorded
|
|
1123
1130
|
* check).
|
|
1124
1131
|
*
|
|
1125
|
-
*
|
|
1126
|
-
* implementation declares that capability as a gap, so a step or test case that declares it is
|
|
1127
|
-
* before it runs, and a refusal that still reaches the step runner means a declaration is missing on one
|
|
1128
|
-
* side. The runner reports that as a framework error, whatever the step already did.
|
|
1132
|
+
* Every refusal names the {@link ControllerCapability} it stands for, and is never a step outcome: the
|
|
1133
|
+
* implementation declares that capability as a gap or out of scope, so a step or test case that declares it is
|
|
1134
|
+
* skipped before it runs, and a refusal that still reaches the step runner means a declaration is missing on one
|
|
1135
|
+
* side. The runner reports that as a framework error, whatever the step already did. A step must never take this
|
|
1136
|
+
* error for an outcome of the device.
|
|
1129
1137
|
*
|
|
1130
|
-
*
|
|
1131
|
-
* the step had not yet recorded a check or made a controller call that may change the device, and fails
|
|
1132
|
-
* and aborts the run otherwise. A step must never take this error for an outcome of the device.
|
|
1138
|
+
* `detail` says why the controller lacks the capability; an implementation passes the reason it registered.
|
|
1133
1139
|
*/
|
|
1134
1140
|
export class UnsupportedByControllerError extends Error {
|
|
1135
1141
|
constructor(
|
|
1136
1142
|
readonly operation: string,
|
|
1137
1143
|
readonly controller: string,
|
|
1138
|
-
detail
|
|
1139
|
-
readonly capability
|
|
1144
|
+
detail: string,
|
|
1145
|
+
readonly capability: ControllerCapability,
|
|
1140
1146
|
) {
|
|
1141
|
-
super(
|
|
1142
|
-
`not implementable on controller "${controller}": ${operation}` +
|
|
1143
|
-
(detail === undefined ? "" : ` — ${detail}`),
|
|
1144
|
-
);
|
|
1147
|
+
super(`not implementable on controller "${controller}": ${operation} — ${detail}`);
|
|
1145
1148
|
}
|
|
1146
1149
|
}
|
|
1147
1150
|
|
|
@@ -1185,6 +1188,23 @@ export interface ControllerAdapter {
|
|
|
1185
1188
|
*/
|
|
1186
1189
|
parseManualPairingCode(code: string): Promise<ManualPairingCodeFields>;
|
|
1187
1190
|
|
|
1191
|
+
/**
|
|
1192
|
+
* The commissionable nodes the controller finds through DNS-SD, without commissioning any of them.
|
|
1193
|
+
*
|
|
1194
|
+
* Each controller looks for as long as its own discovery does, and reports what it found then: matter.js for a
|
|
1195
|
+
* fixed window, matterjs-server for the window its `discover_commissionable_nodes` command uses, chip-tool until
|
|
1196
|
+
* the first node that matches. A filter narrows the search where the controller can apply one; a controller that
|
|
1197
|
+
* cannot reports every node it found, so a caller still selects the node it is looking for. Where the controller
|
|
1198
|
+
* found nothing, resolves with an empty list, or rejects where the controller reports such a search as a failure
|
|
1199
|
+
* (chip-tool).
|
|
1200
|
+
*
|
|
1201
|
+
* Present where the controller can discover without commissioning; a step that needs it declares
|
|
1202
|
+
* `commissionable-discovery` (see {@link ControllerCapability}).
|
|
1203
|
+
*
|
|
1204
|
+
* @see {@link MatterSpecification.v161.Core} § 4.3.1
|
|
1205
|
+
*/
|
|
1206
|
+
discoverCommissionableNodes?(filter?: CommissionableNodeFilter): Promise<DiscoveredCommissionableNode[]>;
|
|
1207
|
+
|
|
1188
1208
|
node(ref: CertNodeRef): CertNodeApi;
|
|
1189
1209
|
|
|
1190
1210
|
/**
|
|
@@ -1289,6 +1309,33 @@ export interface ManualPairingCodeFields {
|
|
|
1289
1309
|
productId?: number;
|
|
1290
1310
|
}
|
|
1291
1311
|
|
|
1312
|
+
/** What {@link ControllerAdapter.discoverCommissionableNodes} asks the controller to look for. */
|
|
1313
|
+
export interface CommissionableNodeFilter {
|
|
1314
|
+
/** The 12-bit discriminator of the `_L` commissioning subtype (§ 4.3.1.3). */
|
|
1315
|
+
longDiscriminator?: number;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* A commissionable node as {@link ControllerAdapter.discoverCommissionableNodes} reports it: the values of its DNS-SD
|
|
1320
|
+
* advertisement, as the controller read them.
|
|
1321
|
+
*
|
|
1322
|
+
* @see {@link MatterSpecification.v161.Core} § 4.3.1
|
|
1323
|
+
*/
|
|
1324
|
+
export interface DiscoveredCommissionableNode {
|
|
1325
|
+
/** The DNS-SD service instance name. */
|
|
1326
|
+
instanceName: string;
|
|
1327
|
+
|
|
1328
|
+
/** The `D` TXT key (§ 4.3.1.5). */
|
|
1329
|
+
longDiscriminator: number;
|
|
1330
|
+
|
|
1331
|
+
/** From the `VP` TXT key (§ 4.3.1.6); absent where the node states none. */
|
|
1332
|
+
vendorId?: number;
|
|
1333
|
+
productId?: number;
|
|
1334
|
+
|
|
1335
|
+
/** The `CM` TXT key (§ 4.3.1.7). */
|
|
1336
|
+
commissioningMode: number;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1292
1339
|
/**
|
|
1293
1340
|
* How a controller reaches its peers. `"tcp"` asks for a TCP-backed session, which a large-payload
|
|
1294
1341
|
* interaction requires; omitted, a controller keeps the transport every other TC's evidence and
|
|
@@ -1505,9 +1552,18 @@ export type ControllerRoleKind = "dut" | "helper";
|
|
|
1505
1552
|
*
|
|
1506
1553
|
* - `onboarding-payload-parse` — {@link ControllerAdapter.parseQrPayload} and
|
|
1507
1554
|
* {@link ControllerAdapter.parseManualPairingCode}
|
|
1555
|
+
* - `commissionable-discovery` — {@link ControllerAdapter.discoverCommissionableNodes}
|
|
1508
1556
|
* - `multi-path-write` — {@link CertNodeApi.writeAttributes} with several entries or a data version
|
|
1557
|
+
* - `mixed-version-write` — {@link CertNodeApi.writeAttributes} in which some entries carry a data version and others
|
|
1558
|
+
* do not
|
|
1559
|
+
* - `typed-list-write-with-others` — {@link CertNodeApi.writeAttributes} with several entries, one of them a list
|
|
1560
|
+
* attribute the controller writes only through a command of its own for that attribute, which carries no other
|
|
1561
|
+
* entry (the implementation's gap text names the attributes)
|
|
1562
|
+
* - `many-paths-per-request` — a read, subscription or write that names more paths in one request than a controller
|
|
1563
|
+
* accepts in one command (the implementation's gap text names its limit)
|
|
1509
1564
|
* - `chunked-write` — a write too large for one message sent as chunked WriteRequestMessages, each next one after the
|
|
1510
1565
|
* WriteResponse to the previous (Matter Core § 10.2.3)
|
|
1566
|
+
* - `batch-invoke` — {@link CertNodeApi.invokeBatch}: several commands in one InvokeRequest
|
|
1511
1567
|
* - `batch-arrival-order` — {@link CertNodeApi.invokeBatch} results in the order the device's answers arrived
|
|
1512
1568
|
* - `basic-commissioning-window` — {@link CertNodeApi.openCommissioningWindow} without `enhanced`
|
|
1513
1569
|
* - `max-value-path-ids` — a concrete path naming endpoint 0xFFFF or a cluster, attribute or event id 0xFFFFFFFF
|
|
@@ -1539,8 +1595,13 @@ export type ControllerRoleKind = "dut" | "helper";
|
|
|
1539
1595
|
*/
|
|
1540
1596
|
export type ControllerCapability =
|
|
1541
1597
|
| "onboarding-payload-parse"
|
|
1598
|
+
| "commissionable-discovery"
|
|
1542
1599
|
| "multi-path-write"
|
|
1600
|
+
| "mixed-version-write"
|
|
1601
|
+
| "typed-list-write-with-others"
|
|
1602
|
+
| "many-paths-per-request"
|
|
1543
1603
|
| "chunked-write"
|
|
1604
|
+
| "batch-invoke"
|
|
1544
1605
|
| "batch-arrival-order"
|
|
1545
1606
|
| "basic-commissioning-window"
|
|
1546
1607
|
| "max-value-path-ids"
|
|
@@ -127,8 +127,8 @@ export interface RunRecord {
|
|
|
127
127
|
*/
|
|
128
128
|
runError?: string;
|
|
129
129
|
/**
|
|
130
|
-
* How many steps the controller under test
|
|
131
|
-
* verdict `"controller-gap"`, and the count says how much of the plan the run left out.
|
|
130
|
+
* How many steps were skipped because the controller under test lacks a capability they declare, absent if none.
|
|
131
|
+
* Any such step makes the verdict `"controller-gap"`, and the count says how much of the plan the run left out.
|
|
132
132
|
*/
|
|
133
133
|
controllerUnsupportedSkips?: number;
|
|
134
134
|
/**
|
|
@@ -287,7 +287,7 @@ export class EvidenceRecorder implements StepRecorder {
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
|
-
* Records how many steps the controller under test
|
|
290
|
+
* Records how many steps were skipped because the controller under test lacks a capability they declare (see
|
|
291
291
|
* {@link RunRecord.controllerUnsupportedSkips}). Such a step is a gap in coverage, not a defect in the device,
|
|
292
292
|
* so it settles a run that failed nothing as `"controller-gap"`.
|
|
293
293
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { delay } from "../../util/async.js";
|
|
7
|
+
import { delay, MAX_TIMEOUT_MS } from "../../util/async.js";
|
|
8
8
|
import { deansify } from "../../util/text.js";
|
|
9
9
|
import type { DeviceFlavor, LogSource } from "./cert-context.js";
|
|
10
10
|
|
|
@@ -16,6 +16,13 @@ const DEFAULT_TIMEOUT_MS = 30_000;
|
|
|
16
16
|
export interface LogLine {
|
|
17
17
|
index: number;
|
|
18
18
|
at: Date;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* When the follower took the line in, on the monotonic clock (`performance.now()`, milliseconds). Use it for the
|
|
22
|
+
* time between two lines; {@link at} follows wall-clock steps.
|
|
23
|
+
*/
|
|
24
|
+
receivedAt: number;
|
|
25
|
+
|
|
19
26
|
text: string;
|
|
20
27
|
/** Set on a line added via {@link LogFollower.annotate} — never matched by {@link LogFollower.expect}. */
|
|
21
28
|
synthetic?: true;
|
|
@@ -153,15 +160,12 @@ export class LogFollower implements LogSource {
|
|
|
153
160
|
#closed = false;
|
|
154
161
|
#closeError?: Error;
|
|
155
162
|
#waiters = new Array<() => void>();
|
|
156
|
-
#
|
|
157
|
-
#
|
|
163
|
+
#isClosing = false;
|
|
164
|
+
#stopConsuming?: () => void;
|
|
158
165
|
#pump: Promise<void>;
|
|
159
166
|
|
|
160
167
|
constructor(source: AsyncIterable<string>, name: string) {
|
|
161
168
|
this.name = name;
|
|
162
|
-
this.#closeSignal = new Promise<void>(resolve => {
|
|
163
|
-
this.#resolveCloseSignal = resolve;
|
|
164
|
-
});
|
|
165
169
|
this.#pump = this.#consume(source);
|
|
166
170
|
}
|
|
167
171
|
|
|
@@ -172,7 +176,13 @@ export class LogFollower implements LogSource {
|
|
|
172
176
|
* satisfying a step's own pattern.
|
|
173
177
|
*/
|
|
174
178
|
annotate(text: string): void {
|
|
175
|
-
this.#lines.push({
|
|
179
|
+
this.#lines.push({
|
|
180
|
+
index: this.#lines.length,
|
|
181
|
+
at: new Date(),
|
|
182
|
+
receivedAt: performance.now(),
|
|
183
|
+
text,
|
|
184
|
+
synthetic: true,
|
|
185
|
+
});
|
|
176
186
|
this.#wake();
|
|
177
187
|
}
|
|
178
188
|
|
|
@@ -226,6 +236,14 @@ export class LogFollower implements LogSource {
|
|
|
226
236
|
await delay(0).promise;
|
|
227
237
|
}
|
|
228
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Whether the source has ended, by {@link close} or because the process behind it stopped writing. Lines
|
|
241
|
+
* already taken in stay readable; no further line arrives.
|
|
242
|
+
*/
|
|
243
|
+
get closed(): boolean {
|
|
244
|
+
return this.#closed;
|
|
245
|
+
}
|
|
246
|
+
|
|
229
247
|
/**
|
|
230
248
|
* Every line seen so far, in arrival order. A fresh copy on each access — callers cannot
|
|
231
249
|
* mutate the follower's own buffer through it. Prefer {@link count} and {@link lastMatchBefore}
|
|
@@ -330,14 +348,23 @@ export class LogFollower implements LogSource {
|
|
|
330
348
|
async expectPattern(original: RegExp, options: Omit<LogExpectOptions, "flavor">): Promise<LogLine> {
|
|
331
349
|
const pattern = matchableCopy(original);
|
|
332
350
|
const from = options.from ?? this.#lastMark;
|
|
333
|
-
|
|
351
|
+
let timedOut = false;
|
|
352
|
+
const timer = setTimeout(
|
|
353
|
+
() => {
|
|
354
|
+
timedOut = true;
|
|
355
|
+
this.#wake();
|
|
356
|
+
},
|
|
357
|
+
Math.min(options.timeoutMs ?? DEFAULT_TIMEOUT_MS, MAX_TIMEOUT_MS),
|
|
358
|
+
);
|
|
359
|
+
let next = from;
|
|
334
360
|
|
|
335
361
|
try {
|
|
336
362
|
for (;;) {
|
|
337
|
-
const matched = this.#firstMatchFrom(pattern,
|
|
363
|
+
const matched = this.#firstMatchFrom(pattern, next);
|
|
338
364
|
if (matched) {
|
|
339
365
|
return matched;
|
|
340
366
|
}
|
|
367
|
+
next = Math.max(next, this.#lines.length);
|
|
341
368
|
|
|
342
369
|
if (this.#closeError) {
|
|
343
370
|
throw this.#closeError;
|
|
@@ -346,13 +373,13 @@ export class LogFollower implements LogSource {
|
|
|
346
373
|
throw new CertLogClosedError(this.name);
|
|
347
374
|
}
|
|
348
375
|
|
|
349
|
-
|
|
350
|
-
if (outcome === "timeout") {
|
|
376
|
+
if (timedOut) {
|
|
351
377
|
throw new CertLogTimeoutError(String(original), from, this.#lines.slice(from));
|
|
352
378
|
}
|
|
379
|
+
await this.#waitForWake();
|
|
353
380
|
}
|
|
354
381
|
} finally {
|
|
355
|
-
|
|
382
|
+
clearTimeout(timer);
|
|
356
383
|
}
|
|
357
384
|
}
|
|
358
385
|
|
|
@@ -361,7 +388,8 @@ export class LogFollower implements LogSource {
|
|
|
361
388
|
}
|
|
362
389
|
|
|
363
390
|
async close(): Promise<void> {
|
|
364
|
-
this.#
|
|
391
|
+
this.#isClosing = true;
|
|
392
|
+
this.#stopConsuming?.();
|
|
365
393
|
await this.#pump;
|
|
366
394
|
}
|
|
367
395
|
|
|
@@ -413,26 +441,33 @@ export class LogFollower implements LogSource {
|
|
|
413
441
|
}
|
|
414
442
|
}
|
|
415
443
|
|
|
416
|
-
//
|
|
417
|
-
//
|
|
444
|
+
// close() ends the wait for the next line at once, without forcing the source's iterator closed (which
|
|
445
|
+
// could hang on a source parked mid-await). Nothing attached per line may outlive that line.
|
|
418
446
|
// Never rethrows: failures land on #closeError for expect() to surface, so #pump always
|
|
419
447
|
// resolves and close() has nothing to catch.
|
|
420
448
|
async #consume(source: AsyncIterable<string>): Promise<void> {
|
|
421
449
|
const iterator = source[Symbol.asyncIterator]();
|
|
422
450
|
try {
|
|
423
|
-
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
this.#
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
451
|
+
while (!this.#isClosing) {
|
|
452
|
+
const next = iterator.next();
|
|
453
|
+
const result = await new Promise<IteratorResult<string> | undefined>((resolve, reject) => {
|
|
454
|
+
this.#stopConsuming = () => resolve(undefined);
|
|
455
|
+
next.then(resolve, reject);
|
|
456
|
+
});
|
|
457
|
+
this.#stopConsuming = undefined;
|
|
458
|
+
|
|
459
|
+
if (result === undefined || result.done) {
|
|
430
460
|
return;
|
|
431
461
|
}
|
|
432
462
|
|
|
433
463
|
// chip binaries colorize log output even when stdout isn't a TTY; a trailing ANSI reset
|
|
434
464
|
// sequence after the visible text breaks any pattern anchored on end-of-line ($).
|
|
435
|
-
this.#lines.push({
|
|
465
|
+
this.#lines.push({
|
|
466
|
+
index: this.#lines.length,
|
|
467
|
+
at: new Date(),
|
|
468
|
+
receivedAt: performance.now(),
|
|
469
|
+
text: deansify(result.value),
|
|
470
|
+
});
|
|
436
471
|
this.#wake();
|
|
437
472
|
}
|
|
438
473
|
} catch (e) {
|
|
@@ -85,7 +85,7 @@ export class PromptDrivenPythonTest extends PythonTest {
|
|
|
85
85
|
let handled = 0;
|
|
86
86
|
try {
|
|
87
87
|
for await (let line of terminal) {
|
|
88
|
-
this.#log.push({ index: this.#log.length, at: new Date(), text: line });
|
|
88
|
+
this.#log.push({ index: this.#log.length, at: new Date(), receivedAt: performance.now(), text: line });
|
|
89
89
|
|
|
90
90
|
line = parseStep(line, step);
|
|
91
91
|
|