blob: 6e82a530471707370a752046060554c275159eea [file] [log] [blame]
James Kuszmaul4ed5fb12022-03-22 15:20:04 -07001#include "aos/util/mcap_logger.h"
2
3#include <iostream>
4#include "flatbuffers/reflection_generated.h"
5#include "gtest/gtest.h"
6
7namespace aos::testing {
8// TODO(james): Write a proper test for the McapLogger itself. However, that
9// will require writing an MCAP reader (or importing an existing one).
10
11// Confirm that the schema for the reflection.Schema table itself hasn't
12// changed. reflection.Schema should be a very stable type, so this should need
13// updating except when we change the JSON schema generation itself.
14TEST(JsonSchemaTest, ReflectionSchema) {
15 std::string schema_json =
16 JsonSchemaForFlatbuffer({reflection::Schema::MiniReflectTypeTable()})
17 .dump(4);
18 EXPECT_EQ(R"json({
19 "$schema": "https://json-schema.org/draft/2020-12/schema",
20 "properties": {
21 "advanced_features": {
22 "type": "number"
23 },
24 "enums": {
25 "items": {
26 "properties": {
27 "attributes": {
28 "items": {
29 "properties": {
30 "key": {
31 "type": "string"
32 },
33 "value": {
34 "type": "string"
35 }
36 },
37 "type": "object"
38 },
39 "type": "array"
40 },
41 "declaration_file": {
42 "type": "string"
43 },
44 "documentation": {
45 "items": {
46 "type": "string"
47 },
48 "type": "array"
49 },
50 "is_union": {
51 "type": "boolean"
52 },
53 "name": {
54 "type": "string"
55 },
56 "underlying_type": {
57 "properties": {
58 "base_size": {
59 "type": "number"
60 },
61 "base_type": {
62 "type": "number"
63 },
64 "element": {
65 "type": "number"
66 },
67 "element_size": {
68 "type": "number"
69 },
70 "fixed_length": {
71 "type": "number"
72 },
73 "index": {
74 "type": "number"
75 }
76 },
77 "type": "object"
78 },
79 "values": {
80 "items": {
81 "properties": {
82 "documentation": {
83 "items": {
84 "type": "string"
85 },
86 "type": "array"
87 },
88 "name": {
89 "type": "string"
90 },
91 "object": {
92 "properties": {
93 "attributes": {
94 "items": {
95 "properties": {
96 "key": {
97 "type": "string"
98 },
99 "value": {
100 "type": "string"
101 }
102 },
103 "type": "object"
104 },
105 "type": "array"
106 },
107 "bytesize": {
108 "type": "number"
109 },
110 "declaration_file": {
111 "type": "string"
112 },
113 "documentation": {
114 "items": {
115 "type": "string"
116 },
117 "type": "array"
118 },
119 "fields": {
120 "items": {
121 "properties": {
122 "attributes": {
123 "items": {
124 "properties": {
125 "key": {
126 "type": "string"
127 },
128 "value": {
129 "type": "string"
130 }
131 },
132 "type": "object"
133 },
134 "type": "array"
135 },
136 "default_integer": {
137 "type": "number"
138 },
139 "default_real": {
140 "type": "number"
141 },
142 "deprecated": {
143 "type": "boolean"
144 },
145 "documentation": {
146 "items": {
147 "type": "string"
148 },
149 "type": "array"
150 },
151 "id": {
152 "type": "number"
153 },
154 "key": {
155 "type": "boolean"
156 },
157 "name": {
158 "type": "string"
159 },
160 "offset": {
161 "type": "number"
162 },
163 "optional": {
164 "type": "boolean"
165 },
166 "padding": {
167 "type": "number"
168 },
169 "required": {
170 "type": "boolean"
171 },
172 "type": {
173 "properties": {
174 "base_size": {
175 "type": "number"
176 },
177 "base_type": {
178 "type": "number"
179 },
180 "element": {
181 "type": "number"
182 },
183 "element_size": {
184 "type": "number"
185 },
186 "fixed_length": {
187 "type": "number"
188 },
189 "index": {
190 "type": "number"
191 }
192 },
193 "type": "object"
194 }
195 },
196 "type": "object"
197 },
198 "type": "array"
199 },
200 "is_struct": {
201 "type": "boolean"
202 },
203 "minalign": {
204 "type": "number"
205 },
206 "name": {
207 "type": "string"
208 }
209 },
210 "type": "object"
211 },
212 "union_type": {
213 "properties": {
214 "base_size": {
215 "type": "number"
216 },
217 "base_type": {
218 "type": "number"
219 },
220 "element": {
221 "type": "number"
222 },
223 "element_size": {
224 "type": "number"
225 },
226 "fixed_length": {
227 "type": "number"
228 },
229 "index": {
230 "type": "number"
231 }
232 },
233 "type": "object"
234 },
235 "value": {
236 "type": "number"
237 }
238 },
239 "type": "object"
240 },
241 "type": "array"
242 }
243 },
244 "type": "object"
245 },
246 "type": "array"
247 },
248 "fbs_files": {
249 "items": {
250 "properties": {
251 "filename": {
252 "type": "string"
253 },
254 "included_filenames": {
255 "items": {
256 "type": "string"
257 },
258 "type": "array"
259 }
260 },
261 "type": "object"
262 },
263 "type": "array"
264 },
265 "file_ext": {
266 "type": "string"
267 },
268 "file_ident": {
269 "type": "string"
270 },
271 "objects": {
272 "items": {
273 "properties": {
274 "attributes": {
275 "items": {
276 "properties": {
277 "key": {
278 "type": "string"
279 },
280 "value": {
281 "type": "string"
282 }
283 },
284 "type": "object"
285 },
286 "type": "array"
287 },
288 "bytesize": {
289 "type": "number"
290 },
291 "declaration_file": {
292 "type": "string"
293 },
294 "documentation": {
295 "items": {
296 "type": "string"
297 },
298 "type": "array"
299 },
300 "fields": {
301 "items": {
302 "properties": {
303 "attributes": {
304 "items": {
305 "properties": {
306 "key": {
307 "type": "string"
308 },
309 "value": {
310 "type": "string"
311 }
312 },
313 "type": "object"
314 },
315 "type": "array"
316 },
317 "default_integer": {
318 "type": "number"
319 },
320 "default_real": {
321 "type": "number"
322 },
323 "deprecated": {
324 "type": "boolean"
325 },
326 "documentation": {
327 "items": {
328 "type": "string"
329 },
330 "type": "array"
331 },
332 "id": {
333 "type": "number"
334 },
335 "key": {
336 "type": "boolean"
337 },
338 "name": {
339 "type": "string"
340 },
341 "offset": {
342 "type": "number"
343 },
344 "optional": {
345 "type": "boolean"
346 },
347 "padding": {
348 "type": "number"
349 },
350 "required": {
351 "type": "boolean"
352 },
353 "type": {
354 "properties": {
355 "base_size": {
356 "type": "number"
357 },
358 "base_type": {
359 "type": "number"
360 },
361 "element": {
362 "type": "number"
363 },
364 "element_size": {
365 "type": "number"
366 },
367 "fixed_length": {
368 "type": "number"
369 },
370 "index": {
371 "type": "number"
372 }
373 },
374 "type": "object"
375 }
376 },
377 "type": "object"
378 },
379 "type": "array"
380 },
381 "is_struct": {
382 "type": "boolean"
383 },
384 "minalign": {
385 "type": "number"
386 },
387 "name": {
388 "type": "string"
389 }
390 },
391 "type": "object"
392 },
393 "type": "array"
394 },
395 "root_table": {
396 "properties": {
397 "attributes": {
398 "items": {
399 "properties": {
400 "key": {
401 "type": "string"
402 },
403 "value": {
404 "type": "string"
405 }
406 },
407 "type": "object"
408 },
409 "type": "array"
410 },
411 "bytesize": {
412 "type": "number"
413 },
414 "declaration_file": {
415 "type": "string"
416 },
417 "documentation": {
418 "items": {
419 "type": "string"
420 },
421 "type": "array"
422 },
423 "fields": {
424 "items": {
425 "properties": {
426 "attributes": {
427 "items": {
428 "properties": {
429 "key": {
430 "type": "string"
431 },
432 "value": {
433 "type": "string"
434 }
435 },
436 "type": "object"
437 },
438 "type": "array"
439 },
440 "default_integer": {
441 "type": "number"
442 },
443 "default_real": {
444 "type": "number"
445 },
446 "deprecated": {
447 "type": "boolean"
448 },
449 "documentation": {
450 "items": {
451 "type": "string"
452 },
453 "type": "array"
454 },
455 "id": {
456 "type": "number"
457 },
458 "key": {
459 "type": "boolean"
460 },
461 "name": {
462 "type": "string"
463 },
464 "offset": {
465 "type": "number"
466 },
467 "optional": {
468 "type": "boolean"
469 },
470 "padding": {
471 "type": "number"
472 },
473 "required": {
474 "type": "boolean"
475 },
476 "type": {
477 "properties": {
478 "base_size": {
479 "type": "number"
480 },
481 "base_type": {
482 "type": "number"
483 },
484 "element": {
485 "type": "number"
486 },
487 "element_size": {
488 "type": "number"
489 },
490 "fixed_length": {
491 "type": "number"
492 },
493 "index": {
494 "type": "number"
495 }
496 },
497 "type": "object"
498 }
499 },
500 "type": "object"
501 },
502 "type": "array"
503 },
504 "is_struct": {
505 "type": "boolean"
506 },
507 "minalign": {
508 "type": "number"
509 },
510 "name": {
511 "type": "string"
512 }
513 },
514 "type": "object"
515 },
516 "services": {
517 "items": {
518 "properties": {
519 "attributes": {
520 "items": {
521 "properties": {
522 "key": {
523 "type": "string"
524 },
525 "value": {
526 "type": "string"
527 }
528 },
529 "type": "object"
530 },
531 "type": "array"
532 },
533 "calls": {
534 "items": {
535 "properties": {
536 "attributes": {
537 "items": {
538 "properties": {
539 "key": {
540 "type": "string"
541 },
542 "value": {
543 "type": "string"
544 }
545 },
546 "type": "object"
547 },
548 "type": "array"
549 },
550 "documentation": {
551 "items": {
552 "type": "string"
553 },
554 "type": "array"
555 },
556 "name": {
557 "type": "string"
558 },
559 "request": {
560 "properties": {
561 "attributes": {
562 "items": {
563 "properties": {
564 "key": {
565 "type": "string"
566 },
567 "value": {
568 "type": "string"
569 }
570 },
571 "type": "object"
572 },
573 "type": "array"
574 },
575 "bytesize": {
576 "type": "number"
577 },
578 "declaration_file": {
579 "type": "string"
580 },
581 "documentation": {
582 "items": {
583 "type": "string"
584 },
585 "type": "array"
586 },
587 "fields": {
588 "items": {
589 "properties": {
590 "attributes": {
591 "items": {
592 "properties": {
593 "key": {
594 "type": "string"
595 },
596 "value": {
597 "type": "string"
598 }
599 },
600 "type": "object"
601 },
602 "type": "array"
603 },
604 "default_integer": {
605 "type": "number"
606 },
607 "default_real": {
608 "type": "number"
609 },
610 "deprecated": {
611 "type": "boolean"
612 },
613 "documentation": {
614 "items": {
615 "type": "string"
616 },
617 "type": "array"
618 },
619 "id": {
620 "type": "number"
621 },
622 "key": {
623 "type": "boolean"
624 },
625 "name": {
626 "type": "string"
627 },
628 "offset": {
629 "type": "number"
630 },
631 "optional": {
632 "type": "boolean"
633 },
634 "padding": {
635 "type": "number"
636 },
637 "required": {
638 "type": "boolean"
639 },
640 "type": {
641 "properties": {
642 "base_size": {
643 "type": "number"
644 },
645 "base_type": {
646 "type": "number"
647 },
648 "element": {
649 "type": "number"
650 },
651 "element_size": {
652 "type": "number"
653 },
654 "fixed_length": {
655 "type": "number"
656 },
657 "index": {
658 "type": "number"
659 }
660 },
661 "type": "object"
662 }
663 },
664 "type": "object"
665 },
666 "type": "array"
667 },
668 "is_struct": {
669 "type": "boolean"
670 },
671 "minalign": {
672 "type": "number"
673 },
674 "name": {
675 "type": "string"
676 }
677 },
678 "type": "object"
679 },
680 "response": {
681 "properties": {
682 "attributes": {
683 "items": {
684 "properties": {
685 "key": {
686 "type": "string"
687 },
688 "value": {
689 "type": "string"
690 }
691 },
692 "type": "object"
693 },
694 "type": "array"
695 },
696 "bytesize": {
697 "type": "number"
698 },
699 "declaration_file": {
700 "type": "string"
701 },
702 "documentation": {
703 "items": {
704 "type": "string"
705 },
706 "type": "array"
707 },
708 "fields": {
709 "items": {
710 "properties": {
711 "attributes": {
712 "items": {
713 "properties": {
714 "key": {
715 "type": "string"
716 },
717 "value": {
718 "type": "string"
719 }
720 },
721 "type": "object"
722 },
723 "type": "array"
724 },
725 "default_integer": {
726 "type": "number"
727 },
728 "default_real": {
729 "type": "number"
730 },
731 "deprecated": {
732 "type": "boolean"
733 },
734 "documentation": {
735 "items": {
736 "type": "string"
737 },
738 "type": "array"
739 },
740 "id": {
741 "type": "number"
742 },
743 "key": {
744 "type": "boolean"
745 },
746 "name": {
747 "type": "string"
748 },
749 "offset": {
750 "type": "number"
751 },
752 "optional": {
753 "type": "boolean"
754 },
755 "padding": {
756 "type": "number"
757 },
758 "required": {
759 "type": "boolean"
760 },
761 "type": {
762 "properties": {
763 "base_size": {
764 "type": "number"
765 },
766 "base_type": {
767 "type": "number"
768 },
769 "element": {
770 "type": "number"
771 },
772 "element_size": {
773 "type": "number"
774 },
775 "fixed_length": {
776 "type": "number"
777 },
778 "index": {
779 "type": "number"
780 }
781 },
782 "type": "object"
783 }
784 },
785 "type": "object"
786 },
787 "type": "array"
788 },
789 "is_struct": {
790 "type": "boolean"
791 },
792 "minalign": {
793 "type": "number"
794 },
795 "name": {
796 "type": "string"
797 }
798 },
799 "type": "object"
800 }
801 },
802 "type": "object"
803 },
804 "type": "array"
805 },
806 "declaration_file": {
807 "type": "string"
808 },
809 "documentation": {
810 "items": {
811 "type": "string"
812 },
813 "type": "array"
814 },
815 "name": {
816 "type": "string"
817 }
818 },
819 "type": "object"
820 },
821 "type": "array"
822 }
823 },
824 "type": "object"
825})json",
826 schema_json);
827}
828
829} // namespace aos::testing