diff --git a/AGENTS.md b/AGENTS.md index fdc96e57..5e069d8d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1015,7 +1015,8 @@ variants; and `std::exit` sets the status without ending node, so that a later write replaces it, and anything pending keeps node running. Under the pre-js, a program ends with these statuses (measured with Emscripten 6.0.11 and node 26.7.0, the same source built without a variant, with `-sJSPI` and -with `-sASYNCIFY`): +with `-sASYNCIFY`; the two rows of work still pending after the status with +node 26.13.0, since node ends on its own): | `main` | without suspension | JSPI | Asyncify | | --- | --- | --- | --- | @@ -1026,8 +1027,8 @@ with `-sASYNCIFY`): | suspends, `std::exit(7)` unmarked | (aborts) | 7 | 7 | | suspends, `std::exit(0)` unmarked | (aborts) | 0 | **1**, with the line below | | awaits a promise that nothing settles | (aborts) | **1** at once, with the line below | **1** at once, with the line below | -| suspends, `exit_status(3)`; later a callback gives `exit_status(0)` and a timer sets `process.exitCode = 0` | (aborts) | 3 at once | 3 at once | -| suspends, `exit_status(0)` while a timer of 300 s is pending | (aborts) | 0 at once | 0 at once | +| suspends, `exit_status(3)`; later a callback gives `exit_status(0)` and a timer sets `process.exitCode = 0` (both after 50 ms) | (aborts) | 3, once the pending 50 ms timers have run | 3, once the pending 50 ms timers have run | +| suspends, `exit_status(0)` while a timer of 300 s is pending | (aborts) | 0 after 10 s | 0 after 10 s | | sleeps 600 s after `bound(3s)` | (aborts) | 1 after 3 s | 1 after 3 s | | never called (`-sINVOKE_RUN=0`), returns 0 | **1**, with the line below | **1**, with the line below | **1**, with the line below | | `bound(0s)`, or a bound past 2147483 s | (aborts) | **1** at once, naming it | **1** at once, naming it | @@ -1041,10 +1042,23 @@ is a failure already. It reads `main` as finished only when the glue called it (it wraps the glue's `callMain`), so that a program linked with `-sINVOKE_RUN=0`, whose `main` nothing calls, fails too. `webcpp::test::exit_status` gives its status to the pre-js, which ends node -with the first status it is given on node's next turn, whatever is still -pending or runs later, and restores it over any later write of -`process.exitCode`. It never calls `std::exit`, which in a debug build prints -Emscripten's notice that the runtime is kept alive. A test is also bounded: past 120 s, the +with the first status it is given, whatever runs later, and restores it over +any later write of `process.exitCode`. Node ends on its own as soon as +nothing holds it, and through `process.exit` only if something still holds it +(a pending timer, a live worker) 10 s after the status. That is a workaround +for node issue #64274: in node 26.13.0 `process.exit` can deadlock, when a +background compile waits for a GC that the exiting main thread never runs +(hash's `async_heavy` hung 5 times in 300 runs, 10 at a time), and a natural +exit cannot. Under 10 to 36 runs at once on 18 cores, `async_heavy` ended on +its own 0.2 ms to 5.4 s after its status, hence the 10 s. Two paths still +end through `process.exit` and can meet the same deadlock: the 10 s fallback +itself, for a test that holds node past its grace, and the bound below, for a +test that runs past it; such a test can then hang until the CI job's timeout +instead of failing at its bound. Both are rare and outside a test's normal +end. Once the pinned node is a release with node PR #66171, which fixes it, +the pre-js calls `process.exit` on node's next turn again, and both paths are +safe again. It never calls `std::exit`, which +in a debug build prints Emscripten's notice that the runtime is kept alive. A test is also bounded: past 120 s, the pre-js stops it with 1 and the line `webcpp: the test ran past its bound of s`. 120 s is longer than any emscripten test of webcpp, and short enough that a test that waits forever fails inside the CI job instead of running to diff --git a/libs/hash b/libs/hash index 030e7572..569b51bc 160000 --- a/libs/hash +++ b/libs/hash @@ -1 +1 @@ -Subproject commit 030e7572e7f89120639fe807c717ae91353d87e1 +Subproject commit 569b51bc5d160a1d6dc290229b4fcde323b053ea diff --git a/tools/hash/doc_tables.py b/tools/hash/doc_tables.py index c41618aa..969c9ec6 100644 --- a/tools/hash/doc_tables.py +++ b/tools/hash/doc_tables.py @@ -17,7 +17,9 @@ security and where the world uses it, each with a source, and the rows of "Choose by use case"), and, when it is there, measurements.json (each program's size per target and its throughput, a reference measured once, on 2026-11-16, that decides nothing: the default backend is fixed, spec -4.1). It writes, in doc/: +4.1). A function row is keyed by its name and its form: a row with "form" (HKDF's "pieces") is +another form of the function its name names, rendered as "`hkdf_extract` over pieces", and shares +that function's facts of guide.json. It writes, in doc/: - generated/compare-.adoc: the comparison that opens each chapter, two tables with a row per public name: what it is (output, security, standard, status, the browser's @@ -43,9 +45,11 @@ `python3 tools/hash/doc_tables.py --write`, when one differs from what is committed, is missing, or is left over; the doc build runs it (doc/Jamfile). It also fails when guide.json lacks a public name of the capability table, names one it does not have, or a use case names -an example that example/ does not hold; when a function of the capability table names a -default that is not among its backends or outside the order hash2, xkcp, blake3, sodium -(design D33), or none (null) though a backend of that order has it; when a family's tag (kind +an example that example/ does not hold; when a row's form is not "pieces", is on a row whose +function the table does not have without a form, or two rows share a name and a form; when a +function of the capability table names a default that is not among its backends or outside the +order hash2, xkcp, blake3, sodium (design D33), or none (null) though a backend of that order has +it; when a family's tag (kind digest, mac or kdf) names a default outside that order (design D34; null for a tag with none) or one without its cell; when any default is a backend that only the asynchronous family takes, a type has a default, or a row has an unknown kind; when a tag of digests or macs sits outside @@ -64,7 +68,7 @@ import re import sys from pathlib import Path -from typing import Any +from typing import Any, Optional ROOT = Path(__file__).resolve().parents[2] WRITE = 'python3 tools/hash/doc_tables.py --write' @@ -147,6 +151,31 @@ def link(text: str, url: str) -> str: return f'link:{url}[{text.replace("]", "]")}]' +# The forms a function row may have besides its own: HKDF's overloads over byte_pieces. +FORMS = ('pieces',) + +# A function row's key: its name and its form (None for the function's own row). +Key = tuple[str, Optional[str]] + + +def row_key(function: dict) -> Key: + return function['name'], function.get('form') + + +def label(function: dict) -> str: + """A row as prose names it without markup: `hkdf_extract`, or `hkdf_extract over pieces`.""" + name, form = row_key(function) + return name if form is None else f'{name} over {form}' + + +def shown(function: dict, called: str | None = None) -> str: + """A row as the guide names it in code: `` `hkdf_extract` ``, or `` `hkdf_extract` over + pieces ``; `called` replaces the name inside the backticks (a tag through its family).""" + name, form = row_key(function) + text = f'`{called or name}`' + return text if form is None else f'{text} over {form}' + + class Data: """The capability table, the guide's facts and the measurements, joined.""" @@ -158,18 +187,49 @@ def __init__(self, library: Path) -> None: measured = doc / 'measurements.json' self.measurements = load(measured) if measured.is_file() else None self.backends = {b['name']: b for b in self.capabilities['backends']} - self.functions: dict[str, tuple[dict, dict]] = {} + self.functions: dict[Key, tuple[dict, dict]] = {} + repeated = [] for algorithm in self.capabilities['algorithms']: for function in algorithm['functions']: - self.functions[function['name']] = (algorithm, function) + if row_key(function) in self.functions: + repeated.append(f'doc/capabilities.json has two rows {label(function)}') + self.functions[row_key(function)] = (algorithm, function) + if repeated: + raise Failure('\n'.join(repeated)) + self.names = {name for name, _ in self.functions} + self.check_forms() self.check_guide() self.check_defaults() self.check_chapters() self.check_digest() # The template argument each function's and each tag's call names its backend as. - self.arguments = {name: self.backend_argument(function) - for name, (_, function) in self.functions.items() + self.arguments = {key: self.backend_argument(function) + for key, (_, function) in self.functions.items() if function['kind'] == 'function' or function['kind'] in FAMILY_KINDS} + # The parameters a form's overload takes as byte_pieces, read from its header. + self.form_parameters = {key: self.pieces_parameters(function) + for key, (_, function) in self.functions.items() + if 'form' in function} + + def pieces_parameters(self, function: dict) -> list[str]: + """The names of the byte_pieces parameters of the function's overload over pieces, as + input_key_material, read from the declarations in its header.""" + path = self.library / 'include' / function['header'] + try: + text = path.read_text(encoding='utf-8') + except OSError as error: + raise Failure(f'{path}: {error}') from error + code = re.sub(r'//[^\n]*|/\*.*?\*/', ' ', text, flags=re.DOTALL) + found: list[str] = [] + for match in re.finditer(rf'(? str: """The words "as its template argument", where a call names the backend, @@ -190,12 +250,12 @@ def backend_argument(self, function: dict) -> str: if re.match(r'(?:class|typename)\s+Backend\b', parameter)} if not places: raise Failure(f'{header} declares no template {name} with a Backend parameter ' - f'(doc/capabilities.json, {function["name"]})') + f'(doc/capabilities.json, {label(function)})') found |= places indices = {i for i, _ in found} if len(indices) != 1: raise Failure(f'{header}: {listed(list(names))} take the Backend at different ' - f'positions (doc/capabilities.json, {function["name"]})') + f'positions (doc/capabilities.json, {label(function)})') (index,) = indices position = 'only' if all(count == 1 for _, count in found) else ORDINALS[index] return f'as its {position} template argument' @@ -208,7 +268,8 @@ def check_defaults(self) -> None: or none (null): every default has its engine (ruling R84); no default is a backend only the asynchronous family takes (design D35); a type has none.""" faults = [] - for name, (_, function) in self.functions.items(): + for _, function in self.functions.values(): + name = label(function) default = function.get('default') kind = function['kind'] ordered = [b for b in FAMILY_DEFAULTS if b in function['backends']] @@ -244,7 +305,7 @@ def check_chapters(self) -> None: """A tag of digests sits in the digests chapter, a tag of macs in the macs chapter, so that each chapter's table and llms.txt's section list every tag of its namespace.""" faults = [] - for name, (algorithm, _) in self.functions.items(): + for (name, _), (algorithm, _) in self.functions.items(): for prefix, chapter in NAMESPACE_CHAPTERS.items(): if name.startswith(prefix) and algorithm['chapter'] != chapter: faults.append(f'doc/capabilities.json: the tag {name} is in the chapter ' @@ -264,10 +325,24 @@ def check_digest(self) -> None: 'was edited by hand; the reference measured on 2026-11-16 is kept as ' 'measured') + def check_forms(self) -> None: + """A row's form is one of FORMS, on a function the table also has without a form.""" + faults = [] + for (name, form), _ in self.functions.items(): + if form is None: + continue + if form not in FORMS: + faults.append(f'doc/capabilities.json: {name} has the unknown form {form}') + elif (name, None) not in self.functions: + faults.append(f'doc/capabilities.json: {name} over {form} is a form of no row ' + f'{name}') + if faults: + raise Failure('\n'.join(faults)) + def check_guide(self) -> None: facts = self.guide['functions'] - missing = [name for name in self.functions if name not in facts] - extra = [name for name in facts if name not in self.functions] + missing = [name for name in sorted(self.names) if name not in facts] + extra = [name for name in facts if name not in self.names] faults = [f'doc/guide.json has no entry for {name}, a function of ' f'doc/capabilities.json' for name in missing] faults += [f'doc/guide.json describes {name}, which doc/capabilities.json does not ' @@ -277,7 +352,7 @@ def check_guide(self) -> None: faults += [f'doc/guide.json has no chapter {c} of doc/capabilities.json' for c in sorted(chapters - set(chapter_names))] for case in self.guide['use_cases']: - if case['function'] not in self.functions: + if (case['function'], None) not in self.functions: faults.append(f'doc/guide.json: the use case "{case["need"]}" names ' f'{case["function"]}, which doc/capabilities.json does not have') if not (self.library / 'example' / case['example']).is_file(): @@ -346,6 +421,8 @@ def compare_table(data: Data, chapter: dict) -> str: if algorithm['chapter'] != key: continue for function in algorithm['functions']: + if 'form' in function: + continue # one row per public name: its forms share its facts name = function['name'] facts = data.guide['functions'][name] uses = '; '.join(link(cell(u['text']), u['source']) for u in facts['uses']) @@ -495,10 +572,10 @@ def hmacs_text(hmacs: list[str] | None) -> str: def backends_table(data: Data, algorithm: dict) -> str: out = [generated_header('doc/capabilities.json'), ''] out.append(f'[#hash-backends-of-{algorithm["name"].replace("_", "-")}]') - names = [f['name'] for f in algorithm['functions']] - shown = ', '.join(f'`{n}`' for n in names) if len(names) <= 3 else \ + names = list(dict.fromkeys(f['name'] for f in algorithm['functions'])) + title = ', '.join(f'`{n}`' for n in names) if len(names) <= 3 else \ f'`{names[0]}` to `{names[-1]}`, {len(names)} names' - out.append(f'.Who implements {shown} ({algorithm["standard"]})') + out.append(f'.Who implements {title} ({algorithm["standard"]})') out.append('[cols="2,1,2,2,3,1",options="header"]') out.append('|===') out.append('| Function | Backend | The program\'s Jamfile names | Targets | Hmacs ' @@ -506,7 +583,7 @@ def backends_table(data: Data, algorithm: dict) -> str: for function in algorithm['functions']: for backend, held in function['backends'].items(): out.append('') - out.append(f'| `{function["name"]}`') + out.append(f'| {shown(function)}') out.append(f'| {backend_text(data, backend, held)}') out.append(f'| `{data.backends[backend]["jamfile"]}`') out.append(f'| {backend_targets(data, backend)}') @@ -525,15 +602,15 @@ def backends_table(data: Data, algorithm: dict) -> str: for backend in sorted(sources): out.extend(source_bullets(f'`{backend}`:', [cell(s) for s in sorted(sources[backend])])) out.append('') - defaults = [(f['name'], f['default']) for f in algorithm['functions'] if f['default']] + defaults = [(row_key(f), f['default']) for f in algorithm['functions'] if f['default']] # A family's tag, and a function without a default (design D34), each say how its default # stands. families = [f for f in algorithm['functions'] if f['kind'] in FAMILY_KINDS or (f['kind'] == 'function' and f['default'] is None)] for function in families: if function['default'] is None: - out.append(f'`{function["name"]}` has no default backend: the call names one of its ' - f'backends, {data.arguments[function["name"]]} ' + out.append(f'{shown(function)} has no default backend: the call names one of its ' + f'backends, {data.arguments[row_key(function)]} ' '(<>).') out.append('') if not defaults: @@ -547,15 +624,15 @@ def backends_table(data: Data, algorithm: dict) -> str: # One sentence per default and set of other backends, so that each names, as the backends a # call may name instead, those of its own functions alone. by_backend: dict[tuple[str, tuple[str, ...], str], list[str]] = {} - for name, default in defaults: + for key, default in defaults: # The backends a call may name instead: those of this function, not of the algorithm's # others, and never one only the asynchronous family takes. - others = tuple(sorted(b for b in set(data.functions[name][1]['backends']) - {default} + function = data.functions[key][1] + others = tuple(sorted(b for b in set(function['backends']) - {default} if not asynchronous_only(data, b))) - by_backend.setdefault((default, others, data.arguments[name]), []).append(name) + by_backend.setdefault((default, others, data.arguments[key]), []).append(shown(function)) used = {b for f in algorithm['functions'] for b in f['backends']} - for (default, others, argument), functions in by_backend.items(): - names = [f'`{name}`' for name in functions] + for (default, others, argument), names in by_backend.items(): named = names[0] if len(names) == 1 else \ ', '.join(names[:-1]) + f' and {names[-1]}' tail = (f'; {", ".join(f"`{b}`" for b in others)} only where the call names it, ' @@ -579,7 +656,7 @@ def choose_table(data: Data) -> str: out.append('| I need to ... | Use | Its backends: the Jamfile names | Backend ' '| Example') for case in data.guide['use_cases']: - _, function = data.functions[case['function']] + _, function = data.functions[(case['function'], None)] jamfiles = ', '.join(f'`{b}`{backend_note(data, b)}: `{data.backends[b]["jamfile"]}`' for b in function['backends']) out.append('') @@ -626,7 +703,7 @@ def function_defaults(data: Data) -> str: never one only the asynchronous family takes) and per template argument the call names it as (the header's), and one for the functions without a default.""" clauses: dict[tuple[str | None, str, str], list[str]] = {} - for name, (_, function) in data.functions.items(): + for key, (_, function) in data.functions.items(): if function['kind'] != 'function': continue default = function['default'] @@ -641,8 +718,8 @@ def function_defaults(data: Data) -> str: instead = f'backends::{others[0]}' else: instead = 'another of its backends' - clauses.setdefault((default, instead, data.arguments[name] if instead else ''), - []).append(name) + clauses.setdefault((default, instead, data.arguments[key] if instead else ''), + []).append(label(function)) sentences = [] for (default, instead, argument), names in clauses.items(): many = len(names) > 1 @@ -700,6 +777,15 @@ def llms_txt(data: Data) -> str: f'{backend_targets(data, b)})' for b in function['backends']) standard = facts.get('standard', algorithm['standard']) + if 'form' in function: + # A form shares its function's facts: say only what differs. + pieces = listed(data.form_parameters[row_key(function)]) + lines.append(f'- webcpp::hash::{label(function)} ' + f'(<{function["header"]}>, {standard}): ' + f'{function["name"]} with its {pieces} as byte_pieces, read ' + 'one after another as if concatenated, with no cap. ' + f'Backends: {backends}. [Section]({page}#{facts["anchor"]})') + continue lines.append(f'- webcpp::hash::{function["name"]} ' f'(<{function["header"]}>, {standard}): ' f'{facts["summary"]} Status: {facts["status"]}. ' @@ -725,8 +811,9 @@ def llms_txt(data: Data) -> str: def keyed_rows(data: Data) -> tuple[dict[str, list[str]], list[str]]: - """The rows that set DIT, by chapter, each as a call names it (a tag through its family), and - the types of the keyed chapters that do not (the aliases), in the table's order.""" + """The rows that set DIT, by chapter, each as a call names it (a tag through its family), in + code (`` `mac` ``, `` `hkdf` over pieces ``), and the names of the types of the + keyed chapters that do not (the aliases), in the table's order.""" keyed: dict[str, list[str]] = {} aliases: list[str] = [] for algorithm in data.capabilities['algorithms']: @@ -737,9 +824,9 @@ def keyed_rows(data: Data) -> tuple[dict[str, list[str]], list[str]]: aliases.append(function['name']) else: called = CALLED_AS.get(function['kind'], '{}').format(function['name']) - keyed.setdefault(algorithm['chapter'], []).append(called) - if function['name'] in ALSO_KEYED: - keyed[algorithm['chapter']].append(ALSO_KEYED[function['name']]) + keyed.setdefault(algorithm['chapter'], []).append(shown(function, called)) + if function['name'] in ALSO_KEYED and 'form' not in function: + keyed[algorithm['chapter']].append(f'`{ALSO_KEYED[function["name"]]}`') return keyed, aliases @@ -767,8 +854,8 @@ def dit_section(data: Data) -> list[str]: 'it.', '', 'The functions that set DIT, on every synchronous backend of their cells:', ''] for chapter, names in keyed.items(): - lines.append(f'* {KEYED_CHAPTERS[chapter]}: {listed([f"`{name}`" for name in names])}.') - calls = [text for row, text in KEYED_CALLS if row in data.functions] + lines.append(f'* {KEYED_CHAPTERS[chapter]}: {listed(names)}.') + calls = [text for row, text in KEYED_CALLS if row in data.names] if calls: lines.append('* Keyed by their arguments: ' + '; '.join(calls) + '. Called without a ' 'key, they hold a disengaged guard, which reads its flag and does nothing ' @@ -851,7 +938,7 @@ def backends_chapter(data: Data) -> str: continue hmacs = ', '.join(c['hmacs']) if c['hmacs'] else '-' targets = ', '.join(data.backends[name]['targets']) - lines += ['', f'| {function["name"]}', + lines += ['', f'| {label(function)}', f'| {name}{backend_note(data, name)}{partial_text(c)}', f'| {hmacs}', f'| {c["constant_time"]["value"]}', f'| {targets}'] @@ -863,9 +950,9 @@ def backends_chapter(data: Data) -> str: '[cols="2,1",options="header"]', '|===', '| Function | Default'] for _, function in data.functions.values(): if function['default'] is not None: - lines += ['', f'| {function["name"]}', f'| {function["default"]}'] + lines += ['', f'| {label(function)}', f'| {function["default"]}'] elif function['kind'] in FAMILY_KINDS: - lines += ['', f'| {function["name"]}', '| none: the call names its backend'] + lines += ['', f'| {label(function)}', '| none: the call names its backend'] lines += ['|===', '', '=== Constant time', '', 'What each backend\'s upstream states, and where:', ''] # One bullet per backend and value, in the capability table's order of backends, with each @@ -891,7 +978,7 @@ def measured_time(ns: float) -> str: def measured_speed(data: Data, operation: str, t: dict) -> str: - algorithm, _ = data.functions[operation] + algorithm, _ = data.functions[(operation, None)] if algorithm['chapter'] in RATE_CHAPTERS: def per_second(ns: float) -> str: return f'{1e9 / ns:.0f}' diff --git a/tools/node-test/include/webcpp/test/exit_status.hpp b/tools/node-test/include/webcpp/test/exit_status.hpp index 2b6a5f45..58517201 100644 --- a/tools/node-test/include/webcpp/test/exit_status.hpp +++ b/tools/node-test/include/webcpp/test/exit_status.hpp @@ -21,7 +21,8 @@ namespace webcpp::test { /** Gives status to webcpp's test support and returns it, so that main ends with it: natively the status is main's; on emscripten the support ends node with the first status it is given, - on its next turn, whatever is still pending or runs later. + whatever runs later: as soon as nothing holds node, or 10 s later if something still does (a + pending timer, a live worker). Tip: it never calls std::exit, which under Emscripten's default EXIT_RUNTIME=0 neither ends node nor keeps the status from a later write, and in a debug build prints Emscripten's notice diff --git a/tools/node-test/node-pre.js b/tools/node-test/node-pre.js index abba0cb9..eb148bfa 100644 --- a/tools/node-test/node-pre.js +++ b/tools/node-test/node-pre.js @@ -23,6 +23,7 @@ if (typeof process === 'object' && typeof process.on === 'function') { if (watchdog) { clearTimeout(watchdog) } + // process.exit here can meet node #64274's deadlock: see the grace below. watchdog = setTimeout(() => { process.stderr.write(`webcpp: the test ran past its bound of ${seconds} s\n`) process.exit(1) @@ -31,13 +32,30 @@ if (typeof process === 'object' && typeof process.on === 'function') { } bound(120) Module['webcppTestBound'] = bound - // Node ends with the first status on its next turn, whatever is still pending or runs - // later: a timer, a callback that gives another status, a write of process.exitCode. + // Node ends with the first status, whatever runs later: a callback that gives another + // status, a write of process.exitCode. It ends on its own as soon as nothing holds it, as + // Emscripten's own glue ends under node, and through process.exit only if something + // still holds it (a pending timer, a live worker) after the grace below. + // Workaround for node issue #64274: in node 26.13.0, process.exit can deadlock when a + // background compile of the main isolate waits for a GC that the exiting main thread never + // runs (seen in hash's async_heavy, 5 hangs in 300 runs); a natural exit disposes the + // isolate first and cannot. Remove the grace and call process.exit(status) on the next + // turn again once the pinned node is a release with node PR #66171 (commit 77fdeb6fa0). + // The grace is 10 s: async_heavy, under 10 to 36 runs at once on 18 cores, ended on its + // own 0.2 ms to 5.4 s after its status (median 0.3 to 1.6 s), and a fallback that fires + // before the workers wind down meets the deadlock. + // Two paths still call process.exit and can meet the same deadlock: this fallback, for a + // test that holds node past the grace, and the bound above, for a test that runs past it. + // Such a test can then hang until the CI job's timeout instead of failing at its bound; + // both are rare and outside a test's normal end, and safe again under the same condition + // (a pinned node with PR #66171). + const grace = 10000 Module['webcppTestFinished'] = given => { finished = true if (status === null) { status = given - setImmediate(() => process.exit(status)) + process.exitCode = status + setTimeout(() => process.exit(status), grace).unref() } } // Whether main was called: postRun runs all the same in a program whose glue never calls diff --git a/tools/test/emscripten_test.py b/tools/test/emscripten_test.py index 1f3989d1..6bf3508b 100644 --- a/tools/test/emscripten_test.py +++ b/tools/test/emscripten_test.py @@ -20,14 +20,15 @@ needs, asyncify in a directory of its own, and natively adds nothing. Every program node runs links the test support (/webcpp//node-test), whose fixture library node_test_demo pins each case's exact status: a main that did not finish fails, the first status given through webcpp::test::exit_status -ends the test at once and is kept, and a test past its bound is stopped; a program node runs that -links -sMODULARIZE or -sEXPORT_ES6, which node would load without running, is refused. A program a -page loads (webcpp.variants) is named Boost's way in each variant, debug and release, with its -manifest beside its jspi artifact and its size table (webcpp.size-table), and none of them is built -natively; a build of them that asks for JavaScript exceptions, which their jspi variant would keep, -is refused. Each case builds a scratch superproject with browser_demo and node_test_demo, whose -path holds a space, and the emsdk linked into its .local; Emscripten's cache is the one the harness -gives every b2. Run with the names of some cases to run only those.""" +ends the test and is kept, as node ends on its own or, with a timer still pending, 10 s later, and +a test past its bound is stopped; a program node runs that links -sMODULARIZE or -sEXPORT_ES6, +which node would load without running, is refused. A program a page loads (webcpp.variants) is +named Boost's way in each variant, debug and release, with its manifest beside its jspi artifact +and its size table (webcpp.size-table), and none of them is built natively; a build of them that +asks for JavaScript exceptions, which their jspi variant would keep, is refused. Each case builds a +scratch superproject with browser_demo and node_test_demo, whose path holds a space, and the emsdk +linked into its .local; Emscripten's cache is the one the harness gives every b2. Run with the +names of some cases to run only those.""" from __future__ import annotations @@ -334,7 +335,8 @@ def test_a_test_ends_as_its_main_ends(root): 'returns_zero_after_suspension_jspi', 'never_resumes_jspi', 'never_resumes_asyncify', 'keeps_the_first_status_jspi', 'keeps_the_first_status_asyncify', 'ends_with_a_timer_pending_jspi', 'ends_with_a_timer_pending_asyncify', - 'exits_unmarked_jspi', 'exits_unmarked_asyncify', 'main_never_called', 'bound_zero', + 'ends_on_its_own_jspi', 'ends_on_its_own_asyncify', 'exits_unmarked_jspi', + 'exits_unmarked_asyncify', 'main_never_called', 'bound_zero', 'bound_too_long'}, result.stdout[-4000:] assert exit_status(root, 'returns_one_after_suspension_jspi')[0] == 1 # Under JSPI a main that returns 0 after a suspension finished: the pre-js reads its end @@ -352,14 +354,19 @@ def test_a_test_ends_as_its_main_ends(root): assert 'past its bound' not in text, (name, text) assert exit_status(root, 'exit_in_coroutine_asyncify')[0] == 3 assert exit_status(root, 'exit_in_handler_jspi')[0] == 3 - # The first status exit_status gives ends the test at once: neither a later exit_status(0) - # nor a later write of process.exitCode = 0 replaces it, and a pending timer does not hold - # it to its bound. + # The first status exit_status gives ends the test: neither a later exit_status(0) nor a + # later write of process.exitCode = 0 replaces it, and a pending timer does not hold it to + # its bound, only to the pre-js's grace of 10 s. for name in ('keeps_the_first_status_jspi', 'keeps_the_first_status_asyncify'): assert exit_status(root, name)[0] == 3, name for name in ('ends_with_a_timer_pending_jspi', 'ends_with_a_timer_pending_asyncify'): status, text = exit_status(root, name) assert status == 0 and 'past its bound' not in text, (name, text) + # A test that gives its status with nothing pending ends as node ends on its own, never + # through process.exit, which can hang in node 26.13.0 (node issue #64274). + for name in ('ends_on_its_own_jspi', 'ends_on_its_own_asyncify'): + status, text = exit_status(root, name) + assert status == 0 and 'node ended on its own' in text, (name, text) # An unmarked std::exit after a suspension: JSPI keeps its status, Asyncify fails it. assert exit_status(root, 'exits_unmarked_jspi')[0] == 0 status, text = exit_status(root, 'exits_unmarked_asyncify') diff --git a/tools/test/fixtures/hash_jamfiles/argon2_no_default/app.cpp b/tools/test/fixtures/hash_jamfiles/argon2_no_default/app.cpp index 92ee9298..8feac127 100644 --- a/tools/test/fixtures/hash_jamfiles/argon2_no_default/app.cpp +++ b/tools/test/fixtures/hash_jamfiles/argon2_no_default/app.cpp @@ -15,6 +15,6 @@ int main() { std::array output{}; std::array salt{}; auto done = webcpp::hash::argon2( - output, {}, salt, {.passes = 3, .memory_kib = 65536}); + output, {}, salt, {.passes = 3, .memory_kibibytes = 65536}); return done ? 0 : 1; } diff --git a/tools/test/fixtures/hash_jamfiles/argon2_not_a_variant/app.cpp b/tools/test/fixtures/hash_jamfiles/argon2_not_a_variant/app.cpp index 72577917..2349760a 100644 --- a/tools/test/fixtures/hash_jamfiles/argon2_not_a_variant/app.cpp +++ b/tools/test/fixtures/hash_jamfiles/argon2_not_a_variant/app.cpp @@ -14,6 +14,7 @@ int main() { std::array output{}; std::array salt{}; - auto done = webcpp::hash::argon2(output, {}, salt, {.passes = 3, .memory_kib = 65536}); + auto done = + webcpp::hash::argon2(output, {}, salt, {.passes = 3, .memory_kibibytes = 65536}); return done ? 0 : 1; } diff --git a/tools/test/fixtures/hash_jamfiles/argon2d_on_sodium/app.cpp b/tools/test/fixtures/hash_jamfiles/argon2d_on_sodium/app.cpp index 5f6baf71..b7f923bf 100644 --- a/tools/test/fixtures/hash_jamfiles/argon2d_on_sodium/app.cpp +++ b/tools/test/fixtures/hash_jamfiles/argon2d_on_sodium/app.cpp @@ -16,6 +16,6 @@ int main() { std::array output{}; std::array salt{}; auto done = webcpp::hash::argon2( - output, {}, salt, {.passes = 3, .memory_kib = 65536}); + output, {}, salt, {.passes = 3, .memory_kibibytes = 65536}); return done ? 0 : 1; } diff --git a/tools/test/fixtures/hash_jamfiles/async_argon2_without_threads/app.cpp b/tools/test/fixtures/hash_jamfiles/async_argon2_without_threads/app.cpp index 8d01fd13..60a4402c 100644 --- a/tools/test/fixtures/hash_jamfiles/async_argon2_without_threads/app.cpp +++ b/tools/test/fixtures/hash_jamfiles/async_argon2_without_threads/app.cpp @@ -24,7 +24,7 @@ int main() { std::array const salt{}; webcpp::hash::async_argon2( context.get_executor(), output, {}, salt, - webcpp::hash::argon2_parameters{.passes = 3, .memory_kib = 65536}, + webcpp::hash::argon2_parameters{.passes = 3, .memory_kibibytes = 65536}, [](boost::system::error_code /*code*/) {}); return 0; } diff --git a/tools/test/fixtures/hash_jamfiles/async_hkdf_not_in_webcrypto/app.cpp b/tools/test/fixtures/hash_jamfiles/async_hkdf_not_in_webcrypto/app.cpp index e4d5e78f..262babb0 100644 --- a/tools/test/fixtures/hash_jamfiles/async_hkdf_not_in_webcrypto/app.cpp +++ b/tools/test/fixtures/hash_jamfiles/async_hkdf_not_in_webcrypto/app.cpp @@ -20,7 +20,9 @@ int main() { webcpp::asio::io_context context; std::array output{}; + std::array input{}; webcpp::hash::async_hkdf( - context.get_executor(), output, {}, {}, {}, [](boost::system::error_code /*code*/) {}); + context.get_executor(), output, input, input, input, + [](boost::system::error_code /*code*/) {}); return 0; } diff --git a/tools/test/fixtures/hash_jamfiles/async_scrypt_without_threads/app.cpp b/tools/test/fixtures/hash_jamfiles/async_scrypt_without_threads/app.cpp index a4019f87..de7fe9c0 100644 --- a/tools/test/fixtures/hash_jamfiles/async_scrypt_without_threads/app.cpp +++ b/tools/test/fixtures/hash_jamfiles/async_scrypt_without_threads/app.cpp @@ -21,8 +21,9 @@ int main() { webcpp::asio::io_context context; std::array output{}; - webcpp::hash::async_scrypt(context.get_executor(), output, {}, {}, - webcpp::hash::scrypt_parameters{.n = 16, .r = 1, .p = 1}, - [](boost::system::error_code /*code*/) {}); + webcpp::hash::async_scrypt( + context.get_executor(), output, {}, {}, + webcpp::hash::scrypt_parameters{.cost = 16, .block_size = 1, .parallelism = 1}, + [](boost::system::error_code /*code*/) {}); return 0; } diff --git a/tools/test/fixtures/hash_jamfiles/extract_on_bearssl/Jamfile b/tools/test/fixtures/hash_jamfiles/extract_on_bearssl/Jamfile new file mode 100644 index 00000000..753caad5 --- /dev/null +++ b/tools/test/fixtures/hash_jamfiles/extract_on_bearssl/Jamfile @@ -0,0 +1,9 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# test/messages/extract_on_bearssl of webcpp::hash, built for Emscripten +# by a user's Jamfile. +exe app : app.cpp /webcpp/hash//hash /third_party//bearssl ; diff --git a/tools/test/fixtures/hash_jamfiles/extract_on_bearssl/app.cpp b/tools/test/fixtures/hash_jamfiles/extract_on_bearssl/app.cpp new file mode 100644 index 00000000..21a717f1 --- /dev/null +++ b/tools/test/fixtures/hash_jamfiles/extract_on_bearssl/app.cpp @@ -0,0 +1,28 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// The single-buffer hkdf_extract on backends::bearssl, whose br_hkdf_* keeps the PRK inside its +// context, stops with spec section 3.3's text, and with no other error, while hkdf_extract over +// pieces on BearSSL compiles (the change hkdf-pieces, scenario "BearSSL's Extract over pieces"). + +#include +#include +#include + +#include +#include + +int main() { + std::array salt{}; + std::array ikm{}; + auto pieces = + webcpp::hash::hkdf_extract( + salt, {ikm, ikm}); + auto single = + webcpp::hash::hkdf_extract( + salt, ikm); + return pieces && single ? 0 : 1; +} diff --git a/tools/test/fixtures/hash_jamfiles/extract_on_bearssl/extract_on_bearssl.outcome b/tools/test/fixtures/hash_jamfiles/extract_on_bearssl/extract_on_bearssl.outcome new file mode 100644 index 00000000..59f44ac8 --- /dev/null +++ b/tools/test/fixtures/hash_jamfiles/extract_on_bearssl/extract_on_bearssl.outcome @@ -0,0 +1,13 @@ +# Copyright (c) 2026 WebCpp.org +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# The compiler's line starts with the header's path on the machine, so the +# message is a contains: line. Natively and on WASI the same text is +# test/messages/extract_on_bearssl, a compile-diagnostic. +[all] +targets: emscripten +build: fails +contains: webcpp::hash: hkdf_extract and hkdf_expand are not in backends::bearssl, whose HKDF does both steps together: call hkdf, or name backends::hash2, backends::sodium, backends::openssl or backends::botan. diff --git a/tools/test/fixtures/hash_jamfiles/openssl_kdf_not_linked/app.cpp b/tools/test/fixtures/hash_jamfiles/openssl_kdf_not_linked/app.cpp index 2441146d..9d0383ba 100644 --- a/tools/test/fixtures/hash_jamfiles/openssl_kdf_not_linked/app.cpp +++ b/tools/test/fixtures/hash_jamfiles/openssl_kdf_not_linked/app.cpp @@ -20,7 +20,7 @@ int main() { std::array salt{}; auto const argon2id = hash::argon2id( output, {}, salt, hash::argon2id_parameters{.passes = 2, .memory = 19456 * 1024}); - auto const scrypt = hash::scrypt(output, {}, salt, - hash::scrypt_parameters{1024, 8, 1}); + auto const scrypt = hash::scrypt( + output, {}, salt, hash::scrypt_parameters{.cost = 1024, .block_size = 8, .parallelism = 1}); return argon2id && scrypt ? 0 : 1; } diff --git a/tools/test/fixtures/hash_jamfiles/scrypt_default_not_linked/app.cpp b/tools/test/fixtures/hash_jamfiles/scrypt_default_not_linked/app.cpp index 654f579d..36fcb360 100644 --- a/tools/test/fixtures/hash_jamfiles/scrypt_default_not_linked/app.cpp +++ b/tools/test/fixtures/hash_jamfiles/scrypt_default_not_linked/app.cpp @@ -15,6 +15,8 @@ int main() { std::array output{}; std::array salt{}; - auto done = webcpp::hash::scrypt(output, {}, salt, webcpp::hash::scrypt_parameters{1024, 8, 1}); + auto done = webcpp::hash::scrypt( + output, {}, salt, + webcpp::hash::scrypt_parameters{.cost = 1024, .block_size = 8, .parallelism = 1}); return done ? 0 : 1; } diff --git a/tools/test/fixtures/hash_jamfiles/webcrypto_synchronous/app.cpp b/tools/test/fixtures/hash_jamfiles/webcrypto_synchronous/app.cpp index 3e96fa62..a29550f1 100644 --- a/tools/test/fixtures/hash_jamfiles/webcrypto_synchronous/app.cpp +++ b/tools/test/fixtures/hash_jamfiles/webcrypto_synchronous/app.cpp @@ -15,7 +15,8 @@ int main() { std::array output{}; + std::array input{}; auto done = webcpp::hash::hkdf( - output, {}, {}, {}); + output, input, input, input); return done ? 0 : 1; } diff --git a/tools/test/fixtures/node_test_demo/test/Jamfile b/tools/test/fixtures/node_test_demo/test/Jamfile index c1b3ece5..461e942c 100644 --- a/tools/test/fixtures/node_test_demo/test/Jamfile +++ b/tools/test/fixtures/node_test_demo/test/Jamfile @@ -34,6 +34,8 @@ webcpp.run-fail keeps_the_first_status_jspi : keeps_the_first_status.cpp : $(jsp webcpp.run-fail keeps_the_first_status_asyncify : keeps_the_first_status.cpp : $(asyncify) ; webcpp.run ends_with_a_timer_pending_jspi : ends_with_a_timer_pending.cpp : $(jspi) ; webcpp.run ends_with_a_timer_pending_asyncify : ends_with_a_timer_pending.cpp : $(asyncify) ; +webcpp.run ends_on_its_own_jspi : ends_on_its_own.cpp : $(jspi) ; +webcpp.run ends_on_its_own_asyncify : ends_on_its_own.cpp : $(asyncify) ; webcpp.run exits_unmarked_jspi : exits_unmarked.cpp : $(jspi) ; webcpp.run-fail exits_unmarked_asyncify : exits_unmarked.cpp : $(asyncify) ; # The glue never calls a main linked with -sINVOKE_RUN=0. diff --git a/tools/test/fixtures/node_test_demo/test/ends_on_its_own.cpp b/tools/test/fixtures/node_test_demo/test/ends_on_its_own.cpp new file mode 100644 index 00000000..135166e4 --- /dev/null +++ b/tools/test/fixtures/node_test_demo/test/ends_on_its_own.cpp @@ -0,0 +1,27 @@ +// Copyright (c) 2026 WebCpp.org +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// Ends with 0 through exit_status with nothing pending, and says so when node, its loop empty, +// emits beforeExit, which it never emits on a call of process.exit. + +#include + +#include +#include + +// clang-format off +EM_JS(void, say_when_node_ends_on_its_own, (), { + process.once('beforeExit', () => { + process.stdout.write('node ended on its own\n'); + }); +}); +// clang-format on + +int main() { + say_when_node_ends_on_its_own(); + emscripten_sleep(10); + return webcpp::test::exit_status(0); +} diff --git a/tools/test/hash_allocation_collect_test.py b/tools/test/hash_allocation_collect_test.py index 6897c132..845a9f8a 100755 --- a/tools/test/hash_allocation_collect_test.py +++ b/tools/test/hash_allocation_collect_test.py @@ -9,10 +9,11 @@ into doc/measurements.allocation.json and renders doc/allocation.adoc, builds its table only from release builds: an output of a program whose build directory, b2's bench/.test///..., names another variant (the lanes' test/ directories -included), or does not say, is refused before anything is written; one at variant=release is -taken and the data records the build and the toolset; backends::botan's records give one row per -operation and target; `--render-only` and `--check` refuse data whose build is not -variant=release. Run with the names of some cases to run only those.""" +included), or does not say, is refused before anything is written; one at variant=release is taken +and the data records the build and the toolset; backends::botan's records give one row per operation +and target; a record of HKDF over pieces is named by its function; `--render-only` and `--check` +refuse data whose build is not variant=release. Run with the names of some cases to run only +those.""" from __future__ import annotations @@ -137,6 +138,40 @@ def test_botan_s_records_give_one_row_per_operation(scratch: Path) -> None: expect(run('--check', '--data', data, '--page', page), 0) +PIECES_RECORDS = ( + 'record operation=counter c_counted=1\n' + 'record operation=hkdf_pieces backend=openssl new=0 hmac=hmac_sha2_256 call=1 openssl=9\n' + 'record operation=hkdf_pieces backend=openssl new=0 hmac=hmac_sha2_512 call=1 openssl=6\n' + 'record operation=hkdf_pieces backend=openssl new=0 hmac=hmac_sha2_512 call=2 openssl=3\n' + 'record operation=hkdf_extract_pieces tag=hmac_sha2_256 backend=botan target=native call=1 ' + 'new=2 c=4 counted=1\n' + 'record operation=hkdf_extract_pieces tag=hmac_sha2_256 backend=botan target=native call=2 ' + 'new=2 c=4 counted=1\n' +) + + +def test_hkdf_over_pieces_is_named_by_its_function(scratch: Path) -> None: + """A record of HKDF over byte pieces, operation=_pieces, becomes the row of "`` + over pieces", OpenSSL's and Botan's alike.""" + base = (scratch / 'bin/libs/hash/bench/allocation_openssl_release.test/clang-darwin-21' + / 'release/cxxstd-20-iso') + base.mkdir(parents=True) + (base / 'allocation_openssl_release.output').write_text(PIECES_RECORDS) + data, page = scratch / 'data.json', scratch / 'page.adoc' + page.write_text(PAGE.read_text()) + expect(run('--lane', f'native={scratch / "bin"}', '--data', data, '--page', page), 0) + table = page.read_text() + for row in ('| `hkdf` over pieces | `openssl` | native | 0 | OpenSSL: 9 first call ' + '(hmac_sha2_256), 6 first call (hmac_sha2_512), 3 steady state', + '| `hkdf_extract` over pieces | `botan` | native | 2 | Botan: 4 C library calls ' + "(operator new's included), of hmac_sha2_256; the same in a steady call"): + if row not in table: + raise AssertionError(f'{row!r} is not in the table:\n{table}') + if '_pieces`' in table: + raise AssertionError(f'a record name was rendered as a function name:\n{table}') + expect(run('--check', '--data', data, '--page', page), 0) + + def test_render_only_and_check_refuse_data_not_built_at_variant_release(scratch: Path) -> None: committed = json.loads(DATA.read_text()) page = scratch / 'page.adoc' @@ -166,6 +201,7 @@ def test_the_committed_data_is_from_release_builds_and_renders_the_page(scratch: test_an_output_not_built_at_variant_release_is_refused, test_an_output_built_at_variant_release_is_collected, test_botan_s_records_give_one_row_per_operation, + test_hkdf_over_pieces_is_named_by_its_function, test_render_only_and_check_refuse_data_not_built_at_variant_release, test_the_committed_data_is_from_release_builds_and_renders_the_page, ] diff --git a/tools/test/hash_doc_tables_test.py b/tools/test/hash_doc_tables_test.py index 46ab5f1f..32ab1df1 100644 --- a/tools/test/hash_doc_tables_test.py +++ b/tools/test/hash_doc_tables_test.py @@ -30,8 +30,12 @@ measurements.adoc; with it (a fixture in its shape) they carry the throughput and the size, and measurements.adoc renders it as the dated reference that decides nothing; a hand edit of the data, which its digest tells, fails. The includes of the measured chapters name only those -present. And `--check` passes on the real library's committed files. Run with the names of some -cases to run only those.""" +present. A row of a form of its function (HKDF's "pieces") is keyed by its name and form, +rendered as "`hkdf_extract` over pieces" in the backends' tables, the DIT section, the defaults and +llms.txt (with the parameters its header declares as byte_pieces), and left out of the +comparison tables, which hold one row per public name; an unknown form, a form of no function +and two rows of one name and form fail. And `--check` passes on the +real library's committed files. Run with the names of some cases to run only those.""" from __future__ import annotations @@ -292,8 +296,9 @@ def test_a_default_without_its_cell_fails_and_a_partial_cell_is_said(scratch: Pa expect('`hash2` (partial: an output under 64 bytes' in blake2, blake2) expect('| hash2 (partial: a tag under 32 bytes' in files['backends.adoc'], 'the backends chapter does not say what the partial cell refuses') - expect('`webcrypto` (asynchronous family only) (partial: an info longer than 1,024 bytes' - in files['generated/backends-hkdf.adoc'], files['generated/backends-hkdf.adoc']) + expect('`webcrypto` (asynchronous family only) (partial: an application_info longer than ' + '1,024 bytes' in files['generated/backends-hkdf.adoc'], + files['generated/backends-hkdf.adoc']) expect('| webcrypto (asynchronous family only) (partial: an iteration count above 2^32 - 1' in files['backends.adoc'], 'webcrypto\'s PBKDF2 limits are not said') @@ -330,6 +335,48 @@ def misplace(table: dict) -> None: done.stderr) +def test_a_form_row_is_keyed_by_its_name_and_form(scratch: Path) -> None: + library = scratch_library(scratch) + files = write_ok(library) + backends = files['generated/backends-hkdf.adoc'] + expect('.Who implements `hkdf_extract`, `hkdf_expand`, `hkdf` (RFC 5869)' in backends, + backends) + expect('| `hkdf_extract` over pieces' in backends, backends) + expect('The default of `hkdf`, `hkdf_extract` over pieces, `hkdf_expand` over pieces and ' + '`hkdf` over pieces: `hash2` on every target' in backends, backends) + compare = files['generated/compare-kdfs.adoc'] + expect('over pieces' not in compare, 'a form has a row of its own in the comparison') + expect(compare.count('`hkdf_extract`') == 2, 'hkdf_extract is not one row of each table') + chapter = files['backends.adoc'] + expect('`hkdf` over pieces, `pbkdf2`' in chapter, 'the DIT section misses the pieces forms') + expect('| hkdf_expand over pieces\n| hash2\n' in chapter, 'the default of a form') + llms = files['llms.txt'] + for name, pieces in (('hkdf_extract', 'input_key_material'), + ('hkdf_expand', 'application_info'), + ('hkdf', 'input_key_material and application_info')): + expect(f'webcpp::hash::{name} over pieces (, RFC 5869): {name} ' + f'with its {pieces} as byte_pieces,' in llms, f'llms.txt on {name} over pieces') + + def form_of(form: str, name: str = 'hkdf') -> Callable[[dict], None]: + def edit(table: dict) -> None: + hkdf = next(a for a in table['algorithms'] if a['name'] == 'hkdf') + row = next(f for f in hkdf['functions'] if f.get('form') == 'pieces' + and f['name'] == 'hkdf') + row['form'] = form + row['name'] = name + return edit + for edit, fault in ((form_of('slices'), 'hkdf has the unknown form slices'), + (form_of('pieces', 'hkdf_squeeze'), + 'hkdf_squeeze over pieces is a form of no row hkdf_squeeze'), + (form_of('pieces', 'hkdf_expand'), + 'doc/capabilities.json has two rows hkdf_expand over pieces')): + library = scratch_library(scratch / fault.split()[0]) + edit_capabilities(library, edit) + done = run(library, '--write') + expect(done.returncode == 1, f'rendered: {fault}') + expect(fault in done.stderr, done.stderr) + + def test_an_asynchronous_backend_is_never_a_default(scratch: Path) -> None: library = scratch_library(scratch) @@ -361,8 +408,9 @@ def test_llms_txt_s_defaults_are_the_table_s(scratch: Path) -> None: their only template argument, hkdf's and pbkdf2's the second, after the hmac.""" library = scratch_library(scratch) llms = write_ok(library)['llms.txt'] - expect('By default, hkdf_extract, hkdf_expand, hkdf and pbkdf2 run on backends::hash2 unless ' - 'the call names another of its backends as its second template argument; ' + expect('By default, hkdf_extract, hkdf_expand, hkdf, hkdf_extract over pieces, hkdf_expand ' + 'over pieces, hkdf over pieces and pbkdf2 run on backends::hash2 unless the call ' + 'names another of its backends as its second template argument; ' 'blake2b_subkey runs on backends::sodium alone; kbkdf, sskdf and x963kdf have no ' 'default backend, and the call names one of its backends as its second template ' 'argument; argon2id and scrypt run on backends::sodium unless the call names another ' @@ -621,7 +669,8 @@ def test_without_measurements_the_tables_say_so(scratch: Path) -> None: expect('measurements.adoc' not in files, 'measurements.adoc without its data') hkdf = files['generated/backends-hkdf.adoc'] expect('The default of `hkdf_extract` and `hkdf_expand`: `hash2` on every target' in hkdf - and 'The default of `hkdf`: `hash2` on every target' in hkdf, + and 'The default of `hkdf`, `hkdf_extract` over pieces, `hkdf_expand` over pieces and ' + '`hkdf` over pieces: `hash2` on every target' in hkdf, f'the backends of HKDF do not name the default: {hkdf}') expect('`bearssl`, `botan`, `openssl`, `sodium` only where the call names it' in hkdf, hkdf) expect('The default of `argon2id`: `sodium` on every target' @@ -632,8 +681,9 @@ def test_without_measurements_the_tables_say_so(scratch: Path) -> None: expect('| pbkdf2\n| hash2' in backends and '| scrypt\n| sodium' in backends, 'backends.adoc does not list the defaults') expect('Backends: hash2 (/webcpp/hash//hash' in files['llms.txt'], 'llms.txt has no backends') - expect('hkdf_extract, hkdf_expand, hkdf and pbkdf2 run on backends::hash2 unless the call ' - 'names another of its backends as its second template argument' in files['llms.txt'], + expect('hkdf_extract, hkdf_expand, hkdf, hkdf_extract over pieces, hkdf_expand over pieces, ' + 'hkdf over pieces and pbkdf2 run on backends::hash2 unless the call names another of ' + 'its backends as its second template argument' in files['llms.txt'], 'llms.txt does not say the default') @@ -650,7 +700,8 @@ def test_with_measurements_the_tables_carry_them(scratch: Path) -> None: expect('a loaded, shared machine' in digests, 'the note hides that the machine was loaded') hkdf = files['generated/backends-hkdf.adoc'] # BearSSL is the smallest and the fastest HKDF of the fixture: the default stays hash2. - expect('`hkdf`: `hash2` on every target' in hkdf, 'the measurements moved a default') + expect('`hkdf` over pieces: `hash2` on every target' in hkdf, + 'the measurements moved a default') expect('libsodium 1.0.22: its headers state constant time' in hkdf, 'the constant-time column does not give its source') page = files['measurements.adoc'] @@ -732,6 +783,7 @@ def test_the_real_library_s_files_are_its_data_s(scratch: Path) -> None: test_a_family_default_is_of_the_order_or_none, test_a_default_without_its_cell_fails_and_a_partial_cell_is_said, test_a_tag_sits_in_its_namespace_s_chapter, + test_a_form_row_is_keyed_by_its_name_and_form, test_an_asynchronous_backend_is_never_a_default, test_an_asynchronous_backend_s_targets_are_spelled, test_llms_txt_s_defaults_are_the_table_s,