|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +--- |
| 5 | +# Each case is one device of the {{ cdi_device_kind }} kind, selected as |
| 6 | +# `{{ cdi_device_kind }}=<name>`. A case declares the host fixtures it |
| 7 | +# needs and the CDI edits that reference them; tasks/scenarios.yaml creates the |
| 8 | +# fixtures and templates/scenarios.yaml.j2 renders the spec. |
| 9 | +# |
| 10 | +# Fixture `path` is relative to {{ cdi_scenario_dir }}. Types: |
| 11 | +# dir directory (parents must be declared first) |
| 12 | +# file regular file with `content` |
| 13 | +# Both accept `mode`, `owner` and `group`. |
| 14 | +# |
| 15 | +# `expect` records the behavior the CDI feature tests assert for the scenario, |
| 16 | +# and is rendered to {{ cdi_fixture_root }}/scenarios.json for them. It states |
| 17 | +# what the sandbox does today; a change that alters that behavior updates the |
| 18 | +# values here. Either: |
| 19 | +# rejected: <text> sandbox creation fails; <text> must appear in the |
| 20 | +# diagnostic (empty matches any failure). No workload |
| 21 | +# runs, so no checks apply. |
| 22 | +# checks: [...] sandbox creation succeeds and each check holds, where a |
| 23 | +# check is one of |
| 24 | +# {type: exists, path, expect} whether the path exists (true) |
| 25 | +# {type: contents, path, expect} the file's contents |
| 26 | +# {type: filetype, path, expect} `file`, `directory`, `character-device`, |
| 27 | +# `block-device`, `socket` or `fifo` |
| 28 | +# {type: read, path, expect} `ok` or `denied` |
| 29 | +# {type: write, path, expect} `ok` or `denied` (nothing is written) |
| 30 | +# {type: env, name, expect} value, null when unset |
| 31 | +# {type: non-root, expect} whether the workload is not uid 0 (true) |
| 32 | +# {type: in-group-of, path, expect} |
| 33 | +# whether the workload's groups include |
| 34 | +# the group that owns path (true) |
| 35 | +# `non-root` and `in-group-of` describe the workload process, not a file's |
| 36 | +# owner. |
| 37 | +cdi_scenario_dir: "{{ cdi_fixture_files_root }}/scenarios" |
| 38 | + |
| 39 | +# Edits applied by every case, to check that spec and device edits merge. The |
| 40 | +# marker is mounted under /usr/share, which the sandbox already allows reading, |
| 41 | +# so these checks do not depend on grants derived from the CDI spec. |
| 42 | +cdi_scenario_spec_edits: |
| 43 | + env: |
| 44 | + - TMACHINE_CDI_SCENARIO_SPEC=fixture |
| 45 | + mounts: |
| 46 | + - hostPath: "{{ cdi_scenario_dir }}/spec-marker" |
| 47 | + containerPath: /usr/share/tmachine-cdi/common/spec-marker |
| 48 | + options: [bind, ro] |
| 49 | + |
| 50 | +# Checked in every scenario that is created, to show that spec and device edits |
| 51 | +# merge. |
| 52 | +cdi_scenario_common_checks: |
| 53 | + - {type: env, name: TMACHINE_CDI_SCENARIO_SPEC, expect: fixture} |
| 54 | + - {type: contents, path: /usr/share/tmachine-cdi/common/spec-marker, expect: tmachine-cdi-spec-marker} |
| 55 | + - {type: write, path: /usr/share/tmachine-cdi/common/spec-marker, expect: denied} |
| 56 | + |
| 57 | +cdi_scenario_common_fixtures: |
| 58 | + - {path: spec-marker, type: file, content: "tmachine-cdi-spec-marker\n", mode: "0644"} |
| 59 | + |
| 60 | +cdi_scenarios: |
| 61 | + # The mount point is under a directory the sandbox baseline already makes |
| 62 | + # read-only, so nothing needs to be derived for the mount to be readable. |
| 63 | + - name: mount-under-read-only-baseline |
| 64 | + fixtures: |
| 65 | + - {path: baseline-read-only-file, type: file, content: "tmachine-cdi-baseline-read-only-file\n", mode: "0644"} |
| 66 | + edits: |
| 67 | + mounts: |
| 68 | + - hostPath: "{{ cdi_scenario_dir }}/baseline-read-only-file" |
| 69 | + containerPath: /usr/share/tmachine-cdi/baseline-read-only-file |
| 70 | + options: [bind, ro] |
| 71 | + expect: |
| 72 | + checks: |
| 73 | + - {type: contents, path: /usr/share/tmachine-cdi/baseline-read-only-file, expect: tmachine-cdi-baseline-read-only-file} |
| 74 | + - {type: write, path: /usr/share/tmachine-cdi/baseline-read-only-file, expect: denied} |
0 commit comments