spirv-reader: update tests to valid SPIR-V

Bug: tint:765
Change-Id: I4312f9aa94fd813aeb9b388c10303f967057066f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49644
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
diff --git a/src/reader/spirv/function_misc_test.cc b/src/reader/spirv/function_misc_test.cc
index 0539563..5a93548 100644
--- a/src/reader/spirv/function_misc_test.cc
+++ b/src/reader/spirv/function_misc_test.cc
@@ -25,6 +25,15 @@
 using ::testing::Eq;
 using ::testing::HasSubstr;
 
+std::string Preamble() {
+  return R"(
+   OpCapability Shader
+   OpMemoryModel Logical Simple
+   OpEntryPoint Fragment %100 "main"
+   OpExecutionMode %100 OriginUpperLeft
+)";
+}
+
 std::string CommonTypes() {
   return R"(
   %void = OpTypeVoid
@@ -45,7 +54,7 @@
 using SpvParserTestMiscInstruction = SpvParserTest;
 
 TEST_F(SpvParserTestMiscInstruction, OpUndef_BeforeFunction_Scalar) {
-  const auto assembly = CommonTypes() + R"(
+  const auto assembly = Preamble() + CommonTypes() + R"(
      %1 = OpUndef %bool
      %2 = OpUndef %uint
      %3 = OpUndef %int
@@ -108,7 +117,7 @@
 }
 
 TEST_F(SpvParserTestMiscInstruction, OpUndef_BeforeFunction_Vector) {
-  const auto assembly = CommonTypes() + R"(
+  const auto assembly = Preamble() + CommonTypes() + R"(
      %4 = OpUndef %v2bool
      %1 = OpUndef %v2uint
      %2 = OpUndef %v2int
@@ -188,7 +197,7 @@
 }
 
 TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Scalar) {
-  const auto assembly = CommonTypes() + R"(
+  const auto assembly = Preamble() + CommonTypes() + R"(
      %100 = OpFunction %void None %voidfn
      %entry = OpLabel
      %1 = OpUndef %bool
@@ -251,7 +260,7 @@
 }
 
 TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) {
-  const auto assembly = CommonTypes() + R"(
+  const auto assembly = Preamble() + CommonTypes() + R"(
      %100 = OpFunction %void None %voidfn
      %entry = OpLabel
      %1 = OpUndef %v2uint
@@ -314,7 +323,7 @@
 }
 
 TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) {
-  const auto assembly = CommonTypes() + R"(
+  const auto assembly = Preamble() + CommonTypes() + R"(
      %mat = OpTypeMatrix %v2float 2
 
      %100 = OpFunction %void None %voidfn
@@ -355,7 +364,7 @@
 }
 
 TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) {
-  const auto assembly = CommonTypes() + R"(
+  const auto assembly = Preamble() + CommonTypes() + R"(
      %uint_2 = OpConstant %uint 2
      %arr = OpTypeArray %uint %uint_2
 
@@ -389,7 +398,7 @@
 }
 
 TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) {
-  const auto assembly = CommonTypes() + R"(
+  const auto assembly = Preamble() + CommonTypes() + R"(
      %strct = OpTypeStruct %bool %uint %int %float
 
      %100 = OpFunction %void None %voidfn
@@ -424,7 +433,7 @@
 }
 
 TEST_F(SpvParserTestMiscInstruction, OpNop) {
-  const auto assembly = CommonTypes() + R"(
+  const auto assembly = Preamble() + CommonTypes() + R"(
      %100 = OpFunction %void None %voidfn
      %entry = OpLabel
      OpNop
@@ -452,7 +461,7 @@
 
 TEST_P(SpvParserSwizzleTest, Sample) {
   // We need a function so we can get a FunctionEmitter.
-  const auto assembly = CommonTypes() + R"(
+  const auto assembly = Preamble() + CommonTypes() + R"(
      %100 = OpFunction %void None %voidfn
      %entry = OpLabel
      OpReturn
diff --git a/src/reader/spirv/parser_impl_handle_test.cc b/src/reader/spirv/parser_impl_handle_test.cc
index 757d18b..a633fca 100644
--- a/src/reader/spirv/parser_impl_handle_test.cc
+++ b/src/reader/spirv/parser_impl_handle_test.cc
@@ -33,10 +33,18 @@
     OpCapability Sampled1D
     OpCapability Image1D
     OpCapability StorageImageExtendedFormats
+    OpCapability ImageQuery
     OpMemoryModel Logical Simple
   )";
 }
 
+std::string FragMain() {
+  return R"(
+    OpEntryPoint Fragment %main "main" ; assume no IO
+    OpExecutionMode %main OriginUpperLeft
+  )";
+}
+
 std::string CommonBasicTypes() {
   return R"(
     %void = OpTypeVoid
@@ -811,7 +819,7 @@
     SpvParserTestBase<::testing::TestWithParam<UsageImageAccessCase>>;
 
 TEST_P(SpvParserTest_RegisterHandleUsage_SampledImage, Variable) {
-  const auto assembly = Preamble() + CommonTypes() + R"(
+  const auto assembly = Preamble() + FragMain() + CommonTypes() + R"(
      %si_ty = OpTypeSampledImage %f_texture_2d
      %coords = OpConstantNull %v2float
 
@@ -1098,6 +1106,7 @@
 
 TEST_P(SpvParserTest_DeclUnderspecifiedHandle, Variable) {
   const auto assembly = Preamble() + R"(
+     OpEntryPoint GLCompute %main "main"
      OpDecorate %10 DescriptorSet 0
      OpDecorate %10 Binding 0
 )" + GetParam().decorations +