Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: unittest/IceParseInstsTest.cpp

Issue 800883006: Add ability to test parsing of bitcode records in Subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix issues in last patch set. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « unittest/BitcodeMunge.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //===- unittest/IceParseInstsTest.cpp - test instruction errors -----------===//
2 //
3 // The Subzero Code Generator
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h"
12 #include "llvm/Bitcode/NaCl/NaClLLVMBitCodes.h"
13
14 #include "BitcodeMunge.h"
15
16 #include "gtest/gtest.h"
17
18 using namespace llvm;
19
20 namespace {
21
22 static const uint64_t Terminator = 0x5768798008978675LL;
23
24 /// Test how we report a call arg that refers to nonexistent call argument
25 TEST(IceParseInstsTest, NonexistentCallArg) {
26 const uint64_t BitcodeRecords[] = {
27 1, naclbitc::BLK_CODE_ENTER, naclbitc::MODULE_BLOCK_ID, 2, Terminator,
28 1, naclbitc::BLK_CODE_ENTER, naclbitc::TYPE_BLOCK_ID_NEW, 2, Terminator,
29 3, naclbitc::TYPE_CODE_NUMENTRY, 3, Terminator,
30 3, naclbitc::TYPE_CODE_INTEGER, 32, Terminator,
31 3, naclbitc::TYPE_CODE_VOID, Terminator,
32 3, naclbitc::TYPE_CODE_FUNCTION, 0, 1, 0, 0, Terminator,
33 0, naclbitc::BLK_CODE_EXIT, Terminator,
34 3, naclbitc::MODULE_CODE_FUNCTION, 2, 0, 1, 0, Terminator,
35 3, naclbitc::MODULE_CODE_FUNCTION, 2, 0, 0, 0, Terminator,
36 1, naclbitc::BLK_CODE_ENTER, naclbitc::FUNCTION_BLOCK_ID, 2, Terminator,
37 3, naclbitc::FUNC_CODE_DECLAREBLOCKS, 1, Terminator,
38 // Note: 100 is a bad value index in next line.
39 3, naclbitc::FUNC_CODE_INST_CALL, 0, 4, 2, 100, Terminator,
40 3, naclbitc::FUNC_CODE_INST_RET, Terminator,
41 0, naclbitc::BLK_CODE_EXIT, Terminator,
42 0, naclbitc::BLK_CODE_EXIT, Terminator
43 };
44
45
46 // Show bitcode objdump for BitcodeRecords.
47 NaClObjDumpMunger DumpMunger(BitcodeRecords,
48 array_lengthof(BitcodeRecords), Terminator);
49 EXPECT_FALSE(DumpMunger.runTestForAssembly("Nonexistent call arg"));
50 EXPECT_EQ(
51 "module { // BlockID = 8\n"
52 " types { // BlockID = 17\n"
53 " count 3;\n"
54 " @t0 = i32;\n"
55 " @t1 = void;\n"
56 " @t2 = void (i32, i32);\n"
57 " }\n"
58 " declare external void @f0(i32, i32);\n"
59 " define external void @f1(i32, i32);\n"
60 " function void @f1(i32 %p0, i32 %p1) { // BlockID = 12\n"
61 " blocks 1;\n"
62 " %b0:\n"
63 " call void @f0(i32 %p0, i32 @f0);\n"
64 "Error(66:4): Invalid relative value id: 100 (Must be <= 4)\n"
65 " ret void;\n"
66 " }\n"
67 "}\n",
68 DumpMunger.getTestResults());
69
70 // Show that we get appropriate error when parsing in Subzero.
71 IceTest::SubzeroBitcodeMunger Munger(
72 BitcodeRecords, array_lengthof(BitcodeRecords), Terminator);
73 EXPECT_FALSE(Munger.runTest("Nonexistent call arg"));
74 EXPECT_EQ(
75 "Error: (66:4) Invalid function record: <34 0 4 2 100>\n",
76 Munger.getTestResults());
77 }
78
79 } // end of anonymous namespace
OLDNEW
« no previous file with comments | « unittest/BitcodeMunge.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698