merge in nyc-mr1-release history after reset to nyc-mr1-dev
diff --git a/android/cts/master/com.drawelements.deqp.gles3.xml b/android/cts/master/com.drawelements.deqp.gles3.xml
index 76ef6b4..5e19de4 100644
--- a/android/cts/master/com.drawelements.deqp.gles3.xml
+++ b/android/cts/master/com.drawelements.deqp.gles3.xml
@@ -3211,12 +3211,6 @@
 						<Test name="basic_2_fragment">
 							<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 						</Test>
-						<Test name="defined_macro_defined_test_vertex">
-							<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-						</Test>
-						<Test name="defined_macro_defined_test_fragment">
-							<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-						</Test>
 						<Test name="defined_macro_undef_vertex">
 							<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 						</Test>
diff --git a/android/cts/master/gles3-master.txt b/android/cts/master/gles3-master.txt
index 6b535ab..9980ae0 100644
--- a/android/cts/master/gles3-master.txt
+++ b/android/cts/master/gles3-master.txt
@@ -956,8 +956,6 @@
 dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.basic_1_fragment
 dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.basic_2_vertex
 dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.basic_2_fragment
-dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.defined_macro_defined_test_vertex
-dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.defined_macro_defined_test_fragment
 dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.defined_macro_undef_vertex
 dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.defined_macro_undef_fragment
 dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.defined_invalid_before_all_macros_replaced_vertex
diff --git a/android/cts/master/src/gles3-spec-issues.txt b/android/cts/master/src/gles3-spec-issues.txt
index ad1f008..2b7cf96 100644
--- a/android/cts/master/src/gles3-spec-issues.txt
+++ b/android/cts/master/src/gles3-spec-issues.txt
@@ -525,3 +525,5 @@
 dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.define_defined_fragment
 dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.define_defined_outside_if_vertex
 dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.define_defined_outside_if_fragment
+dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.defined_macro_defined_test_fragment
+dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.defined_macro_defined_test_vertex
diff --git a/framework/delibs/debase/deString.c b/framework/delibs/debase/deString.c
index e6290f0..a9d3a3e 100644
--- a/framework/delibs/debase/deString.c
+++ b/framework/delibs/debase/deString.c
@@ -185,7 +185,7 @@
 	return strnlen_s(string, maxSize);
 #else
 	size_t len = 0;
-	while (len < maxSize || string[len] != 0)
+	while (len < maxSize && string[len] != 0)
 		++len;
 	return len;
 #endif
diff --git a/modules/egl/teglPartialUpdateTests.cpp b/modules/egl/teglPartialUpdateTests.cpp
index 33ff3ea..f2f280e 100644
--- a/modules/egl/teglPartialUpdateTests.cpp
+++ b/modules/egl/teglPartialUpdateTests.cpp
@@ -504,7 +504,6 @@
 		tcu::Surface	refBuffer		 (width, height);
 		Frame			newFrame		 (width, height);
 		EGLint			currentBufferAge = -1;
-		vector<EGLint>	damageRegion;
 
 		if (frameNdx % 2 == 0)
 			generateRandomFrame(newFrame, m_evenFrameDrawType, rnd);
@@ -528,12 +527,22 @@
 
 		if (currentBufferAge > 0)
 		{
+			vector<EGLint>	damageRegion;
+
 			hasPositiveAge = true;
 
 			if (m_supportBufferAge)
+			{
 				damageRegion = getDamageRegion(newFrame, 10, 10, 10, 10);
+			}
 			else
+			{
 				damageRegion = getDamageRegion(newFrame, 0, 0, 0, 0);
+				// Set empty damage region to avoid invalidating the framebuffer. The damage area is invalidated
+				// if the buffer age extension is not supported.
+				if (damageRegion.size() == 0)
+					damageRegion = vector<EGLint>(4, 0);
+			}
 
 			EGLU_CHECK_CALL(egl, setDamageRegionKHR(m_eglDisplay, m_eglSurface, &damageRegion[0], (EGLint)damageRegion.size()/4));
 		}
diff --git a/modules/gles31/functional/es31fNegativeBufferApiTests.cpp b/modules/gles31/functional/es31fNegativeBufferApiTests.cpp
index 1e4632b..d2bb14f 100644
--- a/modules/gles31/functional/es31fNegativeBufferApiTests.cpp
+++ b/modules/gles31/functional/es31fNegativeBufferApiTests.cpp
@@ -309,13 +309,17 @@
 	ctx.glReadPixels			(0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
 	ctx.expectError				(GL_INVALID_OPERATION);
 
-	ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
-	ctx.expectError				(GL_NO_ERROR);
-	ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
-	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
-	ctx.expectError				(GL_NO_ERROR);
-	ctx.glReadPixels			(0, 0, 1, 1, GL_RGBA, GL_INT, &floatData[0]);
-	ctx.expectError				(GL_INVALID_OPERATION);
+	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ||
+		ctx.isExtensionSupported("GL_EXT_color_buffer_float"))
+	{
+		ctx.glTexImage2D			(GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
+		ctx.expectError				(GL_NO_ERROR);
+		ctx.glFramebufferTexture2D	(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
+		ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
+		ctx.expectError				(GL_NO_ERROR);
+		ctx.glReadPixels			(0, 0, 1, 1, GL_RGBA, GL_INT, &floatData[0]);
+		ctx.expectError				(GL_INVALID_OPERATION);
+	}
 
 	ctx.endSection();
 
diff --git a/modules/gles31/functional/es31fNegativePreciseTests.cpp b/modules/gles31/functional/es31fNegativePreciseTests.cpp
index c21cb7b..18a3b27 100644
--- a/modules/gles31/functional/es31fNegativePreciseTests.cpp
+++ b/modules/gles31/functional/es31fNegativePreciseTests.cpp
@@ -164,7 +164,10 @@
 
 	ctx.beginSection("Test that precise cannot be used as a variable name.");
 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_shaderTypes); ++ndx)
-		generateAndVerifyShader(ctx, s_shaderTypes[ndx], TEST_PRECISE_AS_VARIABLE_NAME);
+	{
+		if (ctx.isShaderSupported(s_shaderTypes[ndx]))
+			generateAndVerifyShader(ctx, s_shaderTypes[ndx], TEST_PRECISE_AS_VARIABLE_NAME);
+	}
 	ctx.endSection();
 }
 
@@ -176,7 +179,10 @@
 
 	ctx.beginSection("Test that precise cannot be used as a function name.");
 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_shaderTypes); ++ndx)
-		generateAndVerifyShader(ctx, s_shaderTypes[ndx], TEST_PRECISE_AS_FUNCTION_NAME);
+	{
+		if (ctx.isShaderSupported(s_shaderTypes[ndx]))
+			generateAndVerifyShader(ctx, s_shaderTypes[ndx], TEST_PRECISE_AS_FUNCTION_NAME);
+	}
 	ctx.endSection();
 }
 
@@ -188,7 +194,10 @@
 
 	ctx.beginSection("Test that precise cannot be used as a argument name.");
 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_shaderTypes); ++ndx)
-		generateAndVerifyShader(ctx, s_shaderTypes[ndx], TEST_PRECISE_AS_ARGUMENT_NAME);
+	{
+		if (ctx.isShaderSupported(s_shaderTypes[ndx]))
+			generateAndVerifyShader(ctx, s_shaderTypes[ndx], TEST_PRECISE_AS_ARGUMENT_NAME);
+	}
 	ctx.endSection();
 }
 
diff --git a/modules/gles31/functional/es31fNegativeShaderDirectiveTests.cpp b/modules/gles31/functional/es31fNegativeShaderDirectiveTests.cpp
index 09ae12a..f4f4bdf 100644
--- a/modules/gles31/functional/es31fNegativeShaderDirectiveTests.cpp
+++ b/modules/gles31/functional/es31fNegativeShaderDirectiveTests.cpp
@@ -109,8 +109,9 @@
 
 void primitive_bounding_box (NegativeTestContext& ctx)
 {
-	ctx.beginSection("GL_EXT_primitive_bounding_box features require enabling the extension in 310 es shaders.");
+	if (ctx.isShaderSupported(glu::SHADERTYPE_TESSELLATION_CONTROL))
 	{
+		ctx.beginSection("GL_EXT_primitive_bounding_box features require enabling the extension in 310 es shaders.");
 		std::ostringstream source;
 		source <<	"#version 310 es\n"
 					"void main()\n"
@@ -119,8 +120,8 @@
 					"	gl_BoundingBoxEXT[1] = vec4(1.0, 1.0, 1.0, 1.0);\n"
 					"}\n";
 		verifyShader(ctx, glu::SHADERTYPE_TESSELLATION_CONTROL, source.str(), EXPECT_RESULT_FAIL);
+		ctx.endSection();
 	}
-	ctx.endSection();
 
 	if (contextSupports(ctx.getRenderContext().getType() , glu::ApiType::es(3, 2)))
 	{
@@ -303,22 +304,25 @@
 
 void geometry_shader (NegativeTestContext& ctx)
 {
-	const std::string	simpleVtxFrag	=	"#version 310 es\n"
-											"void main()\n"
-											"{\n"
-											"}\n";
-	const std::string	geometry		=	"#version 310 es\n"
-											"layout(points, invocations = 1) in;\n"
-											"layout(points, max_vertices = 3) out;\n"
-											"precision mediump float;\n"
-											"void main()\n"
-											"{\n"
-											"	EmitVertex();\n"
-											"	EndPrimitive();\n"
-											"}\n";
-	ctx.beginSection("GL_EXT_geometry_shader features require enabling the extension in 310 es shaders.");
-	verifyProgram(ctx, glu::ProgramSources() << glu::VertexSource(simpleVtxFrag) << glu::GeometrySource(geometry) << glu::FragmentSource(simpleVtxFrag), EXPECT_RESULT_FAIL);
-	ctx.endSection();
+	if (ctx.isShaderSupported(glu::SHADERTYPE_GEOMETRY))
+	{
+		const std::string	simpleVtxFrag	=	"#version 310 es\n"
+												"void main()\n"
+												"{\n"
+												"}\n";
+		const std::string	geometry		=	"#version 310 es\n"
+												"layout(points, invocations = 1) in;\n"
+												"layout(points, max_vertices = 3) out;\n"
+												"precision mediump float;\n"
+												"void main()\n"
+												"{\n"
+												"	EmitVertex();\n"
+												"	EndPrimitive();\n"
+												"}\n";
+		ctx.beginSection("GL_EXT_geometry_shader features require enabling the extension in 310 es shaders.");
+		verifyProgram(ctx, glu::ProgramSources() << glu::VertexSource(simpleVtxFrag) << glu::GeometrySource(geometry) << glu::FragmentSource(simpleVtxFrag), EXPECT_RESULT_FAIL);
+		ctx.endSection();
+	}
 }
 
 void gpu_shader_5 (NegativeTestContext& ctx)
@@ -389,28 +393,31 @@
 
 void tessellation_shader (NegativeTestContext& ctx)
 {
-	const std::string	simpleVtxFrag	=	"#version 310 es\n"
-											"void main()\n"
-											"{\n"
-											"}\n";
-	const std::string	tessControl		=	"#version 310 es\n"
-											"layout(vertices = 3) out;\n"
-											"void main()\n"
-											"{\n"
-											"}\n";
-	const std::string	tessEvaluation	=	"#version 310 es\n"
-											"layout(triangles, equal_spacing, cw) in;\n"
-											"void main()\n"
-											"{\n"
-											"}\n";
-	ctx.beginSection("GL_EXT_tessellation_shader features require enabling the extension in 310 es shaders.");
-	glu::ProgramSources sources;
-	sources << glu::VertexSource(simpleVtxFrag)
-			<< glu::TessellationControlSource(tessControl)
-			<< glu::TessellationEvaluationSource(tessEvaluation)
-			<< glu::FragmentSource(simpleVtxFrag);
-	verifyProgram(ctx, sources, EXPECT_RESULT_FAIL);
-	ctx.endSection();
+	if (ctx.isShaderSupported(glu::SHADERTYPE_TESSELLATION_CONTROL))
+	{
+		const std::string	simpleVtxFrag	=	"#version 310 es\n"
+												"void main()\n"
+												"{\n"
+												"}\n";
+		const std::string	tessControl		=	"#version 310 es\n"
+												"layout(vertices = 3) out;\n"
+												"void main()\n"
+												"{\n"
+												"}\n";
+		const std::string	tessEvaluation	=	"#version 310 es\n"
+												"layout(triangles, equal_spacing, cw) in;\n"
+												"void main()\n"
+												"{\n"
+												"}\n";
+		ctx.beginSection("GL_EXT_tessellation_shader features require enabling the extension in 310 es shaders.");
+		glu::ProgramSources sources;
+		sources << glu::VertexSource(simpleVtxFrag)
+				<< glu::TessellationControlSource(tessControl)
+				<< glu::TessellationEvaluationSource(tessEvaluation)
+				<< glu::FragmentSource(simpleVtxFrag);
+		verifyProgram(ctx, sources, EXPECT_RESULT_FAIL);
+		ctx.endSection();
+	}
 }
 
 void texture_buffer (NegativeTestContext& ctx)