Free EGLImages at the end of the testcase

Bug: 28641861
Change-Id: I578d06f0cf312102f6e180a6e9697fbf160c63c7
diff --git a/modules/egl/teglGLES2SharingThreadedTests.cpp b/modules/egl/teglGLES2SharingThreadedTests.cpp
index 2a44613..91f32cc 100644
--- a/modules/egl/teglGLES2SharingThreadedTests.cpp
+++ b/modules/egl/teglGLES2SharingThreadedTests.cpp
@@ -2216,6 +2216,21 @@
 	for (int operationNdx = 0; operationNdx < m_config.operationCount; operationNdx++)
 		addRandomOperation(resourceManager);
 
+	{
+		int threadNdx  = 0;
+
+		// Destroy images
+		// \note Android reference counts EGLDisplays so we can't trust the eglTerminate() to clean up resources
+		while (resourceManager.getImageCount() > 0)
+		{
+			const SharedPtr<GLES2ThreadTest::EGLImage> image = resourceManager.popImage(0);
+
+			m_threads[threadNdx]->addOperation(new GLES2ThreadTest::DestroyImage(image, m_config.useFenceSync, m_config.serverSync));
+
+			threadNdx = (threadNdx + 1) % m_config.threadCount;
+		}
+	}
+
 	// Release contexts
 	for (int threadNdx = 0; threadNdx < m_config.threadCount; threadNdx++)
 	{