//===- DeserializationTest.cpp - SPIR-V Deserialization Tests -------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // The purpose of this file is to provide negative deserialization tests. // For positive deserialization tests, please use serialization and // deserialization for roundtripping. // //===----------------------------------------------------------------------===// #include "mlir/Target/SPIRV/Deserialization.h" #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" #include "mlir/IR/Diagnostics.h" #include "mlir/IR/MLIRContext.h" #include "mlir/Target/SPIRV/SPIRVBinaryUtils.h" #include "gmock/gmock.h" #include <memory> usingnamespacemlir; StrEq; //===----------------------------------------------------------------------===// // Test Fixture //===----------------------------------------------------------------------===// /// A deserialization test fixture providing minimal SPIR-V building and /// diagnostic checking utilities. class DeserializationTest : public ::testing::Test { … }; //===----------------------------------------------------------------------===// // Basics //===----------------------------------------------------------------------===// TEST_F(DeserializationTest, EmptyModuleFailure) { … } TEST_F(DeserializationTest, WrongMagicNumberFailure) { … } TEST_F(DeserializationTest, OnlyHeaderSuccess) { … } TEST_F(DeserializationTest, ZeroWordCountFailure) { … } TEST_F(DeserializationTest, InsufficientWordFailure) { … } //===----------------------------------------------------------------------===// // Types //===----------------------------------------------------------------------===// TEST_F(DeserializationTest, IntTypeMissingSignednessFailure) { … } //===----------------------------------------------------------------------===// // StructType //===----------------------------------------------------------------------===// TEST_F(DeserializationTest, OpMemberNameSuccess) { … } TEST_F(DeserializationTest, OpMemberNameMissingOperands) { … } TEST_F(DeserializationTest, OpMemberNameExcessOperands) { … } //===----------------------------------------------------------------------===// // Functions //===----------------------------------------------------------------------===// TEST_F(DeserializationTest, FunctionMissingEndFailure) { … } TEST_F(DeserializationTest, FunctionMissingParameterFailure) { … } TEST_F(DeserializationTest, FunctionMissingLabelForFirstBlockFailure) { … } TEST_F(DeserializationTest, FunctionMalformedLabelFailure) { … }