Remove an obselete and redundant text.

This commit is contained in:
Lei Zhang 2015-11-12 14:42:03 -05:00 committed by David Neto
parent e7c426ac8d
commit 321c3e206b

View File

@ -138,161 +138,6 @@ union char_word_t {
uint32_t u;
};
TEST(TextToBinary, Default) {
// TODO: Ensure that on big endian systems that this converts the word to
// little endian for encoding comparison!
spv_endianness_t endian = SPV_ENDIANNESS_LITTLE;
const char* textStr = R"(
OpSource OpenCL_C 12
OpMemoryModel Physical64 OpenCL
OpSourceExtension "PlaceholderExtensionName"
OpEntryPoint Kernel %1 "foo"
OpExecutionMode %1 LocalSizeHint 1 1 1
%2 = OpTypeVoid
%3 = OpTypeBool
; commment
%4 = OpTypeInt 8 0 ; comment
%5 = OpTypeInt 8 1
%6 = OpTypeInt 16 0
%7 = OpTypeInt 16 1
%8 = OpTypeInt 32 0
%9 = OpTypeInt 32 1
%10 = OpTypeInt 64 0
%11 = OpTypeInt 64 1
%12 = OpTypeFloat 16
%13 = OpTypeFloat 32
%14 = OpTypeFloat 64
%15 = OpTypeVector %4 2
)";
spv_binary binary;
spv_diagnostic diagnostic = nullptr;
spv_result_t error =
spvTextToBinary(textStr, strlen(textStr), &binary, &diagnostic);
if (error) {
spvDiagnosticPrint(diagnostic);
spvDiagnosticDestroy(diagnostic);
ASSERT_EQ(SPV_SUCCESS, error);
}
EXPECT_NE(nullptr, binary->code);
EXPECT_NE(0, binary->wordCount);
// TODO: Verify binary
ASSERT_EQ(SpvMagicNumber, binary->code[SPV_INDEX_MAGIC_NUMBER]);
ASSERT_EQ(SpvVersion, binary->code[SPV_INDEX_VERSION_NUMBER]);
ASSERT_EQ(SPV_GENERATOR_KHRONOS, binary->code[SPV_INDEX_GENERATOR_NUMBER]);
ASSERT_EQ(16, binary->code[SPV_INDEX_BOUND]); // TODO: Bound?
ASSERT_EQ(0, binary->code[SPV_INDEX_SCHEMA]); // Reserved: schema
uint64_t instIndex = SPV_INDEX_INSTRUCTION;
ASSERT_EQ(spvOpcodeMake(3, SpvOpSource), binary->code[instIndex++]);
ASSERT_EQ(SpvSourceLanguageOpenCL_C, binary->code[instIndex++]);
ASSERT_EQ(12, binary->code[instIndex++]);
ASSERT_EQ(spvOpcodeMake(3, SpvOpMemoryModel), binary->code[instIndex++]);
ASSERT_EQ(SpvAddressingModelPhysical64, binary->code[instIndex++]);
ASSERT_EQ(SpvMemoryModelOpenCL, binary->code[instIndex++]);
uint16_t sourceExtensionWordCount =
(uint16_t)((strlen("PlaceholderExtensionName") / sizeof(uint32_t)) + 2);
ASSERT_EQ(spvOpcodeMake(sourceExtensionWordCount, SpvOpSourceExtension),
binary->code[instIndex++]);
// TODO: This only works on little endian systems!
char_word_t cw = {{'P', 'l', 'a', 'c'}};
ASSERT_EQ(spvFixWord(cw.u, endian), binary->code[instIndex++]);
cw = {{'e', 'h', 'o', 'l'}};
ASSERT_EQ(spvFixWord(cw.u, endian), binary->code[instIndex++]);
cw = {{'d', 'e', 'r', 'E'}};
ASSERT_EQ(spvFixWord(cw.u, endian), binary->code[instIndex++]);
cw = {{'x', 't', 'e', 'n'}};
ASSERT_EQ(spvFixWord(cw.u, endian), binary->code[instIndex++]);
cw = {{'s', 'i', 'o', 'n'}};
ASSERT_EQ(spvFixWord(cw.u, endian), binary->code[instIndex++]);
cw = {{'N', 'a', 'm', 'e'}};
ASSERT_EQ(spvFixWord(cw.u, endian), binary->code[instIndex++]);
ASSERT_EQ(0, binary->code[instIndex++]);
ASSERT_EQ(spvOpcodeMake(4, SpvOpEntryPoint), binary->code[instIndex++]);
ASSERT_EQ(SpvExecutionModelKernel, binary->code[instIndex++]);
ASSERT_EQ(1, binary->code[instIndex++]);
cw = {{'f', 'o', 'o', 0}};
ASSERT_EQ(spvFixWord(cw.u, endian), binary->code[instIndex++]);
ASSERT_EQ(spvOpcodeMake(6, SpvOpExecutionMode), binary->code[instIndex++]);
ASSERT_EQ(1, binary->code[instIndex++]);
ASSERT_EQ(SpvExecutionModeLocalSizeHint, binary->code[instIndex++]);
ASSERT_EQ(1, binary->code[instIndex++]);
ASSERT_EQ(1, binary->code[instIndex++]);
ASSERT_EQ(1, binary->code[instIndex++]);
ASSERT_EQ(spvOpcodeMake(2, SpvOpTypeVoid), binary->code[instIndex++]);
ASSERT_EQ(2, binary->code[instIndex++]);
ASSERT_EQ(spvOpcodeMake(2, SpvOpTypeBool), binary->code[instIndex++]);
ASSERT_EQ(3, binary->code[instIndex++]);
ASSERT_EQ(spvOpcodeMake(4, SpvOpTypeInt), binary->code[instIndex++]);
ASSERT_EQ(4, binary->code[instIndex++]);
ASSERT_EQ(8, binary->code[instIndex++]); // NOTE: 8 bits wide
ASSERT_EQ(0, binary->code[instIndex++]); // NOTE: Unsigned
ASSERT_EQ(spvOpcodeMake(4, SpvOpTypeInt), binary->code[instIndex++]);
ASSERT_EQ(5, binary->code[instIndex++]);
ASSERT_EQ(8, binary->code[instIndex++]); // NOTE: 8 bits wide
ASSERT_EQ(1, binary->code[instIndex++]); // NOTE: Signed
ASSERT_EQ(spvOpcodeMake(4, SpvOpTypeInt), binary->code[instIndex++]);
ASSERT_EQ(6, binary->code[instIndex++]);
ASSERT_EQ(16, binary->code[instIndex++]); // NOTE: 16 bits wide
ASSERT_EQ(0, binary->code[instIndex++]); // NOTE: Unsigned
ASSERT_EQ(spvOpcodeMake(4, SpvOpTypeInt), binary->code[instIndex++]);
ASSERT_EQ(7, binary->code[instIndex++]);
ASSERT_EQ(16, binary->code[instIndex++]); // NOTE: 16 bits wide
ASSERT_EQ(1, binary->code[instIndex++]); // NOTE: Signed
ASSERT_EQ(spvOpcodeMake(4, SpvOpTypeInt), binary->code[instIndex++]);
ASSERT_EQ(8, binary->code[instIndex++]);
ASSERT_EQ(32, binary->code[instIndex++]); // NOTE: 32 bits wide
ASSERT_EQ(0, binary->code[instIndex++]); // NOTE: Unsigned
ASSERT_EQ(spvOpcodeMake(4, SpvOpTypeInt), binary->code[instIndex++]);
ASSERT_EQ(9, binary->code[instIndex++]);
ASSERT_EQ(32, binary->code[instIndex++]); // NOTE: 32 bits wide
ASSERT_EQ(1, binary->code[instIndex++]); // NOTE: Signed
ASSERT_EQ(spvOpcodeMake(4, SpvOpTypeInt), binary->code[instIndex++]);
ASSERT_EQ(10, binary->code[instIndex++]);
ASSERT_EQ(64, binary->code[instIndex++]); // NOTE: 64 bits wide
ASSERT_EQ(0, binary->code[instIndex++]); // NOTE: Unsigned
ASSERT_EQ(spvOpcodeMake(4, SpvOpTypeInt), binary->code[instIndex++]);
ASSERT_EQ(11, binary->code[instIndex++]);
ASSERT_EQ(64, binary->code[instIndex++]); // NOTE: 64 bits wide
ASSERT_EQ(1, binary->code[instIndex++]); // NOTE: Signed
ASSERT_EQ(spvOpcodeMake(3, SpvOpTypeFloat), binary->code[instIndex++]);
ASSERT_EQ(12, binary->code[instIndex++]);
ASSERT_EQ(16, binary->code[instIndex++]); // NOTE: 16 bits wide
ASSERT_EQ(spvOpcodeMake(3, SpvOpTypeFloat), binary->code[instIndex++]);
ASSERT_EQ(13, binary->code[instIndex++]);
ASSERT_EQ(32, binary->code[instIndex++]); // NOTE: 32 bits wide
ASSERT_EQ(spvOpcodeMake(3, SpvOpTypeFloat), binary->code[instIndex++]);
ASSERT_EQ(14, binary->code[instIndex++]);
ASSERT_EQ(64, binary->code[instIndex++]); // NOTE: 64 bits wide
ASSERT_EQ(spvOpcodeMake(4, SpvOpTypeVector), binary->code[instIndex++]);
ASSERT_EQ(15, binary->code[instIndex++]);
ASSERT_EQ(4, binary->code[instIndex++]);
ASSERT_EQ(2, binary->code[instIndex++]);
}
TEST_F(TextToBinaryTest, InvalidText) {
spv_binary binary;
ASSERT_EQ(SPV_ERROR_INVALID_TEXT,