From bed7233f5d39774ffb817f23a5453882aebe8686 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 15 Mar 2016 21:28:49 -0400 Subject: [PATCH] Add tests Signed-off-by: Philippe Proulx --- README.md | 24 + tests/bats/LICENSE | 20 + tests/bats/bin/bats | 1 + tests/bats/libexec/bats | 142 +++ tests/bats/libexec/bats-exec-suite | 55 + tests/bats/libexec/bats-exec-test | 346 ++++++ tests/bats/libexec/bats-format-tap-stream | 165 +++ tests/bats/libexec/bats-preprocess | 52 + tests/common.bash | 13 + tests/config/.gitignore | 31 + tests/config/common.bash | 23 + tests/config/fail/barectf-bitfield.h | 232 ++++ tests/config/fail/barectf.c | 1001 +++++++++++++++++ tests/config/fail/barectf.h | 158 +++ .../fail/clock/absolute-invalid-type.yaml | 26 + .../fail/clock/description-invalid-type.yaml | 26 + tests/config/fail/clock/ec-invalid-type.yaml | 26 + tests/config/fail/clock/ec-invalid.yaml | 26 + tests/config/fail/clock/fail.bats | 89 ++ tests/config/fail/clock/freq-0.yaml | 26 + .../config/fail/clock/freq-invalid-type.yaml | 26 + tests/config/fail/clock/freq-neg.yaml | 26 + .../clock/offset-cycles-invalid-type.yaml | 27 + .../config/fail/clock/offset-cycles-neg.yaml | 27 + .../fail/clock/offset-invalid-type.yaml | 26 + .../clock/offset-seconds-invalid-type.yaml | 27 + .../config/fail/clock/offset-seconds-neg.yaml | 27 + .../fail/clock/offset-unknown-prop.yaml | 27 + tests/config/fail/clock/rct-invalid-type.yaml | 26 + tests/config/fail/clock/unknown-prop.yaml | 27 + .../config/fail/clock/uuid-invalid-type.yaml | 26 + tests/config/fail/clock/uuid-invalid.yaml | 26 + tests/config/fail/config/fail.bats | 49 + .../fail/config/metadata-invalid-type.yaml | 3 + tests/config/fail/config/metadata-no.yaml | 1 + .../config/prefix-invalid-identifier.yaml | 24 + .../fail/config/prefix-invalid-type.yaml | 24 + tests/config/fail/config/unknown-prop.yaml | 24 + .../fail/config/version-invalid-19.yaml | 23 + .../fail/config/version-invalid-22.yaml | 23 + .../fail/config/version-invalid-type.yaml | 23 + tests/config/fail/config/version-no.yaml | 22 + tests/config/fail/event/ct-invalid-type.yaml | 24 + tests/config/fail/event/ct-not-struct.yaml | 26 + tests/config/fail/event/fail.bats | 49 + tests/config/fail/event/ll-invalid-type.yaml | 24 + tests/config/fail/event/ll-non-existing.yaml | 27 + tests/config/fail/event/pt-invalid-type.yaml | 18 + tests/config/fail/event/pt-no.yaml | 21 + tests/config/fail/event/pt-not-struct.yaml | 20 + tests/config/fail/event/unknown-prop.yaml | 24 + tests/config/fail/include/cycle-sym.yaml | 24 + tests/config/fail/include/cycle.yaml | 24 + tests/config/fail/include/fail.bats | 42 + .../fail/include/file-not-found-abs.yaml | 24 + .../fail/include/file-not-found-in-array.yaml | 26 + .../include/file-not-found-recursive.yaml | 24 + tests/config/fail/include/file-not-found.yaml | 24 + tests/config/fail/include/inc-empty.yaml | 1 + .../fail/include/inc-inc-not-found.yaml | 1 + .../fail/include/inc-recursive-sym1.yaml | 1 + .../fail/include/inc-recursive-sym2.yaml | 1 + tests/config/fail/include/inc-recursive1.yaml | 1 + tests/config/fail/include/inc-recursive2.yaml | 1 + tests/config/fail/include/inc-recursive3.yaml | 1 + .../fail/include/include-include-replace.yaml | 25 + tests/config/fail/include/invalid-type.yaml | 24 + .../replace-file-not-found-in-array.yaml | 26 + .../fail/include/replace-file-not-found.yaml | 24 + .../fail/metadata/clocks-invalid-type.yaml | 24 + .../clocks-key-invalid-identifier.yaml | 26 + .../fail/metadata/env-invalid-type.yaml | 24 + .../metadata/env-key-invalid-identifier.yaml | 25 + .../fail/metadata/env-value-invalid-type.yaml | 27 + tests/config/fail/metadata/fail.bats | 84 ++ .../config/fail/metadata/ll-invalid-type.yaml | 24 + .../fail/metadata/ll-value-invalid-type.yaml | 25 + tests/config/fail/metadata/streams-empty.yaml | 5 + .../fail/metadata/streams-invalid-type.yaml | 9 + .../streams-key-invalid-identifier.yaml | 23 + tests/config/fail/metadata/streams-no.yaml | 4 + .../config/fail/metadata/ta-invalid-type.yaml | 23 + tests/config/fail/metadata/trace-empty.yaml | 22 + .../fail/metadata/trace-invalid-type.yaml | 22 + tests/config/fail/metadata/trace-no.yaml | 17 + tests/config/fail/metadata/unknown-prop.yaml | 24 + .../config/fail/stream/ect-invalid-type.yaml | 19 + tests/config/fail/stream/ect-not-struct.yaml | 20 + .../stream/eht-id-no-multiple-events.yaml | 32 + tests/config/fail/stream/eht-id-not-int.yaml | 30 + .../config/fail/stream/eht-id-too-small.yaml | 50 + .../fail/stream/eht-id-wrong-signed.yaml | 32 + .../config/fail/stream/eht-invalid-type.yaml | 19 + tests/config/fail/stream/eht-not-struct.yaml | 20 + .../fail/stream/eht-timestamp-not-int.yaml | 30 + .../fail/stream/eht-timestamp-wrong-pm.yaml | 31 + .../stream/eht-timestamp-wrong-signed.yaml | 36 + tests/config/fail/stream/events-empty.yaml | 7 + .../fail/stream/events-invalid-type.yaml | 16 + .../stream/events-key-invalid-identifier.yaml | 23 + tests/config/fail/stream/events-no.yaml | 15 + tests/config/fail/stream/fail.bats | 189 ++++ tests/config/fail/stream/pct-cs-gt-ps.yaml | 29 + tests/config/fail/stream/pct-cs-not-int.yaml | 24 + .../fail/stream/pct-cs-wrong-signed.yaml | 28 + .../config/fail/stream/pct-cs-yes-ps-no.yaml | 22 + tests/config/fail/stream/pct-ed-not-int.yaml | 23 + .../fail/stream/pct-ed-wrong-signed.yaml | 27 + .../config/fail/stream/pct-invalid-type.yaml | 19 + tests/config/fail/stream/pct-no.yaml | 20 + tests/config/fail/stream/pct-not-struct.yaml | 20 + tests/config/fail/stream/pct-ps-not-int.yaml | 24 + .../fail/stream/pct-ps-wrong-signed.yaml | 28 + .../config/fail/stream/pct-ps-yes-cs-no.yaml | 22 + tests/config/fail/stream/pct-tb-not-int.yaml | 25 + .../stream/pct-tb-te-different-clocks.yaml | 40 + tests/config/fail/stream/pct-tb-wrong-pm.yaml | 28 + .../fail/stream/pct-tb-wrong-signed.yaml | 33 + .../config/fail/stream/pct-tb-yes-te-no.yaml | 32 + tests/config/fail/stream/pct-te-not-int.yaml | 25 + tests/config/fail/stream/pct-te-wrong-pm.yaml | 28 + .../fail/stream/pct-te-wrong-signed.yaml | 33 + .../config/fail/stream/pct-te-yes-tb-no.yaml | 32 + tests/config/fail/stream/unknown-prop.yaml | 24 + tests/config/fail/trace/bo-invalid-type.yaml | 23 + tests/config/fail/trace/bo-invalid.yaml | 23 + tests/config/fail/trace/bo-no.yaml | 22 + tests/config/fail/trace/fail.bats | 99 ++ tests/config/fail/trace/ph-magic-not-int.yaml | 28 + .../fail/trace/ph-magic-wrong-signed.yaml | 30 + .../fail/trace/ph-magic-wrong-size.yaml | 29 + tests/config/fail/trace/ph-not-struct.yaml | 26 + .../fail/trace/ph-streamid-not-int.yaml | 28 + .../fail/trace/ph-streamid-too-small.yaml | 103 ++ .../fail/trace/ph-streamid-wrong-signed.yaml | 30 + .../config/fail/trace/ph-uuid-et-not-int.yaml | 32 + .../fail/trace/ph-uuid-et-wrong-align.yaml | 34 + .../fail/trace/ph-uuid-et-wrong-signed.yaml | 34 + .../fail/trace/ph-uuid-et-wrong-size.yaml | 33 + .../config/fail/trace/ph-uuid-not-array.yaml | 28 + .../fail/trace/ph-uuid-wrong-length.yaml | 33 + tests/config/fail/trace/unknown-prop.yaml | 24 + .../config/fail/trace/uuid-invalid-type.yaml | 24 + .../config/fail/trace/uuid-invalid-uuid.yaml | 24 + tests/config/fail/type-enum/fail.bats | 69 ++ .../type-enum/members-el-invalid-type.yaml | 20 + .../members-el-member-label-invalid-type.yaml | 21 + .../members-el-member-unknown-prop.yaml | 22 + .../members-el-member-value-invalid-type.yaml | 21 + ...-el-member-value-outside-range-signed.yaml | 22 + ...l-member-value-outside-range-unsigned.yaml | 21 + .../config/fail/type-enum/members-empty.yaml | 17 + .../fail/type-enum/members-invalid-type.yaml | 17 + tests/config/fail/type-enum/members-no.yaml | 16 + .../fail/type-enum/members-overlap.yaml | 22 + tests/config/fail/type-enum/unknown-prop.yaml | 19 + .../fail/type-enum/vt-invalid-type.yaml | 16 + tests/config/fail/type-enum/vt-no.yaml | 15 + tests/config/fail/type-float/align-0.yaml | 17 + tests/config/fail/type-float/align-3.yaml | 17 + .../fail/type-float/align-invalid-type.yaml | 17 + .../fail/type-float/bo-invalid-type.yaml | 17 + tests/config/fail/type-float/bo-invalid.yaml | 17 + tests/config/fail/type-float/fail.bats | 64 ++ .../type-float/size-exp-mant-wrong-sum.yaml | 16 + tests/config/fail/type-float/size-exp-no.yaml | 15 + .../fail/type-float/size-invalid-type.yaml | 14 + .../config/fail/type-float/size-mant-no.yaml | 15 + tests/config/fail/type-float/size-no.yaml | 13 + .../fail/type-float/size-unknown-prop.yaml | 17 + .../config/fail/type-float/unknown-prop.yaml | 17 + tests/config/fail/type-int/align-0.yaml | 15 + tests/config/fail/type-int/align-3.yaml | 15 + .../fail/type-int/align-invalid-type.yaml | 14 + .../fail/type-int/base-invalid-type.yaml | 15 + tests/config/fail/type-int/base-invalid.yaml | 15 + .../config/fail/type-int/bo-invalid-type.yaml | 14 + tests/config/fail/type-int/bo-invalid.yaml | 15 + tests/config/fail/type-int/fail.bats | 89 ++ .../config/fail/type-int/pm-invalid-type.yaml | 14 + .../fail/type-int/pm-property-invalid.yaml | 20 + .../config/fail/type-int/pm-type-invalid.yaml | 20 + .../fail/type-int/pm-unknown-clock.yaml | 20 + .../fail/type-int/signed-invalid-type.yaml | 14 + tests/config/fail/type-int/size-0.yaml | 14 + tests/config/fail/type-int/size-65.yaml | 15 + .../fail/type-int/size-invalid-type.yaml | 14 + tests/config/fail/type-int/size-no.yaml | 13 + tests/config/fail/type-int/unknown-prop.yaml | 15 + tests/config/fail/type-string/fail.bats | 9 + .../config/fail/type-string/unknown-prop.yaml | 14 + tests/config/fail/type-struct/fail.bats | 34 + .../fields-field-invalid-identifier.yaml | 14 + .../fail/type-struct/fields-invalid-type.yaml | 11 + tests/config/fail/type-struct/ma-0.yaml | 11 + tests/config/fail/type-struct/ma-3.yaml | 11 + .../fail/type-struct/ma-invalid-type.yaml | 11 + .../config/fail/type-struct/unknown-prop.yaml | 15 + tests/config/fail/type/fail.bats | 24 + tests/config/fail/type/inherit-forward.yaml | 20 + tests/config/fail/type/inherit-unknown.yaml | 18 + tests/config/fail/type/invalid-type.yaml | 21 + tests/config/fail/type/no-class.yaml | 13 + tests/config/fail/yaml/fail.bats | 9 + tests/config/fail/yaml/invalid.yaml | 24 + tests/config/pass/everything/config.yaml | 77 ++ tests/config/pass/everything/inc-clock.yaml | 5 + tests/config/pass/everything/inc-event.yaml | 5 + .../config/pass/everything/inc-metadata.yaml | 33 + tests/config/pass/everything/inc-stream.yaml | 11 + tests/config/pass/everything/inc-trace.yaml | 4 + tests/config/pass/everything/pass.bats | 34 + tests/test.bash | 39 + 213 files changed, 7205 insertions(+) create mode 100644 tests/bats/LICENSE create mode 120000 tests/bats/bin/bats create mode 100755 tests/bats/libexec/bats create mode 100755 tests/bats/libexec/bats-exec-suite create mode 100755 tests/bats/libexec/bats-exec-test create mode 100755 tests/bats/libexec/bats-format-tap-stream create mode 100755 tests/bats/libexec/bats-preprocess create mode 100644 tests/common.bash create mode 100644 tests/config/.gitignore create mode 100644 tests/config/common.bash create mode 100644 tests/config/fail/barectf-bitfield.h create mode 100644 tests/config/fail/barectf.c create mode 100644 tests/config/fail/barectf.h create mode 100644 tests/config/fail/clock/absolute-invalid-type.yaml create mode 100644 tests/config/fail/clock/description-invalid-type.yaml create mode 100644 tests/config/fail/clock/ec-invalid-type.yaml create mode 100644 tests/config/fail/clock/ec-invalid.yaml create mode 100644 tests/config/fail/clock/fail.bats create mode 100644 tests/config/fail/clock/freq-0.yaml create mode 100644 tests/config/fail/clock/freq-invalid-type.yaml create mode 100644 tests/config/fail/clock/freq-neg.yaml create mode 100644 tests/config/fail/clock/offset-cycles-invalid-type.yaml create mode 100644 tests/config/fail/clock/offset-cycles-neg.yaml create mode 100644 tests/config/fail/clock/offset-invalid-type.yaml create mode 100644 tests/config/fail/clock/offset-seconds-invalid-type.yaml create mode 100644 tests/config/fail/clock/offset-seconds-neg.yaml create mode 100644 tests/config/fail/clock/offset-unknown-prop.yaml create mode 100644 tests/config/fail/clock/rct-invalid-type.yaml create mode 100644 tests/config/fail/clock/unknown-prop.yaml create mode 100644 tests/config/fail/clock/uuid-invalid-type.yaml create mode 100644 tests/config/fail/clock/uuid-invalid.yaml create mode 100644 tests/config/fail/config/fail.bats create mode 100644 tests/config/fail/config/metadata-invalid-type.yaml create mode 100644 tests/config/fail/config/metadata-no.yaml create mode 100644 tests/config/fail/config/prefix-invalid-identifier.yaml create mode 100644 tests/config/fail/config/prefix-invalid-type.yaml create mode 100644 tests/config/fail/config/unknown-prop.yaml create mode 100644 tests/config/fail/config/version-invalid-19.yaml create mode 100644 tests/config/fail/config/version-invalid-22.yaml create mode 100644 tests/config/fail/config/version-invalid-type.yaml create mode 100644 tests/config/fail/config/version-no.yaml create mode 100644 tests/config/fail/event/ct-invalid-type.yaml create mode 100644 tests/config/fail/event/ct-not-struct.yaml create mode 100644 tests/config/fail/event/fail.bats create mode 100644 tests/config/fail/event/ll-invalid-type.yaml create mode 100644 tests/config/fail/event/ll-non-existing.yaml create mode 100644 tests/config/fail/event/pt-invalid-type.yaml create mode 100644 tests/config/fail/event/pt-no.yaml create mode 100644 tests/config/fail/event/pt-not-struct.yaml create mode 100644 tests/config/fail/event/unknown-prop.yaml create mode 100644 tests/config/fail/include/cycle-sym.yaml create mode 100644 tests/config/fail/include/cycle.yaml create mode 100644 tests/config/fail/include/fail.bats create mode 100644 tests/config/fail/include/file-not-found-abs.yaml create mode 100644 tests/config/fail/include/file-not-found-in-array.yaml create mode 100644 tests/config/fail/include/file-not-found-recursive.yaml create mode 100644 tests/config/fail/include/file-not-found.yaml create mode 100644 tests/config/fail/include/inc-empty.yaml create mode 100644 tests/config/fail/include/inc-inc-not-found.yaml create mode 100644 tests/config/fail/include/inc-recursive-sym1.yaml create mode 100644 tests/config/fail/include/inc-recursive-sym2.yaml create mode 100644 tests/config/fail/include/inc-recursive1.yaml create mode 100644 tests/config/fail/include/inc-recursive2.yaml create mode 100644 tests/config/fail/include/inc-recursive3.yaml create mode 100644 tests/config/fail/include/include-include-replace.yaml create mode 100644 tests/config/fail/include/invalid-type.yaml create mode 100644 tests/config/fail/include/replace-file-not-found-in-array.yaml create mode 100644 tests/config/fail/include/replace-file-not-found.yaml create mode 100644 tests/config/fail/metadata/clocks-invalid-type.yaml create mode 100644 tests/config/fail/metadata/clocks-key-invalid-identifier.yaml create mode 100644 tests/config/fail/metadata/env-invalid-type.yaml create mode 100644 tests/config/fail/metadata/env-key-invalid-identifier.yaml create mode 100644 tests/config/fail/metadata/env-value-invalid-type.yaml create mode 100644 tests/config/fail/metadata/fail.bats create mode 100644 tests/config/fail/metadata/ll-invalid-type.yaml create mode 100644 tests/config/fail/metadata/ll-value-invalid-type.yaml create mode 100644 tests/config/fail/metadata/streams-empty.yaml create mode 100644 tests/config/fail/metadata/streams-invalid-type.yaml create mode 100644 tests/config/fail/metadata/streams-key-invalid-identifier.yaml create mode 100644 tests/config/fail/metadata/streams-no.yaml create mode 100644 tests/config/fail/metadata/ta-invalid-type.yaml create mode 100644 tests/config/fail/metadata/trace-empty.yaml create mode 100644 tests/config/fail/metadata/trace-invalid-type.yaml create mode 100644 tests/config/fail/metadata/trace-no.yaml create mode 100644 tests/config/fail/metadata/unknown-prop.yaml create mode 100644 tests/config/fail/stream/ect-invalid-type.yaml create mode 100644 tests/config/fail/stream/ect-not-struct.yaml create mode 100644 tests/config/fail/stream/eht-id-no-multiple-events.yaml create mode 100644 tests/config/fail/stream/eht-id-not-int.yaml create mode 100644 tests/config/fail/stream/eht-id-too-small.yaml create mode 100644 tests/config/fail/stream/eht-id-wrong-signed.yaml create mode 100644 tests/config/fail/stream/eht-invalid-type.yaml create mode 100644 tests/config/fail/stream/eht-not-struct.yaml create mode 100644 tests/config/fail/stream/eht-timestamp-not-int.yaml create mode 100644 tests/config/fail/stream/eht-timestamp-wrong-pm.yaml create mode 100644 tests/config/fail/stream/eht-timestamp-wrong-signed.yaml create mode 100644 tests/config/fail/stream/events-empty.yaml create mode 100644 tests/config/fail/stream/events-invalid-type.yaml create mode 100644 tests/config/fail/stream/events-key-invalid-identifier.yaml create mode 100644 tests/config/fail/stream/events-no.yaml create mode 100644 tests/config/fail/stream/fail.bats create mode 100644 tests/config/fail/stream/pct-cs-gt-ps.yaml create mode 100644 tests/config/fail/stream/pct-cs-not-int.yaml create mode 100644 tests/config/fail/stream/pct-cs-wrong-signed.yaml create mode 100644 tests/config/fail/stream/pct-cs-yes-ps-no.yaml create mode 100644 tests/config/fail/stream/pct-ed-not-int.yaml create mode 100644 tests/config/fail/stream/pct-ed-wrong-signed.yaml create mode 100644 tests/config/fail/stream/pct-invalid-type.yaml create mode 100644 tests/config/fail/stream/pct-no.yaml create mode 100644 tests/config/fail/stream/pct-not-struct.yaml create mode 100644 tests/config/fail/stream/pct-ps-not-int.yaml create mode 100644 tests/config/fail/stream/pct-ps-wrong-signed.yaml create mode 100644 tests/config/fail/stream/pct-ps-yes-cs-no.yaml create mode 100644 tests/config/fail/stream/pct-tb-not-int.yaml create mode 100644 tests/config/fail/stream/pct-tb-te-different-clocks.yaml create mode 100644 tests/config/fail/stream/pct-tb-wrong-pm.yaml create mode 100644 tests/config/fail/stream/pct-tb-wrong-signed.yaml create mode 100644 tests/config/fail/stream/pct-tb-yes-te-no.yaml create mode 100644 tests/config/fail/stream/pct-te-not-int.yaml create mode 100644 tests/config/fail/stream/pct-te-wrong-pm.yaml create mode 100644 tests/config/fail/stream/pct-te-wrong-signed.yaml create mode 100644 tests/config/fail/stream/pct-te-yes-tb-no.yaml create mode 100644 tests/config/fail/stream/unknown-prop.yaml create mode 100644 tests/config/fail/trace/bo-invalid-type.yaml create mode 100644 tests/config/fail/trace/bo-invalid.yaml create mode 100644 tests/config/fail/trace/bo-no.yaml create mode 100644 tests/config/fail/trace/fail.bats create mode 100644 tests/config/fail/trace/ph-magic-not-int.yaml create mode 100644 tests/config/fail/trace/ph-magic-wrong-signed.yaml create mode 100644 tests/config/fail/trace/ph-magic-wrong-size.yaml create mode 100644 tests/config/fail/trace/ph-not-struct.yaml create mode 100644 tests/config/fail/trace/ph-streamid-not-int.yaml create mode 100644 tests/config/fail/trace/ph-streamid-too-small.yaml create mode 100644 tests/config/fail/trace/ph-streamid-wrong-signed.yaml create mode 100644 tests/config/fail/trace/ph-uuid-et-not-int.yaml create mode 100644 tests/config/fail/trace/ph-uuid-et-wrong-align.yaml create mode 100644 tests/config/fail/trace/ph-uuid-et-wrong-signed.yaml create mode 100644 tests/config/fail/trace/ph-uuid-et-wrong-size.yaml create mode 100644 tests/config/fail/trace/ph-uuid-not-array.yaml create mode 100644 tests/config/fail/trace/ph-uuid-wrong-length.yaml create mode 100644 tests/config/fail/trace/unknown-prop.yaml create mode 100644 tests/config/fail/trace/uuid-invalid-type.yaml create mode 100644 tests/config/fail/trace/uuid-invalid-uuid.yaml create mode 100644 tests/config/fail/type-enum/fail.bats create mode 100644 tests/config/fail/type-enum/members-el-invalid-type.yaml create mode 100644 tests/config/fail/type-enum/members-el-member-label-invalid-type.yaml create mode 100644 tests/config/fail/type-enum/members-el-member-unknown-prop.yaml create mode 100644 tests/config/fail/type-enum/members-el-member-value-invalid-type.yaml create mode 100644 tests/config/fail/type-enum/members-el-member-value-outside-range-signed.yaml create mode 100644 tests/config/fail/type-enum/members-el-member-value-outside-range-unsigned.yaml create mode 100644 tests/config/fail/type-enum/members-empty.yaml create mode 100644 tests/config/fail/type-enum/members-invalid-type.yaml create mode 100644 tests/config/fail/type-enum/members-no.yaml create mode 100644 tests/config/fail/type-enum/members-overlap.yaml create mode 100644 tests/config/fail/type-enum/unknown-prop.yaml create mode 100644 tests/config/fail/type-enum/vt-invalid-type.yaml create mode 100644 tests/config/fail/type-enum/vt-no.yaml create mode 100644 tests/config/fail/type-float/align-0.yaml create mode 100644 tests/config/fail/type-float/align-3.yaml create mode 100644 tests/config/fail/type-float/align-invalid-type.yaml create mode 100644 tests/config/fail/type-float/bo-invalid-type.yaml create mode 100644 tests/config/fail/type-float/bo-invalid.yaml create mode 100644 tests/config/fail/type-float/fail.bats create mode 100644 tests/config/fail/type-float/size-exp-mant-wrong-sum.yaml create mode 100644 tests/config/fail/type-float/size-exp-no.yaml create mode 100644 tests/config/fail/type-float/size-invalid-type.yaml create mode 100644 tests/config/fail/type-float/size-mant-no.yaml create mode 100644 tests/config/fail/type-float/size-no.yaml create mode 100644 tests/config/fail/type-float/size-unknown-prop.yaml create mode 100644 tests/config/fail/type-float/unknown-prop.yaml create mode 100644 tests/config/fail/type-int/align-0.yaml create mode 100644 tests/config/fail/type-int/align-3.yaml create mode 100644 tests/config/fail/type-int/align-invalid-type.yaml create mode 100644 tests/config/fail/type-int/base-invalid-type.yaml create mode 100644 tests/config/fail/type-int/base-invalid.yaml create mode 100644 tests/config/fail/type-int/bo-invalid-type.yaml create mode 100644 tests/config/fail/type-int/bo-invalid.yaml create mode 100644 tests/config/fail/type-int/fail.bats create mode 100644 tests/config/fail/type-int/pm-invalid-type.yaml create mode 100644 tests/config/fail/type-int/pm-property-invalid.yaml create mode 100644 tests/config/fail/type-int/pm-type-invalid.yaml create mode 100644 tests/config/fail/type-int/pm-unknown-clock.yaml create mode 100644 tests/config/fail/type-int/signed-invalid-type.yaml create mode 100644 tests/config/fail/type-int/size-0.yaml create mode 100644 tests/config/fail/type-int/size-65.yaml create mode 100644 tests/config/fail/type-int/size-invalid-type.yaml create mode 100644 tests/config/fail/type-int/size-no.yaml create mode 100644 tests/config/fail/type-int/unknown-prop.yaml create mode 100644 tests/config/fail/type-string/fail.bats create mode 100644 tests/config/fail/type-string/unknown-prop.yaml create mode 100644 tests/config/fail/type-struct/fail.bats create mode 100644 tests/config/fail/type-struct/fields-field-invalid-identifier.yaml create mode 100644 tests/config/fail/type-struct/fields-invalid-type.yaml create mode 100644 tests/config/fail/type-struct/ma-0.yaml create mode 100644 tests/config/fail/type-struct/ma-3.yaml create mode 100644 tests/config/fail/type-struct/ma-invalid-type.yaml create mode 100644 tests/config/fail/type-struct/unknown-prop.yaml create mode 100644 tests/config/fail/type/fail.bats create mode 100644 tests/config/fail/type/inherit-forward.yaml create mode 100644 tests/config/fail/type/inherit-unknown.yaml create mode 100644 tests/config/fail/type/invalid-type.yaml create mode 100644 tests/config/fail/type/no-class.yaml create mode 100644 tests/config/fail/yaml/fail.bats create mode 100644 tests/config/fail/yaml/invalid.yaml create mode 100644 tests/config/pass/everything/config.yaml create mode 100644 tests/config/pass/everything/inc-clock.yaml create mode 100644 tests/config/pass/everything/inc-event.yaml create mode 100644 tests/config/pass/everything/inc-metadata.yaml create mode 100644 tests/config/pass/everything/inc-stream.yaml create mode 100644 tests/config/pass/everything/inc-trace.yaml create mode 100644 tests/config/pass/everything/pass.bats create mode 100755 tests/test.bash diff --git a/README.md b/README.md index 08172cf..445b350 100644 --- a/README.md +++ b/README.md @@ -140,3 +140,27 @@ CTF type. barectf requires them to be structure types. See the [project's wiki](https://github.com/efficios/barectf/wiki) which contains all the information needed to use barectf. + + +## Testing + +Bash is required for testing barectf. + +The barectf tests execute the `barectf` command available in your +`$PATH`. The best way to test a specific version of barectf is to create +a Python 3 [virtual environment](https://virtualenv.pypa.io/en/latest/), +install the appropriate version, and then run the tests. + +In the barectf source tree root, do: + + virtualenv virt + . ./virt/bin/activate + rehash # if using zsh + ./setup.py install + (cd tests && ./test.bash) + +You can specify [Bats](https://github.com/sstephenson/bats) options to +`./test.bash`, like `--tap` to get a [TAP](https://testanything.org/) +output. + +You can exit the virtual environment by running `deactivate`. diff --git a/tests/bats/LICENSE b/tests/bats/LICENSE new file mode 100644 index 0000000..bac4eb2 --- /dev/null +++ b/tests/bats/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2014 Sam Stephenson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tests/bats/bin/bats b/tests/bats/bin/bats new file mode 120000 index 0000000..a50a884 --- /dev/null +++ b/tests/bats/bin/bats @@ -0,0 +1 @@ +../libexec/bats \ No newline at end of file diff --git a/tests/bats/libexec/bats b/tests/bats/libexec/bats new file mode 100755 index 0000000..71f392f --- /dev/null +++ b/tests/bats/libexec/bats @@ -0,0 +1,142 @@ +#!/usr/bin/env bash +set -e + +version() { + echo "Bats 0.4.0" +} + +usage() { + version + echo "Usage: bats [-c] [-p | -t] [ ...]" +} + +help() { + usage + echo + echo " is the path to a Bats test file, or the path to a directory" + echo " containing Bats test files." + echo + echo " -c, --count Count the number of test cases without running any tests" + echo " -h, --help Display this help message" + echo " -p, --pretty Show results in pretty format (default for terminals)" + echo " -t, --tap Show results in TAP format" + echo " -v, --version Display the version number" + echo + echo " For more information, see https://github.com/sstephenson/bats" + echo +} + +resolve_link() { + $(type -p greadlink readlink | head -1) "$1" +} + +abs_dirname() { + local cwd="$(pwd)" + local path="$1" + + while [ -n "$path" ]; do + cd "${path%/*}" + local name="${path##*/}" + path="$(resolve_link "$name" || true)" + done + + pwd + cd "$cwd" +} + +expand_path() { + { cd "$(dirname "$1")" 2>/dev/null + local dirname="$PWD" + cd "$OLDPWD" + echo "$dirname/$(basename "$1")" + } || echo "$1" +} + +BATS_LIBEXEC="$(abs_dirname "$0")" +export BATS_PREFIX="$(abs_dirname "$BATS_LIBEXEC")" +export BATS_CWD="$(abs_dirname .)" +export PATH="$BATS_LIBEXEC:$PATH" + +options=() +arguments=() +for arg in "$@"; do + if [ "${arg:0:1}" = "-" ]; then + if [ "${arg:1:1}" = "-" ]; then + options[${#options[*]}]="${arg:2}" + else + index=1 + while option="${arg:$index:1}"; do + [ -n "$option" ] || break + options[${#options[*]}]="$option" + let index+=1 + done + fi + else + arguments[${#arguments[*]}]="$arg" + fi +done + +unset count_flag pretty +[ -t 0 ] && [ -t 1 ] && pretty="1" +[ -n "$CI" ] && pretty="" + +for option in "${options[@]}"; do + case "$option" in + "h" | "help" ) + help + exit 0 + ;; + "v" | "version" ) + version + exit 0 + ;; + "c" | "count" ) + count_flag="-c" + ;; + "t" | "tap" ) + pretty="" + ;; + "p" | "pretty" ) + pretty="1" + ;; + * ) + usage >&2 + exit 1 + ;; + esac +done + +if [ "${#arguments[@]}" -eq 0 ]; then + usage >&2 + exit 1 +fi + +filenames=() +for filename in "${arguments[@]}"; do + if [ -d "$filename" ]; then + shopt -s nullglob + for suite_filename in "$(expand_path "$filename")"/*.bats; do + filenames["${#filenames[@]}"]="$suite_filename" + done + shopt -u nullglob + else + filenames["${#filenames[@]}"]="$(expand_path "$filename")" + fi +done + +if [ "${#filenames[@]}" -eq 1 ]; then + command="bats-exec-test" +else + command="bats-exec-suite" +fi + +if [ -n "$pretty" ]; then + extended_syntax_flag="-x" + formatter="bats-format-tap-stream" +else + extended_syntax_flag="" + formatter="cat" +fi + +set -o pipefail execfail +exec "$command" $count_flag $extended_syntax_flag "${filenames[@]}" | "$formatter" diff --git a/tests/bats/libexec/bats-exec-suite b/tests/bats/libexec/bats-exec-suite new file mode 100755 index 0000000..29ab255 --- /dev/null +++ b/tests/bats/libexec/bats-exec-suite @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -e + +count_only_flag="" +if [ "$1" = "-c" ]; then + count_only_flag=1 + shift +fi + +extended_syntax_flag="" +if [ "$1" = "-x" ]; then + extended_syntax_flag="-x" + shift +fi + +trap "kill 0; exit 1" int + +count=0 +for filename in "$@"; do + let count+="$(bats-exec-test -c "$filename")" +done + +if [ -n "$count_only_flag" ]; then + echo "$count" + exit +fi + +echo "1..$count" +status=0 +offset=0 +for filename in "$@"; do + index=0 + { + IFS= read -r # 1..n + while IFS= read -r line; do + case "$line" in + "begin "* ) + let index+=1 + echo "${line/ $index / $(($offset + $index)) }" + ;; + "ok "* | "not ok "* ) + [ -n "$extended_syntax_flag" ] || let index+=1 + echo "${line/ $index / $(($offset + $index)) }" + [ "${line:0:6}" != "not ok" ] || status=1 + ;; + * ) + echo "$line" + ;; + esac + done + } < <( bats-exec-test $extended_syntax_flag "$filename" ) + offset=$(($offset + $index)) +done + +exit "$status" diff --git a/tests/bats/libexec/bats-exec-test b/tests/bats/libexec/bats-exec-test new file mode 100755 index 0000000..8f3bd51 --- /dev/null +++ b/tests/bats/libexec/bats-exec-test @@ -0,0 +1,346 @@ +#!/usr/bin/env bash +set -e +set -E +set -T + +BATS_COUNT_ONLY="" +if [ "$1" = "-c" ]; then + BATS_COUNT_ONLY=1 + shift +fi + +BATS_EXTENDED_SYNTAX="" +if [ "$1" = "-x" ]; then + BATS_EXTENDED_SYNTAX="$1" + shift +fi + +BATS_TEST_FILENAME="$1" +if [ -z "$BATS_TEST_FILENAME" ]; then + echo "usage: bats-exec " >&2 + exit 1 +elif [ ! -f "$BATS_TEST_FILENAME" ]; then + echo "bats: $BATS_TEST_FILENAME does not exist" >&2 + exit 1 +else + shift +fi + +BATS_TEST_DIRNAME="$(dirname "$BATS_TEST_FILENAME")" +BATS_TEST_NAMES=() + +load() { + local name="$1" + local filename + + if [ "${name:0:1}" = "/" ]; then + filename="${name}" + else + filename="$BATS_TEST_DIRNAME/${name}.bash" + fi + + [ -f "$filename" ] || { + echo "bats: $filename does not exist" >&2 + exit 1 + } + + source "${filename}" +} + +run() { + local e E T oldIFS + [[ ! "$-" =~ e ]] || e=1 + [[ ! "$-" =~ E ]] || E=1 + [[ ! "$-" =~ T ]] || T=1 + set +e + set +E + set +T + output="$("$@" 2>&1)" + status="$?" + oldIFS=$IFS + IFS=$'\n' lines=($output) + [ -z "$e" ] || set -e + [ -z "$E" ] || set -E + [ -z "$T" ] || set -T + IFS=$oldIFS +} + +setup() { + true +} + +teardown() { + true +} + +skip() { + BATS_TEST_SKIPPED=${1:-1} + BATS_TEST_COMPLETED=1 + exit 0 +} + +bats_test_begin() { + BATS_TEST_DESCRIPTION="$1" + if [ -n "$BATS_EXTENDED_SYNTAX" ]; then + echo "begin $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION" >&3 + fi + setup +} + +bats_test_function() { + local test_name="$1" + BATS_TEST_NAMES["${#BATS_TEST_NAMES[@]}"]="$test_name" +} + +bats_capture_stack_trace() { + BATS_PREVIOUS_STACK_TRACE=( "${BATS_CURRENT_STACK_TRACE[@]}" ) + BATS_CURRENT_STACK_TRACE=() + + local test_pattern=" $BATS_TEST_NAME $BATS_TEST_SOURCE" + local setup_pattern=" setup $BATS_TEST_SOURCE" + local teardown_pattern=" teardown $BATS_TEST_SOURCE" + + local frame + local index=1 + + while frame="$(caller "$index")"; do + BATS_CURRENT_STACK_TRACE["${#BATS_CURRENT_STACK_TRACE[@]}"]="$frame" + if [[ "$frame" = *"$test_pattern" || \ + "$frame" = *"$setup_pattern" || \ + "$frame" = *"$teardown_pattern" ]]; then + break + else + let index+=1 + fi + done + + BATS_SOURCE="$(bats_frame_filename "${BATS_CURRENT_STACK_TRACE[0]}")" + BATS_LINENO="$(bats_frame_lineno "${BATS_CURRENT_STACK_TRACE[0]}")" +} + +bats_print_stack_trace() { + local frame + local index=1 + local count="${#@}" + + for frame in "$@"; do + local filename="$(bats_trim_filename "$(bats_frame_filename "$frame")")" + local lineno="$(bats_frame_lineno "$frame")" + + if [ $index -eq 1 ]; then + echo -n "# (" + else + echo -n "# " + fi + + local fn="$(bats_frame_function "$frame")" + if [ "$fn" != "$BATS_TEST_NAME" ]; then + echo -n "from function \`$fn' " + fi + + if [ $index -eq $count ]; then + echo "in test file $filename, line $lineno)" + else + echo "in file $filename, line $lineno," + fi + + let index+=1 + done +} + +bats_print_failed_command() { + local frame="$1" + local status="$2" + local filename="$(bats_frame_filename "$frame")" + local lineno="$(bats_frame_lineno "$frame")" + + local failed_line="$(bats_extract_line "$filename" "$lineno")" + local failed_command="$(bats_strip_string "$failed_line")" + echo -n "# \`${failed_command}' " + + if [ $status -eq 1 ]; then + echo "failed" + else + echo "failed with status $status" + fi +} + +bats_frame_lineno() { + local frame="$1" + local lineno="${frame%% *}" + echo "$lineno" +} + +bats_frame_function() { + local frame="$1" + local rest="${frame#* }" + local fn="${rest%% *}" + echo "$fn" +} + +bats_frame_filename() { + local frame="$1" + local rest="${frame#* }" + local filename="${rest#* }" + + if [ "$filename" = "$BATS_TEST_SOURCE" ]; then + echo "$BATS_TEST_FILENAME" + else + echo "$filename" + fi +} + +bats_extract_line() { + local filename="$1" + local lineno="$2" + sed -n "${lineno}p" "$filename" +} + +bats_strip_string() { + local string="$1" + printf "%s" "$string" | sed -e "s/^[ "$'\t'"]*//" -e "s/[ "$'\t'"]*$//" +} + +bats_trim_filename() { + local filename="$1" + local length="${#BATS_CWD}" + + if [ "${filename:0:length+1}" = "${BATS_CWD}/" ]; then + echo "${filename:length+1}" + else + echo "$filename" + fi +} + +bats_debug_trap() { + if [ "$BASH_SOURCE" != "$1" ]; then + bats_capture_stack_trace + fi +} + +bats_error_trap() { + BATS_ERROR_STATUS="$?" + BATS_ERROR_STACK_TRACE=( "${BATS_PREVIOUS_STACK_TRACE[@]}" ) + trap - debug +} + +bats_teardown_trap() { + trap "bats_exit_trap" exit + local status=0 + teardown >>"$BATS_OUT" 2>&1 || status="$?" + + if [ $status -eq 0 ]; then + BATS_TEARDOWN_COMPLETED=1 + elif [ -n "$BATS_TEST_COMPLETED" ]; then + BATS_ERROR_STATUS="$status" + BATS_ERROR_STACK_TRACE=( "${BATS_CURRENT_STACK_TRACE[@]}" ) + fi + + bats_exit_trap +} + +bats_exit_trap() { + local status + local skipped + trap - err exit + + skipped="" + if [ -n "$BATS_TEST_SKIPPED" ]; then + skipped=" # skip" + if [ "1" != "$BATS_TEST_SKIPPED" ]; then + skipped+=" ($BATS_TEST_SKIPPED)" + fi + fi + + if [ -z "$BATS_TEST_COMPLETED" ] || [ -z "$BATS_TEARDOWN_COMPLETED" ]; then + echo "not ok $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION" >&3 + bats_print_stack_trace "${BATS_ERROR_STACK_TRACE[@]}" >&3 + bats_print_failed_command "${BATS_ERROR_STACK_TRACE[${#BATS_ERROR_STACK_TRACE[@]}-1]}" "$BATS_ERROR_STATUS" >&3 + sed -e "s/^/# /" < "$BATS_OUT" >&3 + status=1 + else + echo "ok ${BATS_TEST_NUMBER}${skipped} ${BATS_TEST_DESCRIPTION}" >&3 + status=0 + fi + + rm -f "$BATS_OUT" + exit "$status" +} + +bats_perform_tests() { + echo "1..$#" + test_number=1 + status=0 + for test_name in "$@"; do + "$0" $BATS_EXTENDED_SYNTAX "$BATS_TEST_FILENAME" "$test_name" "$test_number" || status=1 + let test_number+=1 + done + exit "$status" +} + +bats_perform_test() { + BATS_TEST_NAME="$1" + if [ "$(type -t "$BATS_TEST_NAME" || true)" = "function" ]; then + BATS_TEST_NUMBER="$2" + if [ -z "$BATS_TEST_NUMBER" ]; then + echo "1..1" + BATS_TEST_NUMBER="1" + fi + + BATS_TEST_COMPLETED="" + BATS_TEARDOWN_COMPLETED="" + trap "bats_debug_trap \"\$BASH_SOURCE\"" debug + trap "bats_error_trap" err + trap "bats_teardown_trap" exit + "$BATS_TEST_NAME" >>"$BATS_OUT" 2>&1 + BATS_TEST_COMPLETED=1 + + else + echo "bats: unknown test name \`$BATS_TEST_NAME'" >&2 + exit 1 + fi +} + +if [ -z "$TMPDIR" ]; then + BATS_TMPDIR="/tmp" +else + BATS_TMPDIR="${TMPDIR%/}" +fi + +BATS_TMPNAME="$BATS_TMPDIR/bats.$$" +BATS_PARENT_TMPNAME="$BATS_TMPDIR/bats.$PPID" +BATS_OUT="${BATS_TMPNAME}.out" + +bats_preprocess_source() { + BATS_TEST_SOURCE="${BATS_TMPNAME}.src" + { tr -d '\r' < "$BATS_TEST_FILENAME"; echo; } | bats-preprocess > "$BATS_TEST_SOURCE" + trap "bats_cleanup_preprocessed_source" err exit + trap "bats_cleanup_preprocessed_source; exit 1" int +} + +bats_cleanup_preprocessed_source() { + rm -f "$BATS_TEST_SOURCE" +} + +bats_evaluate_preprocessed_source() { + if [ -z "$BATS_TEST_SOURCE" ]; then + BATS_TEST_SOURCE="${BATS_PARENT_TMPNAME}.src" + fi + source "$BATS_TEST_SOURCE" +} + +exec 3<&1 + +if [ "$#" -eq 0 ]; then + bats_preprocess_source + bats_evaluate_preprocessed_source + + if [ -n "$BATS_COUNT_ONLY" ]; then + echo "${#BATS_TEST_NAMES[@]}" + else + bats_perform_tests "${BATS_TEST_NAMES[@]}" + fi +else + bats_evaluate_preprocessed_source + bats_perform_test "$@" +fi diff --git a/tests/bats/libexec/bats-format-tap-stream b/tests/bats/libexec/bats-format-tap-stream new file mode 100755 index 0000000..614768f --- /dev/null +++ b/tests/bats/libexec/bats-format-tap-stream @@ -0,0 +1,165 @@ +#!/usr/bin/env bash +set -e + +# Just stream the TAP output (sans extended syntax) if tput is missing +command -v tput >/dev/null || exec grep -v "^begin " + +header_pattern='[0-9]+\.\.[0-9]+' +IFS= read -r header + +if [[ "$header" =~ $header_pattern ]]; then + count="${header:3}" + index=0 + failures=0 + skipped=0 + name="" + count_column_width=$(( ${#count} * 2 + 2 )) +else + # If the first line isn't a TAP plan, print it and pass the rest through + printf "%s\n" "$header" + exec cat +fi + +update_screen_width() { + screen_width="$(tput cols)" + count_column_left=$(( $screen_width - $count_column_width )) +} + +trap update_screen_width WINCH +update_screen_width + +begin() { + go_to_column 0 + printf_with_truncation $(( $count_column_left - 1 )) " %s" "$name" + clear_to_end_of_line + go_to_column $count_column_left + printf "%${#count}s/${count}" "$index" + go_to_column 1 +} + +pass() { + go_to_column 0 + printf " ✓ %s" "$name" + advance +} + +skip() { + local reason="$1" + [ -z "$reason" ] || reason=": $reason" + go_to_column 0 + printf " - %s (skipped%s)" "$name" "$reason" + advance +} + +fail() { + go_to_column 0 + set_color 1 bold + printf " ✗ %s" "$name" + advance +} + +log() { + set_color 1 + printf " %s\n" "$1" + clear_color +} + +summary() { + printf "\n%d test%s" "$count" "$(plural "$count")" + + printf ", %d failure%s" "$failures" "$(plural "$failures")" + + if [ "$skipped" -gt 0 ]; then + printf ", %d skipped" "$skipped" + fi + + printf "\n" +} + +printf_with_truncation() { + local width="$1" + shift + local string="$(printf "$@")" + + if [ "${#string}" -gt "$width" ]; then + printf "%s..." "${string:0:$(( $width - 4 ))}" + else + printf "%s" "$string" + fi +} + +go_to_column() { + local column="$1" + printf "\x1B[%dG" $(( $column + 1 )) +} + +clear_to_end_of_line() { + printf "\x1B[K" +} + +advance() { + clear_to_end_of_line + echo + clear_color +} + +set_color() { + local color="$1" + local weight="$2" + printf "\x1B[%d;%dm" $(( 30 + $color )) "$( [ "$weight" = "bold" ] && echo 1 || echo 22 )" +} + +clear_color() { + printf "\x1B[0m" +} + +plural() { + [ "$1" -eq 1 ] || echo "s" +} + +_buffer="" + +buffer() { + _buffer="${_buffer}$("$@")" +} + +flush() { + printf "%s" "$_buffer" + _buffer="" +} + +finish() { + flush + printf "\n" +} + +trap finish EXIT + +while IFS= read -r line; do + case "$line" in + "begin "* ) + let index+=1 + name="${line#* $index }" + buffer begin + flush + ;; + "ok "* ) + skip_expr="ok $index # skip (\(([^)]*)\))?" + if [[ "$line" =~ $skip_expr ]]; then + let skipped+=1 + buffer skip "${BASH_REMATCH[2]}" + else + buffer pass + fi + ;; + "not ok "* ) + let failures+=1 + buffer fail + ;; + "# "* ) + buffer log "${line:2}" + ;; + esac +done + +buffer summary diff --git a/tests/bats/libexec/bats-preprocess b/tests/bats/libexec/bats-preprocess new file mode 100755 index 0000000..04297ed --- /dev/null +++ b/tests/bats/libexec/bats-preprocess @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +set -e + +encode_name() { + local name="$1" + local result="test_" + + if [[ ! "$name" =~ [^[:alnum:]\ _-] ]]; then + name="${name//_/-5f}" + name="${name//-/-2d}" + name="${name// /_}" + result+="$name" + else + local length="${#name}" + local char i + + for ((i=0; i&2 + return 1 + fi + + run barectf "$1" + local rc=$? + popd + return $rc +} diff --git a/tests/config/.gitignore b/tests/config/.gitignore new file mode 100644 index 0000000..99e3c80 --- /dev/null +++ b/tests/config/.gitignore @@ -0,0 +1,31 @@ +fail/clock/barectf*.* +fail/clock/metadata +fail/config/barectf*.* +fail/config/metadata +fail/event/barectf*.* +fail/event/metadata +fail/include/barectf*.* +fail/include/metadata +fail/metadata/barectf*.* +fail/metadata/metadata +fail/stream/barectf*.* +fail/stream/metadata +fail/trace/barectf*.* +fail/trace/metadata +fail/type/barectf*.* +fail/type/metadata +fail/type-enum/barectf*.* +fail/type-enum/metadata +fail/type-float/barectf*.* +fail/type-float/metadata +fail/type-int/barectf*.* +fail/type-int/metadata +fail/type-string/barectf*.* +fail/type-string/metadata +fail/type-struct/barectf*.* +fail/type-struct/metadata +fail/yaml/barectf*.* +fail/yaml/metadata +pass/everything/*.c +pass/everything/*.h +pass/everything/metadata diff --git a/tests/config/common.bash b/tests/config/common.bash new file mode 100644 index 0000000..c6422f4 --- /dev/null +++ b/tests/config/common.bash @@ -0,0 +1,23 @@ +barectf_config_check_fail() { + if [ $status -eq 0 ]; then + echo "Fail: exit code is 0" 1>&2 + return 1 + fi + + pushd "$BATS_TEST_DIRNAME" + local find_output="$(find -iname '*.c' -o -iname '*.h' -o -iname metadata)" + popd + + if [ -n "$find_output" ]; then + echo "Fail: barectf generated files" 1>&2 + return 1 + fi +} + +setup() { + : +} + +teardown() { + rm -f *ctf.c *ctf.h *ctf.o *ctf-bitfield.h metadata +} diff --git a/tests/config/fail/barectf-bitfield.h b/tests/config/fail/barectf-bitfield.h new file mode 100644 index 0000000..4e5d2a0 --- /dev/null +++ b/tests/config/fail/barectf-bitfield.h @@ -0,0 +1,232 @@ +#ifndef _BARECTF_BITFIELD_H +#define _BARECTF_BITFIELD_H + +/* + * BabelTrace + * + * Bitfields read/write functions. + * + * Copyright 2010 - Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include /* C99 5.2.4.2 Numerical limits */ +#include + +#define BARECTF_BYTE_ORDER LITTLE_ENDIAN + +/* We can't shift a int from 32 bit, >> 32 and << 32 on int is undefined */ +#define _barectf_bt_piecewise_rshift(_v, _shift) \ +__extension__ ({ \ + __typeof__(_v) ___v = (_v); \ + __typeof__(_shift) ___shift = (_shift); \ + unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \ + unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \ + \ + for (; sb; sb--) \ + ___v >>= sizeof(___v) * CHAR_BIT - 1; \ + ___v >>= final; \ +}) + +#define _barectf_bt_piecewise_lshift(_v, _shift) \ +__extension__ ({ \ + __typeof__(_v) ___v = (_v); \ + __typeof__(_shift) ___shift = (_shift); \ + unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \ + unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \ + \ + for (; sb; sb--) \ + ___v <<= sizeof(___v) * CHAR_BIT - 1; \ + ___v <<= final; \ +}) + +#define _barectf_bt_is_signed_type(type) ((type) -1 < (type) 0) + +#define _barectf_bt_unsigned_cast(type, v) \ +__extension__ ({ \ + (sizeof(v) < sizeof(type)) ? \ + ((type) (v)) & (~(~(type) 0 << (sizeof(v) * CHAR_BIT))) : \ + (type) (v); \ +}) + +/* + * barectf_bt_bitfield_write - write integer to a bitfield in native endianness + * + * Save integer to the bitfield, which starts at the "start" bit, has "len" + * bits. + * The inside of a bitfield is from high bits to low bits. + * Uses native endianness. + * For unsigned "v", pad MSB with 0 if bitfield is larger than v. + * For signed "v", sign-extend v if bitfield is larger than v. + * + * On little endian, bytes are placed from the less significant to the most + * significant. Also, consecutive bitfields are placed from lower bits to higher + * bits. + * + * On big endian, bytes are places from most significant to less significant. + * Also, consecutive bitfields are placed from higher to lower bits. + */ + +#define _barectf_bt_bitfield_write_le(_ptr, type, _start, _length, _v) \ +do { \ + __typeof__(_v) __v = (_v); \ + type *__ptr = (void *) (_ptr); \ + unsigned long __start = (_start), __length = (_length); \ + type mask, cmask; \ + unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \ + unsigned long start_unit, end_unit, this_unit; \ + unsigned long end, cshift; /* cshift is "complement shift" */ \ + \ + if (!__length) \ + break; \ + \ + end = __start + __length; \ + start_unit = __start / ts; \ + end_unit = (end + (ts - 1)) / ts; \ + \ + /* Trim v high bits */ \ + if (__length < sizeof(__v) * CHAR_BIT) \ + __v &= ~((~(__typeof__(__v)) 0) << __length); \ + \ + /* We can now append v with a simple "or", shift it piece-wise */ \ + this_unit = start_unit; \ + if (start_unit == end_unit - 1) { \ + mask = ~((~(type) 0) << (__start % ts)); \ + if (end % ts) \ + mask |= (~(type) 0) << (end % ts); \ + cmask = (type) __v << (__start % ts); \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + break; \ + } \ + if (__start % ts) { \ + cshift = __start % ts; \ + mask = ~((~(type) 0) << cshift); \ + cmask = (type) __v << cshift; \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + __v = _barectf_bt_piecewise_rshift(__v, ts - cshift); \ + __start += ts - cshift; \ + this_unit++; \ + } \ + for (; this_unit < end_unit - 1; this_unit++) { \ + __ptr[this_unit] = (type) __v; \ + __v = _barectf_bt_piecewise_rshift(__v, ts); \ + __start += ts; \ + } \ + if (end % ts) { \ + mask = (~(type) 0) << (end % ts); \ + cmask = (type) __v; \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + } else \ + __ptr[this_unit] = (type) __v; \ +} while (0) + +#define _barectf_bt_bitfield_write_be(_ptr, type, _start, _length, _v) \ +do { \ + __typeof__(_v) __v = (_v); \ + type *__ptr = (void *) (_ptr); \ + unsigned long __start = (_start), __length = (_length); \ + type mask, cmask; \ + unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \ + unsigned long start_unit, end_unit, this_unit; \ + unsigned long end, cshift; /* cshift is "complement shift" */ \ + \ + if (!__length) \ + break; \ + \ + end = __start + __length; \ + start_unit = __start / ts; \ + end_unit = (end + (ts - 1)) / ts; \ + \ + /* Trim v high bits */ \ + if (__length < sizeof(__v) * CHAR_BIT) \ + __v &= ~((~(__typeof__(__v)) 0) << __length); \ + \ + /* We can now append v with a simple "or", shift it piece-wise */ \ + this_unit = end_unit - 1; \ + if (start_unit == end_unit - 1) { \ + mask = ~((~(type) 0) << ((ts - (end % ts)) % ts)); \ + if (__start % ts) \ + mask |= (~((type) 0)) << (ts - (__start % ts)); \ + cmask = (type) __v << ((ts - (end % ts)) % ts); \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + break; \ + } \ + if (end % ts) { \ + cshift = end % ts; \ + mask = ~((~(type) 0) << (ts - cshift)); \ + cmask = (type) __v << (ts - cshift); \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + __v = _barectf_bt_piecewise_rshift(__v, cshift); \ + end -= cshift; \ + this_unit--; \ + } \ + for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \ + __ptr[this_unit] = (type) __v; \ + __v = _barectf_bt_piecewise_rshift(__v, ts); \ + end -= ts; \ + } \ + if (__start % ts) { \ + mask = (~(type) 0) << (ts - (__start % ts)); \ + cmask = (type) __v; \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + } else \ + __ptr[this_unit] = (type) __v; \ +} while (0) + +/* + * barectf_bt_bitfield_write_le - write integer to a bitfield in little endian + * barectf_bt_bitfield_write_be - write integer to a bitfield in big endian + */ + +#if (BARECTF_BYTE_ORDER == LITTLE_ENDIAN) + +#define barectf_bt_bitfield_write_le(ptr, type, _start, _length, _v) \ + _barectf_bt_bitfield_write_le(ptr, type, _start, _length, _v) + +#define barectf_bt_bitfield_write_be(ptr, type, _start, _length, _v) \ + _barectf_bt_bitfield_write_be(ptr, unsigned char, _start, _length, _v) + +#elif (BARECTF_BYTE_ORDER == BIG_ENDIAN) + +#define barectf_bt_bitfield_write_le(ptr, type, _start, _length, _v) \ + _barectf_bt_bitfield_write_le(ptr, unsigned char, _start, _length, _v) + +#define barectf_bt_bitfield_write_be(ptr, type, _start, _length, _v) \ + _barectf_bt_bitfield_write_be(ptr, type, _start, _length, _v) + +#else /* (BARECTF_BYTE_ORDER == PDP_ENDIAN) */ + +#error "Byte order not supported" + +#endif + +#endif /* _BARECTF_BITFIELD_H */ diff --git a/tests/config/fail/barectf.c b/tests/config/fail/barectf.c new file mode 100644 index 0000000..67ebfea --- /dev/null +++ b/tests/config/fail/barectf.c @@ -0,0 +1,1001 @@ +/* + * The following C code was generated by barectf 2.1.0-dev + * on 2016-03-15T21:29:16.070651. + * + * For more details, see . + */ + +#include +#include +#include + +#include "barectf.h" + +#define _ALIGN(_at, _align) \ + do { \ + (_at) = ((_at) + ((_align) - 1)) & -(_align); \ + } while (0) + +#define _BITS_TO_BYTES(_x) ((_x) >> 3) +#define _BYTES_TO_BITS(_x) ((_x) << 3) + +union f2u { + float f; + uint32_t u; +}; + +union d2u { + double f; + uint64_t u; +}; + +uint32_t barectf_packet_size(void *ctx) +{ + return ((struct barectf_ctx *) ctx)->packet_size; +} + +int barectf_packet_is_full(void *ctx) +{ + struct barectf_ctx *cctx = ctx; + + return cctx->at == cctx->packet_size; +} + +int barectf_packet_is_empty(void *ctx) +{ + struct barectf_ctx *cctx = ctx; + + return cctx->at <= cctx->off_content; +} + +uint32_t barectf_packet_events_discarded(void *ctx) +{ + return ((struct barectf_ctx *) ctx)->events_discarded; +} + +uint8_t *barectf_packet_buf(void *ctx) +{ + return ((struct barectf_ctx *) ctx)->buf; +} + +uint32_t barectf_packet_buf_size(void *ctx) +{ + return _BITS_TO_BYTES(((struct barectf_ctx *) ctx)->packet_size); +} + +void barectf_packet_set_buf(void *ctx, uint8_t *buf, uint32_t buf_size) +{ + struct barectf_ctx *barectf_ctx = ctx; + + barectf_ctx->buf = buf; + barectf_ctx->packet_size = _BYTES_TO_BITS(buf_size); +} + +int barectf_packet_is_open(void *ctx) +{ + return ((struct barectf_ctx *) ctx)->packet_is_open; +} + +static +void _write_cstring(struct barectf_ctx *ctx, const char *src) +{ + uint32_t sz = strlen(src) + 1; + + memcpy(&ctx->buf[_BITS_TO_BYTES(ctx->at)], src, sz); + ctx->at += _BYTES_TO_BITS(sz); +} + +static inline +int _packet_is_full(struct barectf_ctx *ctx) +{ + return barectf_packet_is_full(ctx); +} + +static +int _reserve_event_space(struct barectf_ctx *ctx, uint32_t ev_size) +{ + /* event _cannot_ fit? */ + if (ev_size > (ctx->packet_size - ctx->off_content)) { + ctx->events_discarded++; + + return 0; + } + + /* packet is full? */ + if (barectf_packet_is_full(ctx)) { + /* yes: is back-end full? */ + if (ctx->cbs.is_backend_full(ctx->data)) { + /* yes: discard event */ + ctx->events_discarded++; + + return 0; + } + + /* back-end is not full: open new packet */ + ctx->cbs.open_packet(ctx->data); + } + + /* event fits the current packet? */ + if (ev_size > (ctx->packet_size - ctx->at)) { + /* no: close packet now */ + ctx->cbs.close_packet(ctx->data); + + /* is back-end full? */ + if (ctx->cbs.is_backend_full(ctx->data)) { + /* yes: discard event */ + ctx->events_discarded++; + + return 0; + } + + /* back-end is not full: open new packet */ + ctx->cbs.open_packet(ctx->data); + assert(ev_size <= (ctx->packet_size - ctx->at)); + } + + return 1; +} + +static +void _commit_event(struct barectf_ctx *ctx) +{ + /* is packet full? */ + if (barectf_packet_is_full(ctx)) { + /* yes: close it now */ + ctx->cbs.close_packet(ctx->data); + } +} + +/* initialize context */ +void barectf_init( + void *ctx, + uint8_t *buf, + uint32_t buf_size, + struct barectf_platform_callbacks cbs, + void *data +) +{ + struct barectf_ctx *barectf_ctx = ctx; + barectf_ctx->cbs = cbs; + barectf_ctx->data = data; + barectf_ctx->buf = buf; + barectf_ctx->packet_size = _BYTES_TO_BITS(buf_size); + barectf_ctx->at = 0; + barectf_ctx->events_discarded = 0; + barectf_ctx->packet_is_open = 0; +} + +/* open packet for stream "default" */ +void barectf_default_open_packet( + struct barectf_default_ctx *ctx +) +{ + uint64_t ts = ctx->parent.cbs.default_clock_get_value(ctx->parent.data); + + /* do not open a packet that is already open */ + if (ctx->parent.packet_is_open) { + return; + } + + ctx->parent.at = 0; + + /* trace packet header */ + { + /* align structure */ + _ALIGN(ctx->parent.at, 8); + + /* "magic" field */ + _ALIGN(ctx->parent.at, 8); + barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, 0xc1fc1fc1UL); + (&ctx->parent)->at += 32; + + /* "uuid" field */ + { + static uint8_t uuid[] = { + 127, + 53, + 26, + 32, + 235, + 22, + 17, + 229, + 140, + 48, + 36, + 119, + 3, + 138, + 62, + 196, + }; + + _ALIGN(ctx->parent.at, 8); + memcpy(&ctx->parent.buf[_BITS_TO_BYTES(ctx->parent.at)], uuid, 16); + ctx->parent.at += _BYTES_TO_BITS(16); + } + + /* "stream_id" field */ + _ALIGN(ctx->parent.at, 8); + barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 8, (uint8_t) 0); + (&ctx->parent)->at += 8; + } + + /* stream packet context */ + { + /* align structure */ + _ALIGN(ctx->parent.at, 8); + + /* "timestamp_begin" field */ + _ALIGN(ctx->parent.at, 8); + barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 64, (uint64_t) ts); + (&ctx->parent)->at += 64; + + /* "timestamp_end" field */ + _ALIGN(ctx->parent.at, 8); + ctx->off_spc_timestamp_end = ctx->parent.at; + ctx->parent.at += 64; + + /* "packet_size" field */ + _ALIGN(ctx->parent.at, 8); + barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, (uint32_t) ctx->parent.packet_size); + (&ctx->parent)->at += 32; + + /* "content_size" field */ + _ALIGN(ctx->parent.at, 8); + ctx->off_spc_content_size = ctx->parent.at; + ctx->parent.at += 32; + + /* "events_discarded" field */ + _ALIGN(ctx->parent.at, 8); + ctx->off_spc_events_discarded = ctx->parent.at; + ctx->parent.at += 32; + } + + ctx->parent.off_content = ctx->parent.at; + + /* mark current packet as open */ + ctx->parent.packet_is_open = 1; +} + +/* close packet for stream "default" */ +void barectf_default_close_packet(struct barectf_default_ctx *ctx) +{ + uint64_t ts = ctx->parent.cbs.default_clock_get_value(ctx->parent.data); + + /* do not close a packet that is not open */ + if (!ctx->parent.packet_is_open) { + return; + } + + /* save content size */ + ctx->parent.content_size = ctx->parent.at; + + /* "timestamp_end" field */ + ctx->parent.at = ctx->off_spc_timestamp_end; + barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 64, (uint64_t) ts); + (&ctx->parent)->at += 64; + + /* "content_size" field */ + ctx->parent.at = ctx->off_spc_content_size; + barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, (uint32_t) ctx->parent.content_size); + (&ctx->parent)->at += 32; + + /* "events_discarded" field */ + ctx->parent.at = ctx->off_spc_events_discarded; + barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, (uint32_t) ctx->parent.events_discarded); + (&ctx->parent)->at += 32; + + /* go back to end of packet */ + ctx->parent.at = ctx->parent.packet_size; + + /* mark packet as closed */ + ctx->parent.packet_is_open = 0; +} + +static void _serialize_stream_event_header_default( + struct barectf_ctx *ctx, + uint32_t event_id +) +{ + uint64_t ts = ctx->cbs.default_clock_get_value(ctx->data); + + { + /* align structure */ + _ALIGN(ctx->at, 8); + + /* "timestamp" field */ + _ALIGN(ctx->at, 8); + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 64, (uint64_t) ts); + ctx->at += 64; + + /* "id" field */ + _ALIGN(ctx->at, 8); + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 16, (uint16_t) event_id); + ctx->at += 16; + } + +} + +static uint32_t _get_event_size_default_simple_uint32( + struct barectf_ctx *ctx, + uint32_t ep_value +) +{ + uint32_t at = ctx->at; + + /* stream event header */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "timestamp" field */ + _ALIGN(at, 8); + at += 64; + + /* "id" field */ + _ALIGN(at, 8); + at += 16; + } + + /* event payload */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "value" field */ + _ALIGN(at, 8); + at += 32; + } + + return at - ctx->at; +} + +static void _serialize_event_default_simple_uint32( + struct barectf_ctx *ctx, + uint32_t ep_value +) +{ + /* stream event header */ + _serialize_stream_event_header_default(ctx, 0); + + /* event payload */ + { + /* align structure */ + _ALIGN(ctx->at, 8); + + /* "value" field */ + _ALIGN(ctx->at, 8); + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 32, ep_value); + ctx->at += 32; + } + +} + +/* trace (stream "default", event "simple_uint32") */ +void barectf_default_trace_simple_uint32( + struct barectf_default_ctx *ctx, + uint32_t ep_value +) +{ + uint32_t ev_size; + + /* get event size */ + ev_size = _get_event_size_default_simple_uint32((void *) ctx, ep_value); + + /* do we have enough space to serialize? */ + if (!_reserve_event_space((void *) ctx, ev_size)) { + /* no: forget this */ + return; + } + + /* serialize event */ + _serialize_event_default_simple_uint32((void *) ctx, ep_value); + + /* commit event */ + _commit_event((void *) ctx); +} + +static uint32_t _get_event_size_default_simple_int16( + struct barectf_ctx *ctx, + int16_t ep_value +) +{ + uint32_t at = ctx->at; + + /* stream event header */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "timestamp" field */ + _ALIGN(at, 8); + at += 64; + + /* "id" field */ + _ALIGN(at, 8); + at += 16; + } + + /* event payload */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "value" field */ + _ALIGN(at, 8); + at += 16; + } + + return at - ctx->at; +} + +static void _serialize_event_default_simple_int16( + struct barectf_ctx *ctx, + int16_t ep_value +) +{ + /* stream event header */ + _serialize_stream_event_header_default(ctx, 1); + + /* event payload */ + { + /* align structure */ + _ALIGN(ctx->at, 8); + + /* "value" field */ + _ALIGN(ctx->at, 8); + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 16, ep_value); + ctx->at += 16; + } + +} + +/* trace (stream "default", event "simple_int16") */ +void barectf_default_trace_simple_int16( + struct barectf_default_ctx *ctx, + int16_t ep_value +) +{ + uint32_t ev_size; + + /* get event size */ + ev_size = _get_event_size_default_simple_int16((void *) ctx, ep_value); + + /* do we have enough space to serialize? */ + if (!_reserve_event_space((void *) ctx, ev_size)) { + /* no: forget this */ + return; + } + + /* serialize event */ + _serialize_event_default_simple_int16((void *) ctx, ep_value); + + /* commit event */ + _commit_event((void *) ctx); +} + +static uint32_t _get_event_size_default_simple_float( + struct barectf_ctx *ctx, + float ep_value +) +{ + uint32_t at = ctx->at; + + /* stream event header */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "timestamp" field */ + _ALIGN(at, 8); + at += 64; + + /* "id" field */ + _ALIGN(at, 8); + at += 16; + } + + /* event payload */ + { + /* align structure */ + _ALIGN(at, 32); + + /* "value" field */ + _ALIGN(at, 32); + at += 32; + } + + return at - ctx->at; +} + +static void _serialize_event_default_simple_float( + struct barectf_ctx *ctx, + float ep_value +) +{ + /* stream event header */ + _serialize_stream_event_header_default(ctx, 2); + + /* event payload */ + { + /* align structure */ + _ALIGN(ctx->at, 32); + + /* "value" field */ + _ALIGN(ctx->at, 32); + union f2u f2u; + + f2u.f = ep_value; + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 32, f2u.u); + ctx->at += 32; + } + +} + +/* trace (stream "default", event "simple_float") */ +void barectf_default_trace_simple_float( + struct barectf_default_ctx *ctx, + float ep_value +) +{ + uint32_t ev_size; + + /* get event size */ + ev_size = _get_event_size_default_simple_float((void *) ctx, ep_value); + + /* do we have enough space to serialize? */ + if (!_reserve_event_space((void *) ctx, ev_size)) { + /* no: forget this */ + return; + } + + /* serialize event */ + _serialize_event_default_simple_float((void *) ctx, ep_value); + + /* commit event */ + _commit_event((void *) ctx); +} + +static uint32_t _get_event_size_default_simple_string( + struct barectf_ctx *ctx, + const char * ep_value +) +{ + uint32_t at = ctx->at; + + /* stream event header */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "timestamp" field */ + _ALIGN(at, 8); + at += 64; + + /* "id" field */ + _ALIGN(at, 8); + at += 16; + } + + /* event payload */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "value" field */ + _ALIGN(at, 8); + at += _BYTES_TO_BITS(strlen(ep_value) + 1); + } + + return at - ctx->at; +} + +static void _serialize_event_default_simple_string( + struct barectf_ctx *ctx, + const char * ep_value +) +{ + /* stream event header */ + _serialize_stream_event_header_default(ctx, 3); + + /* event payload */ + { + /* align structure */ + _ALIGN(ctx->at, 8); + + /* "value" field */ + _ALIGN(ctx->at, 8); + _write_cstring(ctx, ep_value); + } + +} + +/* trace (stream "default", event "simple_string") */ +void barectf_default_trace_simple_string( + struct barectf_default_ctx *ctx, + const char * ep_value +) +{ + uint32_t ev_size; + + /* get event size */ + ev_size = _get_event_size_default_simple_string((void *) ctx, ep_value); + + /* do we have enough space to serialize? */ + if (!_reserve_event_space((void *) ctx, ev_size)) { + /* no: forget this */ + return; + } + + /* serialize event */ + _serialize_event_default_simple_string((void *) ctx, ep_value); + + /* commit event */ + _commit_event((void *) ctx); +} + +static uint32_t _get_event_size_default_simple_enum( + struct barectf_ctx *ctx, + uint8_t ep_value +) +{ + uint32_t at = ctx->at; + + /* stream event header */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "timestamp" field */ + _ALIGN(at, 8); + at += 64; + + /* "id" field */ + _ALIGN(at, 8); + at += 16; + } + + /* event payload */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "value" field */ + _ALIGN(at, 8); + at += 8; + } + + return at - ctx->at; +} + +static void _serialize_event_default_simple_enum( + struct barectf_ctx *ctx, + uint8_t ep_value +) +{ + /* stream event header */ + _serialize_stream_event_header_default(ctx, 4); + + /* event payload */ + { + /* align structure */ + _ALIGN(ctx->at, 8); + + /* "value" field */ + _ALIGN(ctx->at, 8); + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 8, ep_value); + ctx->at += 8; + } + +} + +/* trace (stream "default", event "simple_enum") */ +void barectf_default_trace_simple_enum( + struct barectf_default_ctx *ctx, + uint8_t ep_value +) +{ + uint32_t ev_size; + + /* get event size */ + ev_size = _get_event_size_default_simple_enum((void *) ctx, ep_value); + + /* do we have enough space to serialize? */ + if (!_reserve_event_space((void *) ctx, ev_size)) { + /* no: forget this */ + return; + } + + /* serialize event */ + _serialize_event_default_simple_enum((void *) ctx, ep_value); + + /* commit event */ + _commit_event((void *) ctx); +} + +static uint32_t _get_event_size_default_a_few_fields( + struct barectf_ctx *ctx, + int32_t ep_int32, + uint16_t ep_uint16, + double ep_dbl, + const char * ep_str, + uint8_t ep_state +) +{ + uint32_t at = ctx->at; + + /* stream event header */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "timestamp" field */ + _ALIGN(at, 8); + at += 64; + + /* "id" field */ + _ALIGN(at, 8); + at += 16; + } + + /* event payload */ + { + /* align structure */ + _ALIGN(at, 64); + + /* "int32" field */ + _ALIGN(at, 8); + at += 32; + + /* "uint16" field */ + _ALIGN(at, 8); + at += 16; + + /* "dbl" field */ + _ALIGN(at, 64); + at += 64; + + /* "str" field */ + _ALIGN(at, 8); + at += _BYTES_TO_BITS(strlen(ep_str) + 1); + + /* "state" field */ + _ALIGN(at, 8); + at += 8; + } + + return at - ctx->at; +} + +static void _serialize_event_default_a_few_fields( + struct barectf_ctx *ctx, + int32_t ep_int32, + uint16_t ep_uint16, + double ep_dbl, + const char * ep_str, + uint8_t ep_state +) +{ + /* stream event header */ + _serialize_stream_event_header_default(ctx, 5); + + /* event payload */ + { + /* align structure */ + _ALIGN(ctx->at, 64); + + /* "int32" field */ + _ALIGN(ctx->at, 8); + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 32, ep_int32); + ctx->at += 32; + + /* "uint16" field */ + _ALIGN(ctx->at, 8); + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 16, ep_uint16); + ctx->at += 16; + + /* "dbl" field */ + _ALIGN(ctx->at, 64); + union d2u d2u; + + d2u.f = ep_dbl; + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 64, d2u.u); + ctx->at += 64; + + /* "str" field */ + _ALIGN(ctx->at, 8); + _write_cstring(ctx, ep_str); + + /* "state" field */ + _ALIGN(ctx->at, 8); + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 8, ep_state); + ctx->at += 8; + } + +} + +/* trace (stream "default", event "a_few_fields") */ +void barectf_default_trace_a_few_fields( + struct barectf_default_ctx *ctx, + int32_t ep_int32, + uint16_t ep_uint16, + double ep_dbl, + const char * ep_str, + uint8_t ep_state +) +{ + uint32_t ev_size; + + /* get event size */ + ev_size = _get_event_size_default_a_few_fields((void *) ctx, ep_int32, ep_uint16, ep_dbl, ep_str, ep_state); + + /* do we have enough space to serialize? */ + if (!_reserve_event_space((void *) ctx, ev_size)) { + /* no: forget this */ + return; + } + + /* serialize event */ + _serialize_event_default_a_few_fields((void *) ctx, ep_int32, ep_uint16, ep_dbl, ep_str, ep_state); + + /* commit event */ + _commit_event((void *) ctx); +} + +static uint32_t _get_event_size_default_bit_packed_integers( + struct barectf_ctx *ctx, + uint8_t ep_uint1, + int8_t ep_int1, + uint8_t ep_uint2, + int8_t ep_int3, + uint8_t ep_uint4, + int8_t ep_int5, + uint8_t ep_uint6, + int8_t ep_int7, + uint8_t ep_uint8 +) +{ + uint32_t at = ctx->at; + + /* stream event header */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "timestamp" field */ + _ALIGN(at, 8); + at += 64; + + /* "id" field */ + _ALIGN(at, 8); + at += 16; + } + + /* event payload */ + { + /* align structure */ + _ALIGN(at, 8); + + /* "uint1" field */ + at += 1; + + /* "int1" field */ + at += 1; + + /* "uint2" field */ + at += 2; + + /* "int3" field */ + at += 3; + + /* "uint4" field */ + at += 4; + + /* "int5" field */ + at += 5; + + /* "uint6" field */ + at += 6; + + /* "int7" field */ + at += 7; + + /* "uint8" field */ + at += 8; + } + + return at - ctx->at; +} + +static void _serialize_event_default_bit_packed_integers( + struct barectf_ctx *ctx, + uint8_t ep_uint1, + int8_t ep_int1, + uint8_t ep_uint2, + int8_t ep_int3, + uint8_t ep_uint4, + int8_t ep_int5, + uint8_t ep_uint6, + int8_t ep_int7, + uint8_t ep_uint8 +) +{ + /* stream event header */ + _serialize_stream_event_header_default(ctx, 6); + + /* event payload */ + { + /* align structure */ + _ALIGN(ctx->at, 8); + + /* "uint1" field */ + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 1, ep_uint1); + ctx->at += 1; + + /* "int1" field */ + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 1, 1, ep_int1); + ctx->at += 1; + + /* "uint2" field */ + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 2, 2, ep_uint2); + ctx->at += 2; + + /* "int3" field */ + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 4, 3, ep_int3); + ctx->at += 3; + + /* "uint4" field */ + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 7, 4, ep_uint4); + ctx->at += 4; + + /* "int5" field */ + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 3, 5, ep_int5); + ctx->at += 5; + + /* "uint6" field */ + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 6, ep_uint6); + ctx->at += 6; + + /* "int7" field */ + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 6, 7, ep_int7); + ctx->at += 7; + + /* "uint8" field */ + barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 5, 8, ep_uint8); + ctx->at += 8; + } + +} + +/* trace (stream "default", event "bit_packed_integers") */ +void barectf_default_trace_bit_packed_integers( + struct barectf_default_ctx *ctx, + uint8_t ep_uint1, + int8_t ep_int1, + uint8_t ep_uint2, + int8_t ep_int3, + uint8_t ep_uint4, + int8_t ep_int5, + uint8_t ep_uint6, + int8_t ep_int7, + uint8_t ep_uint8 +) +{ + uint32_t ev_size; + + /* get event size */ + ev_size = _get_event_size_default_bit_packed_integers((void *) ctx, ep_uint1, ep_int1, ep_uint2, ep_int3, ep_uint4, ep_int5, ep_uint6, ep_int7, ep_uint8); + + /* do we have enough space to serialize? */ + if (!_reserve_event_space((void *) ctx, ev_size)) { + /* no: forget this */ + return; + } + + /* serialize event */ + _serialize_event_default_bit_packed_integers((void *) ctx, ep_uint1, ep_int1, ep_uint2, ep_int3, ep_uint4, ep_int5, ep_uint6, ep_int7, ep_uint8); + + /* commit event */ + _commit_event((void *) ctx); +} diff --git a/tests/config/fail/barectf.h b/tests/config/fail/barectf.h new file mode 100644 index 0000000..3f75102 --- /dev/null +++ b/tests/config/fail/barectf.h @@ -0,0 +1,158 @@ +#ifndef _BARECTF_H +#define _BARECTF_H + +/* + * The following C code was generated by barectf 2.1.0-dev + * on 2016-03-15T21:29:16.069818. + * + * For more details, see . + */ + +#include + +#include "barectf-bitfield.h" + +struct barectf_ctx; + +uint32_t barectf_packet_size(void *ctx); +int barectf_packet_is_full(void *ctx); +int barectf_packet_is_empty(void *ctx); +uint32_t barectf_packet_events_discarded(void *ctx); +uint8_t *barectf_packet_buf(void *ctx); +void barectf_packet_set_buf(void *ctx, uint8_t *buf, uint32_t buf_size); +uint32_t barectf_packet_buf_size(void *ctx); +int barectf_packet_is_open(void *ctx); + +/* barectf platform callbacks */ +struct barectf_platform_callbacks { + /* clock callbacks */ + uint64_t (*default_clock_get_value)(void *); + + /* is back-end full? */ + int (*is_backend_full)(void *); + + /* open packet */ + void (*open_packet)(void *); + + /* close packet */ + void (*close_packet)(void *); +}; + +/* common barectf context */ +struct barectf_ctx { + /* platform callbacks */ + struct barectf_platform_callbacks cbs; + + /* platform data (passed to callbacks) */ + void *data; + + /* output buffer (will contain a CTF binary packet) */ + uint8_t *buf; + + /* packet size in bits */ + uint32_t packet_size; + + /* content size in bits */ + uint32_t content_size; + + /* current position from beginning of packet in bits */ + uint32_t at; + + /* packet header + context size (content offset) */ + uint32_t off_content; + + /* events discarded */ + uint32_t events_discarded; + + /* current packet is opened */ + int packet_is_open; +}; + +/* context for stream "default" */ +struct barectf_default_ctx { + /* parent */ + struct barectf_ctx parent; + + /* config-specific members follow */ + uint32_t off_tph_magic; + uint32_t off_tph_uuid; + uint32_t off_tph_stream_id; + uint32_t off_spc_timestamp_begin; + uint32_t off_spc_timestamp_end; + uint32_t off_spc_packet_size; + uint32_t off_spc_content_size; + uint32_t off_spc_events_discarded; +}; + +/* initialize context */ +void barectf_init( + void *ctx, + uint8_t *buf, + uint32_t buf_size, + struct barectf_platform_callbacks cbs, + void *data +); + +/* open packet for stream "default" */ +void barectf_default_open_packet( + struct barectf_default_ctx *ctx +); + +/* close packet for stream "default" */ +void barectf_default_close_packet(struct barectf_default_ctx *ctx); + +/* trace (stream "default", event "simple_uint32") */ +void barectf_default_trace_simple_uint32( + struct barectf_default_ctx *ctx, + uint32_t ep_value +); + +/* trace (stream "default", event "simple_int16") */ +void barectf_default_trace_simple_int16( + struct barectf_default_ctx *ctx, + int16_t ep_value +); + +/* trace (stream "default", event "simple_float") */ +void barectf_default_trace_simple_float( + struct barectf_default_ctx *ctx, + float ep_value +); + +/* trace (stream "default", event "simple_string") */ +void barectf_default_trace_simple_string( + struct barectf_default_ctx *ctx, + const char * ep_value +); + +/* trace (stream "default", event "simple_enum") */ +void barectf_default_trace_simple_enum( + struct barectf_default_ctx *ctx, + uint8_t ep_value +); + +/* trace (stream "default", event "a_few_fields") */ +void barectf_default_trace_a_few_fields( + struct barectf_default_ctx *ctx, + int32_t ep_int32, + uint16_t ep_uint16, + double ep_dbl, + const char * ep_str, + uint8_t ep_state +); + +/* trace (stream "default", event "bit_packed_integers") */ +void barectf_default_trace_bit_packed_integers( + struct barectf_default_ctx *ctx, + uint8_t ep_uint1, + int8_t ep_int1, + uint8_t ep_uint2, + int8_t ep_int3, + uint8_t ep_uint4, + int8_t ep_int5, + uint8_t ep_uint6, + int8_t ep_int7, + uint8_t ep_uint8 +); + +#endif /* _BARECTF_H */ \ No newline at end of file diff --git a/tests/config/fail/clock/absolute-invalid-type.yaml b/tests/config/fail/clock/absolute-invalid-type.yaml new file mode 100644 index 0000000..b30b0b5 --- /dev/null +++ b/tests/config/fail/clock/absolute-invalid-type.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + absolute: [] diff --git a/tests/config/fail/clock/description-invalid-type.yaml b/tests/config/fail/clock/description-invalid-type.yaml new file mode 100644 index 0000000..08cb5a0 --- /dev/null +++ b/tests/config/fail/clock/description-invalid-type.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + description: 23 diff --git a/tests/config/fail/clock/ec-invalid-type.yaml b/tests/config/fail/clock/ec-invalid-type.yaml new file mode 100644 index 0000000..e2dc63a --- /dev/null +++ b/tests/config/fail/clock/ec-invalid-type.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + error-cycles: string diff --git a/tests/config/fail/clock/ec-invalid.yaml b/tests/config/fail/clock/ec-invalid.yaml new file mode 100644 index 0000000..42e562d --- /dev/null +++ b/tests/config/fail/clock/ec-invalid.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + error-cycles: -17 diff --git a/tests/config/fail/clock/fail.bats b/tests/config/fail/clock/fail.bats new file mode 100644 index 0000000..1938051 --- /dev/null +++ b/tests/config/fail/clock/fail.bats @@ -0,0 +1,89 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in clock object makes barectf fail' { + barectf_assert_file_exists unknown-prop.yaml + barectf_config_check_fail +} + +@test 'wrong "freq" property type in clock object makes barectf fail' { + barectf_assert_file_exists freq-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "freq" property (0) in clock object makes barectf fail' { + barectf_assert_file_exists freq-0.yaml + barectf_config_check_fail +} + +@test 'invalid "freq" property (negative) in clock object makes barectf fail' { + barectf_assert_file_exists freq-neg.yaml + barectf_config_check_fail +} + +@test 'wrong "description" property type in clock object makes barectf fail' { + barectf_assert_file_exists description-invalid-type.yaml + barectf_config_check_fail +} + +@test 'wrong "uuid" property type in clock object makes barectf fail' { + barectf_assert_file_exists uuid-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "uuid" property in clock object makes barectf fail' { + barectf_assert_file_exists uuid-invalid.yaml + barectf_config_check_fail +} + +@test 'wrong "error-cycles" property type in clock object makes barectf fail' { + barectf_assert_file_exists ec-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "error-cycles" property in clock object makes barectf fail' { + barectf_assert_file_exists ec-invalid.yaml + barectf_config_check_fail +} + +@test 'wrong "offset" property type in clock object makes barectf fail' { + barectf_assert_file_exists offset-invalid-type.yaml + barectf_config_check_fail +} + +@test 'wrong "absolute" property type in clock object makes barectf fail' { + barectf_assert_file_exists absolute-invalid-type.yaml + barectf_config_check_fail +} + +@test 'unknown property in clock offset object makes barectf fail' { + barectf_assert_file_exists offset-unknown-prop.yaml + barectf_config_check_fail +} + +@test 'wrong "seconds" property type in clock offset object makes barectf fail' { + barectf_assert_file_exists offset-seconds-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "seconds" property in clock offset object makes barectf fail' { + barectf_assert_file_exists offset-seconds-neg.yaml + barectf_config_check_fail +} + +@test 'wrong "cycles" property type in clock offset object makes barectf fail' { + barectf_assert_file_exists offset-cycles-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "cycles" property in clock offset object makes barectf fail' { + barectf_assert_file_exists offset-cycles-neg.yaml + barectf_config_check_fail +} + +@test 'wrong "$return-ctype" property type in clock object makes barectf fail' { + barectf_assert_file_exists rct-invalid-type.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/clock/freq-0.yaml b/tests/config/fail/clock/freq-0.yaml new file mode 100644 index 0000000..f97183e --- /dev/null +++ b/tests/config/fail/clock/freq-0.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + freq: 0 diff --git a/tests/config/fail/clock/freq-invalid-type.yaml b/tests/config/fail/clock/freq-invalid-type.yaml new file mode 100644 index 0000000..051333f --- /dev/null +++ b/tests/config/fail/clock/freq-invalid-type.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + freq: string diff --git a/tests/config/fail/clock/freq-neg.yaml b/tests/config/fail/clock/freq-neg.yaml new file mode 100644 index 0000000..3b24285 --- /dev/null +++ b/tests/config/fail/clock/freq-neg.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + freq: -12 diff --git a/tests/config/fail/clock/offset-cycles-invalid-type.yaml b/tests/config/fail/clock/offset-cycles-invalid-type.yaml new file mode 100644 index 0000000..e92d0a5 --- /dev/null +++ b/tests/config/fail/clock/offset-cycles-invalid-type.yaml @@ -0,0 +1,27 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + offset: + cycles: string diff --git a/tests/config/fail/clock/offset-cycles-neg.yaml b/tests/config/fail/clock/offset-cycles-neg.yaml new file mode 100644 index 0000000..c90ec67 --- /dev/null +++ b/tests/config/fail/clock/offset-cycles-neg.yaml @@ -0,0 +1,27 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + offset: + cycles: -17 diff --git a/tests/config/fail/clock/offset-invalid-type.yaml b/tests/config/fail/clock/offset-invalid-type.yaml new file mode 100644 index 0000000..c63d514 --- /dev/null +++ b/tests/config/fail/clock/offset-invalid-type.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + offset: 23 diff --git a/tests/config/fail/clock/offset-seconds-invalid-type.yaml b/tests/config/fail/clock/offset-seconds-invalid-type.yaml new file mode 100644 index 0000000..07ef954 --- /dev/null +++ b/tests/config/fail/clock/offset-seconds-invalid-type.yaml @@ -0,0 +1,27 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + offset: + seconds: string diff --git a/tests/config/fail/clock/offset-seconds-neg.yaml b/tests/config/fail/clock/offset-seconds-neg.yaml new file mode 100644 index 0000000..52dc956 --- /dev/null +++ b/tests/config/fail/clock/offset-seconds-neg.yaml @@ -0,0 +1,27 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + offset: + seconds: -17 diff --git a/tests/config/fail/clock/offset-unknown-prop.yaml b/tests/config/fail/clock/offset-unknown-prop.yaml new file mode 100644 index 0000000..8c14bd2 --- /dev/null +++ b/tests/config/fail/clock/offset-unknown-prop.yaml @@ -0,0 +1,27 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + offset: + unknown: false diff --git a/tests/config/fail/clock/rct-invalid-type.yaml b/tests/config/fail/clock/rct-invalid-type.yaml new file mode 100644 index 0000000..f8cb0f4 --- /dev/null +++ b/tests/config/fail/clock/rct-invalid-type.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + $return-ctype: 23 diff --git a/tests/config/fail/clock/unknown-prop.yaml b/tests/config/fail/clock/unknown-prop.yaml new file mode 100644 index 0000000..5d964b0 --- /dev/null +++ b/tests/config/fail/clock/unknown-prop.yaml @@ -0,0 +1,27 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + freq: 1000 + unknown: false diff --git a/tests/config/fail/clock/uuid-invalid-type.yaml b/tests/config/fail/clock/uuid-invalid-type.yaml new file mode 100644 index 0000000..5d6e140 --- /dev/null +++ b/tests/config/fail/clock/uuid-invalid-type.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + uuid: -17 diff --git a/tests/config/fail/clock/uuid-invalid.yaml b/tests/config/fail/clock/uuid-invalid.yaml new file mode 100644 index 0000000..889a007 --- /dev/null +++ b/tests/config/fail/clock/uuid-invalid.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + my_clock: + uuid: zoom diff --git a/tests/config/fail/config/fail.bats b/tests/config/fail/config/fail.bats new file mode 100644 index 0000000..310373c --- /dev/null +++ b/tests/config/fail/config/fail.bats @@ -0,0 +1,49 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in config object makes barectf fail' { + barectf_assert_file_exists unknown-prop.yaml + barectf_config_check_fail +} + +@test 'no "version" property in config object makes barectf fail' { + barectf_assert_file_exists version-no.yaml + barectf_config_check_fail +} + +@test 'wrong "version" property type in config object makes barectf fail' { + barectf_assert_file_exists version-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "version" property (1.9) in config object makes barectf fail' { + barectf_assert_file_exists version-invalid-19.yaml + barectf_config_check_fail +} + +@test 'invalid "version" property (2.2) in config object makes barectf fail' { + barectf_assert_file_exists version-invalid-22.yaml + barectf_config_check_fail +} + +@test 'wrong "prefix" property type in config object makes barectf fail' { + barectf_assert_file_exists prefix-invalid-type.yaml + barectf_config_check_fail +} + +@test 'no valid C identifier in "prefix" property type in config object makes barectf fail' { + barectf_assert_file_exists prefix-invalid-identifier.yaml + barectf_config_check_fail +} + +@test 'no "metadata" property in config object makes barectf fail' { + barectf_assert_file_exists metadata-no.yaml + barectf_config_check_fail +} + +@test 'wrong "metadata" property type in config object makes barectf fail' { + barectf_assert_file_exists metadata-invalid-type.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/config/metadata-invalid-type.yaml b/tests/config/fail/config/metadata-invalid-type.yaml new file mode 100644 index 0000000..0a5ec6b --- /dev/null +++ b/tests/config/fail/config/metadata-invalid-type.yaml @@ -0,0 +1,3 @@ +version: '2.1' +metadata: 23 + diff --git a/tests/config/fail/config/metadata-no.yaml b/tests/config/fail/config/metadata-no.yaml new file mode 100644 index 0000000..045fdea --- /dev/null +++ b/tests/config/fail/config/metadata-no.yaml @@ -0,0 +1 @@ +version: '2.1' diff --git a/tests/config/fail/config/prefix-invalid-identifier.yaml b/tests/config/fail/config/prefix-invalid-identifier.yaml new file mode 100644 index 0000000..09bc612 --- /dev/null +++ b/tests/config/fail/config/prefix-invalid-identifier.yaml @@ -0,0 +1,24 @@ +version: '2.1' +prefix: 'some prefix' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/config/prefix-invalid-type.yaml b/tests/config/fail/config/prefix-invalid-type.yaml new file mode 100644 index 0000000..bfdf493 --- /dev/null +++ b/tests/config/fail/config/prefix-invalid-type.yaml @@ -0,0 +1,24 @@ +version: '2.1' +prefix: -21 +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/config/unknown-prop.yaml b/tests/config/fail/config/unknown-prop.yaml new file mode 100644 index 0000000..88a165a --- /dev/null +++ b/tests/config/fail/config/unknown-prop.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 +unknown: false diff --git a/tests/config/fail/config/version-invalid-19.yaml b/tests/config/fail/config/version-invalid-19.yaml new file mode 100644 index 0000000..b8e8241 --- /dev/null +++ b/tests/config/fail/config/version-invalid-19.yaml @@ -0,0 +1,23 @@ +version: '1.9' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/config/version-invalid-22.yaml b/tests/config/fail/config/version-invalid-22.yaml new file mode 100644 index 0000000..1907e8e --- /dev/null +++ b/tests/config/fail/config/version-invalid-22.yaml @@ -0,0 +1,23 @@ +version: '2.2' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/config/version-invalid-type.yaml b/tests/config/fail/config/version-invalid-type.yaml new file mode 100644 index 0000000..4b4d67a --- /dev/null +++ b/tests/config/fail/config/version-invalid-type.yaml @@ -0,0 +1,23 @@ +version: 2.1 +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/config/version-no.yaml b/tests/config/fail/config/version-no.yaml new file mode 100644 index 0000000..223bd75 --- /dev/null +++ b/tests/config/fail/config/version-no.yaml @@ -0,0 +1,22 @@ +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/event/ct-invalid-type.yaml b/tests/config/fail/event/ct-invalid-type.yaml new file mode 100644 index 0000000..0f5af75 --- /dev/null +++ b/tests/config/fail/event/ct-invalid-type.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + context-type: 23 + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/event/ct-not-struct.yaml b/tests/config/fail/event/ct-not-struct.yaml new file mode 100644 index 0000000..2052a76 --- /dev/null +++ b/tests/config/fail/event/ct-not-struct.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + context-type: + class: int + size: 8 + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/event/fail.bats b/tests/config/fail/event/fail.bats new file mode 100644 index 0000000..0722f01 --- /dev/null +++ b/tests/config/fail/event/fail.bats @@ -0,0 +1,49 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in event object makes barectf fail' { + barectf_assert_file_exists unknown-prop.yaml + barectf_config_check_fail +} + +@test 'wrong "log-level" property type in event object makes barectf fail' { + barectf_assert_file_exists ll-invalid-type.yaml + barectf_config_check_fail +} + +@test 'non existing log level name as "log-level" property value in event object makes barectf fail' { + barectf_assert_file_exists ll-non-existing.yaml + barectf_config_check_fail +} + +@test 'wrong "context-type" property type in event object makes barectf fail' { + barectf_assert_file_exists ct-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "context-type" property field type (not a structure) in event object makes barectf fail' { + barectf_assert_file_exists ct-not-struct.yaml + barectf_config_check_fail +} + +@test 'wrong "payload-type" property type in event object makes barectf fail' { + barectf_assert_file_exists pt-invalid-type.yaml + barectf_config_check_fail +} + +@test 'no "payload-type" property in event object makes barectf fail' { + barectf_assert_file_exists pt-no.yaml + barectf_config_check_fail +} + +@test 'invalid "payload-type" property field type (not a structure) in event object makes barectf fail' { + barectf_assert_file_exists pt-not-struct.yaml + barectf_config_check_fail +} + +@test 'empty struct type as "payload-type" property in event object makes barectf fail' { + barectf_assert_file_exists pt-empty.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/event/ll-invalid-type.yaml b/tests/config/fail/event/ll-invalid-type.yaml new file mode 100644 index 0000000..aec9175 --- /dev/null +++ b/tests/config/fail/event/ll-invalid-type.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + log-level: true + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/event/ll-non-existing.yaml b/tests/config/fail/event/ll-non-existing.yaml new file mode 100644 index 0000000..a6381d5 --- /dev/null +++ b/tests/config/fail/event/ll-non-existing.yaml @@ -0,0 +1,27 @@ +version: '2.1' +metadata: + $log-levels: + EMERG: 0 + WARNING: 23 + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + log-level: EME + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/event/pt-invalid-type.yaml b/tests/config/fail/event/pt-invalid-type.yaml new file mode 100644 index 0000000..bc58c2a --- /dev/null +++ b/tests/config/fail/event/pt-invalid-type.yaml @@ -0,0 +1,18 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: -17 diff --git a/tests/config/fail/event/pt-no.yaml b/tests/config/fail/event/pt-no.yaml new file mode 100644 index 0000000..3cf2693 --- /dev/null +++ b/tests/config/fail/event/pt-no.yaml @@ -0,0 +1,21 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + context-type: + class: struct + fields: + allo: uint16 diff --git a/tests/config/fail/event/pt-not-struct.yaml b/tests/config/fail/event/pt-not-struct.yaml new file mode 100644 index 0000000..e20436a --- /dev/null +++ b/tests/config/fail/event/pt-not-struct.yaml @@ -0,0 +1,20 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + diff --git a/tests/config/fail/event/unknown-prop.yaml b/tests/config/fail/event/unknown-prop.yaml new file mode 100644 index 0000000..2b66200 --- /dev/null +++ b/tests/config/fail/event/unknown-prop.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + unknown: false + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/include/cycle-sym.yaml b/tests/config/fail/include/cycle-sym.yaml new file mode 100644 index 0000000..2577098 --- /dev/null +++ b/tests/config/fail/include/cycle-sym.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + $include: inc-recursive-sym1.yaml + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/include/cycle.yaml b/tests/config/fail/include/cycle.yaml new file mode 100644 index 0000000..d25b74f --- /dev/null +++ b/tests/config/fail/include/cycle.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + $include: inc-recursive1.yaml + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/include/fail.bats b/tests/config/fail/include/fail.bats new file mode 100644 index 0000000..51a96d4 --- /dev/null +++ b/tests/config/fail/include/fail.bats @@ -0,0 +1,42 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'wrong "$include" property type makes barectf fail' { + barectf_assert_file_exists invalid-type.yaml + barectf_config_check_fail +} + +@test 'non-existing file in "$include" property (string) makes barectf fail' { + barectf_assert_file_exists file-not-found.yaml + barectf_config_check_fail +} + +@test 'non-existing absolute file in "$include" property (string) makes barectf fail' { + barectf_assert_file_exists file-not-found-abs.yaml + barectf_config_check_fail +} + +@test 'non-existing file in "$include" property (array) makes barectf fail' { + barectf_assert_file_exists file-not-found-in-array.yaml + barectf_config_check_fail +} + +@test 'non-existing file in "$include" property (recursive) makes barectf fail' { + barectf_assert_file_exists file-not-found-recursive.yaml + barectf_config_check_fail +} + +@test 'cycle in include graph makes barectf fail' { + barectf_assert_file_exists cycle.yaml + barectf_config_check_fail +} + +@test 'cycle in include graph (with a symbolic link) makes barectf fail' { + local symlink="$BATS_TEST_DIRNAME/inc-recursive-sym3.yaml" + ln -fs inc-recursive-sym1.yaml "$symlink" + barectf_assert_file_exists cycle-sym.yaml + barectf_config_check_fail + rm -f "$symlink" +} diff --git a/tests/config/fail/include/file-not-found-abs.yaml b/tests/config/fail/include/file-not-found-abs.yaml new file mode 100644 index 0000000..1ff5aa6 --- /dev/null +++ b/tests/config/fail/include/file-not-found-abs.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + $include: /path/to/not/found + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/include/file-not-found-in-array.yaml b/tests/config/fail/include/file-not-found-in-array.yaml new file mode 100644 index 0000000..028ff6a --- /dev/null +++ b/tests/config/fail/include/file-not-found-in-array.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + $include: + - inc-empty.yaml + - yes.yaml + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/include/file-not-found-recursive.yaml b/tests/config/fail/include/file-not-found-recursive.yaml new file mode 100644 index 0000000..ee5d0cf --- /dev/null +++ b/tests/config/fail/include/file-not-found-recursive.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + $include: inc-inc-not-found.yaml + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/include/file-not-found.yaml b/tests/config/fail/include/file-not-found.yaml new file mode 100644 index 0000000..044060c --- /dev/null +++ b/tests/config/fail/include/file-not-found.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + $include: yes.yaml + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/include/inc-empty.yaml b/tests/config/fail/include/inc-empty.yaml new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tests/config/fail/include/inc-empty.yaml @@ -0,0 +1 @@ +{} diff --git a/tests/config/fail/include/inc-inc-not-found.yaml b/tests/config/fail/include/inc-inc-not-found.yaml new file mode 100644 index 0000000..063266d --- /dev/null +++ b/tests/config/fail/include/inc-inc-not-found.yaml @@ -0,0 +1 @@ +$include: yes.yaml diff --git a/tests/config/fail/include/inc-recursive-sym1.yaml b/tests/config/fail/include/inc-recursive-sym1.yaml new file mode 100644 index 0000000..f9823d5 --- /dev/null +++ b/tests/config/fail/include/inc-recursive-sym1.yaml @@ -0,0 +1 @@ +$include: inc-recursive-sym2.yaml diff --git a/tests/config/fail/include/inc-recursive-sym2.yaml b/tests/config/fail/include/inc-recursive-sym2.yaml new file mode 100644 index 0000000..93e2eb2 --- /dev/null +++ b/tests/config/fail/include/inc-recursive-sym2.yaml @@ -0,0 +1 @@ +$include: inc-recursive-sym3.yaml diff --git a/tests/config/fail/include/inc-recursive1.yaml b/tests/config/fail/include/inc-recursive1.yaml new file mode 100644 index 0000000..7245cb8 --- /dev/null +++ b/tests/config/fail/include/inc-recursive1.yaml @@ -0,0 +1 @@ +$include: inc-recursive2.yaml diff --git a/tests/config/fail/include/inc-recursive2.yaml b/tests/config/fail/include/inc-recursive2.yaml new file mode 100644 index 0000000..78f7180 --- /dev/null +++ b/tests/config/fail/include/inc-recursive2.yaml @@ -0,0 +1 @@ +$include: inc-recursive3.yaml diff --git a/tests/config/fail/include/inc-recursive3.yaml b/tests/config/fail/include/inc-recursive3.yaml new file mode 100644 index 0000000..3312b46 --- /dev/null +++ b/tests/config/fail/include/inc-recursive3.yaml @@ -0,0 +1 @@ +$include: inc-recursive1.yaml diff --git a/tests/config/fail/include/include-include-replace.yaml b/tests/config/fail/include/include-include-replace.yaml new file mode 100644 index 0000000..ebcd432 --- /dev/null +++ b/tests/config/fail/include/include-include-replace.yaml @@ -0,0 +1,25 @@ +version: '2.1' +metadata: + $include: inc-empty.yaml + $include-replace: inc-empty.yaml + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/include/invalid-type.yaml b/tests/config/fail/include/invalid-type.yaml new file mode 100644 index 0000000..93824d7 --- /dev/null +++ b/tests/config/fail/include/invalid-type.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + $include: 23 + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/include/replace-file-not-found-in-array.yaml b/tests/config/fail/include/replace-file-not-found-in-array.yaml new file mode 100644 index 0000000..a0b3d37 --- /dev/null +++ b/tests/config/fail/include/replace-file-not-found-in-array.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + $include-replace: + - inc-empty.yaml + - yes.yaml + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/include/replace-file-not-found.yaml b/tests/config/fail/include/replace-file-not-found.yaml new file mode 100644 index 0000000..0bedeb2 --- /dev/null +++ b/tests/config/fail/include/replace-file-not-found.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + $include-replace: yes.yaml + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/metadata/clocks-invalid-type.yaml b/tests/config/fail/metadata/clocks-invalid-type.yaml new file mode 100644 index 0000000..278b6ee --- /dev/null +++ b/tests/config/fail/metadata/clocks-invalid-type.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: 23 diff --git a/tests/config/fail/metadata/clocks-key-invalid-identifier.yaml b/tests/config/fail/metadata/clocks-key-invalid-identifier.yaml new file mode 100644 index 0000000..a20e553 --- /dev/null +++ b/tests/config/fail/metadata/clocks-key-invalid-identifier.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + clocks: + 'some clock': + freq: 1000 diff --git a/tests/config/fail/metadata/env-invalid-type.yaml b/tests/config/fail/metadata/env-invalid-type.yaml new file mode 100644 index 0000000..9c8ee8c --- /dev/null +++ b/tests/config/fail/metadata/env-invalid-type.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + env: 17 diff --git a/tests/config/fail/metadata/env-key-invalid-identifier.yaml b/tests/config/fail/metadata/env-key-invalid-identifier.yaml new file mode 100644 index 0000000..09c0b47 --- /dev/null +++ b/tests/config/fail/metadata/env-key-invalid-identifier.yaml @@ -0,0 +1,25 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + env: + 'yes sir miller': bug diff --git a/tests/config/fail/metadata/env-value-invalid-type.yaml b/tests/config/fail/metadata/env-value-invalid-type.yaml new file mode 100644 index 0000000..b6980b0 --- /dev/null +++ b/tests/config/fail/metadata/env-value-invalid-type.yaml @@ -0,0 +1,27 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + env: + yes-sir-miller: + - a + - b diff --git a/tests/config/fail/metadata/fail.bats b/tests/config/fail/metadata/fail.bats new file mode 100644 index 0000000..46d6371 --- /dev/null +++ b/tests/config/fail/metadata/fail.bats @@ -0,0 +1,84 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in metadata object makes barectf fail' { + barectf_assert_file_exists unknown-prop.yaml + barectf_config_check_fail +} + +@test 'wrong "env" property type in metadata object makes barectf fail' { + barectf_assert_file_exists env-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "env" key (invalid C identifier) in metadata object makes barectf fail' { + barectf_assert_file_exists env-key-invalid-identifier.yaml + barectf_config_check_fail +} + +@test 'invalid "env" value (not an int/string) in metadata object makes barectf fail' { + barectf_assert_file_exists env-value-invalid-type.yaml + barectf_config_check_fail +} + +@test 'wrong "clocks" property type in metadata object makes barectf fail' { + barectf_assert_file_exists clocks-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "clocks" key (invalid C identifier) in metadata object makes barectf fail' { + barectf_assert_file_exists clocks-key-invalid-identifier.yaml + barectf_config_check_fail +} + +@test 'wrong "$log-levels" property type in metadata object makes barectf fail' { + barectf_assert_file_exists ll-invalid-type.yaml + barectf_config_check_fail +} + +@test 'wrong "$log-levels" property value type in metadata object makes barectf fail' { + barectf_assert_file_exists ll-value-invalid-type.yaml + barectf_config_check_fail +} + +@test 'wrong "type-aliases" property type in metadata object makes barectf fail' { + barectf_assert_file_exists ta-invalid-type.yaml + barectf_config_check_fail +} + +@test 'no "trace" property in metadata object makes barectf fail' { + barectf_assert_file_exists trace-no.yaml + barectf_config_check_fail +} + +@test 'wrong "trace" property type in metadata object makes barectf fail' { + barectf_assert_file_exists trace-invalid-type.yaml + barectf_config_check_fail +} + +@test 'empty "trace" property in metadata object makes barectf fail' { + barectf_assert_file_exists trace-empty.yaml + barectf_config_check_fail +} + +@test 'no "streams" property in metadata object makes barectf fail' { + barectf_assert_file_exists streams-no.yaml + barectf_config_check_fail +} + +@test 'wrong "streams" property type in metadata object makes barectf fail' { + barectf_assert_file_exists streams-invalid-type.yaml + barectf_config_check_fail +} + +@test 'empty "streams" property in metadata object makes barectf fail' { + barectf_assert_file_exists streams-empty.yaml + barectf_config_check_fail +} + +@test 'invalid "streams" key (invalid C identifier) in metadata object makes barectf fail' { + barectf_assert_file_exists streams-key-invalid-identifier.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/metadata/ll-invalid-type.yaml b/tests/config/fail/metadata/ll-invalid-type.yaml new file mode 100644 index 0000000..758c6a4 --- /dev/null +++ b/tests/config/fail/metadata/ll-invalid-type.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + $log-levels: hello diff --git a/tests/config/fail/metadata/ll-value-invalid-type.yaml b/tests/config/fail/metadata/ll-value-invalid-type.yaml new file mode 100644 index 0000000..803548b --- /dev/null +++ b/tests/config/fail/metadata/ll-value-invalid-type.yaml @@ -0,0 +1,25 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + $log-levels: + 'yes sir miller': meow diff --git a/tests/config/fail/metadata/streams-empty.yaml b/tests/config/fail/metadata/streams-empty.yaml new file mode 100644 index 0000000..8d7f4da --- /dev/null +++ b/tests/config/fail/metadata/streams-empty.yaml @@ -0,0 +1,5 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: {} diff --git a/tests/config/fail/metadata/streams-invalid-type.yaml b/tests/config/fail/metadata/streams-invalid-type.yaml new file mode 100644 index 0000000..dfe9509 --- /dev/null +++ b/tests/config/fail/metadata/streams-invalid-type.yaml @@ -0,0 +1,9 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: -17 diff --git a/tests/config/fail/metadata/streams-key-invalid-identifier.yaml b/tests/config/fail/metadata/streams-key-invalid-identifier.yaml new file mode 100644 index 0000000..05fa7c3 --- /dev/null +++ b/tests/config/fail/metadata/streams-key-invalid-identifier.yaml @@ -0,0 +1,23 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + 'some stream': + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/metadata/streams-no.yaml b/tests/config/fail/metadata/streams-no.yaml new file mode 100644 index 0000000..284283d --- /dev/null +++ b/tests/config/fail/metadata/streams-no.yaml @@ -0,0 +1,4 @@ +version: '2.1' +metadata: + trace: + byte-order: le diff --git a/tests/config/fail/metadata/ta-invalid-type.yaml b/tests/config/fail/metadata/ta-invalid-type.yaml new file mode 100644 index 0000000..59d386a --- /dev/null +++ b/tests/config/fail/metadata/ta-invalid-type.yaml @@ -0,0 +1,23 @@ +version: '2.1' +metadata: + type-aliases: + - uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/metadata/trace-empty.yaml b/tests/config/fail/metadata/trace-empty.yaml new file mode 100644 index 0000000..86dda3b --- /dev/null +++ b/tests/config/fail/metadata/trace-empty.yaml @@ -0,0 +1,22 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: {} + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/metadata/trace-invalid-type.yaml b/tests/config/fail/metadata/trace-invalid-type.yaml new file mode 100644 index 0000000..d73c1e2 --- /dev/null +++ b/tests/config/fail/metadata/trace-invalid-type.yaml @@ -0,0 +1,22 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: switch + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/metadata/trace-no.yaml b/tests/config/fail/metadata/trace-no.yaml new file mode 100644 index 0000000..6c5e3ae --- /dev/null +++ b/tests/config/fail/metadata/trace-no.yaml @@ -0,0 +1,17 @@ +version: '2.1' +metadata: + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/metadata/unknown-prop.yaml b/tests/config/fail/metadata/unknown-prop.yaml new file mode 100644 index 0000000..8d178db --- /dev/null +++ b/tests/config/fail/metadata/unknown-prop.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + unknown: false diff --git a/tests/config/fail/stream/ect-invalid-type.yaml b/tests/config/fail/stream/ect-invalid-type.yaml new file mode 100644 index 0000000..ce270d6 --- /dev/null +++ b/tests/config/fail/stream/ect-invalid-type.yaml @@ -0,0 +1,19 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + event-context-type: 23 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/ect-not-struct.yaml b/tests/config/fail/stream/ect-not-struct.yaml new file mode 100644 index 0000000..4caaf38 --- /dev/null +++ b/tests/config/fail/stream/ect-not-struct.yaml @@ -0,0 +1,20 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + event-context-type: + class: string + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/eht-id-no-multiple-events.yaml b/tests/config/fail/stream/eht-id-no-multiple-events.yaml new file mode 100644 index 0000000..33753b6 --- /dev/null +++ b/tests/config/fail/stream/eht-id-no-multiple-events.yaml @@ -0,0 +1,32 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + my_other_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/eht-id-not-int.yaml b/tests/config/fail/stream/eht-id-not-int.yaml new file mode 100644 index 0000000..ef8c72f --- /dev/null +++ b/tests/config/fail/stream/eht-id-not-int.yaml @@ -0,0 +1,30 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + event-header-type: + class: struct + fields: + id: + class: string + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/eht-id-too-small.yaml b/tests/config/fail/stream/eht-id-too-small.yaml new file mode 100644 index 0000000..aaa5992 --- /dev/null +++ b/tests/config/fail/stream/eht-id-too-small.yaml @@ -0,0 +1,50 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + event-header-type: + class: struct + min-align: 8 + fields: + id: + class: int + size: 2 + events: + my_event: + payload-type: + class: struct + fields: + my_field: uint16 + my_event2: + payload-type: + class: struct + fields: + my_field: uint16 + my_event3: + payload-type: + class: struct + fields: + my_field: uint16 + my_event4: + payload-type: + class: struct + fields: + my_field: uint16 + my_event5: + payload-type: + class: struct + fields: + my_field: uint16 diff --git a/tests/config/fail/stream/eht-id-wrong-signed.yaml b/tests/config/fail/stream/eht-id-wrong-signed.yaml new file mode 100644 index 0000000..e2d76f1 --- /dev/null +++ b/tests/config/fail/stream/eht-id-wrong-signed.yaml @@ -0,0 +1,32 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + event-header-type: + class: struct + fields: + id: + class: int + size: 16 + signed: true + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/eht-invalid-type.yaml b/tests/config/fail/stream/eht-invalid-type.yaml new file mode 100644 index 0000000..8c974b4 --- /dev/null +++ b/tests/config/fail/stream/eht-invalid-type.yaml @@ -0,0 +1,19 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + event-header-type: 23 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/eht-not-struct.yaml b/tests/config/fail/stream/eht-not-struct.yaml new file mode 100644 index 0000000..d20f2b6 --- /dev/null +++ b/tests/config/fail/stream/eht-not-struct.yaml @@ -0,0 +1,20 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + event-header-type: + class: string + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/eht-timestamp-not-int.yaml b/tests/config/fail/stream/eht-timestamp-not-int.yaml new file mode 100644 index 0000000..fc9c4b6 --- /dev/null +++ b/tests/config/fail/stream/eht-timestamp-not-int.yaml @@ -0,0 +1,30 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + event-header-type: + class: struct + fields: + timestamp: + class: string + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/eht-timestamp-wrong-pm.yaml b/tests/config/fail/stream/eht-timestamp-wrong-pm.yaml new file mode 100644 index 0000000..38463e5 --- /dev/null +++ b/tests/config/fail/stream/eht-timestamp-wrong-pm.yaml @@ -0,0 +1,31 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + event-header-type: + class: struct + fields: + timestamp: + class: int + size: 16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/eht-timestamp-wrong-signed.yaml b/tests/config/fail/stream/eht-timestamp-wrong-signed.yaml new file mode 100644 index 0000000..d3dfc91 --- /dev/null +++ b/tests/config/fail/stream/eht-timestamp-wrong-signed.yaml @@ -0,0 +1,36 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + event-header-type: + class: struct + fields: + timestamp: + class: int + size: 16 + signed: true + property-mappings: + - type: clock + name: my_clock + property: value + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/events-empty.yaml b/tests/config/fail/stream/events-empty.yaml new file mode 100644 index 0000000..f8e5034 --- /dev/null +++ b/tests/config/fail/stream/events-empty.yaml @@ -0,0 +1,7 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: {} diff --git a/tests/config/fail/stream/events-invalid-type.yaml b/tests/config/fail/stream/events-invalid-type.yaml new file mode 100644 index 0000000..7972d65 --- /dev/null +++ b/tests/config/fail/stream/events-invalid-type.yaml @@ -0,0 +1,16 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: 23.5 diff --git a/tests/config/fail/stream/events-key-invalid-identifier.yaml b/tests/config/fail/stream/events-key-invalid-identifier.yaml new file mode 100644 index 0000000..973cdae --- /dev/null +++ b/tests/config/fail/stream/events-key-invalid-identifier.yaml @@ -0,0 +1,23 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + a_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + 'my event': + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/events-no.yaml b/tests/config/fail/stream/events-no.yaml new file mode 100644 index 0000000..93a0700 --- /dev/null +++ b/tests/config/fail/stream/events-no.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: + class: int + size: 16 + content_size: + class: int + size: 16 diff --git a/tests/config/fail/stream/fail.bats b/tests/config/fail/stream/fail.bats new file mode 100644 index 0000000..3b83ef6 --- /dev/null +++ b/tests/config/fail/stream/fail.bats @@ -0,0 +1,189 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in stream object makes barectf fail' { + barectf_assert_file_exists unknown-prop.yaml + barectf_config_check_fail +} + +@test 'no "packet-context-type" property in stream object makes barectf fail' { + barectf_assert_file_exists pct-no.yaml + barectf_config_check_fail +} + +@test 'wrong "packet-context-type" property type in stream object makes barectf fail' { + barectf_assert_file_exists pct-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "packet-context-type" property field type (not a structure) in stream object makes barectf fail' { + barectf_assert_file_exists pct-not-struct.yaml + barectf_config_check_fail +} + +@test 'invalid "timestamp_begin" field type (not an integer) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-tb-not-int.yaml + barectf_config_check_fail +} + +@test 'invalid "timestamp_begin" field type (signed) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-tb-wrong-signed.yaml + barectf_config_check_fail +} + +@test 'invalid "timestamp_begin" field type (not mapped to a clock) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-tb-wrong-pm.yaml + barectf_config_check_fail +} + +@test 'no "timestamp_begin" field with an existing "timestamp_end" field in packet context type makes barectf fail' { + barectf_assert_file_exists pct-te-yes-tb-no.yaml + barectf_config_check_fail +} + +@test 'invalid "timestamp_end" field type (not an integer) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-te-not-int.yaml + barectf_config_check_fail +} + +@test 'invalid "timestamp_end" field type (signed) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-te-wrong-signed.yaml + barectf_config_check_fail +} + +@test 'invalid "timestamp_end" field type (not mapped to a clock) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-te-wrong-pm.yaml + barectf_config_check_fail +} + +@test 'no "timestamp_end" field with an existing "timestamp_begin" field in packet context type makes barectf fail' { + barectf_assert_file_exists pct-tb-yes-te-no.yaml + barectf_config_check_fail +} + +@test '"timestamp_begin" field and "timestamp_end" field are not mapped to the same clock in packet context type makes barectf fail' { + barectf_assert_file_exists pct-tb-te-different-clocks.yaml + barectf_config_check_fail +} + +@test 'invalid "packet_size" field type (not an integer) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-ps-not-int.yaml + barectf_config_check_fail +} + +@test 'invalid "packet_size" field type (signed) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-ps-wrong-signed.yaml + barectf_config_check_fail +} + +@test 'no "packet_size" field with an existing "content_size" field in packet context type makes barectf fail' { + barectf_assert_file_exists pct-cs-yes-ps-no.yaml + barectf_config_check_fail +} + +@test 'invalid "content_size" field type (not an integer) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-cs-not-int.yaml + barectf_config_check_fail +} + +@test 'invalid "content_size" field type (signed) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-cs-wrong-signed.yaml + barectf_config_check_fail +} + +@test 'no "content_size" field with an existing "packet_size" field in packet context type makes barectf fail' { + barectf_assert_file_exists pct-ps-yes-cs-no.yaml + barectf_config_check_fail +} + +@test '"content_size" field size greater than "packet_size" field size in packet context type makes barectf fail' { + barectf_assert_file_exists pct-cs-gt-ps.yaml + barectf_config_check_fail +} + +@test 'invalid "events_discarded" field type (not an integer) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-ed-not-int.yaml + barectf_config_check_fail +} + +@test 'invalid "events_discarded" field type (signed) in packet context type makes barectf fail' { + barectf_assert_file_exists pct-ed-wrong-signed.yaml + barectf_config_check_fail +} + +@test 'wrong "event-header-type" property type in stream object makes barectf fail' { + barectf_assert_file_exists eht-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "event-header-type" property field type (not a structure) in stream object makes barectf fail' { + barectf_assert_file_exists eht-not-struct.yaml + barectf_config_check_fail +} + +@test 'invalid "timestamp" field type (not an integer) in event header type makes barectf fail' { + barectf_assert_file_exists eht-timestamp-not-int.yaml + barectf_config_check_fail +} + +@test 'invalid "timestamp" field type (signed) in event header type makes barectf fail' { + barectf_assert_file_exists eht-timestamp-wrong-signed.yaml + barectf_config_check_fail +} + +@test 'invalid "timestamp" field type (not mapped to a clock) in event header type makes barectf fail' { + barectf_assert_file_exists eht-timestamp-wrong-pm.yaml + barectf_config_check_fail +} + +@test 'invalid "id" field type (not an integer) in event header type makes barectf fail' { + barectf_assert_file_exists eht-id-not-int.yaml + barectf_config_check_fail +} + +@test 'invalid "id" field type (signed) in event header type makes barectf fail' { + barectf_assert_file_exists eht-id-wrong-signed.yaml + barectf_config_check_fail +} + +@test 'no event header type with multiple events in stream object makes barectf fail' { + barectf_assert_file_exists eht-id-no-multiple-events.yaml + barectf_config_check_fail +} + +@test '"id" field type size too small for the number of stream events in event header type makes barectf fail' { + barectf_assert_file_exists eht-id-too-small.yaml + barectf_config_check_fail +} + +@test 'wrong "event-context-type" property type in stream object makes barectf fail' { + barectf_assert_file_exists ect-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "event-context-type" property field type (not a structure) in stream object makes barectf fail' { + barectf_assert_file_exists ect-not-struct.yaml + barectf_config_check_fail +} + +@test 'no "events" property in stream object makes barectf fail' { + barectf_assert_file_exists events-no.yaml + barectf_config_check_fail +} + +@test 'wrong "events" property type in stream object makes barectf fail' { + barectf_assert_file_exists events-invalid-type.yaml + barectf_config_check_fail +} + +@test 'empty "events" property in stream object makes barectf fail' { + barectf_assert_file_exists events-empty.yaml + barectf_config_check_fail +} + +@test 'invalid "events" key (invalid C identifier) in metadata object makes barectf fail' { + barectf_assert_file_exists events-key-invalid-identifier.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/stream/pct-cs-gt-ps.yaml b/tests/config/fail/stream/pct-cs-gt-ps.yaml new file mode 100644 index 0000000..6904b46 --- /dev/null +++ b/tests/config/fail/stream/pct-cs-gt-ps.yaml @@ -0,0 +1,29 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: + class: int + size: 16 + packet_size: + class: int + size: 8 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-cs-not-int.yaml b/tests/config/fail/stream/pct-cs-not-int.yaml new file mode 100644 index 0000000..2260ffb --- /dev/null +++ b/tests/config/fail/stream/pct-cs-not-int.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: + class: string + packet_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-cs-wrong-signed.yaml b/tests/config/fail/stream/pct-cs-wrong-signed.yaml new file mode 100644 index 0000000..306be90 --- /dev/null +++ b/tests/config/fail/stream/pct-cs-wrong-signed.yaml @@ -0,0 +1,28 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: + class: int + size: 16 + signed: true + packet_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-cs-yes-ps-no.yaml b/tests/config/fail/stream/pct-cs-yes-ps-no.yaml new file mode 100644 index 0000000..957b611 --- /dev/null +++ b/tests/config/fail/stream/pct-cs-yes-ps-no.yaml @@ -0,0 +1,22 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-ed-not-int.yaml b/tests/config/fail/stream/pct-ed-not-int.yaml new file mode 100644 index 0000000..8e787a8 --- /dev/null +++ b/tests/config/fail/stream/pct-ed-not-int.yaml @@ -0,0 +1,23 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + events_discarded: + class: string + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-ed-wrong-signed.yaml b/tests/config/fail/stream/pct-ed-wrong-signed.yaml new file mode 100644 index 0000000..80f8756 --- /dev/null +++ b/tests/config/fail/stream/pct-ed-wrong-signed.yaml @@ -0,0 +1,27 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + events_discarded: + class: int + size: 16 + signed: true + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-invalid-type.yaml b/tests/config/fail/stream/pct-invalid-type.yaml new file mode 100644 index 0000000..032834a --- /dev/null +++ b/tests/config/fail/stream/pct-invalid-type.yaml @@ -0,0 +1,19 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: 23 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-no.yaml b/tests/config/fail/stream/pct-no.yaml new file mode 100644 index 0000000..f8fd71f --- /dev/null +++ b/tests/config/fail/stream/pct-no.yaml @@ -0,0 +1,20 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-not-struct.yaml b/tests/config/fail/stream/pct-not-struct.yaml new file mode 100644 index 0000000..bba5c04 --- /dev/null +++ b/tests/config/fail/stream/pct-not-struct.yaml @@ -0,0 +1,20 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: string + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-ps-not-int.yaml b/tests/config/fail/stream/pct-ps-not-int.yaml new file mode 100644 index 0000000..e693baa --- /dev/null +++ b/tests/config/fail/stream/pct-ps-not-int.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: + class: string + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-ps-wrong-signed.yaml b/tests/config/fail/stream/pct-ps-wrong-signed.yaml new file mode 100644 index 0000000..16ac3ef --- /dev/null +++ b/tests/config/fail/stream/pct-ps-wrong-signed.yaml @@ -0,0 +1,28 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: + class: int + size: 16 + signed: true + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-ps-yes-cs-no.yaml b/tests/config/fail/stream/pct-ps-yes-cs-no.yaml new file mode 100644 index 0000000..b8996da --- /dev/null +++ b/tests/config/fail/stream/pct-ps-yes-cs-no.yaml @@ -0,0 +1,22 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-tb-not-int.yaml b/tests/config/fail/stream/pct-tb-not-int.yaml new file mode 100644 index 0000000..3dc2743 --- /dev/null +++ b/tests/config/fail/stream/pct-tb-not-int.yaml @@ -0,0 +1,25 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + timestamp_begin: + class: string + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-tb-te-different-clocks.yaml b/tests/config/fail/stream/pct-tb-te-different-clocks.yaml new file mode 100644 index 0000000..c858302 --- /dev/null +++ b/tests/config/fail/stream/pct-tb-te-different-clocks.yaml @@ -0,0 +1,40 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + my_other_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + timestamp_begin: + class: int + size: 32 + property-mappings: + - type: clock + name: my_clock + property: value + timestamp_end: + class: int + size: 32 + property-mappings: + - type: clock + name: my_other_clock + property: value + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-tb-wrong-pm.yaml b/tests/config/fail/stream/pct-tb-wrong-pm.yaml new file mode 100644 index 0000000..594fee5 --- /dev/null +++ b/tests/config/fail/stream/pct-tb-wrong-pm.yaml @@ -0,0 +1,28 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + timestamp_begin: + class: int + size: 16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-tb-wrong-signed.yaml b/tests/config/fail/stream/pct-tb-wrong-signed.yaml new file mode 100644 index 0000000..7f49b21 --- /dev/null +++ b/tests/config/fail/stream/pct-tb-wrong-signed.yaml @@ -0,0 +1,33 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + timestamp_begin: + class: int + size: 16 + signed: true + property-mappings: + - type: clock + name: my_clock + property: value + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-tb-yes-te-no.yaml b/tests/config/fail/stream/pct-tb-yes-te-no.yaml new file mode 100644 index 0000000..98cf21f --- /dev/null +++ b/tests/config/fail/stream/pct-tb-yes-te-no.yaml @@ -0,0 +1,32 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + timestamp_begin: + class: int + size: 32 + property-mappings: + - type: clock + name: my_clock + property: value + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-te-not-int.yaml b/tests/config/fail/stream/pct-te-not-int.yaml new file mode 100644 index 0000000..235adee --- /dev/null +++ b/tests/config/fail/stream/pct-te-not-int.yaml @@ -0,0 +1,25 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + timestamp_end: + class: string + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-te-wrong-pm.yaml b/tests/config/fail/stream/pct-te-wrong-pm.yaml new file mode 100644 index 0000000..5bf8514 --- /dev/null +++ b/tests/config/fail/stream/pct-te-wrong-pm.yaml @@ -0,0 +1,28 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + timestamp_end: + class: int + size: 16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-te-wrong-signed.yaml b/tests/config/fail/stream/pct-te-wrong-signed.yaml new file mode 100644 index 0000000..aeba11e --- /dev/null +++ b/tests/config/fail/stream/pct-te-wrong-signed.yaml @@ -0,0 +1,33 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + timestamp_end: + class: int + size: 16 + signed: true + property-mappings: + - type: clock + name: my_clock + property: value + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/pct-te-yes-tb-no.yaml b/tests/config/fail/stream/pct-te-yes-tb-no.yaml new file mode 100644 index 0000000..d0330bf --- /dev/null +++ b/tests/config/fail/stream/pct-te-yes-tb-no.yaml @@ -0,0 +1,32 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + timestamp_end: + class: int + size: 32 + property-mappings: + - type: clock + name: my_clock + property: value + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/stream/unknown-prop.yaml b/tests/config/fail/stream/unknown-prop.yaml new file mode 100644 index 0000000..28ecfcb --- /dev/null +++ b/tests/config/fail/stream/unknown-prop.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + streams: + my_stream: + unknown: true + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/bo-invalid-type.yaml b/tests/config/fail/trace/bo-invalid-type.yaml new file mode 100644 index 0000000..71a7c53 --- /dev/null +++ b/tests/config/fail/trace/bo-invalid-type.yaml @@ -0,0 +1,23 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: 23 + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/bo-invalid.yaml b/tests/config/fail/trace/bo-invalid.yaml new file mode 100644 index 0000000..9723567 --- /dev/null +++ b/tests/config/fail/trace/bo-invalid.yaml @@ -0,0 +1,23 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: ze + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/bo-no.yaml b/tests/config/fail/trace/bo-no.yaml new file mode 100644 index 0000000..86dda3b --- /dev/null +++ b/tests/config/fail/trace/bo-no.yaml @@ -0,0 +1,22 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: {} + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/fail.bats b/tests/config/fail/trace/fail.bats new file mode 100644 index 0000000..c07cf67 --- /dev/null +++ b/tests/config/fail/trace/fail.bats @@ -0,0 +1,99 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in trace object makes barectf fail' { + barectf_assert_file_exists unknown-prop.yaml + barectf_config_check_fail +} + +@test 'wrong "byte-order" property type in trace object makes barectf fail' { + barectf_assert_file_exists bo-invalid-type.yaml + barectf_config_check_fail +} + +@test 'no "byte-order" property in trace object makes barectf fail' { + barectf_assert_file_exists bo-no.yaml + barectf_config_check_fail +} + +@test 'invalid "byte-order" property in trace object makes barectf fail' { + barectf_assert_file_exists bo-invalid.yaml + barectf_config_check_fail +} + +@test 'invalid "packet-header-type" property field type (not a structure) in trace object makes barectf fail' { + barectf_assert_file_exists ph-not-struct.yaml + barectf_config_check_fail +} + +@test 'wrong "uuid" property type in trace object makes barectf fail' { + barectf_assert_file_exists uuid-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "uuid" property (invalid UUID format) in trace object makes barectf fail' { + barectf_assert_file_exists uuid-invalid-uuid.yaml + barectf_config_check_fail +} + +@test 'invalid "magic" field type (not an integer) in packet header type makes barectf fail' { + barectf_assert_file_exists ph-magic-not-int.yaml + barectf_config_check_fail +} + +@test 'invalid "magic" field type (wrong integer size) in packet header type makes barectf fail' { + barectf_assert_file_exists ph-magic-wrong-size.yaml + barectf_config_check_fail +} + +@test 'invalid "magic" field type (signed) in packet header type makes barectf fail' { + barectf_assert_file_exists ph-magic-wrong-signed.yaml + barectf_config_check_fail +} + +@test 'invalid "stream_id" field type (not an integer) in packet header type makes barectf fail' { + barectf_assert_file_exists ph-streamid-not-int.yaml + barectf_config_check_fail +} + +@test 'invalid "stream_id" field type (signed) in packet header type makes barectf fail' { + barectf_assert_file_exists ph-streamid-wrong-signed.yaml + barectf_config_check_fail +} + +@test '"stream_id" field type size too small for the number of trace streams in packet header type makes barectf fail' { + barectf_assert_file_exists ph-streamid-too-small.yaml + barectf_config_check_fail +} + +@test 'invalid "uuid" field type (not an array) in packet header type makes barectf fail' { + barectf_assert_file_exists ph-uuid-not-array.yaml + barectf_config_check_fail +} + +@test 'invalid "uuid" field type (wrong array length) in packet header type makes barectf fail' { + barectf_assert_file_exists ph-uuid-wrong-length.yaml + barectf_config_check_fail +} + +@test 'invalid "uuid" field type (element type is not an integer) in packet header type makes barectf fail' { + barectf_assert_file_exists ph-uuid-et-not-int.yaml + barectf_config_check_fail +} + +@test 'invalid "uuid" field type (wrong element type size) in packet header type makes barectf fail' { + barectf_assert_file_exists ph-uuid-et-wrong-size.yaml + barectf_config_check_fail +} + +@test 'invalid "uuid" field type (element type is signed) in packet header type makes barectf fail' { + barectf_assert_file_exists ph-uuid-et-wrong-signed.yaml + barectf_config_check_fail +} + +@test 'invalid "uuid" field type (wrong element type alignment) in packet header type makes barectf fail' { + barectf_assert_file_exists ph-uuid-et-wrong-align.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/trace/ph-magic-not-int.yaml b/tests/config/fail/trace/ph-magic-not-int.yaml new file mode 100644 index 0000000..0e72923 --- /dev/null +++ b/tests/config/fail/trace/ph-magic-not-int.yaml @@ -0,0 +1,28 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: be + packet-header-type: + class: struct + fields: + magic: + class: string + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/ph-magic-wrong-signed.yaml b/tests/config/fail/trace/ph-magic-wrong-signed.yaml new file mode 100644 index 0000000..62cfbb6 --- /dev/null +++ b/tests/config/fail/trace/ph-magic-wrong-signed.yaml @@ -0,0 +1,30 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: be + packet-header-type: + class: struct + fields: + magic: + class: int + size: 32 + signed: true + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/ph-magic-wrong-size.yaml b/tests/config/fail/trace/ph-magic-wrong-size.yaml new file mode 100644 index 0000000..7fbe38a --- /dev/null +++ b/tests/config/fail/trace/ph-magic-wrong-size.yaml @@ -0,0 +1,29 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: be + packet-header-type: + class: struct + fields: + magic: + class: int + size: 16 + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/ph-not-struct.yaml b/tests/config/fail/trace/ph-not-struct.yaml new file mode 100644 index 0000000..274a775 --- /dev/null +++ b/tests/config/fail/trace/ph-not-struct.yaml @@ -0,0 +1,26 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: be + packet-header-type: + class: int + size: 32 + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/ph-streamid-not-int.yaml b/tests/config/fail/trace/ph-streamid-not-int.yaml new file mode 100644 index 0000000..411a71a --- /dev/null +++ b/tests/config/fail/trace/ph-streamid-not-int.yaml @@ -0,0 +1,28 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: be + packet-header-type: + class: struct + fields: + stream_id: + class: string + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/ph-streamid-too-small.yaml b/tests/config/fail/trace/ph-streamid-too-small.yaml new file mode 100644 index 0000000..8081a79 --- /dev/null +++ b/tests/config/fail/trace/ph-streamid-too-small.yaml @@ -0,0 +1,103 @@ +version: '2.1' +metadata: + clocks: + my_clock: {} + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: le + packet-header-type: + class: struct + min-align: 8 + fields: + stream_id: + class: int + size: 2 + streams: + my_stream: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + event-header-type: + class: struct + min-align: 8 + fields: + id: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: uint16 + my_stream2: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + event-header-type: + class: struct + min-align: 8 + fields: + id: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: uint16 + my_stream3: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + event-header-type: + class: struct + min-align: 8 + fields: + id: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: uint16 + my_stream4: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + event-header-type: + class: struct + min-align: 8 + fields: + id: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: uint16 + my_stream5: + packet-context-type: + class: struct + fields: + content_size: uint16 + packet_size: uint16 + event-header-type: + class: struct + min-align: 8 + fields: + id: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: uint16 diff --git a/tests/config/fail/trace/ph-streamid-wrong-signed.yaml b/tests/config/fail/trace/ph-streamid-wrong-signed.yaml new file mode 100644 index 0000000..b978e7d --- /dev/null +++ b/tests/config/fail/trace/ph-streamid-wrong-signed.yaml @@ -0,0 +1,30 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: be + packet-header-type: + class: struct + fields: + stream_id: + class: int + size: 16 + signed: true + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/ph-uuid-et-not-int.yaml b/tests/config/fail/trace/ph-uuid-et-not-int.yaml new file mode 100644 index 0000000..0a084df --- /dev/null +++ b/tests/config/fail/trace/ph-uuid-et-not-int.yaml @@ -0,0 +1,32 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + uuid: auto + byte-order: be + packet-header-type: + class: struct + fields: + uuid: + class: array + length: 16 + element-type: + class: string + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/ph-uuid-et-wrong-align.yaml b/tests/config/fail/trace/ph-uuid-et-wrong-align.yaml new file mode 100644 index 0000000..5cc38ae --- /dev/null +++ b/tests/config/fail/trace/ph-uuid-et-wrong-align.yaml @@ -0,0 +1,34 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + uuid: auto + byte-order: be + packet-header-type: + class: struct + fields: + uuid: + class: array + length: 16 + element-type: + class: int + size: 8 + align: 16 + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/ph-uuid-et-wrong-signed.yaml b/tests/config/fail/trace/ph-uuid-et-wrong-signed.yaml new file mode 100644 index 0000000..ba2acb2 --- /dev/null +++ b/tests/config/fail/trace/ph-uuid-et-wrong-signed.yaml @@ -0,0 +1,34 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + uuid: auto + byte-order: be + packet-header-type: + class: struct + fields: + uuid: + class: array + length: 16 + element-type: + class: int + size: 8 + signed: true + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/ph-uuid-et-wrong-size.yaml b/tests/config/fail/trace/ph-uuid-et-wrong-size.yaml new file mode 100644 index 0000000..46ad928 --- /dev/null +++ b/tests/config/fail/trace/ph-uuid-et-wrong-size.yaml @@ -0,0 +1,33 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + uuid: auto + byte-order: be + packet-header-type: + class: struct + fields: + uuid: + class: array + length: 16 + element-type: + class: int + size: 4 + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/ph-uuid-not-array.yaml b/tests/config/fail/trace/ph-uuid-not-array.yaml new file mode 100644 index 0000000..4346b37 --- /dev/null +++ b/tests/config/fail/trace/ph-uuid-not-array.yaml @@ -0,0 +1,28 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + uuid: auto + byte-order: be + packet-header-type: + class: struct + fields: + uuid: uint16 + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/ph-uuid-wrong-length.yaml b/tests/config/fail/trace/ph-uuid-wrong-length.yaml new file mode 100644 index 0000000..afdca3b --- /dev/null +++ b/tests/config/fail/trace/ph-uuid-wrong-length.yaml @@ -0,0 +1,33 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + uuid: auto + byte-order: be + packet-header-type: + class: struct + fields: + uuid: + class: array + length: 17 + element-type: + class: int + size: 8 + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/unknown-prop.yaml b/tests/config/fail/trace/unknown-prop.yaml new file mode 100644 index 0000000..6e0e454 --- /dev/null +++ b/tests/config/fail/trace/unknown-prop.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: be + unknown: false + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/uuid-invalid-type.yaml b/tests/config/fail/trace/uuid-invalid-type.yaml new file mode 100644 index 0000000..5a8e7e3 --- /dev/null +++ b/tests/config/fail/trace/uuid-invalid-type.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + uuid: 12 + byte-order: be + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/trace/uuid-invalid-uuid.yaml b/tests/config/fail/trace/uuid-invalid-uuid.yaml new file mode 100644 index 0000000..74916dd --- /dev/null +++ b/tests/config/fail/trace/uuid-invalid-uuid.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + uuid: something + byte-order: be + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/type-enum/fail.bats b/tests/config/fail/type-enum/fail.bats new file mode 100644 index 0000000..d69b9ff --- /dev/null +++ b/tests/config/fail/type-enum/fail.bats @@ -0,0 +1,69 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in enum type object makes barectf fail' { + barectf_assert_file_exists unknown-prop.yaml + barectf_config_check_fail +} + +@test 'no "value-type" property in enum type object makes barectf fail' { + barectf_assert_file_exists vt-no.yaml + barectf_config_check_fail +} + +@test 'wrong "value-type" property type in enum type object makes barectf fail' { + barectf_assert_file_exists vt-invalid-type.yaml + barectf_config_check_fail +} + +@test 'no "members" property in enum type object makes barectf fail' { + barectf_assert_file_exists members-no.yaml + barectf_config_check_fail +} + +@test 'wrong "members" property type in enum type object makes barectf fail' { + barectf_assert_file_exists members-invalid-type.yaml + barectf_config_check_fail +} + +@test 'empty "members" property in enum type object makes barectf fail' { + barectf_assert_file_exists members-empty.yaml + barectf_config_check_fail +} + +@test 'wrong "members" property element type in enum type object makes barectf fail' { + barectf_assert_file_exists members-el-invalid-type.yaml + barectf_config_check_fail +} + +@test 'unknown property in enum type member object makes barectf fail' { + barectf_assert_file_exists members-el-member-unknown-prop.yaml + barectf_config_check_fail +} + +@test 'wrong "label" property type in enum type member object makes barectf fail' { + barectf_assert_file_exists members-el-member-label-invalid-type.yaml + barectf_config_check_fail +} + +@test 'wrong "value" property type in enum type member object makes barectf fail' { + barectf_assert_file_exists members-el-member-value-invalid-type.yaml + barectf_config_check_fail +} + +@test '"value" property outside the unsigned value type range in enum type member object makes barectf fail' { + barectf_assert_file_exists members-el-member-value-outside-range-unsigned.yaml + barectf_config_check_fail +} + +@test '"value" property outside the signed value type range in enum type member object makes barectf fail' { + barectf_assert_file_exists members-el-member-value-outside-range-signed.yaml + barectf_config_check_fail +} + +@test 'overlapping members in enum type object makes barectf fail' { + barectf_assert_file_exists members-overlap.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/type-enum/members-el-invalid-type.yaml b/tests/config/fail/type-enum/members-el-invalid-type.yaml new file mode 100644 index 0000000..821226f --- /dev/null +++ b/tests/config/fail/type-enum/members-el-invalid-type.yaml @@ -0,0 +1,20 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: + class: int + size: 8 + members: + - HELLO + - 23 + - ZOOM diff --git a/tests/config/fail/type-enum/members-el-member-label-invalid-type.yaml b/tests/config/fail/type-enum/members-el-member-label-invalid-type.yaml new file mode 100644 index 0000000..5f8ff70 --- /dev/null +++ b/tests/config/fail/type-enum/members-el-member-label-invalid-type.yaml @@ -0,0 +1,21 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: + class: int + size: 8 + members: + - HELLO + - label: 65 + value: 6 + - ZOOM diff --git a/tests/config/fail/type-enum/members-el-member-unknown-prop.yaml b/tests/config/fail/type-enum/members-el-member-unknown-prop.yaml new file mode 100644 index 0000000..cc92292 --- /dev/null +++ b/tests/config/fail/type-enum/members-el-member-unknown-prop.yaml @@ -0,0 +1,22 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: + class: int + size: 8 + members: + - HELLO + - label: six + value: 6 + unknown: true + - ZOOM diff --git a/tests/config/fail/type-enum/members-el-member-value-invalid-type.yaml b/tests/config/fail/type-enum/members-el-member-value-invalid-type.yaml new file mode 100644 index 0000000..ed174b3 --- /dev/null +++ b/tests/config/fail/type-enum/members-el-member-value-invalid-type.yaml @@ -0,0 +1,21 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: + class: int + size: 8 + members: + - HELLO + - label: label + value: meow + - ZOOM diff --git a/tests/config/fail/type-enum/members-el-member-value-outside-range-signed.yaml b/tests/config/fail/type-enum/members-el-member-value-outside-range-signed.yaml new file mode 100644 index 0000000..c90a30f --- /dev/null +++ b/tests/config/fail/type-enum/members-el-member-value-outside-range-signed.yaml @@ -0,0 +1,22 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: + class: int + size: 8 + signed: true + members: + - HELLO + - label: label + value: -129 + - ZOOM diff --git a/tests/config/fail/type-enum/members-el-member-value-outside-range-unsigned.yaml b/tests/config/fail/type-enum/members-el-member-value-outside-range-unsigned.yaml new file mode 100644 index 0000000..98654d5 --- /dev/null +++ b/tests/config/fail/type-enum/members-el-member-value-outside-range-unsigned.yaml @@ -0,0 +1,21 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: + class: int + size: 8 + members: + - HELLO + - label: label + value: 256 + - ZOOM diff --git a/tests/config/fail/type-enum/members-empty.yaml b/tests/config/fail/type-enum/members-empty.yaml new file mode 100644 index 0000000..89be8b2 --- /dev/null +++ b/tests/config/fail/type-enum/members-empty.yaml @@ -0,0 +1,17 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: + class: int + size: 8 + members: [] diff --git a/tests/config/fail/type-enum/members-invalid-type.yaml b/tests/config/fail/type-enum/members-invalid-type.yaml new file mode 100644 index 0000000..7bd3ac2 --- /dev/null +++ b/tests/config/fail/type-enum/members-invalid-type.yaml @@ -0,0 +1,17 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: + class: int + size: 8 + members: string diff --git a/tests/config/fail/type-enum/members-no.yaml b/tests/config/fail/type-enum/members-no.yaml new file mode 100644 index 0000000..8dde9f9 --- /dev/null +++ b/tests/config/fail/type-enum/members-no.yaml @@ -0,0 +1,16 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: + class: int + size: 8 diff --git a/tests/config/fail/type-enum/members-overlap.yaml b/tests/config/fail/type-enum/members-overlap.yaml new file mode 100644 index 0000000..1d53780 --- /dev/null +++ b/tests/config/fail/type-enum/members-overlap.yaml @@ -0,0 +1,22 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: + class: int + size: 8 + signed: true + members: + - HELLO + - ZOOM + - label: MAGOG + value: 0 diff --git a/tests/config/fail/type-enum/unknown-prop.yaml b/tests/config/fail/type-enum/unknown-prop.yaml new file mode 100644 index 0000000..6c1844d --- /dev/null +++ b/tests/config/fail/type-enum/unknown-prop.yaml @@ -0,0 +1,19 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: + class: int + size: 8 + members: + - HELLO + unknown: false diff --git a/tests/config/fail/type-enum/vt-invalid-type.yaml b/tests/config/fail/type-enum/vt-invalid-type.yaml new file mode 100644 index 0000000..a916566 --- /dev/null +++ b/tests/config/fail/type-enum/vt-invalid-type.yaml @@ -0,0 +1,16 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + value-type: 23 + members: + - HELLO diff --git a/tests/config/fail/type-enum/vt-no.yaml b/tests/config/fail/type-enum/vt-no.yaml new file mode 100644 index 0000000..83c6df2 --- /dev/null +++ b/tests/config/fail/type-enum/vt-no.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: enum + members: + - HELLO diff --git a/tests/config/fail/type-float/align-0.yaml b/tests/config/fail/type-float/align-0.yaml new file mode 100644 index 0000000..716b9d2 --- /dev/null +++ b/tests/config/fail/type-float/align-0.yaml @@ -0,0 +1,17 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float + size: + exp: 8 + mant: 24 + align: 0 diff --git a/tests/config/fail/type-float/align-3.yaml b/tests/config/fail/type-float/align-3.yaml new file mode 100644 index 0000000..bb89768 --- /dev/null +++ b/tests/config/fail/type-float/align-3.yaml @@ -0,0 +1,17 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float + size: + exp: 8 + mant: 24 + align: 3 diff --git a/tests/config/fail/type-float/align-invalid-type.yaml b/tests/config/fail/type-float/align-invalid-type.yaml new file mode 100644 index 0000000..2cacddd --- /dev/null +++ b/tests/config/fail/type-float/align-invalid-type.yaml @@ -0,0 +1,17 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float + size: + exp: 8 + mant: 24 + align: string diff --git a/tests/config/fail/type-float/bo-invalid-type.yaml b/tests/config/fail/type-float/bo-invalid-type.yaml new file mode 100644 index 0000000..7ca68a7 --- /dev/null +++ b/tests/config/fail/type-float/bo-invalid-type.yaml @@ -0,0 +1,17 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float + size: + exp: 8 + mant: 24 + byte-order: 17 diff --git a/tests/config/fail/type-float/bo-invalid.yaml b/tests/config/fail/type-float/bo-invalid.yaml new file mode 100644 index 0000000..1e20aaa --- /dev/null +++ b/tests/config/fail/type-float/bo-invalid.yaml @@ -0,0 +1,17 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float + size: + exp: 8 + mant: 24 + byte-order: ze diff --git a/tests/config/fail/type-float/fail.bats b/tests/config/fail/type-float/fail.bats new file mode 100644 index 0000000..b31a83e --- /dev/null +++ b/tests/config/fail/type-float/fail.bats @@ -0,0 +1,64 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in float type object makes barectf fail' { + barectf_assert_file_exists unknown-prop.yaml + barectf_config_check_fail +} + +@test 'no "size" property in float type object makes barectf fail' { + barectf_assert_file_exists size-no.yaml + barectf_config_check_fail +} + +@test 'wrong "size" property type in float type object makes barectf fail' { + barectf_assert_file_exists size-invalid-type.yaml + barectf_config_check_fail +} + +@test 'unknown property in float type object "size" property makes barectf fail' { + barectf_assert_file_exists size-unknown-prop.yaml + barectf_config_check_fail +} + +@test 'no "exp" property in float type object "size" property makes barectf fail' { + barectf_assert_file_exists size-exp-no.yaml + barectf_config_check_fail +} + +@test 'no "mant" property in float type object "size" property makes barectf fail' { + barectf_assert_file_exists size-mant-no.yaml + barectf_config_check_fail +} + +@test 'sum of "mant" and "exp" properties of float type size object not a multiple of 32 property makes barectf fail' { + barectf_assert_file_exists size-exp-mant-wrong-sum.yaml + barectf_config_check_fail +} + +@test 'wrong "align" property type in float type object makes barectf fail' { + barectf_assert_file_exists align-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "align" property (0) in float type object makes barectf fail' { + barectf_assert_file_exists align-0.yaml + barectf_config_check_fail +} + +@test 'invalid "align" property (3) in float type object makes barectf fail' { + barectf_assert_file_exists align-3.yaml + barectf_config_check_fail +} + +@test 'wrong "byte-order" property type in float type object makes barectf fail' { + barectf_assert_file_exists bo-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "byte-order" property in float type object makes barectf fail' { + barectf_assert_file_exists bo-invalid.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/type-float/size-exp-mant-wrong-sum.yaml b/tests/config/fail/type-float/size-exp-mant-wrong-sum.yaml new file mode 100644 index 0000000..ed22be8 --- /dev/null +++ b/tests/config/fail/type-float/size-exp-mant-wrong-sum.yaml @@ -0,0 +1,16 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float + size: + exp: 5 + mant: 21 diff --git a/tests/config/fail/type-float/size-exp-no.yaml b/tests/config/fail/type-float/size-exp-no.yaml new file mode 100644 index 0000000..0aae725 --- /dev/null +++ b/tests/config/fail/type-float/size-exp-no.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float + size: + mant: 24 diff --git a/tests/config/fail/type-float/size-invalid-type.yaml b/tests/config/fail/type-float/size-invalid-type.yaml new file mode 100644 index 0000000..76fce82 --- /dev/null +++ b/tests/config/fail/type-float/size-invalid-type.yaml @@ -0,0 +1,14 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float + size: string diff --git a/tests/config/fail/type-float/size-mant-no.yaml b/tests/config/fail/type-float/size-mant-no.yaml new file mode 100644 index 0000000..37f6fa8 --- /dev/null +++ b/tests/config/fail/type-float/size-mant-no.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float + size: + exp: 8 diff --git a/tests/config/fail/type-float/size-no.yaml b/tests/config/fail/type-float/size-no.yaml new file mode 100644 index 0000000..7689d99 --- /dev/null +++ b/tests/config/fail/type-float/size-no.yaml @@ -0,0 +1,13 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float diff --git a/tests/config/fail/type-float/size-unknown-prop.yaml b/tests/config/fail/type-float/size-unknown-prop.yaml new file mode 100644 index 0000000..5071d92 --- /dev/null +++ b/tests/config/fail/type-float/size-unknown-prop.yaml @@ -0,0 +1,17 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float + size: + exp: 8 + mant: 24 + unknown: false diff --git a/tests/config/fail/type-float/unknown-prop.yaml b/tests/config/fail/type-float/unknown-prop.yaml new file mode 100644 index 0000000..47af0c6 --- /dev/null +++ b/tests/config/fail/type-float/unknown-prop.yaml @@ -0,0 +1,17 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: float + size: + exp: 8 + mant: 24 + unknown: false diff --git a/tests/config/fail/type-int/align-0.yaml b/tests/config/fail/type-int/align-0.yaml new file mode 100644 index 0000000..fdb8b87 --- /dev/null +++ b/tests/config/fail/type-int/align-0.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 32 + align: 0 diff --git a/tests/config/fail/type-int/align-3.yaml b/tests/config/fail/type-int/align-3.yaml new file mode 100644 index 0000000..02e1f57 --- /dev/null +++ b/tests/config/fail/type-int/align-3.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 32 + align: 3 diff --git a/tests/config/fail/type-int/align-invalid-type.yaml b/tests/config/fail/type-int/align-invalid-type.yaml new file mode 100644 index 0000000..4c70f95 --- /dev/null +++ b/tests/config/fail/type-int/align-invalid-type.yaml @@ -0,0 +1,14 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + align: string diff --git a/tests/config/fail/type-int/base-invalid-type.yaml b/tests/config/fail/type-int/base-invalid-type.yaml new file mode 100644 index 0000000..a32d61f --- /dev/null +++ b/tests/config/fail/type-int/base-invalid-type.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + base: 17.34 diff --git a/tests/config/fail/type-int/base-invalid.yaml b/tests/config/fail/type-int/base-invalid.yaml new file mode 100644 index 0000000..669e3e9 --- /dev/null +++ b/tests/config/fail/type-int/base-invalid.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 32 + base: inval diff --git a/tests/config/fail/type-int/bo-invalid-type.yaml b/tests/config/fail/type-int/bo-invalid-type.yaml new file mode 100644 index 0000000..83fb976 --- /dev/null +++ b/tests/config/fail/type-int/bo-invalid-type.yaml @@ -0,0 +1,14 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + byte-order: 17.34 diff --git a/tests/config/fail/type-int/bo-invalid.yaml b/tests/config/fail/type-int/bo-invalid.yaml new file mode 100644 index 0000000..033ea5e --- /dev/null +++ b/tests/config/fail/type-int/bo-invalid.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 32 + byte-order: ze diff --git a/tests/config/fail/type-int/fail.bats b/tests/config/fail/type-int/fail.bats new file mode 100644 index 0000000..fbc8b1d --- /dev/null +++ b/tests/config/fail/type-int/fail.bats @@ -0,0 +1,89 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in int type object makes barectf fail' { + barectf_assert_file_exists unknown-prop.yaml + barectf_config_check_fail +} + +@test 'no "size" property in int type object makes barectf fail' { + barectf_assert_file_exists size-no.yaml + barectf_config_check_fail +} + +@test 'wrong "size" property type in int type object makes barectf fail' { + barectf_assert_file_exists size-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "size" property (0) in int type object makes barectf fail' { + barectf_assert_file_exists size-0.yaml + barectf_config_check_fail +} + +@test 'invalid "size" property (65) in int type object makes barectf fail' { + barectf_assert_file_exists size-65.yaml + barectf_config_check_fail +} + +@test 'wrong "signed" property type in int type object makes barectf fail' { + barectf_assert_file_exists signed-invalid-type.yaml + barectf_config_check_fail +} + +@test 'wrong "align" property type in int type object makes barectf fail' { + barectf_assert_file_exists align-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "align" property (0) in int type object makes barectf fail' { + barectf_assert_file_exists align-0.yaml + barectf_config_check_fail +} + +@test 'invalid "align" property (3) in int type object makes barectf fail' { + barectf_assert_file_exists align-3.yaml + barectf_config_check_fail +} + +@test 'wrong "base" property type in int type object makes barectf fail' { + barectf_assert_file_exists base-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "base" property in int type object makes barectf fail' { + barectf_assert_file_exists base-invalid.yaml + barectf_config_check_fail +} + +@test 'wrong "byte-order" property type in int type object makes barectf fail' { + barectf_assert_file_exists bo-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "byte-order" property in int type object makes barectf fail' { + barectf_assert_file_exists bo-invalid.yaml + barectf_config_check_fail +} + +@test 'wrong "property-mappings" property type in int type object makes barectf fail' { + barectf_assert_file_exists pm-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "property-mappings" property in int type object makes barectf fail' { + barectf_assert_file_exists pm-unknown-clock.yaml + barectf_config_check_fail +} + +@test 'invalid "property-mappings" property (invalid "type" property) in int type object makes barectf fail' { + barectf_assert_file_exists pm-type-invalid.yaml + barectf_config_check_fail +} + +@test 'invalid "property-mappings" property (invalid "property" property) in int type object makes barectf fail' { + barectf_assert_file_exists pm-property-invalid.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/type-int/pm-invalid-type.yaml b/tests/config/fail/type-int/pm-invalid-type.yaml new file mode 100644 index 0000000..053d991 --- /dev/null +++ b/tests/config/fail/type-int/pm-invalid-type.yaml @@ -0,0 +1,14 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + property-mappings: hello diff --git a/tests/config/fail/type-int/pm-property-invalid.yaml b/tests/config/fail/type-int/pm-property-invalid.yaml new file mode 100644 index 0000000..7b63c5a --- /dev/null +++ b/tests/config/fail/type-int/pm-property-invalid.yaml @@ -0,0 +1,20 @@ +version: '2.1' +metadata: + trace: + byte-order: le + clocks: + my_clock: {} + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + property-mappings: + - type: clock + name: my_clock + property: type diff --git a/tests/config/fail/type-int/pm-type-invalid.yaml b/tests/config/fail/type-int/pm-type-invalid.yaml new file mode 100644 index 0000000..23cafa4 --- /dev/null +++ b/tests/config/fail/type-int/pm-type-invalid.yaml @@ -0,0 +1,20 @@ +version: '2.1' +metadata: + trace: + byte-order: le + clocks: + my_clock: {} + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + property-mappings: + - type: stream + name: zala + property: value diff --git a/tests/config/fail/type-int/pm-unknown-clock.yaml b/tests/config/fail/type-int/pm-unknown-clock.yaml new file mode 100644 index 0000000..686a9a2 --- /dev/null +++ b/tests/config/fail/type-int/pm-unknown-clock.yaml @@ -0,0 +1,20 @@ +version: '2.1' +metadata: + trace: + byte-order: le + clocks: + my_clock: {} + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + property-mappings: + - type: clock + name: zala + property: value diff --git a/tests/config/fail/type-int/signed-invalid-type.yaml b/tests/config/fail/type-int/signed-invalid-type.yaml new file mode 100644 index 0000000..d000788 --- /dev/null +++ b/tests/config/fail/type-int/signed-invalid-type.yaml @@ -0,0 +1,14 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + signed: string diff --git a/tests/config/fail/type-int/size-0.yaml b/tests/config/fail/type-int/size-0.yaml new file mode 100644 index 0000000..b37ebf8 --- /dev/null +++ b/tests/config/fail/type-int/size-0.yaml @@ -0,0 +1,14 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 0 diff --git a/tests/config/fail/type-int/size-65.yaml b/tests/config/fail/type-int/size-65.yaml new file mode 100644 index 0000000..ba258fa --- /dev/null +++ b/tests/config/fail/type-int/size-65.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 65 + align: 8 diff --git a/tests/config/fail/type-int/size-invalid-type.yaml b/tests/config/fail/type-int/size-invalid-type.yaml new file mode 100644 index 0000000..647052d --- /dev/null +++ b/tests/config/fail/type-int/size-invalid-type.yaml @@ -0,0 +1,14 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: string diff --git a/tests/config/fail/type-int/size-no.yaml b/tests/config/fail/type-int/size-no.yaml new file mode 100644 index 0000000..2cba6f1 --- /dev/null +++ b/tests/config/fail/type-int/size-no.yaml @@ -0,0 +1,13 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int diff --git a/tests/config/fail/type-int/unknown-prop.yaml b/tests/config/fail/type-int/unknown-prop.yaml new file mode 100644 index 0000000..3e27467 --- /dev/null +++ b/tests/config/fail/type-int/unknown-prop.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + unknown: false diff --git a/tests/config/fail/type-string/fail.bats b/tests/config/fail/type-string/fail.bats new file mode 100644 index 0000000..1f6ec27 --- /dev/null +++ b/tests/config/fail/type-string/fail.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in string type object makes barectf fail' { + barectf_assert_file_exists unknown-prop.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/type-string/unknown-prop.yaml b/tests/config/fail/type-string/unknown-prop.yaml new file mode 100644 index 0000000..0d7ede7 --- /dev/null +++ b/tests/config/fail/type-string/unknown-prop.yaml @@ -0,0 +1,14 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: string + unknown: false diff --git a/tests/config/fail/type-struct/fail.bats b/tests/config/fail/type-struct/fail.bats new file mode 100644 index 0000000..52beffa --- /dev/null +++ b/tests/config/fail/type-struct/fail.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in struct type object makes barectf fail' { + barectf_assert_file_exists unknown-prop.yaml + barectf_config_check_fail +} + +@test 'wrong "fields" property type in struct type object makes barectf fail' { + barectf_assert_file_exists fields-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid field in "fields" property (invalid C identifier) in struct type object makes barectf fail' { + barectf_assert_file_exists fields-field-invalid-identifier.yaml + barectf_config_check_fail +} + +@test 'wrong "min-align" property type in struct type object makes barectf fail' { + barectf_assert_file_exists ma-invalid-type.yaml + barectf_config_check_fail +} + +@test 'invalid "min-align" property (0) in struct type object makes barectf fail' { + barectf_assert_file_exists ma-0.yaml + barectf_config_check_fail +} + +@test 'invalid "min-align" property (3) in struct type object makes barectf fail' { + barectf_assert_file_exists ma-3.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/type-struct/fields-field-invalid-identifier.yaml b/tests/config/fail/type-struct/fields-field-invalid-identifier.yaml new file mode 100644 index 0000000..e628510 --- /dev/null +++ b/tests/config/fail/type-struct/fields-field-invalid-identifier.yaml @@ -0,0 +1,14 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + 'a field': + class: int + size: 1 diff --git a/tests/config/fail/type-struct/fields-invalid-type.yaml b/tests/config/fail/type-struct/fields-invalid-type.yaml new file mode 100644 index 0000000..3d427cb --- /dev/null +++ b/tests/config/fail/type-struct/fields-invalid-type.yaml @@ -0,0 +1,11 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: 23 diff --git a/tests/config/fail/type-struct/ma-0.yaml b/tests/config/fail/type-struct/ma-0.yaml new file mode 100644 index 0000000..90ee5e6 --- /dev/null +++ b/tests/config/fail/type-struct/ma-0.yaml @@ -0,0 +1,11 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + min-align: 0 diff --git a/tests/config/fail/type-struct/ma-3.yaml b/tests/config/fail/type-struct/ma-3.yaml new file mode 100644 index 0000000..dcb7379 --- /dev/null +++ b/tests/config/fail/type-struct/ma-3.yaml @@ -0,0 +1,11 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + min-align: 3 diff --git a/tests/config/fail/type-struct/ma-invalid-type.yaml b/tests/config/fail/type-struct/ma-invalid-type.yaml new file mode 100644 index 0000000..d6258a5 --- /dev/null +++ b/tests/config/fail/type-struct/ma-invalid-type.yaml @@ -0,0 +1,11 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + min-align: yes diff --git a/tests/config/fail/type-struct/unknown-prop.yaml b/tests/config/fail/type-struct/unknown-prop.yaml new file mode 100644 index 0000000..0032be7 --- /dev/null +++ b/tests/config/fail/type-struct/unknown-prop.yaml @@ -0,0 +1,15 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + unknown: true + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/type/fail.bats b/tests/config/fail/type/fail.bats new file mode 100644 index 0000000..00a7aef --- /dev/null +++ b/tests/config/fail/type/fail.bats @@ -0,0 +1,24 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'type inheriting an unknown type alias makes barectf fail' { + barectf_assert_file_exists inherit-unknown.yaml + barectf_config_check_fail +} + +@test 'type inheriting a type alias defined after makes barectf fail' { + barectf_assert_file_exists inherit-forward.yaml + barectf_config_check_fail +} + +@test 'wrong type property type makes barectf fail' { + barectf_assert_file_exists invalid-type.yaml + barectf_config_check_fail +} + +@test 'no "class" property in type object makes barectf fail' { + barectf_assert_file_exists no-class.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/type/inherit-forward.yaml b/tests/config/fail/type/inherit-forward.yaml new file mode 100644 index 0000000..2f4f242 --- /dev/null +++ b/tests/config/fail/type/inherit-forward.yaml @@ -0,0 +1,20 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + $inherit: meow + size: 16 + meow: + class: int + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/type/inherit-unknown.yaml b/tests/config/fail/type/inherit-unknown.yaml new file mode 100644 index 0000000..e2b9e7e --- /dev/null +++ b/tests/config/fail/type/inherit-unknown.yaml @@ -0,0 +1,18 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + $inherit: unknown + size: 16 + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/type/invalid-type.yaml b/tests/config/fail/type/invalid-type.yaml new file mode 100644 index 0000000..368d768 --- /dev/null +++ b/tests/config/fail/type/invalid-type.yaml @@ -0,0 +1,21 @@ +version: '2.1' +metadata: + type-aliases: + an-int: 23 + trace: + byte-order: le + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/fail/type/no-class.yaml b/tests/config/fail/type/no-class.yaml new file mode 100644 index 0000000..7efd5b3 --- /dev/null +++ b/tests/config/fail/type/no-class.yaml @@ -0,0 +1,13 @@ +version: '2.1' +metadata: + trace: + byte-order: le + streams: + my_stream: + events: + my_event: + payload-type: + class: struct + fields: + my_field: + size: 8 diff --git a/tests/config/fail/yaml/fail.bats b/tests/config/fail/yaml/fail.bats new file mode 100644 index 0000000..6936f79 --- /dev/null +++ b/tests/config/fail/yaml/fail.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'invalid YAML input makes barectf fail' { + barectf_assert_file_exists invalid.yaml + barectf_config_check_fail +} diff --git a/tests/config/fail/yaml/invalid.yaml b/tests/config/fail/yaml/invalid.yaml new file mode 100644 index 0000000..f6e15b6 --- /dev/null +++ b/tests/config/fail/yaml/invalid.yaml @@ -0,0 +1,24 @@ +version: '2.1' +metadata: + type-aliases: + uint16: + class: int + size: 16 + trace: + byte-order: + le: - 23 + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 diff --git a/tests/config/pass/everything/config.yaml b/tests/config/pass/everything/config.yaml new file mode 100644 index 0000000..1e78b4a --- /dev/null +++ b/tests/config/pass/everything/config.yaml @@ -0,0 +1,77 @@ +version: '2.1' +prefix: bctf_ +metadata: + $include: + - inc-metadata.yaml + - stdmisc.yaml + - lttng-ust-log-levels.yaml + type-aliases: + my-clock-int: + $inherit: uint32 + property-mappings: + - type: clock + name: some_clock + property: value + my-special-int: + size: 19 + base: hex + $log-levels: + couch: 0755 + trace: + $include: inc-trace.yaml + byte-order: be + clocks: + some_clock: + $include: inc-clock.yaml + description: this is my favorite clock + offset: + cycles: 91827439187 + absolute: null + streams: + my_stream: + packet-context-type: + class: struct + fields: + packet_size: uint16 + content_size: uint16 + timestamp_begin: my-clock-int + timestamp_end: my-clock-int + events: + my_event: + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + my_other_stream: + $include: inc-stream.yaml + packet-context-type: + class: struct + fields: + packet_size: uint32 + content_size: uint32 + events_discarded: uint16 + event-header-type: + class: struct + fields: + id: uint8 + timestamp: my-clock-int + events: + my_event: + $include: inc-event.yaml + context-type: null + payload-type: + class: struct + fields: + my_field: + class: int + size: 8 + oh_henry_event: + payload-type: + class: struct + fields: + s1: string + s2: string + s3: string + s4: string diff --git a/tests/config/pass/everything/inc-clock.yaml b/tests/config/pass/everything/inc-clock.yaml new file mode 100644 index 0000000..b9a29eb --- /dev/null +++ b/tests/config/pass/everything/inc-clock.yaml @@ -0,0 +1,5 @@ +freq: 123456789 +offset: + seconds: 18 +absolute: true +$return-ctype: unsigned long diff --git a/tests/config/pass/everything/inc-event.yaml b/tests/config/pass/everything/inc-event.yaml new file mode 100644 index 0000000..ee1931c --- /dev/null +++ b/tests/config/pass/everything/inc-event.yaml @@ -0,0 +1,5 @@ +log-level: WARNING +context-type: + class: struct + fields: + fff: float diff --git a/tests/config/pass/everything/inc-metadata.yaml b/tests/config/pass/everything/inc-metadata.yaml new file mode 100644 index 0000000..206c543 --- /dev/null +++ b/tests/config/pass/everything/inc-metadata.yaml @@ -0,0 +1,33 @@ +$include: + - stdint.yaml + - stdfloat.yaml +type-aliases: + my-special-int: + class: int + size: 23 + align: 2 + struct32: + class: struct + min-align: 32 + def-payload-type: + $inherit: struct32 + fields: + haha: float + hihi: uint32 + huhu: uint16 + hoho: double +streams: + my_other_stream: + events: + this_event: + payload-type: + class: struct + fields: + special: my-special-int + more_special: + $inherit: my-special-int + align: 32 +$log-levels: + couch: 23 + tv: 199 + thread: 0x28aff diff --git a/tests/config/pass/everything/inc-stream.yaml b/tests/config/pass/everything/inc-stream.yaml new file mode 100644 index 0000000..28ce6e6 --- /dev/null +++ b/tests/config/pass/everything/inc-stream.yaml @@ -0,0 +1,11 @@ +event-context-type: + class: struct + fields: + i: int32 + f: float + d: double + s: string + m: ctf-magic +events: + evev: + payload-type: def-payload-type diff --git a/tests/config/pass/everything/inc-trace.yaml b/tests/config/pass/everything/inc-trace.yaml new file mode 100644 index 0000000..676cdf3 --- /dev/null +++ b/tests/config/pass/everything/inc-trace.yaml @@ -0,0 +1,4 @@ +$include: trace-basic.yaml +packet-header-type: + fields: + soy_sauce: uint64 diff --git a/tests/config/pass/everything/pass.bats b/tests/config/pass/everything/pass.bats new file mode 100644 index 0000000..7a15f4f --- /dev/null +++ b/tests/config/pass/everything/pass.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../common + +@test 'unknown property in config object makes barectf fail' { + barectf_assert_file_exists config.yaml + [ $status -eq 0 ] + [ -f metadata ] + [ -f bctf.c ] + [ -f bctf.h ] + [ -f bctf-bitfield.h ] + + # test should be more extensive than that, but it's a start + $CC -c bctf.c + nm bctf.o | grep bctf_init + nm bctf.o | grep bctf_my_other_stream_close_packet + nm bctf.o | grep bctf_my_other_stream_open_packet + nm bctf.o | grep bctf_my_other_stream_trace_evev + nm bctf.o | grep bctf_my_other_stream_trace_my_event + nm bctf.o | grep bctf_my_other_stream_trace_oh_henry_event + nm bctf.o | grep bctf_my_other_stream_trace_this_event + nm bctf.o | grep bctf_my_stream_close_packet + nm bctf.o | grep bctf_my_stream_open_packet + nm bctf.o | grep bctf_my_stream_trace_my_event + nm bctf.o | grep bctf_packet_buf + nm bctf.o | grep bctf_packet_buf_size + nm bctf.o | grep bctf_packet_events_discarded + nm bctf.o | grep bctf_packet_is_empty + nm bctf.o | grep bctf_packet_is_full + nm bctf.o | grep bctf_packet_is_open + nm bctf.o | grep bctf_packet_set_buf + nm bctf.o | grep bctf_packet_size +} diff --git a/tests/test.bash b/tests/test.bash new file mode 100755 index 0000000..3d7003b --- /dev/null +++ b/tests/test.bash @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +test_dirs=( + "config/fail/clock" + "config/fail/config" + "config/fail/event" + "config/fail/include" + "config/fail/metadata" + "config/fail/stream" + "config/fail/trace" + "config/fail/type" + "config/fail/type-enum" + "config/fail/type-float" + "config/fail/type-int" + "config/fail/type-string" + "config/fail/type-struct" + "config/fail/yaml" + "config/pass/everything" +) +bats_bin="$(pwd)/bats/bin/bats" +rc=0 + +if [ -z ${CC+x} ]; then + # default to gcc + export CC=gcc +fi + +for d in ${test_dirs[@]}; do + pushd $d + $bats_bin $@ . + popd + + if [ $? -ne 0 ]; then + # latch error, but continue other tests + rc=1 + fi +done + +exit $rc -- 2.34.1