llvm/llvm/unittests/Object/DXContainerTest.cpp

//===- DXContainerTest.cpp - Tests for DXContainerFile --------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "llvm/Object/DXContainer.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/ObjectYAML/DXContainerYAML.h"
#include "llvm/ObjectYAML/yaml2obj.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"

usingnamespacellvm;
usingnamespacellvm::object;

template <std::size_t X> MemoryBufferRef getMemoryBuffer(uint8_t Data[X]) {}

TEST(DXCFile, IdentifyMagic) {}

TEST(DXCFile, ParseHeaderErrors) {}

TEST(DXCFile, EmptyFile) {}

TEST(DXCFile, ParseHeader) {}

TEST(DXCFile, ParsePartMissingOffsets) {}

TEST(DXCFile, ParsePartInvalidOffsets) {}

TEST(DXCFile, ParsePartTooSmallBuffer) {}

TEST(DXCFile, ParsePartNoSize) {}

TEST(DXCFile, ParseOverlappingParts) {}

TEST(DXCFile, ParseEmptyParts) {}

// This test verify DXIL part are correctly parsed.
// This test is based on the binary output constructed from this yaml.
// --- !dxcontainer
// Header:
//   Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
//                      0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
//   Version:
//     Major:           1
//     Minor:           0
//   PartCount:       1
// Parts:
//   - Name:            DXIL
//     Size:            28
//     Program:
//       MajorVersion:    6
//       MinorVersion:    5
//       ShaderKind:      5
//       Size:            8
//       DXILMajorVersion: 1
//       DXILMinorVersion: 5
//       DXILSize:        4
//       DXIL:            [ 0x42, 0x43, 0xC0, 0xDE, ]
// ...
TEST(DXCFile, ParseDXILPart) {}

static Expected<DXContainer>
generateDXContainer(StringRef Yaml, SmallVectorImpl<char> &BinaryData) {}

TEST(DXCFile, PSVResourceIterators) {}

// The malicious file bits in these tests are mutations of the binary produced
// by the following YAML:
//
// --- !dxcontainer
// Header:
//   Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
//                      0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
//   Version:
//     Major:           1
//     Minor:           0
//   PartCount:       3
// Parts:
//   - Name:            DXIL
//     Size:            24
//     Program:
//       MajorVersion:    6
//       MinorVersion:    0
//       ShaderKind:      14
//       Size:            6
//       DXILMajorVersion: 1
//       DXILMinorVersion: 0
//       DXILSize:        0
//   - Name:            PSV0
//     Size:            36
//     PSVInfo:
//       Version:         0
//       ShaderStage:     5
//       MinimumWaveLaneCount: 0
//       MaximumWaveLaneCount: 0
//       ResourceStride:       16
//       Resources: []
//   - Name: BLEH
//     Size: 16
// ...

TEST(DXCFile, MaliciousFiles) {}

// This test verifies that the resource iterator follows the stride even if the
// stride doesn't match an expected or known value. In this test, the resource
// data is structured validly, with 32 bytes per resource. This test is based on
// editing the binary output constructed from this yaml.
//
// --- !dxcontainer
// Header:
//   Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
//                      0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
//   Version:
//     Major:           1
//     Minor:           0
//   PartCount:       2
// Parts:
//   - Name:            DXIL
//     Size:            24
//     Program:
//       MajorVersion:    6
//       MinorVersion:    0
//       ShaderKind:      14
//       Size:            6
//       DXILMajorVersion: 1
//       DXILMinorVersion: 0
//       DXILSize:        0
//   - Name:            PSV0
//     Size:            100
//     PSVInfo:
//       Version:         0
//       ShaderStage:     5
//       MinimumWaveLaneCount: 0
//       MaximumWaveLaneCount: 0
//       ResourceStride:       16
//       Resources:
//         - Type:            1
//           Space:           2
//           LowerBound:      3
//           UpperBound:      4
//         - Type:            5
//           Space:           6
//           LowerBound:      7
//           UpperBound:      8
// ...
TEST(DXCFile, PSVResourceIteratorsStride) {}

// This test binary is created using mutations of the yaml in the SigElements
// test found under test/ObjectYAML/DXContainer/SigElements.yaml.

TEST(DXCFile, MisalignedStringTable) {}

// This test binary is created using mutations of the yaml in the SigElements
// test found under test/ObjectYAML/DXContainer/SigElements.yaml.
TEST(DXCFile, SigElementsExtendBeyondPart) {}

TEST(DXCFile, MalformedSignature) {}