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