Commit 282aa417 by Nicolas Capens Committed by Nicolas Capens

Add GN builds for Reactor unit tests

This will enable running Reactor tests both with the LLVM and Subzero backend for maximum coverage. Bug: b/173404759 Change-Id: I43ff938924ccf864583fbf455141d7937998f754 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/50388Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent 06002016
......@@ -15,6 +15,7 @@
import("//build/config/c++/c++.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/mips.gni")
import("src/Reactor/reactor.gni")
config("swiftshader_config") {
defines = []
......@@ -201,5 +202,13 @@ if (build_with_chromium) {
"tests/GLESUnitTests:swiftshader_unittests",
"tests/SystemUnitTests:swiftshader_system_unittests",
]
if (supports_llvm) {
data_deps += [ "tests/ReactorUnitTests:swiftshader_reactor_llvm_unittests" ]
}
if (supports_subzero) {
data_deps += [ "tests/ReactorUnitTests:swiftshader_reactor_subzero_unittests" ]
}
}
}
......@@ -12,16 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("reactor.gni")
import("../swiftshader.gni")
declare_args() {
# Subzero produces smaller binaries, but doesn't support ARM64, MIPS64, and
# PPC64. It also doesn't support MemorySanitizer instrumentation.
use_swiftshader_with_subzero =
current_cpu != "arm64" && current_cpu != "mips64el" && current_cpu != "ppc64" && !is_msan
supports_llvm = is_linux || is_chromeos || is_fuchsia || is_win || is_android || is_mac
}
config("swiftshader_reactor_private_config") {
if (is_win) {
cflags = [
......@@ -54,7 +47,7 @@ swiftshader_source_set("swiftshader_reactor_base") {
]
}
if (use_swiftshader_with_subzero) {
if (supports_subzero) {
# Need a separate config to ensure the warnings are added to the end.
config("swiftshader_subzero_common_private_config") {
defines = [
......@@ -299,6 +292,7 @@ if (use_swiftshader_with_subzero) {
":swiftshader_subzero_private_config",
]
}
swiftshader_source_set("swiftshader_subzero_reactor") {
deps = [
"../../third_party/marl:Marl",
......
# Copyright (c) 2020 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.
# This file contains configs that need to be added or removed to all
# SwiftShader libraries
import("../swiftshader.gni")
import("//build_overrides/build.gni")
declare_args() {
# Subzero doesn't support ARM64, MIPS64, and PPC64.
supports_subzero = current_cpu != "arm64" && current_cpu != "mips64el" && current_cpu != "ppc64"
supports_llvm = is_linux || is_chromeos || is_fuchsia || is_win || is_android || is_mac
}
declare_args() {
# Subzero produces much smaller binaries, so always use it when available,
# except for MSan builds which only get Reactor code instrumented with LLVM.
use_swiftshader_with_subzero = supports_subzero && !is_msan
}
\ No newline at end of file
......@@ -22,9 +22,8 @@ set(ROOT_PROJECT_LINK_LIBRARIES
${SWIFTSHADER_LIBS}
)
# TODO(b/154013190): move source file to separate folder for this target.
set(REACTOR_BENCHMARKS_SRC_FILES
../../src/Reactor/ReactorBenchmarks.cpp
ReactorBenchmarks.cpp
)
add_executable(ReactorBenchmarks
......
# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//testing/test.gni")
test("swiftshader_reactor_llvm_unittests") {
deps = [
"//base",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
"//third_party/swiftshader/src/Reactor:swiftshader_llvm_reactor",
]
sources = [
"//gpu/swiftshader_tests_main.cc",
"ReactorUnitTests.cpp",
]
include_dirs = [
"../../src/Reactor"
]
}
test("swiftshader_reactor_subzero_unittests") {
deps = [
"//base",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
"//third_party/swiftshader/src/Reactor:swiftshader_subzero_reactor",
]
sources = [
"//gpu/swiftshader_tests_main.cc",
"ReactorUnitTests.cpp",
]
include_dirs = [
"../../src/Reactor"
]
}
\ No newline at end of file
......@@ -22,9 +22,9 @@ set(ROOT_PROJECT_LINK_LIBRARIES
${SWIFTSHADER_LIBS}
)
# TODO(b/154013190): move source file to separate folder for this target.
set(REACTOR_UNIT_TESTS_SRC_FILES
../../src/Reactor/ReactorUnitTests.cpp
main.cpp
ReactorUnitTests.cpp
)
add_executable(ReactorUnitTests
......
......@@ -3232,12 +3232,6 @@ TEST(ReactorUnitTests, SpillLocalCopiesOfArgs)
EXPECT_EQ(result, expected);
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
////////////////////////////////
// Trait compile time checks. //
////////////////////////////////
......
// Copyright 2020 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "gtest/gtest.h"
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
......@@ -733,6 +733,7 @@ swiftshader_llvm_source_set("swiftshader_llvm_most") {
"llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp",
"llvm/lib/Transforms/Instrumentation/InstrOrderFile.cpp",
"llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp",
"llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp",
"llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp",
"llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp",
"llvm/lib/Transforms/Instrumentation/ValueProfileCollector.cpp",
......
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