Commit 6a9a79e3 by Jamie Madill

Import Chromium test expectation libs.

This can be useful for our testing code, to filter based on system configurations, such as GPU type, OS, or Debug/Release. BUG=angleproject:998 Change-Id: I88b7fe1a7a1446262cc084e62cdb335776fa8912 Reviewed-on: https://chromium-review.googlesource.com/274422Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 862c0ba4
...@@ -1156,12 +1156,29 @@ ...@@ -1156,12 +1156,29 @@
'include_dirs': 'include_dirs':
[ [
'deqp_support', 'deqp_support',
'third_party/gpu_test_expectations',
], ],
'sources': 'sources':
[ [
'deqp_support/angle_deqp_gtest_main.cpp', 'deqp_support/angle_deqp_gtest_main.cpp',
], ],
'conditions':
[
['angle_standalone==1',
{
'sources':
[
'third_party/gpu_test_expectations/gpu_info.cc',
'third_party/gpu_test_expectations/gpu_info.h',
'third_party/gpu_test_expectations/gpu_test_config.cc',
'third_party/gpu_test_expectations/gpu_test_config.h',
'third_party/gpu_test_expectations/gpu_test_expectations_parser.cc',
'third_party/gpu_test_expectations/gpu_test_expectations_parser.h',
],
}]
],
}, },
], # targets ], # targets
}], # OS == "win" }], # OS == "win"
......
//
// Copyright 2015 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.
//
// angle_config.h:
// Helpers for importing the gpu test expectations package from Chrome.
//
#ifndef GPU_TEST_EXPECTATIONS_ANGLE_CONFIG_H_
#define GPU_TEST_EXPECTATIONS_ANGLE_CONFIG_H_
#include <stdint.h>
#include <iostream>
#include "common/debug.h"
#include "common/string_utils.h"
#define DCHECK_EQ(A,B) ASSERT((A) == (B))
#define DCHECK_NE(A,B) ASSERT((A) != (B))
#define DCHECK ASSERT
#define LOG(X) std::cerr
#define StringPrintf FormatString
#define GPU_EXPORT
#define base
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
using namespace angle;
// TODO(jmadill): other platforms
#define OS_WIN
#endif
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu_info.h"
namespace {
void EnumerateGPUDevice(const gpu::GPUInfo::GPUDevice& device,
gpu::GPUInfo::Enumerator* enumerator) {
enumerator->BeginGPUDevice();
enumerator->AddInt("vendorId", device.vendor_id);
enumerator->AddInt("deviceId", device.device_id);
enumerator->AddBool("active", device.active);
enumerator->AddString("vendorString", device.vendor_string);
enumerator->AddString("deviceString", device.device_string);
enumerator->EndGPUDevice();
}
} // namespace
namespace gpu {
GPUInfo::GPUDevice::GPUDevice()
: vendor_id(0),
device_id(0),
active(false) {
}
GPUInfo::GPUDevice::~GPUDevice() { }
GPUInfo::GPUInfo()
: optimus(false),
amd_switchable(false),
lenovo_dcute(false),
adapter_luid(0),
gl_reset_notification_strategy(0),
can_lose_context(false),
software_rendering(false),
direct_rendering(true),
sandboxed(false),
process_crash_count(0),
basic_info_state(kCollectInfoNone),
context_info_state(kCollectInfoNone) {
}
GPUInfo::~GPUInfo() { }
void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
struct GPUInfoKnownFields {
bool optimus;
bool amd_switchable;
bool lenovo_dcute;
GPUDevice gpu;
std::vector<GPUDevice> secondary_gpus;
uint64 adapter_luid;
std::string driver_vendor;
std::string driver_version;
std::string driver_date;
std::string pixel_shader_version;
std::string vertex_shader_version;
std::string max_msaa_samples;
std::string machine_model_name;
std::string machine_model_version;
std::string gl_version_string;
std::string gl_vendor;
std::string gl_renderer;
std::string gl_extensions;
std::string gl_ws_vendor;
std::string gl_ws_version;
std::string gl_ws_extensions;
uint32 gl_reset_notification_strategy;
bool can_lose_context;
bool software_rendering;
bool direct_rendering;
bool sandboxed;
int process_crash_count;
CollectInfoResult basic_info_state;
CollectInfoResult context_info_state;
};
// If this assert fails then most likely something below needs to be updated.
// Note that this assert is only approximate. If a new field is added to
// GPUInfo which fits within the current padding then it will not be caught.
static_assert(
sizeof(GPUInfo) == sizeof(GPUInfoKnownFields),
"fields have changed in GPUInfo, GPUInfoKnownFields must be updated");
// Required fields (according to DevTools protocol) first.
enumerator->AddString("machineModelName", machine_model_name);
enumerator->AddString("machineModelVersion", machine_model_version);
EnumerateGPUDevice(gpu, enumerator);
for (const auto& secondary_gpu: secondary_gpus)
EnumerateGPUDevice(secondary_gpu, enumerator);
enumerator->BeginAuxAttributes();
enumerator->AddBool("optimus", optimus);
enumerator->AddBool("amdSwitchable", amd_switchable);
enumerator->AddBool("lenovoDcute", lenovo_dcute);
enumerator->AddInt64("adapterLuid", adapter_luid);
enumerator->AddString("driverVendor", driver_vendor);
enumerator->AddString("driverVersion", driver_version);
enumerator->AddString("driverDate", driver_date);
enumerator->AddString("pixelShaderVersion", pixel_shader_version);
enumerator->AddString("vertexShaderVersion", vertex_shader_version);
enumerator->AddString("maxMsaaSamples", max_msaa_samples);
enumerator->AddString("glVersion", gl_version);
enumerator->AddString("glVendor", gl_vendor);
enumerator->AddString("glRenderer", gl_renderer);
enumerator->AddString("glExtensions", gl_extensions);
enumerator->AddString("glWsVendor", gl_ws_vendor);
enumerator->AddString("glWsVersion", gl_ws_version);
enumerator->AddString("glWsExtensions", gl_ws_extensions);
enumerator->AddInt(
"glResetNotificationStrategy",
static_cast<int>(gl_reset_notification_strategy));
enumerator->AddBool("can_lose_context", can_lose_context);
// TODO(kbr): add performance_stats.
enumerator->AddBool("softwareRendering", software_rendering);
enumerator->AddBool("directRendering", direct_rendering);
enumerator->AddBool("sandboxed", sandboxed);
enumerator->AddInt("processCrashCount", process_crash_count);
enumerator->AddInt("basicInfoState", basic_info_state);
enumerator->AddInt("contextInfoState", context_info_state);
enumerator->EndAuxAttributes();
}
} // namespace gpu
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_CONFIG_GPU_INFO_H_
#define GPU_CONFIG_GPU_INFO_H_
// Provides access to the GPU information for the system
// on which chrome is currently running.
#include <string>
#include <vector>
#include "angle_config.h"
namespace gpu {
// Result for the various Collect*Info* functions below.
// Fatal failures are for cases where we can't create a context at all or
// something, making the use of the GPU impossible.
// Non-fatal failures are for cases where we could gather most info, but maybe
// some is missing (e.g. unable to parse a version string or to detect the exact
// model).
enum CollectInfoResult {
kCollectInfoNone = 0,
kCollectInfoSuccess = 1,
kCollectInfoNonFatalFailure = 2,
kCollectInfoFatalFailure = 3
};
// Video profile. This *must* match media::VideoCodecProfile.
enum VideoCodecProfile {
VIDEO_CODEC_PROFILE_UNKNOWN = -1,
VIDEO_CODEC_PROFILE_MIN = VIDEO_CODEC_PROFILE_UNKNOWN,
H264PROFILE_BASELINE = 0,
H264PROFILE_MAIN = 1,
H264PROFILE_EXTENDED = 2,
H264PROFILE_HIGH = 3,
H264PROFILE_HIGH10PROFILE = 4,
H264PROFILE_HIGH422PROFILE = 5,
H264PROFILE_HIGH444PREDICTIVEPROFILE = 6,
H264PROFILE_SCALABLEBASELINE = 7,
H264PROFILE_SCALABLEHIGH = 8,
H264PROFILE_STEREOHIGH = 9,
H264PROFILE_MULTIVIEWHIGH = 10,
VP8PROFILE_ANY = 11,
VP9PROFILE_ANY = 12,
VIDEO_CODEC_PROFILE_MAX = VP9PROFILE_ANY,
};
struct GPU_EXPORT GPUInfo {
struct GPU_EXPORT GPUDevice {
GPUDevice();
~GPUDevice();
// The DWORD (uint32) representing the graphics card vendor id.
uint32 vendor_id;
// The DWORD (uint32) representing the graphics card device id.
// Device ids are unique to vendor, not to one another.
uint32 device_id;
// Whether this GPU is the currently used one.
// Currently this field is only supported and meaningful on OS X.
bool active;
// The strings that describe the GPU.
// In Linux these strings are obtained through libpci.
// In Win/MacOSX, these two strings are not filled at the moment.
// In Android, these are respectively GL_VENDOR and GL_RENDERER.
std::string vendor_string;
std::string device_string;
};
GPUInfo();
~GPUInfo();
bool SupportsAccelerated2dCanvas() const {
return !can_lose_context && !software_rendering;
}
// Computer has NVIDIA Optimus
bool optimus;
// Computer has AMD Dynamic Switchable Graphics
bool amd_switchable;
// Lenovo dCute is installed. http://crbug.com/181665.
bool lenovo_dcute;
// Primary GPU, for exmaple, the discrete GPU in a dual GPU machine.
GPUDevice gpu;
// Secondary GPUs, for example, the integrated GPU in a dual GPU machine.
std::vector<GPUDevice> secondary_gpus;
// On Windows, the unique identifier of the adapter the GPU process uses.
// The default is zero, which makes the browser process create its D3D device
// on the primary adapter. Note that the primary adapter can change at any
// time so it is better to specify a particular LUID. Note that valid LUIDs
// are always non-zero.
uint64 adapter_luid;
// The vendor of the graphics driver currently installed.
std::string driver_vendor;
// The version of the graphics driver currently installed.
std::string driver_version;
// The date of the graphics driver currently installed.
std::string driver_date;
// The version of the pixel/fragment shader used by the gpu.
std::string pixel_shader_version;
// The version of the vertex shader used by the gpu.
std::string vertex_shader_version;
// The maximum multisapling sample count, either through ES3 or
// EXT_multisampled_render_to_texture MSAA.
std::string max_msaa_samples;
// The machine model identifier. They can contain any character, including
// whitespaces. Currently it is supported on MacOSX and Android.
// Android examples: "Naxus 5", "XT1032".
// On MacOSX, the version is stripped out of the model identifier, for
// example, the original identifier is "MacBookPro7,2", and we put
// "MacBookPro" as machine_model_name, and "7.2" as machine_model_version.
std::string machine_model_name;
// The version of the machine model. Currently it is supported on MacOSX.
// See machine_model_name's comment.
std::string machine_model_version;
// The GL_VERSION string.
std::string gl_version;
// The GL_VENDOR string.
std::string gl_vendor;
// The GL_RENDERER string.
std::string gl_renderer;
// The GL_EXTENSIONS string.
std::string gl_extensions;
// GL window system binding vendor. "" if not available.
std::string gl_ws_vendor;
// GL window system binding version. "" if not available.
std::string gl_ws_version;
// GL window system binding extensions. "" if not available.
std::string gl_ws_extensions;
// GL reset notification strategy as defined by GL_ARB_robustness. 0 if GPU
// reset detection or notification not available.
uint32 gl_reset_notification_strategy;
// The device semantics, i.e. whether the Vista and Windows 7 specific
// semantics are available.
bool can_lose_context;
bool software_rendering;
// Whether the driver uses direct rendering. True on most platforms, false on
// X11 when using remote X.
bool direct_rendering;
// Whether the gpu process is running in a sandbox.
bool sandboxed;
// Number of GPU process crashes recorded.
int process_crash_count;
// The state of whether the basic/context/DxDiagnostics info is collected and
// if the collection fails or not.
CollectInfoResult basic_info_state;
CollectInfoResult context_info_state;
// Note: when adding new members, please remember to update EnumerateFields
// in gpu_info.cc.
// In conjunction with EnumerateFields, this allows the embedder to
// enumerate the values in this structure without having to embed
// references to its specific member variables. This simplifies the
// addition of new fields to this type.
class Enumerator {
public:
// The following methods apply to the "current" object. Initially this
// is the root object, but calls to BeginGPUDevice/EndGPUDevice and
// BeginAuxAttributes/EndAuxAttributes change the object to which these
// calls should apply.
virtual void AddInt64(const char* name, int64 value) = 0;
virtual void AddInt(const char* name, int value) = 0;
virtual void AddString(const char* name, const std::string& value) = 0;
virtual void AddBool(const char* name, bool value) = 0;
// Markers indicating that a GPUDevice is being described.
virtual void BeginGPUDevice() = 0;
virtual void EndGPUDevice() = 0;
// Markers indicating that a VideoDecodeAcceleratorSupportedProfile is
// being described.
virtual void BeginVideoDecodeAcceleratorSupportedProfile() = 0;
virtual void EndVideoDecodeAcceleratorSupportedProfile() = 0;
// Markers indicating that a VideoEncodeAcceleratorSupportedProfile is
// being described.
virtual void BeginVideoEncodeAcceleratorSupportedProfile() = 0;
virtual void EndVideoEncodeAcceleratorSupportedProfile() = 0;
// Markers indicating that "auxiliary" attributes of the GPUInfo
// (according to the DevTools protocol) are being described.
virtual void BeginAuxAttributes() = 0;
virtual void EndAuxAttributes() = 0;
protected:
virtual ~Enumerator() {}
};
// Outputs the fields in this structure to the provided enumerator.
void EnumerateFields(Enumerator* enumerator) const;
};
} // namespace gpu
#endif // GPU_CONFIG_GPU_INFO_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu_test_config.h"
#include "gpu_info.h"
#include "gpu_test_expectations_parser.h"
// Disable the deprecated function warning for GetVersionEx
#pragma warning(disable: 4996)
class SysInfo
{
public:
static void OperatingSystemVersionNumbers(
int32 *major_version, int32 *minor_version, int32 *bugfix_version);
};
// static
void SysInfo::OperatingSystemVersionNumbers(
int32 *major_version, int32 *minor_version, int32 *bugfix_version)
{
OSVERSIONINFOEX version_info = { sizeof version_info };
::GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info));
*major_version = version_info.dwMajorVersion;
*minor_version = version_info.dwMinorVersion;
*bugfix_version = version_info.dwBuildNumber;
}
namespace gpu {
namespace {
void DeviceIDToVendorAndDevice(const std::string& id,
uint32* vendor_id,
uint32* device_id) {
*vendor_id = 0;
*device_id = 0;
if (id.length() < 21)
return;
std::string vendor_id_string = id.substr(8, 4);
std::string device_id_string = id.substr(17, 4);
base::HexStringToUInt(vendor_id_string, vendor_id);
base::HexStringToUInt(device_id_string, device_id);
}
CollectInfoResult CollectGpuID(uint32* vendor_id, uint32* device_id) {
DCHECK(vendor_id && device_id);
*vendor_id = 0;
*device_id = 0;
// Taken from http://developer.nvidia.com/object/device_ids.html
DISPLAY_DEVICE dd;
dd.cb = sizeof(DISPLAY_DEVICE);
std::string id;
for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) {
if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
id = dd.DeviceID;
break;
}
}
if (id.length() > 20) {
DeviceIDToVendorAndDevice(id, vendor_id, device_id);
if (*vendor_id != 0 && *device_id != 0)
return kCollectInfoSuccess;
}
return kCollectInfoNonFatalFailure;
}
GPUTestConfig::OS GetCurrentOS() {
#if defined(OS_CHROMEOS)
return GPUTestConfig::kOsChromeOS;
#elif defined(OS_LINUX) || defined(OS_OPENBSD)
return GPUTestConfig::kOsLinux;
#elif defined(OS_WIN)
int32 major_version = 0;
int32 minor_version = 0;
int32 bugfix_version = 0;
base::SysInfo::OperatingSystemVersionNumbers(
&major_version, &minor_version, &bugfix_version);
if (major_version == 5)
return GPUTestConfig::kOsWinXP;
if (major_version == 6 && minor_version == 0)
return GPUTestConfig::kOsWinVista;
if (major_version == 6 && minor_version == 1)
return GPUTestConfig::kOsWin7;
if (major_version == 6 && (minor_version == 2 || minor_version == 3))
return GPUTestConfig::kOsWin8;
#elif defined(OS_MACOSX)
int32 major_version = 0;
int32 minor_version = 0;
int32 bugfix_version = 0;
base::SysInfo::OperatingSystemVersionNumbers(
&major_version, &minor_version, &bugfix_version);
if (major_version == 10) {
switch (minor_version) {
case 5:
return GPUTestConfig::kOsMacLeopard;
case 6:
return GPUTestConfig::kOsMacSnowLeopard;
case 7:
return GPUTestConfig::kOsMacLion;
case 8:
return GPUTestConfig::kOsMacMountainLion;
case 9:
return GPUTestConfig::kOsMacMavericks;
case 10:
return GPUTestConfig::kOsMacYosemite;
}
}
#elif defined(OS_ANDROID)
return GPUTestConfig::kOsAndroid;
#endif
return GPUTestConfig::kOsUnknown;
}
} // namespace anonymous
GPUTestConfig::GPUTestConfig()
: validate_gpu_info_(true),
os_(kOsUnknown),
gpu_device_id_(0),
build_type_(kBuildTypeUnknown) {
}
GPUTestConfig::~GPUTestConfig() {
}
void GPUTestConfig::set_os(int32 os) {
DCHECK_EQ(0, os & ~(kOsAndroid | kOsWin | kOsMac | kOsLinux | kOsChromeOS));
os_ = os;
}
void GPUTestConfig::AddGPUVendor(uint32 gpu_vendor) {
DCHECK_NE(0u, gpu_vendor);
for (size_t i = 0; i < gpu_vendor_.size(); ++i)
DCHECK_NE(gpu_vendor_[i], gpu_vendor);
gpu_vendor_.push_back(gpu_vendor);
}
void GPUTestConfig::set_gpu_device_id(uint32 id) {
gpu_device_id_ = id;
}
void GPUTestConfig::set_build_type(int32 build_type) {
DCHECK_EQ(0, build_type & ~(kBuildTypeRelease | kBuildTypeDebug));
build_type_ = build_type;
}
bool GPUTestConfig::IsValid() const {
if (!validate_gpu_info_)
return true;
if (gpu_device_id_ != 0 && (gpu_vendor_.size() != 1 || gpu_vendor_[0] == 0))
return false;
return true;
}
bool GPUTestConfig::OverlapsWith(const GPUTestConfig& config) const {
DCHECK(IsValid());
DCHECK(config.IsValid());
if (config.os_ != kOsUnknown && os_ != kOsUnknown &&
(os_ & config.os_) == 0)
return false;
if (config.gpu_vendor_.size() > 0 && gpu_vendor_.size() > 0) {
bool shared = false;
for (size_t i = 0; i < config.gpu_vendor_.size() && !shared; ++i) {
for (size_t j = 0; j < gpu_vendor_.size(); ++j) {
if (config.gpu_vendor_[i] == gpu_vendor_[j]) {
shared = true;
break;
}
}
}
if (!shared)
return false;
}
if (config.gpu_device_id_ != 0 && gpu_device_id_ != 0 &&
gpu_device_id_ != config.gpu_device_id_)
return false;
if (config.build_type_ != kBuildTypeUnknown &&
build_type_ != kBuildTypeUnknown &&
(build_type_ & config.build_type_) == 0)
return false;
return true;
}
void GPUTestConfig::DisableGPUInfoValidation() {
validate_gpu_info_ = false;
}
void GPUTestConfig::ClearGPUVendor() {
gpu_vendor_.clear();
}
GPUTestBotConfig::~GPUTestBotConfig() {
}
void GPUTestBotConfig::AddGPUVendor(uint32 gpu_vendor) {
DCHECK_EQ(0u, GPUTestConfig::gpu_vendor().size());
GPUTestConfig::AddGPUVendor(gpu_vendor);
}
bool GPUTestBotConfig::SetGPUInfo(const GPUInfo& gpu_info) {
DCHECK(validate_gpu_info_);
if (gpu_info.gpu.device_id == 0 || gpu_info.gpu.vendor_id == 0)
return false;
ClearGPUVendor();
AddGPUVendor(gpu_info.gpu.vendor_id);
set_gpu_device_id(gpu_info.gpu.device_id);
return true;
}
bool GPUTestBotConfig::IsValid() const {
switch (os()) {
case kOsWinXP:
case kOsWinVista:
case kOsWin7:
case kOsWin8:
case kOsMacLeopard:
case kOsMacSnowLeopard:
case kOsMacLion:
case kOsMacMountainLion:
case kOsMacMavericks:
case kOsMacYosemite:
case kOsLinux:
case kOsChromeOS:
case kOsAndroid:
break;
default:
return false;
}
if (validate_gpu_info_) {
if (gpu_vendor().size() != 1 || gpu_vendor()[0] == 0)
return false;
if (gpu_device_id() == 0)
return false;
}
switch (build_type()) {
case kBuildTypeRelease:
case kBuildTypeDebug:
break;
default:
return false;
}
return true;
}
bool GPUTestBotConfig::Matches(const GPUTestConfig& config) const {
DCHECK(IsValid());
DCHECK(config.IsValid());
if (config.os() != kOsUnknown && (os() & config.os()) == 0)
return false;
if (config.gpu_vendor().size() > 0) {
bool contained = false;
for (size_t i = 0; i < config.gpu_vendor().size(); ++i) {
if (config.gpu_vendor()[i] == gpu_vendor()[0]) {
contained = true;
break;
}
}
if (!contained)
return false;
}
if (config.gpu_device_id() != 0 &&
gpu_device_id() != config.gpu_device_id())
return false;
if (config.build_type() != kBuildTypeUnknown &&
(build_type() & config.build_type()) == 0)
return false;
return true;
}
bool GPUTestBotConfig::Matches(const std::string& config_data) const {
GPUTestExpectationsParser parser;
GPUTestConfig config;
if (!parser.ParseConfig(config_data, &config))
return false;
return Matches(config);
}
bool GPUTestBotConfig::LoadCurrentConfig(const GPUInfo* gpu_info) {
bool rt;
if (gpu_info == NULL) {
GPUInfo my_gpu_info;
CollectInfoResult result = CollectGpuID(
&my_gpu_info.gpu.vendor_id, &my_gpu_info.gpu.device_id);
if (result != kCollectInfoSuccess) {
LOG(ERROR) << "Fail to identify GPU";
DisableGPUInfoValidation();
rt = true;
} else {
rt = SetGPUInfo(my_gpu_info);
}
} else {
rt = SetGPUInfo(*gpu_info);
}
set_os(GetCurrentOS());
if (os() == kOsUnknown) {
LOG(ERROR) << "Unknown OS";
rt = false;
}
#if defined(NDEBUG)
set_build_type(kBuildTypeRelease);
#else
set_build_type(kBuildTypeDebug);
#endif
return rt;
}
// static
bool GPUTestBotConfig::CurrentConfigMatches(const std::string& config_data) {
GPUTestBotConfig my_config;
if (!my_config.LoadCurrentConfig(NULL))
return false;
return my_config.Matches(config_data);
}
// static
bool GPUTestBotConfig::CurrentConfigMatches(
const std::vector<std::string>& configs) {
GPUTestBotConfig my_config;
if (!my_config.LoadCurrentConfig(NULL))
return false;
for (size_t i = 0 ; i < configs.size(); ++i) {
if (my_config.Matches(configs[i]))
return true;
}
return false;
}
} // namespace gpu
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_CONFIG_GPU_TEST_CONFIG_H_
#define GPU_CONFIG_GPU_TEST_CONFIG_H_
#include <string>
#include <vector>
#include "angle_config.h"
namespace gpu {
struct GPUInfo;
class GPU_EXPORT GPUTestConfig {
public:
enum OS {
kOsUnknown = 0,
kOsWinXP = 1 << 0,
kOsWinVista = 1 << 1,
kOsWin7 = 1 << 2,
kOsWin8 = 1 << 3,
kOsWin = kOsWinXP | kOsWinVista | kOsWin7 | kOsWin8,
kOsMacLeopard = 1 << 4,
kOsMacSnowLeopard = 1 << 5,
kOsMacLion = 1 << 6,
kOsMacMountainLion = 1 << 7,
kOsMacMavericks = 1 << 8,
kOsMacYosemite = 1 << 9,
kOsMac = kOsMacLeopard | kOsMacSnowLeopard | kOsMacLion |
kOsMacMountainLion | kOsMacMavericks | kOsMacYosemite,
kOsLinux = 1 << 10,
kOsChromeOS = 1 << 11,
kOsAndroid = 1 << 12,
};
enum BuildType {
kBuildTypeUnknown = 0,
kBuildTypeRelease = 1 << 0,
kBuildTypeDebug = 1 << 1,
};
GPUTestConfig();
virtual ~GPUTestConfig();
void set_os(int32 os);
void set_gpu_device_id(uint32 id);
void set_build_type(int32 build_type);
virtual void AddGPUVendor(uint32 gpu_vendor);
int32 os() const { return os_; }
const std::vector<uint32>& gpu_vendor() const { return gpu_vendor_; }
uint32 gpu_device_id() const { return gpu_device_id_; }
int32 build_type() const { return build_type_; }
// Check if the config is valid. For example, if gpu_device_id_ is set, but
// gpu_vendor_ is unknown, then it's invalid.
virtual bool IsValid() const;
// Check if two configs overlap, i.e., if there exists a config that matches
// both configs.
bool OverlapsWith(const GPUTestConfig& config) const;
// Disable validation of GPU vendor and device ids.
void DisableGPUInfoValidation();
protected:
void ClearGPUVendor();
// Indicates that the OS has the notion of a numeric GPU vendor and device id
// and this data should be validated.
bool validate_gpu_info_;
private:
// operating system.
int32 os_;
// GPU vendor.
std::vector<uint32> gpu_vendor_;
// GPU device id (unique to each vendor).
uint32 gpu_device_id_;
// Release or Debug.
int32 build_type_;
};
class GPU_EXPORT GPUTestBotConfig : public GPUTestConfig {
public:
GPUTestBotConfig() { }
~GPUTestBotConfig() override;
// This should only be called when no gpu_vendor is added.
void AddGPUVendor(uint32 gpu_vendor) override;
// Return false if gpu_info does not have valid vendor_id and device_id.
bool SetGPUInfo(const GPUInfo& gpu_info);
// Check if the bot config is valid, i.e., if it is one valid test-bot
// environment. For example, if a field is unknown, or if OS is not one
// fully defined OS, then it's valid.
bool IsValid() const override;
// Check if a bot config matches a test config, i.e., the test config is a
// superset of the bot config.
bool Matches(const GPUTestConfig& config) const;
bool Matches(const std::string& config_data) const;
// Setup the config with the current gpu testing environment.
// If gpu_info is NULL, collect GPUInfo first.
bool LoadCurrentConfig(const GPUInfo* gpu_info);
// Check if this bot's config matches |config_data| or any of the |configs|.
static bool CurrentConfigMatches(const std::string& config_data);
static bool CurrentConfigMatches(const std::vector<std::string>& configs);
};
} // namespace gpu
#endif // GPU_CONFIG_GPU_TEST_CONFIG_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_CONFIG_GPU_TEST_EXPECTATIONS_PARSER_H_
#define GPU_CONFIG_GPU_TEST_EXPECTATIONS_PARSER_H_
#include <string>
#include <vector>
#include "angle_config.h"
#include "gpu_test_config.h"
namespace gpu {
class GPU_EXPORT GPUTestExpectationsParser {
public:
enum GPUTestExpectation {
kGpuTestPass = 1 << 0,
kGpuTestFail = 1 << 1,
kGpuTestFlaky = 1 << 2,
kGpuTestTimeout = 1 << 3,
kGpuTestSkip = 1 << 4,
};
GPUTestExpectationsParser();
~GPUTestExpectationsParser();
// Parse the text expectations, and if no error is encountered,
// save all the entries. Otherwise, generate error messages.
// Return true if parsing succeeds.
bool LoadTestExpectations(const std::string& data);
bool LoadTestExpectationsFromFile(const std::string& path);
// Query error messages from the last LoadTestExpectations() call.
const std::vector<std::string>& GetErrorMessages() const;
// Get the test expectation of a given test on a given bot.
int32 GetTestExpectation(const std::string& test_name,
const GPUTestBotConfig& bot_config) const;
// Parse a list of config modifiers. If we have a valid entry with no
// conflicts, | config | stores it, and the function returns true.
bool ParseConfig(const std::string& config_data, GPUTestConfig* config);
private:
struct GPUTestExpectationEntry {
GPUTestExpectationEntry();
std::string test_name;
GPUTestConfig test_config;
int32 test_expectation;
size_t line_number;
};
// Parse a line of text. If we have a valid entry, save it; otherwise,
// generate error messages.
bool ParseLine(const std::string& line_data, size_t line_number);
// Update OS/GPUVendor/BuildType modifiers. May generate an error message.
bool UpdateTestConfig(
GPUTestConfig* config, int32 token, size_t line_number);
// Update GPUDeviceID modifier. May generate an error message.
bool UpdateTestConfig(GPUTestConfig* config,
const std::string & gpu_device_id,
size_t line_number);
// Check if two entries' config overlap with each other. May generate an
// error message.
bool DetectConflictsBetweenEntries();
// Save an error message, which can be queried later.
void PushErrorMessage(const std::string& message, size_t line_number);
void PushErrorMessage(const std::string& message,
size_t entry1_line_number,
size_t entry2_line_number);
std::vector<GPUTestExpectationEntry> entries_;
std::vector<std::string> error_messages_;
};
} // namespace gpu
#endif // GPU_CONFIG_GPU_TEST_EXPECTATIONS_PARSER_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment