Josh Steadmon <steadmon@xxxxxxxxxx> writes: > Define a JSON schema[1] that can be used to validate trace2 event > objects. This can be used to add regression tests to verify that the > event output format does not change unexpectedly. > > Two versions of the schema are provided: Actually, four versions of the schema are provided, as you have written in the t/trace_schema_validator/README file. > * event_schema.json is more permissive. It verifies that all expected > fields are present in each trace event, but it allows traces to have > unexpected additional fields. This allows the schema to be specified > more concisely by factoring out the common fields into a reusable > sub-schema. > * strict_schema.json is more restrictive. It verifies that all expected > fields are present and no unexpected fields are present in each trace > event. Due to this additional restriction, the common fields cannot be > factored out into a re-usable subschema (at least as-of draft-07) [2], > and must be repeated for each event definition. > > [1]: https://json-schema.org/ > [2]: https://json-schema.org/understanding-json-schema/reference/combining.html#allof > > Signed-off-by: Josh Steadmon <steadmon@xxxxxxxxxx> > --- > t/trace_schema_validator/README | 23 + > t/trace_schema_validator/event_schema.json | 398 ++++++++++++++ > t/trace_schema_validator/list_schema.json | 401 ++++++++++++++ > .../strict_list_schema.json | 514 ++++++++++++++++++ > t/trace_schema_validator/strict_schema.json | 511 +++++++++++++++++ > 5 files changed, 1847 insertions(+) > create mode 100644 t/trace_schema_validator/README > create mode 100644 t/trace_schema_validator/event_schema.json > create mode 100644 t/trace_schema_validator/list_schema.json > create mode 100644 t/trace_schema_validator/strict_list_schema.json > create mode 100644 t/trace_schema_validator/strict_schema.json > > diff --git a/t/trace_schema_validator/README b/t/trace_schema_validator/README > new file mode 100644 > index 0000000000..45f0e6f0c4 > --- /dev/null > +++ b/t/trace_schema_validator/README > @@ -0,0 +1,23 @@ > +These JSON schemas[1] can be used to validate trace2 event objects. They > +can be used to add regression tests to verify that the event output > +format does not change unexpectedly. > + > +Four versions of the schema are provided: > +* event_schema.json is more permissive. It verifies that all expected > + fields are present in a trace event, but it allows traces to have > + unexpected additional fields. This allows the schema to be specified > + more concisely by factoring out the common fields into a reusable > + sub-schema. > +* strict_schema.json is more restrictive. It verifies that all expected > + fields are present and no unexpected fields are present in the trace > + event. Due to this additional restriction, the common fields cannot be > + factored out into a re-usable subschema (at least as-of draft-07) [2], > + and must be repeated for each event definition. > +* list_schema.json is like event_schema.json above, but validates a JSON > + array of trace events, rather than a single event. > +* strict_list_schema.json is like strict_schema.json above, but > + validates a JSON array of trace events, rather than a single event. > + > +[1]: https://json-schema.org/ > +[2]: https://json-schema.org/understanding-json-schema/reference/combining.html#allof [...] -- Jakub Narębski