binary_version_test.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (c) 2017 Pierre Moreau
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include <string>
  15. #include "gmock/gmock.h"
  16. #include "test/link/linker_fixture.h"
  17. namespace spvtools {
  18. namespace {
  19. using BinaryVersion = spvtest::LinkerTest;
  20. TEST_F(BinaryVersion, LinkerChoosesMaxSpirvVersion) {
  21. // clang-format off
  22. spvtest::Binaries binaries = {
  23. {
  24. SpvMagicNumber,
  25. 0x00000300u,
  26. SPV_GENERATOR_CODEPLAY,
  27. 1u, // NOTE: Bound
  28. 0u // NOTE: Schema; reserved
  29. },
  30. {
  31. SpvMagicNumber,
  32. 0x00000600u,
  33. SPV_GENERATOR_CODEPLAY,
  34. 1u, // NOTE: Bound
  35. 0u // NOTE: Schema; reserved
  36. },
  37. {
  38. SpvMagicNumber,
  39. 0x00000100u,
  40. SPV_GENERATOR_CODEPLAY,
  41. 1u, // NOTE: Bound
  42. 0u // NOTE: Schema; reserved
  43. }
  44. };
  45. // clang-format on
  46. spvtest::Binary linked_binary;
  47. ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary));
  48. EXPECT_THAT(GetErrorMessage(), std::string());
  49. EXPECT_EQ(0x00000600u, linked_binary[1]);
  50. }
  51. } // namespace
  52. } // namespace spvtools