Commit 1af723d5 authored by Almothana Athamneh's avatar Almothana Athamneh Committed by Commit Bot

[test] Use Fuchsia test runner for unittests

This CL attempts to run unittests on Fuchsia
using Infra

Bug: chromium:934932
Change-Id: I4b7cb740e17e65e91ca8c6ba6dfd07719e473e20
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1948709
Commit-Queue: Almothana Athamneh <almuthanna@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65349}
parent 450dfc2b
...@@ -75,8 +75,12 @@ ...@@ -75,8 +75,12 @@
"label": "//test/unittests:unittests", "label": "//test/unittests:unittests",
"type": "script", "type": "script",
}, },
"fuchsia-unittests": {
"label": "//test/unittests:unittests",
"type": "script",
},
"webkit": { "webkit": {
"label": "//test/webkit:v8_webkit", "label": "//test/webkit:v8_webkit",
"type": "script", "type": "script",
}, },
} }
\ No newline at end of file
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
'os': 'Ubuntu-16.04', 'os': 'Ubuntu-16.04',
}, },
'tests': [ 'tests': [
{'name': 'unittests'}, {'name': 'fuchsia-unittests'},
], ],
}, },
############################################################################## ##############################################################################
......
...@@ -4,6 +4,22 @@ ...@@ -4,6 +4,22 @@
import("../../gni/v8.gni") import("../../gni/v8.gni")
if (is_fuchsia) {
import("//build/config/fuchsia/rules.gni")
fuchsia_package("v8_unittests_pkg") {
testonly = true
binary = ":unittests"
package_name_override = "v8_unittests"
}
fuchsia_package_runner("v8_unittests_fuchsia") {
testonly = true
package = ":v8_unittests_pkg"
package_name_override = "v8_unittests"
}
}
v8_executable("unittests") { v8_executable("unittests") {
testonly = true testonly = true
......
...@@ -99,7 +99,10 @@ TEST(LanguageServerJson, TestJsonObjects) { ...@@ -99,7 +99,10 @@ TEST(LanguageServerJson, TestJsonObjects) {
// issue with exceptions enabled for Torque. // issue with exceptions enabled for Torque.
// TODO(szuend): Remove the OS check when errors are reported differently, // TODO(szuend): Remove the OS check when errors are reported differently,
// or the issue is resolved. // or the issue is resolved.
#if !defined(V8_OS_WIN) // TODO(almuthanna): These tests were skipped because they cause a crash when
// they are ran on Fuchsia. This issue should be solved later on
// Ticket: https://crbug.com/1028617
#if !defined(V8_OS_WIN) && !defined(V8_TARGET_OS_FUCHSIA)
using ::testing::HasSubstr; using ::testing::HasSubstr;
TEST(LanguageServerJson, ParserError) { TEST(LanguageServerJson, ParserError) {
JsonParserResult result = ParseJson("{]"); JsonParserResult result = ParseJson("{]");
......
...@@ -79,6 +79,10 @@ TEST(LanguageServer, GotoTypeDefinitionNoDataForFile) { ...@@ -79,6 +79,10 @@ TEST(LanguageServer, GotoTypeDefinitionNoDataForFile) {
EXPECT_FALSE(LanguageServerData::FindDefinition(test_id, {0, 0})); EXPECT_FALSE(LanguageServerData::FindDefinition(test_id, {0, 0}));
} }
// TODO(almuthanna): This test was skipped because it causes a crash when it is
// ran on Fuchsia. This issue should be solved later on
// Ticket: https://crbug.com/1028617
#if !defined(V8_TARGET_OS_FUCHSIA)
TEST(LanguageServer, GotoLabelDefinitionInSignature) { TEST(LanguageServer, GotoLabelDefinitionInSignature) {
const std::string source = const std::string source =
"type void;\n" "type void;\n"
...@@ -99,6 +103,7 @@ TEST(LanguageServer, GotoLabelDefinitionInSignature) { ...@@ -99,6 +103,7 @@ TEST(LanguageServer, GotoLabelDefinitionInSignature) {
ASSERT_TRUE(maybe_position.has_value()); ASSERT_TRUE(maybe_position.has_value());
EXPECT_EQ(*maybe_position, (SourcePosition{id, {5, 19}, {5, 26}})); EXPECT_EQ(*maybe_position, (SourcePosition{id, {5, 19}, {5, 26}}));
} }
#endif
TEST(LanguageServer, GotoLabelDefinitionInTryBlock) { TEST(LanguageServer, GotoLabelDefinitionInTryBlock) {
const std::string source = const std::string source =
...@@ -122,6 +127,10 @@ TEST(LanguageServer, GotoLabelDefinitionInTryBlock) { ...@@ -122,6 +127,10 @@ TEST(LanguageServer, GotoLabelDefinitionInTryBlock) {
EXPECT_EQ(*maybe_position, (SourcePosition{id, {7, 8}, {7, 15}})); EXPECT_EQ(*maybe_position, (SourcePosition{id, {7, 8}, {7, 15}}));
} }
// TODO(almuthanna): This test was skipped because it causes a crash when it is
// ran on Fuchsia. This issue should be solved later on
// Ticket: https://crbug.com/1028617
#if !defined(V8_TARGET_OS_FUCHSIA)
TEST(LanguageServer, GotoDefinitionClassSuperType) { TEST(LanguageServer, GotoDefinitionClassSuperType) {
const std::string source = const std::string source =
"type void;\n" "type void;\n"
...@@ -138,6 +147,7 @@ TEST(LanguageServer, GotoDefinitionClassSuperType) { ...@@ -138,6 +147,7 @@ TEST(LanguageServer, GotoDefinitionClassSuperType) {
ASSERT_TRUE(maybe_position.has_value()); ASSERT_TRUE(maybe_position.has_value());
EXPECT_EQ(*maybe_position, (SourcePosition{id, {2, 5}, {2, 11}})); EXPECT_EQ(*maybe_position, (SourcePosition{id, {2, 5}, {2, 11}}));
} }
#endif
TEST(LanguageServer, GotoLabelDefinitionInSignatureGotoStmt) { TEST(LanguageServer, GotoLabelDefinitionInSignatureGotoStmt) {
const std::string source = const std::string source =
......
...@@ -124,6 +124,10 @@ void ExpectFailingCompilation( ...@@ -124,6 +124,10 @@ void ExpectFailingCompilation(
source, MatcherVector<T>{{message_pattern, LineAndColumn::Invalid()}}); source, MatcherVector<T>{{message_pattern, LineAndColumn::Invalid()}});
} }
// TODO(almuthanna): the definition of this function is skipped on Fuchsia
// because it causes an 'unused function' exception upon buidling gn
// Ticket: https://crbug.com/1028617
#if !defined(V8_TARGET_OS_FUCHSIA)
int CountPreludeLines() { int CountPreludeLines() {
static int result = -1; static int result = -1;
if (result == -1) { if (result == -1) {
...@@ -132,17 +136,23 @@ int CountPreludeLines() { ...@@ -132,17 +136,23 @@ int CountPreludeLines() {
} }
return result; return result;
} }
#endif
using SubstrWithPosition = using SubstrWithPosition =
std::pair<::testing::PolymorphicMatcher< std::pair<::testing::PolymorphicMatcher<
::testing::internal::HasSubstrMatcher<std::string>>, ::testing::internal::HasSubstrMatcher<std::string>>,
LineAndColumn>; LineAndColumn>;
// TODO(almuthanna): the definition of this function is skipped on Fuchsia
// because it causes an 'unused function' exception upon buidling gn
// Ticket: https://crbug.com/1028617
#if !defined(V8_TARGET_OS_FUCHSIA)
SubstrWithPosition SubstrTester(const std::string& message, int line, int col) { SubstrWithPosition SubstrTester(const std::string& message, int line, int col) {
// Change line and column from 1-based to 0-based. // Change line and column from 1-based to 0-based.
return {::testing::HasSubstr(message), return {::testing::HasSubstr(message),
LineAndColumn{line + CountPreludeLines() - 1, col - 1}}; LineAndColumn{line + CountPreludeLines() - 1, col - 1}};
} }
#endif
using SubstrVector = std::vector<SubstrWithPosition>; using SubstrVector = std::vector<SubstrWithPosition>;
...@@ -234,6 +244,10 @@ TEST(Torque, TypeDeclarationOrder) { ...@@ -234,6 +244,10 @@ TEST(Torque, TypeDeclarationOrder) {
)"); )");
} }
// TODO(almuthanna): These tests were skipped because they cause a crash when
// they are ran on Fuchsia. This issue should be solved later on
// Ticket: https://crbug.com/1028617
#if !defined(V8_TARGET_OS_FUCHSIA)
TEST(Torque, ConditionalFields) { TEST(Torque, ConditionalFields) {
// This class should throw alignment errors if @if decorators aren't // This class should throw alignment errors if @if decorators aren't
// working. // working.
...@@ -278,6 +292,7 @@ TEST(Torque, DoubleUnderScorePrefixIllegalForIdentifiers) { ...@@ -278,6 +292,7 @@ TEST(Torque, DoubleUnderScorePrefixIllegalForIdentifiers) {
)", )",
HasSubstr("Lexer Error")); HasSubstr("Lexer Error"));
} }
#endif
TEST(Torque, UnusedLetBindingLintError) { TEST(Torque, UnusedLetBindingLintError) {
ExpectFailingCompilation(R"( ExpectFailingCompilation(R"(
...@@ -296,6 +311,10 @@ TEST(Torque, UnderscorePrefixSilencesUnusedWarning) { ...@@ -296,6 +311,10 @@ TEST(Torque, UnderscorePrefixSilencesUnusedWarning) {
)"); )");
} }
// TODO(almuthanna): This test was skipped because it causes a crash when it is
// ran on Fuchsia. This issue should be solved later on
// Ticket: https://crbug.com/1028617
#if !defined(V8_TARGET_OS_FUCHSIA)
TEST(Torque, UsingUnderscorePrefixedIdentifierError) { TEST(Torque, UsingUnderscorePrefixedIdentifierError) {
ExpectFailingCompilation(R"( ExpectFailingCompilation(R"(
@export macro Foo(y: Smi) { @export macro Foo(y: Smi) {
...@@ -305,6 +324,7 @@ TEST(Torque, UsingUnderscorePrefixedIdentifierError) { ...@@ -305,6 +324,7 @@ TEST(Torque, UsingUnderscorePrefixedIdentifierError) {
)", )",
HasSubstr("Trying to reference '_x'")); HasSubstr("Trying to reference '_x'"));
} }
#endif
TEST(Torque, UnusedArgumentLintError) { TEST(Torque, UnusedArgumentLintError) {
ExpectFailingCompilation(R"( ExpectFailingCompilation(R"(
...@@ -346,10 +366,15 @@ TEST(Torque, NoUnusedWarningForVariablesOnlyUsedInAsserts) { ...@@ -346,10 +366,15 @@ TEST(Torque, NoUnusedWarningForVariablesOnlyUsedInAsserts) {
)"); )");
} }
// TODO(almuthanna): This test was skipped because it causes a crash when it is
// ran on Fuchsia. This issue should be solved later on
// Ticket: https://crbug.com/1028617
#if !defined(V8_TARGET_OS_FUCHSIA)
TEST(Torque, ImportNonExistentFile) { TEST(Torque, ImportNonExistentFile) {
ExpectFailingCompilation(R"(import "foo/bar.tq")", ExpectFailingCompilation(R"(import "foo/bar.tq")",
HasSubstr("File 'foo/bar.tq' not found.")); HasSubstr("File 'foo/bar.tq' not found."));
} }
#endif
TEST(Torque, LetShouldBeConstLintError) { TEST(Torque, LetShouldBeConstLintError) {
ExpectFailingCompilation(R"( ExpectFailingCompilation(R"(
...@@ -370,6 +395,10 @@ TEST(Torque, LetShouldBeConstIsSkippedForStructs) { ...@@ -370,6 +395,10 @@ TEST(Torque, LetShouldBeConstIsSkippedForStructs) {
)"); )");
} }
// TODO(almuthanna): These tests were skipped because they cause a crash when
// they are ran on Fuchsia. This issue should be solved later on
// Ticket: https://crbug.com/1028617
#if !defined(V8_TARGET_OS_FUCHSIA)
TEST(Torque, GenericAbstractType) { TEST(Torque, GenericAbstractType) {
ExpectSuccessfulCompilation(R"( ExpectSuccessfulCompilation(R"(
type Foo<T: type> extends HeapObject; type Foo<T: type> extends HeapObject;
...@@ -483,6 +512,7 @@ TEST(Torque, SpecializationRequesters) { ...@@ -483,6 +512,7 @@ TEST(Torque, SpecializationRequesters) {
SubstrTester("Note: in specialization C<Smi> requested here", 11, SubstrTester("Note: in specialization C<Smi> requested here", 11,
5)}); 5)});
} }
#endif
} // namespace torque } // namespace torque
} // namespace internal } // namespace internal
......
...@@ -110,6 +110,10 @@ sigjmp_buf MemoryAllocationPermissionsTest::continuation_; ...@@ -110,6 +110,10 @@ sigjmp_buf MemoryAllocationPermissionsTest::continuation_;
} // namespace } // namespace
// TODO(almuthanna): This test was skipped because it causes a crash when it is
// ran on Fuchsia. This issue should be solved later on
// Ticket: https://crbug.com/1028617
#if !defined(V8_TARGET_OS_FUCHSIA)
TEST_F(MemoryAllocationPermissionsTest, DoTest) { TEST_F(MemoryAllocationPermissionsTest, DoTest) {
TestPermissions(PageAllocator::Permission::kNoAccess, false, false); TestPermissions(PageAllocator::Permission::kNoAccess, false, false);
TestPermissions(PageAllocator::Permission::kRead, true, false); TestPermissions(PageAllocator::Permission::kRead, true, false);
...@@ -117,6 +121,8 @@ TEST_F(MemoryAllocationPermissionsTest, DoTest) { ...@@ -117,6 +121,8 @@ TEST_F(MemoryAllocationPermissionsTest, DoTest) {
TestPermissions(PageAllocator::Permission::kReadWriteExecute, true, true); TestPermissions(PageAllocator::Permission::kReadWriteExecute, true, true);
TestPermissions(PageAllocator::Permission::kReadExecute, true, false); TestPermissions(PageAllocator::Permission::kReadExecute, true, false);
} }
#endif
#endif // V8_OS_POSIX #endif // V8_OS_POSIX
// Basic tests of allocation. // Basic tests of allocation.
......
...@@ -260,6 +260,10 @@ class TrapHandlerTest : public TestWithIsolate, ...@@ -260,6 +260,10 @@ class TrapHandlerTest : public TestWithIsolate,
std::unique_ptr<TestingAssemblerBuffer> recovery_buffer_; std::unique_ptr<TestingAssemblerBuffer> recovery_buffer_;
}; };
// TODO(almuthanna): These tests were skipped because they cause a crash when
// they are ran on Fuchsia. This issue should be solved later on
// Ticket: https://crbug.com/1028617
#if !defined(V8_TARGET_OS_FUCHSIA)
TEST_P(TrapHandlerTest, TestTrapHandlerRecovery) { TEST_P(TrapHandlerTest, TestTrapHandlerRecovery) {
// Test that the wasm trap handler can recover a memory access violation in // Test that the wasm trap handler can recover a memory access violation in
// wasm code (we fake the wasm code and the access violation). // wasm code (we fake the wasm code and the access violation).
...@@ -417,6 +421,7 @@ TEST_P(TrapHandlerTest, TestCrashInWasmWrongCrashType) { ...@@ -417,6 +421,7 @@ TEST_P(TrapHandlerTest, TestCrashInWasmWrongCrashType) {
*trap_handler::GetThreadInWasmThreadLocalAddress() = 0; *trap_handler::GetThreadInWasmThreadLocalAddress() = 0;
} }
} }
#endif
class CodeRunner : public v8::base::Thread { class CodeRunner : public v8::base::Thread {
public: public:
...@@ -430,6 +435,10 @@ class CodeRunner : public v8::base::Thread { ...@@ -430,6 +435,10 @@ class CodeRunner : public v8::base::Thread {
TestingAssemblerBuffer* buffer_; TestingAssemblerBuffer* buffer_;
}; };
// TODO(almuthanna): This test was skipped because it causes a crash when it is
// ran on Fuchsia. This issue should be solved later on
// Ticket: https://crbug.com/1028617
#if !defined(V8_TARGET_OS_FUCHSIA)
TEST_P(TrapHandlerTest, TestCrashInOtherThread) { TEST_P(TrapHandlerTest, TestCrashInOtherThread) {
// Test setup: // Test setup:
// The current thread enters wasm land (sets the thread_in_wasm flag) // The current thread enters wasm land (sets the thread_in_wasm flag)
...@@ -464,6 +473,7 @@ TEST_P(TrapHandlerTest, TestCrashInOtherThread) { ...@@ -464,6 +473,7 @@ TEST_P(TrapHandlerTest, TestCrashInOtherThread) {
// Reset the thread-in-wasm flag. // Reset the thread-in-wasm flag.
*trap_handler::GetThreadInWasmThreadLocalAddress() = 0; *trap_handler::GetThreadInWasmThreadLocalAddress() = 0;
} }
#endif
INSTANTIATE_TEST_SUITE_P(Traps, TrapHandlerTest, INSTANTIATE_TEST_SUITE_P(Traps, TrapHandlerTest,
::testing::Values(kDefault, kCallback), ::testing::Values(kDefault, kCallback),
......
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