Files
angle/tests/compiler_tests/API_test.cpp
T
Kimmo Kinnunen 7c1cfd6154 Make ShBuiltInResources comparable with memcmp
Chromium builds a std::map with ShBuiltInResources as part of the key.
Comparator for == and < are needed for the map implementation.

Currently Chromium uses memcmp as the comparator. Padding
in ShBuiltInResources causes uninitialized reads.

Fix this by clearing the padding with memset during ShBuiltInResources
initialization.

Change-Id: I78aa3c59ce165503831aa2a67c96cf8af316c152
Reviewed-on: https://chromium-review.googlesource.com/223431
Reviewed-by: Geoff Lang <[email protected]>
Tested-by: Shannon Woods <[email protected]>
2014-10-21 20:45:35 +00:00

27 lines
704 B
C++

//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// API_test.cpp:
// Some tests for the compiler API.
//
#include "angle_gl.h"
#include "gtest/gtest.h"
#include "GLSLANG/ShaderLang.h"
TEST(APITest, CompareShBuiltInResources)
{
ShBuiltInResources a_resources;
memset(&a_resources, 88, sizeof(a_resources));
ShInitBuiltInResources(&a_resources);
ShBuiltInResources b_resources;
memset(&b_resources, 77, sizeof(b_resources));
ShInitBuiltInResources(&b_resources);
EXPECT_TRUE(memcmp(&a_resources, &b_resources, sizeof(a_resources)) == 0);
}