ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
suppression_selftest_fixtures.py
Go to the documentation of this file.
1# SPDX-License-Identifier: MIT
2# Copyright (c) 2026 Brighton Sikarskie
3"""Immutable data fixtures for the suppression scanner selftest."""
4
5from __future__ import annotations
6
7import hashlib
8
9from suppression_tool_selftest import TOOL_CONTROL_FIXTURES
10
11EXPECTED_FIXTURE_SHA256 = "00145bcb1482f63d3811f64bd4d95fd0afdacd684e6127515632d4ebd23c2f54"
12EXPECTED_FIXTURE_INVENTORY_SHA256 = (
13 "d3fea00610180e9fff0dd44cb8d3a8b6f6bcc1e0e97c374ca4cf0e8576c2f26a"
14)
15
16CORE_FIXTURES = {
17 "compiler_controls.c": r"""const char *pragma_text =
18 "#pragma clang diagnostic " "ignored \\"-Wunused-variable\\"";
19const char *attribute_text = "[[maybe_unused]] __attribute__((unused))";
20const char *raw_text = R"tag(RA8_NASA_RULE_3_OK("not code"))tag";
21#pragma clang diagnostic push
22/* Suppression rationale: fixture variable exists only to trigger the warning contract. */
23#pragma clang diagnostic ignored "-Wunused-variable"
24static void clang_region(void) { int fixture_unused; }
25#pragma clang diagnostic pop
26#pragma GCC diagnostic push
27#pragma GCC diagnostic warning "-Wunused-variable"
28#pragma GCC diagnostic pop
29_Pragma("clang diagnostic push")
30/* Suppression rationale: fixture operator variable exists only for warning coverage. */
31_Pragma("clang diagnostic ignored \"-Wunused-variable\"")
32static void clang_operator_region(void) { int fixture_unused; }
33_Pragma("clang diagnostic pop")
34_Pragma("GCC diagnostic push")
35_Pragma("GCC diagnostic warning \"-Wunused-variable\"")
36_Pragma("GCC diagnostic pop")
37[[deprecated("fixture"), maybe_unused]] static int maybe_unused_value;
38[[gnu::unused]] static int scoped_gnu_unused_value;
39__attribute((unused)) static int short_gnu_unused_value;
40__attribute__((unused)) static int gnu_unused_value;
41__attribute__((no_sanitize("undefined"))) int unsanitized_identity(int value) { return value; }
42__attribute__((__no_sanitize__("undefined")))
43int underscored_unsanitized(int value) { return value; }
44__attribute__((__no_sanitize_address__)) int address_unsanitized(int value) { return value; }
45[[clang::no_sanitize("undefined")]] int scoped_unsanitized(int value) { return value; }
46RA8_NASA_RULE_3_OK("fixture host allocator contract")
47static void waived_allocator(void) {}
48void *allowed_alloc(void) { return malloc(4); /* alloc-allow: fixture bounded allocator */ }
49""",
50 "malformed_controls.c": r"""#pragma clang diagnostic ignored "-Wunused-variable"
51#pragma GCC diagnostic sideways "-Wunused-variable"
52#pragma GCC diagnostic push
53#pragma clang diagnostic pop
54_Pragma("clang diagnostic ignored -Wunused-variable")
55[[maybe_unused("reason")]] static int malformed_maybe_args;
56[[maybe_unused bogus]] static int malformed_maybe_tail;
57[[clang::no_sanitize(foo)]] int malformed_scoped_sanitizer(int value) { return value; }
58__attribute__((unused extra)) static int malformed_gnu;
59__attribute__((unused("reason"))) static int malformed_unused;
60__attribute__((no_sanitize)) int malformed_empty_sanitizer(int value) { return value; }
61__attribute__((no_sanitize(foo))) int malformed_sanitizer(int value) { return value; }
62RA8_NASA_RULE_3_OK
63static void bare_nasa(void) {}
64static int orphan_control; /* alloc-allow: no allocator on this line */
65static int bare_control; /* alloc-allow */
66""",
67 "alloc_consumer.c": r"""void *malloc(unsigned long size);
68void *reasoned(void) { return malloc(4); /* alloc-allow: fixture bounded allocation */ }
69void *string_only(void) { const char *text = "alloc-allow: not a comment"; return malloc(4); }
70void orphan_control(void) { /* alloc-allow: no allocation is present */ }
71""",
72 "alloc_consumer.cpp": r"""void active_new(void) {
73 int *value = new int; /* alloc-allow: fixture C++ object allocation */
74 delete value; /* alloc-allow: fixture C++ object release */
75}
76void orphan_cpp_control(void) { /* alloc-allow: no allocation is present */ }
77""",
78 ".clang-tidy": """---
79# Disabled checks:
80# -readability-fixture
81# Synthetic check proves source-located global exclusions.
82Checks: >
83 readability-*,
84 -readability-fixture
85WarningsAsErrors: '*'
86""",
87 "controls.py": """import pytest
88import unittest
89import pytest as pt
90from unittest import expectedFailure, skipIf, skipUnless
91
92@pytest.mark.skip(reason="fixture platform is absent")
93@pytest.mark.skipif(True, reason="fixture condition")
94@pytest.mark.xfail(reason="fixture defect", strict=True)
95def test_controlled():
96 pytest.skip("fixture runtime precondition")
97 pytest.xfail("fixture runtime limitation")
98
99@unittest.skip("fixture feature unavailable")
100def test_unittest_controlled():
101 raise unittest.SkipTest("fixture setup unavailable")
102
103pytestmark = pt.mark.skip(reason="fixture module platform is absent")
104
105@skipIf(True, "fixture skipIf condition")
106def test_skip_if():
107 pass
108
109@skipUnless(False, "fixture skipUnless condition")
110def test_skip_unless():
111 pass
112
113@expectedFailure
114def test_expected_failure():
115 pass
116
117class FixtureCase(unittest.TestCase):
118 def test_method_skip(self):
119 self.skipTest("fixture method setup unavailable")
120
121@pt.mark.xfail(reason="fixture permissive expected failure")
122def test_permissive_xfail():
123 pass
124
125text = "pytest.mark.skip(reason='string only')"
126""",
127 "sample.py": """value = "# noqa: F401 -- string only"
128controls = "# pragma: no cover; # pylint: disable=unused-import; # fmt: off"
129import os # noqa: F401 -- imported for fixture coverage
130result = value # type: ignore[assignment] -- fixture type mismatch
131print(result) # noqa: S603,S607 -- fixture normalized multi-rule waiver
132# pragma: no cover -- fixture impossible branch
133# pylint: disable=unused-import -- fixture analyzer region
134# pylint: enable=unused-import
135# mypy: ignore-errors -- fixture generated API surface
136other = result # pyright: ignore[reportAssignmentType] -- fixture mismatch
137print(other) # nosec B101 -- fixture security false positive
138print(other) # bandit: skip=B602 -- fixture security false positive
139# ruff: noqa: E402 -- fixture file-level import ordering
140# Suppression rationale: hand-aligned fixture table
141# fmt: off
142table = [1, 2]
143# fmt: on
144""",
145 "bare_python_controls.py": """# fmt: off
146value = 1
147# pyright: ignore
148# pylint: skip-file
149""",
150 "sample.c": """const char *text = "NOLINT(readability-magic-numbers)";
151const char *raw = R"tag(// NOLINT(readability-magic-numbers))tag";
152const char *spliced = "text \\
153// NOLINT(readability-magic-numbers)";
154int NOLINT(raw_token);
155int prefixNOLINT = 0;
156// NOLINTNEXTLINE(readability-magic-numbers) -- fixture literal
157int value = 7;
158/* GCOVR_EXCL_LINE -- fixture hardware path */
159/* cppcheck-suppress unreadVariable -- fixture assembly output */
160/* NOLINTBEGIN(readability-identifier-naming) -- fixture generated names */
161int Fixture_Name;
162/* NOLINTEND(readability-identifier-naming) */
163// NOLINT(whitespace/line_length) -- fixture vendored cpplint syntax
164// spliced line comment \\
165NOLINT(readability-redundant-string-init) -- fixture spliced directive
166// spliced line comment \\
167int NOLINT(raw_spliced_token);
168/* GCOVR_EXCL_START -- fixture unreachable region */
169int unreachable_value;
170/* GCOVR_EXCL_STOP */
171/* cppcheck-suppress-begin unusedStructMember -- fixture generated declarations */
172int unused_value;
173/* cppcheck-suppress-end unusedStructMember */
174unsigned long first_set_bit; // NOLINT (runtime/int)
175int legacy_size; // NOLINT[readability/fn_size]
176/* GCOVR_EXCL_BR_START -- fixture branch-only region */
177if (unreachable_value) {
178 unreachable_value = 2;
179}
180/* GCOVR_EXCL_BR_STOP */
181/* LCOV_EXCL_START -- fixture LCOV region */
182unreachable_value = 3;
183/* LCOV_EXCL_STOP */
184/* mcdc-deactivated: fixture operands are coupled by the fixture contract. */
185int fixture_decision = fixture_left && fixture_right;
186""",
187 "malformed_mcdc.c": """/**
188 * mcdc-deactivated: documentation prose is not an active marker.
189 */
190/* mcdc-deactivated because the colon is missing */
191/* mcdc-deactivated: first marker for one decision */
192/* mcdc-deactivated: duplicate marker for the same decision */
193int duplicate_decision = fixture_left || fixture_right;
194RA8_MCDC_DEACTIVATED("fixture function invariant")
195RA8_MCDC_OK("unknown alias")
196RA8_MCDC_DEACTIVATED(reason)
197RA8_MCDC_DEACTIVATED(not_literal) RA8_MCDC_DEACTIVATED("valid after invalid")
198RA8_MCDC_DEACTIVATED("valid before invalid") RA8_MCDC_DEACTIVATED(still_not_literal)
199RA8_MCDC_DEACTIVATED("first distinct reason") RA8_MCDC_DEACTIVATED("second distinct reason")
200/* mcdc-deactivated: no following compound decision */
201int unrelated_value;
202""",
203 "native_test.cpp": """void skip_gtest(void) {
204 GTEST_SKIP() << "fixture platform is absent";
205}
206void skip_unity_message(void) {
207 TEST_IGNORE_MESSAGE("fixture peripheral is absent");
208}
209void skip_unity_bare(void) {
210 TEST_IGNORE();
211}
212const char* skip_text = "GTEST_SKIP()";
213void malformed_skip(void) { GTEST_SKIP(7); }
214void malformed_unity(void) { TEST_IGNORE_MESSAGE(reason); }
215""",
216 "sample.sh": """#!/usr/bin/env bash
217echo '# shellcheck disable=SC2086'
218# shellcheck disable=SC2086 # fixture intentionally expands words
219true;# shellcheck disable=SC2034 # fixture operator starts a comment word
220value=${value#prefix}; cc -Wno-shadow -c sample.c
221word#literal cc -Wno-conversion -c sample.c
222cc -Wno-unused-parameter -c sample.c
223cmake -S . -B build \\
224 -Wno-dev
225"$CMAKE" -S . -B variable-build \\
226 -Wno-dev
227FLAGS=(-DUNIT_TEST -w)
228test -w sample.c
229fold -w 80 sample.c
230echo "-Wno-error is documentation"
231cmake -E echo -Wno-dev
232/usr/bin/cmake -S . -B absolute-build -Wno-dev
233/usr/bin/clang++ -Wno-sign-conversion -c sample.cpp
234echo "/usr/bin/clang++ -Wno-error is quoted documentation"
235"/usr/bin/cmake" -S . -B quoted-build -Wno-dev
236'/usr/bin/clang++' -Wno-float-conversion -c sample.cpp
237cmake -E env /usr/bin/clang++ -Wno-padded -c sample.cpp
238cmake --build build --target -Wno-dev
239"/opt/tool chain/bin/clang++" -Wno-error -c spaced.cpp
240"/opt/cmake tools/bin/cmake" -S . -B spaced-build -Wno-dev
241/opt/tool\\ chain/bin/clang++ -Wno-shadow -c escaped.cpp
242"/opt/tool \\\"quoted\\\" path/bin/clang++" -Wno-padded -c quoted.cpp
243"/opt/tool\\\\path/bin/clang++" -Wno-switch -c backslash.cpp
244'/opt/single quoted/bin/clang' -Wno-cast-align -c single.c
245echo '"/opt/tool chain/bin/clang++" -Wno-unused-variable'
246printf '%s\\n' "/opt/cmake tools/bin/cmake" -Wno-dev
247# "/opt/tool chain/bin/clang++" -Wno-comment
248"/opt/cmake tools/bin/cmake" -S . -B deprecated -Wno-deprecated
249"/opt/cmake tools/bin/cmake" -S . -B dev-errors -Wno-error=dev
250"/opt/cmake tools/bin/cmake" -S . -B deprecated-errors -Wno-error=deprecated
251"/opt/tool chain/bin/clang++" -Wno-deprecated -c compiler-owned.cpp
252"/opt/cmake tools/bin/cmake" -S . -B flags -DCMAKE_C_FLAGS=-Wno-deprecated
253echo '"/opt/cmake tools/bin/cmake" -Wno-deprecated'
254printf '%s\\n' "/opt/cmake tools/bin/cmake" -Wno-error=dev
255# "/opt/cmake tools/bin/cmake" -Wno-error=deprecated
256cat <<'PAYLOAD'
257# shellcheck disable=SC2016
258cc -Wno-error -c hidden.c
259PAYLOAD
260printf '%s\n' '<<PAYLOAD'
261read -r payload <<<$value
262mask=$((1 << 31))
263# shellcheck disable=SC2015 # active after quoted heredoc lookalike
264cat <<\\ESCAPED
265# shellcheck disable=SC2014
266ESCAPED
267cat <<'END-MARK'
268# shellcheck disable=SC2013
269END-MARK
270single='multiline text
271# shellcheck disable=SC2012
272single end'
273double="multiline text
274# shellcheck disable=SC2011
275double end"
276# shellcheck disable=SC2010 # active after multiline quotes
277# shellcheck enable=SC2010
278# shellcheck source=/dev/null
279# shellcheck source-path=SCRIPTDIR
280# shellcheck shell=bash
281# shellcheck external-sources=true
282SHELLCHECK_OPTS='--exclude=SC2001,SC2002' # fixture central exclusions need stable rows
283printf '%s\n' 'SHELLCHECK_OPTS=--exclude=SC2999'
284probe || true # fixture cleanup status is intentionally ignored
285captured="$(probe || true)"
286probe ||
287 true
288probe || \\
289 true
290printf '%s\n' 'probe || true'
291# probe || true
292gcovr --exclude-unreachable-branches # fixture strips compiler-generated dead edges
293coverage_text='--exclude-unreachable-branches'
294gcovr --gcov-ignore-parse-errors=suspicious_hits.warn
295cat <<'STATUS-DATA'
296probe || true
297STATUS-DATA
298cat <<MISSING
299# shellcheck disable=SC2009
300""",
301 "config/gcovr.cfg": """gcov-ignore-parse-errors = negative_hits.warn # fixture diagnostic
302exclude-unreachable-branches = yes # fixture removes compiler-only edges
303exclude-throw-branches = false # fixture keeps source branches
304gcov-ignore-parse-errors = all # duplicate authority must fail
305""",
306 "invalid/gcovr.cfg": """exclude-throw-branches = sideways # invalid boolean must fail
307""",
308 ".shellcheckrc": """# fixture editor parity
309exclude=SC2003,SC2004 # fixture central exclusions need stable rows
310""",
311 "just/sample.just": """set shell := ["bash", "-euo", "pipefail", "-c"]
312probe:
313 probe || true
314captured:
315 value="$(probe || true)"
316""",
317 "CMakeLists.txt": """target_compile_options(sample PRIVATE -w -Wno-unused-variable)
318target_compile_options(sample PRIVATE -Wno-dev)
319execute_process(COMMAND ${CMAKE_COMMAND} -S . -B build -DOPTION=ON -Wno-dev)
320message(STATUS "-Wno-dev is data")
321set(PAYLOAD "-Wno-dev")
322execute_process(COMMAND ${CMAKE_COMMAND} -S . -B deprecated -Wno-deprecated)
323set(CMAKE_C_FLAGS "-Wno-deprecated")
324message(STATUS "/usr/bin/cmake -S . -B hidden -Wno-deprecated")
325set(PROJECT_WNO
326 -Wno-conversion
327)
328# Fixture negative tests intentionally return non-zero.
329set_tests_properties(fails PROPERTIES WILL_FAIL TRUE)
330# Fixture is registered but cannot execute on this platform.
331set_property(TEST platform PROPERTY DISABLED ON)
332# Fixture maps one intentional application status to a skipped result.
333set_tests_properties(status PROPERTIES SKIP_RETURN_CODE 77)
334get_property(not_a_control TEST platform PROPERTY DISABLED)
335message("set_tests_properties(fake PROPERTIES WILL_FAIL TRUE)")
336set(payload [=[
337# NOLINT(readability-magic-numbers)
338-Wno-error
339]=])
340#[=[
341# shellcheck disable=SC2016
342-Wno-error
343]=]
344# -Wno-error in a comment is not active
345""",
346 "Makefile": """WARNING_CFLAGS ?= -Wno-format-nonliteral
347ECHO_TEXT = -Wno-error
348""",
349 "sample.yml": """payload: |
350 # noqa: command-instead-of-shell
351 cc -Wno-error -c hidden.c
352run: |
353 cc -Wno-error -c visible.c
354 cmake -S . -B build \\
355 -Wno-dev
356
357shell: |-
358 clang++ -Wno-dev -c visible.cpp
359steps:
360 - run: >-
361 /usr/bin/cmake -S . -B folded
362 -Wno-dev
363 - run: >
364 /usr/bin/clang++
365 -Wno-conversion -c folded.cpp
366task: value # noqa: command-instead-of-shell
367content: |
368 #!/bin/bash
369 probe || true # fixture generated wrapper tolerates an absent probe
370run: |
371 probe || true
372 probe ||
373 true
374 probe ||
375 # retained rationale
376 true
377ansible.builtin.shell: |
378 probe || true
379items:
380 - |2-
381 # shellcheck disable=SC2016
382 -Wno-error
383pkg.cflags: -Wno-dev -Wno-array-bounds -w
384commented_steps:
385 - run: >-
386 cmake -S . -B commented
387 # The folded shell comment owns the rest of this paragraph.
388 -Wno-dev
389""",
390 ".github/workflows/control.yml": """---
391name: control fixture
392jobs:
393 fixture:
394 continue-on-error: false
395 steps:
396 - name: Optional diagnostic
397 continue-on-error: true
398 run: false
399 - name: Optional artefact
400 uses: actions/upload-artifact@v4
401 with:
402 if-no-files-found: warn
403 - name: Expected-empty artefact
404 uses: actions/upload-artifact@v4
405 with:
406 if-no-files-found: ignore
407""",
408 "infra/ansible/roles/fixture/tasks/main.yml": """---
409- name: Read-only fixture probe
410 ansible.builtin.command: {cmd: probe}
411 changed_when: false
412 failed_when: false
413- name: Protect fixture credential output
414 ansible.builtin.command: {cmd: credential}
415 no_log: true
416- name: Continue fixture cleanup after an absent resource
417 ansible.builtin.command: {cmd: cleanup}
418 ignore_errors: true
419- name: Keep directive-looking block payload inert
420 ansible.builtin.debug:
421 msg: |
422 failed_when: false
423""",
424 "windows.yml": """steps:
425 - shell: pwsh
426 run: |
427 if (($value -eq 1) -and ($other -eq 2)) {
428 Write-Output "PowerShell is not parsed as malformed Bash"
429 }
430""",
431 "policy.md": """A prose NOLINT mention is not a directive.
432<!-- AI-OK: fixture policy quotation -->
433<!-- MAGIC-OK -->
434<!--
435AI-OK: multiline fixture policy quotation
436-->
437<!-- FUTURE-OK: uncataloged policy marker -->
438```html
439<!-- AI-OK: fenced example only -->
440```
441`<!-- AI-OK: inline example only -->`
442<!-- unterminated fixture marker
443""",
444 "malformed.py": """value = 1 # noqa: F401 E402
445# pragma: no cover because fixture
446# pylint: disable
447# mypy: disable-error-code
448# pyright: nonsense
449# bandit: skip=
450# fmt: sideways
451# ruff: noqa: E402 F401
452""",
453 "unmatched.c": """// NOLINTEND(readability-magic-numbers)
454// NOLINT(foo,,bar)
455/* GCOVR_EXCL_BR_START -- mismatched branch region */
456/* GCOVR_EXCL_STOP */
457/* LCOV_EXCL_START -- mismatched tool region */
458/* GCOVR_EXCL_STOP */
459// clang-format off sideways
460""",
461 "unterminated.c": "// trailing line splice \\\\\n",
462 "malformed.sh": """#!/usr/bin/env bash
463cat <<
464# shellcheck disable=SC2008 # remains visible after malformed operator
465""",
466 "unterminated.sh": """#!/usr/bin/env bash
467value='unterminated
468""",
469 "port/threadx/vendor.c": "// NOLINT(readability-magic-numbers) -- vendor C\n",
470 "port/threadx/CMakeLists.txt": "# NOLINT(readability-magic-numbers) -- owned glue\n",
471 "libs/ra8_c6link/src/ra8_media_download.pb-c.c": (
472 "// NOLINT(readability-magic-numbers) -- generated fixture\n"
473 ),
474 ".cppcheck-suppressions": """# ----------------------------------------
475# Fixture grouped rules.
476# Justification: paired divider rationale.
477# ----------------------------------------
478unusedFunction:sample.c
479unusedFunction:sample.c
480# Justification: adjacent local rationale A.
481unreadVariable:sample.c
482# Justification: adjacent local rationale B.
483unknownMacro:sample.c
484bogusRule:sample.c
485""",
486 "pyproject.toml": """[tool.ruff]
487extend-exclude = [
488 "generated", # generated fixture output
489]
490
491[tool.ruff.lint]
492ignore = [
493 "COM812", # formatter owns trailing commas
494]
495
496[tool.ruff.lint.per-file-ignores]
497"fixture.py" = ["SLF001"] # third-party fixture internals lack a public seam
498""",
499 "apps/fixture/src/format_controls.c": r"""
500const char *text = "clang-format off; @cond hidden; IWYU pragma: keep";
501// Suppression rationale: fixture columns encode a protocol table reviewed by row.
502// clang-format off
503int columns[] = {1, 2};
504// clang-format on
505/** Suppression rationale: the fixture hides a private implementation-only contract. */
506/** @cond INTERNAL */
507int internal_contract;
508/** @endcond */
509// Suppression rationale: the fixture include provides a required macro side effect.
510#include "fixture_keep.h" // IWYU pragma: keep
511// Suppression rationale: the fixture include intentionally re-exports its API.
512#include "fixture_export_one.h" // IWYU pragma: export
513// Suppression rationale: these fixture includes form one exported facade.
514// IWYU pragma: begin_exports
515#include "fixture_export.h"
516// IWYU pragma: end_exports
517// Suppression rationale: these includes are required by generated registration.
518// IWYU pragma: begin_keep
519#include "fixture_registration.h"
520// IWYU pragma: end_keep
521// Suppression rationale: this fixture is an implementation-only header.
522// IWYU pragma: private
523// Suppression rationale: consumers must include the public fixture facade.
524// IWYU pragma: private, include "fixture_public.h"
525// Suppression rationale: the generated fixture peer is an intentional friend.
526// IWYU pragma: friend "fixture_peer\\.h"
527// Suppression rationale: the platform header is provided transitively.
528// IWYU pragma: no_include <platform_fixture.h>
529// Suppression rationale: the opaque fixture type must stay complete.
530// IWYU pragma: no_forward_declare "struct fixture_type"
531// Suppression rationale: the nonstandard fixture name has this associated header.
532#include "fixture_associated.h" // IWYU pragma: associated
533// Suppression rationale: consumers always require this registration header.
534// IWYU pragma: always_keep
535""",
536 "apps/fixture/src/wrong_controls.c": r"""// Clang-format off
537// clang-format off -- unsupported suffix
538// iwyu pragma: keep
539// IWYU pragma: no_include platform_fixture.h
540// prettier-ignore
541// markdownlint-disable MD013
542""",
543 "apps/fixture/src/clang_colon_control.c": r"""
544// clang-format off: the fixture probes clang-format's supported colon rationale.
545int columns[] = {1, 2};
546// clang-format on
547""",
548 "apps/fixture/src/clang_empty_colon_control.c": r"""// clang-format off:
549int preserved[] = {1, 2};
550// clang-format on:
551int reformatted[] = {1, 2};
552""",
553 "apps/fixture/src/unmatched_controls.c": r"""// clang-format on
554// IWYU pragma: end_keep
555/** @endcond */
556""",
557 "format_controls.yml": """---
558payload: |
559 # yamllint disable-line rule:line-length
560# Suppression rationale: the fixture block intentionally demonstrates two noisy rules.
561# yamllint disable rule:line-length rule:comments
562url: https://example.invalid/an-intentionally-long-fixture-resource-locator
563# yamllint enable rule:comments rule:line-length
564# Suppression rationale: the signed URL cannot be wrapped or carry trailing whitespace edits.
565# yamllint disable-line rule:line-length rule:trailing-spaces
566signed_url: https://example.invalid/an-intentionally-long-fixture-resource-locator
567""",
568 "disable_file.yml": """# yamllint disable-file
569fixture: deliberately broad
570""",
571 "wrong_format_controls.yml": """---
572# YAMLLINT disable-line rule:line-length
573# yamllint disable-line rule:line-length,rule:comments
574# yamllint disable-file
575fixture: malformed controls
576""",
577 "unmatched_format_controls.yml": """---
578# yamllint enable rule:line-length
579fixture: unmatched enable
580""",
581 "Dockerfile": """# Fixture prose mentions hadolint without controlling it.
582FROM scratch
583# hadolint ignore = DL3003 , SC2164 # The fixture combines Docker and shell findings.
584RUN cd /tmp
585""",
586 "Dockerfile.hadolint-active": """FROM scratch
587RUN cd /tmp
588""",
589 "Dockerfile.global": """# Suppression rationale: this generated fixture has no package index.
590# hadolint global ignore = DL3008 , SC1091
591FROM scratch
592""",
593 "Dockerfile.bad": """# Hadolint ignore=DL3008
594# hadolint ignore=DL3008 -- unsupported suffix
595# hadolint ignore=dl3008
596# hadolint ignore=DL3008 ,
597FROM scratch
598""",
599 "format_controls.cmake": """set(text "cmake-lint: disable=R0912")
600# Suppression rationale: the fixture function is a declarative feature matrix.
601# cmake-lint: disable=R0912,R0915 disable=C0103
602# cmake-format: off -- the fixture table is compared byte-for-byte in source form.
603set(matrix one two)
604# cmake-format: on
605# Suppression rationale: the short spelling protects a second literal table.
606# cmf: off
607set(second_matrix three four)
608# cmf: on
609""",
610 "cmake_lint_space.cmake": """# Suppression rationale: whitespace exposes pragma behavior.
611# cmake-lint: \tdisable=R0912\tdisable=C0103
612function(BadName)
613endfunction()
614""",
615 "cmake_lint_tab.cmake": """# Suppression rationale: tabs do not match the prefix.
616# cmake-lint: disable=C0103
617function(BadName)
618endfunction()
619""",
620 "wrong_format_controls.cmake": """# CMake-format: off
621# cmake-format off
622# cmake-lint: enable=R0912
623set(value one)
624""",
625 "unmatched_format_controls.cmake": """
626# Suppression rationale: unmatched fixture proves region validation.
627# cmake-format: off
628set(value one)
629""",
630 "docs/format_controls.md": """`<!-- prettier-ignore -->`
631```html
632<!-- markdownlint-disable MD013 -->
633```
634<!-- Suppression rationale: the fixture table is compared byte-for-byte. -->
635<!-- prettier-ignore -->
636<table><tr><td>fixture</td></tr></table>
637<!-- Suppression rationale: the fixture URL is intentionally indivisible. -->
638<!-- markdownlint-disable MD013 -->
639https://example.invalid/an-intentionally-long-fixture-resource-locator
640<!-- Suppression rationale: this one line contains a generated indivisible token. -->
641<!-- markdownlint-disable-line MD013 -->
642<!-- Suppression rationale: the next generated line contains an indivisible token. -->
643<!-- markdownlint-disable-next-line MD013 -->
644next generated line
645<!-- markdownlint-capture -->
646<!-- Suppression rationale: the captured fixture contains generated HTML. -->
647<!-- markdownlint-disable MD033 -->
648<!-- Suppression rationale: the nested generated URL intentionally remains bare. -->
649<!-- markdownlint-disable MD034 -->
650<span>generated section</span>
651https://example.invalid/generated
652<!-- markdownlint-restore -->
653<!-- markdownlint-enable MD013 -->
654<!-- Suppression rationale: generated front matter controls the whole fixture file. -->
655<!-- markdownlint-disable-file MD041 -->
656<!-- markdownlint-enable-file MD041 -->
657<!-- @cond HTML_COMMENT_INACTIVE -->
658<!-- @endcond -->
659<!--
660@cond MULTILINE_HTML_COMMENT_INACTIVE
661@endcond
662-->
663<!-- Suppression rationale: the docs fixture hides an internal-only section. -->
664@cond MARKDOWN_INTERNAL
665hidden Markdown
666@endcond
667""",
668 "docs/format_controls.dox": r"""
669/** Suppression rationale: the dox fixture hides an internal-only section. */
670\cond DOX_INTERNAL
671hidden dox
672\endcond
673""",
674 "libs/third_party/vendor/include/vendor_docs.h": """/** @cond VENDOR_INTERNAL */
675int vendor_internal;
676/** @endcond */
677""",
678 "docs/wrong_format_controls.md": """<!-- Prettier-ignore -->
679<!-- prettier-ignore -- unsupported suffix -->
680<!-- Markdownlint-disable MD013 -->
681<!-- markdownlint-disable MD013,MD033 -->
682<!-- markdownlint-capture MD013 -->
683<!-- markdownlint-restore MD013 -->
684<!-- markdownlint-configure-file { "MD013": FALSE } -->
685<!-- markdownlint-configure-file { "MD013": 100 } -->
686@COND WRONG_CASE
687""",
688 "docs/unmatched_format_controls.dox": "@endcond\n",
689 "scripts/checks/suppression_selftest.py": """
690# Suppression rationale: Python docs hide an internal helper.
691## @cond PYTHON_INTERNAL
692internal_helper = 1
693## @endcond
694""",
695 "scripts/checks/suppression_scan.py": """# @cond single_hash_is_not_doxygen
696## @COND WRONG_CASE
697""",
698 "generated/ignored.sh": """#!/bin/sh
699if true; then
700 echo ignored
701fi
702""",
703 "generated/mixed-case.sh": """#!/bin/sh
704if true; then
705 echo ignored
706fi
707""",
708 "generated/false.sh": """#!/bin/sh
709if true; then
710 echo formatted
711fi
712""",
713 "generated/unset.sh": """#!/bin/sh
714if true; then
715 echo formatted
716fi
717""",
718 "bad/generated/uppercase-value.sh": """#!/bin/sh
719if true; then
720 echo formatted
721fi
722""",
723 ".prettierrc.json": "{}\n",
724 ".markdownlint.json": "{}\n",
725 ".editorconfig": """root = true
726
727[generated/**]
728# Generated shell fixtures are byte-for-byte protocol inputs.
729ignore = true
730
731[generated/mixed-case.sh]
732# This mixed-case property proves EditorConfig names are case-insensitive.
733IgNoRe = true
734
735[generated/false.sh]
736IGNORE = false
737
738[generated/unset.sh]
739iGnOrE = unset
740""",
741 "bad/.editorconfig": """root = true
742
743[generated/**]
744Ignore = TRUE
745
746[invalid/**]
747Ignore = maybe
748""",
749 ".yamllint.yaml": """---
750extends: default
751rules:
752 # Fixture keys reproduce GitHub Actions' YAML 1.1 `on` requirement.
753 truthy:
754 check-keys: false
755 # The fixture prose checker deliberately owns comment indentation.
756 comments-indentation: false
757""",
758 ".hadolint.yaml": """---
759failure-threshold: style
760ignored:
761 # Fixture packages resolve from a rotating archive without stable versions.
762 - DL3008
763""",
764 ".github/tidy-baseline.txt": """# Fixture burn-down baseline.
765sample.c\treadability-function-size\t1
766sample.c\treadability-function-size\t1
767malformed-row
768""",
769 ".github/cite-baseline.txt": """# Total at this baseline: 1 uncited access
770missing.c\t1
771""",
772 ".github/mcdc-baseline.txt": """0
773""",
774 ".github/rogue-baseline.txt": """unexpected
775""",
776}
777
778FIXTURES = CORE_FIXTURES | TOOL_CONTROL_FIXTURES
779
780
781def fixture_digest(fixtures: dict[str, str]) -> str:
782 """Return the length-framed digest used to authenticate fixture transport."""
783 digest = hashlib.sha256()
784 for rel, body in sorted(fixtures.items()):
785 for data in (rel.encode(), body.encode()):
786 digest.update(len(data).to_bytes(8, "big"))
787 digest.update(data)
788 return digest.hexdigest()