Skip to content

test: port most of the interpreter tests to Windows #21902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/Interpreter/SDK/libc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import Darwin
#elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android)
import Glibc
#elseif os(Windows)
import MSVCRT
#endif

let sourcePath = CommandLine.arguments[1]
Expand Down
21 changes: 17 additions & 4 deletions test/Interpreter/dynamic_replacement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ import StdlibUnittest

#if os(Linux)
import Glibc
let dylibSuffix = "so"
#elseif os(Windows)
import MSVCRT
import WinSDK
#else
import Darwin
let dylibSuffix = "dylib"
#endif

var DynamicallyReplaceable = TestSuite("DynamicallyReplaceable")
Expand Down Expand Up @@ -108,6 +109,16 @@ func checkExpectedResults(forOriginalLibrary useOrig: Bool) {
expectedResult(useOrig, "public_enum_generic_func"))
}

private func target_library_name(_ name: String) -> String {
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
return "lib\(name).dylib"
#elseif os(Windows)
return "\(name).dll"
#else
return "lib\(name).so"
#endif
}

DynamicallyReplaceable.test("DynamicallyReplaceable") {
var executablePath = CommandLine.arguments[0]
executablePath.removeLast(4)
Expand All @@ -118,9 +129,11 @@ DynamicallyReplaceable.test("DynamicallyReplaceable") {
// Now, test with the module containing the replacements.

#if os(Linux)
_ = dlopen("libModule2."+dylibSuffix, RTLD_NOW)
_ = dlopen(target_library_name("Module2"), RTLD_NOW)
#elseif os(Windows)
_ = LoadLibraryA(target_library_name("Module2"))
#else
_ = dlopen(executablePath+"libModule2."+dylibSuffix, RTLD_NOW)
_ = dlopen(target_library_name("Module2"), RTLD_NOW)
#endif
checkExpectedResults(forOriginalLibrary: false)
}
Expand Down
25 changes: 19 additions & 6 deletions test/Interpreter/dynamic_replacement_chaining.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,38 @@ import StdlibUnittest

#if os(Linux)
import Glibc
let dylibSuffix = "so"
#elseif os(Windows)
import MSVCRT
import WinSDK
#else
import Darwin
let dylibSuffix = "dylib"
#endif

var DynamicallyReplaceable = TestSuite("DynamicallyReplaceableChaining")

func target_library_name(_ name: String) -> String {
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
return "lib\(name).dylib"
#elseif os(Windows)
return "\(name).dll"
#else
return "lib\(name).so"
#endif
}

DynamicallyReplaceable.test("DynamicallyReplaceable") {
var executablePath = CommandLine.arguments[0]
executablePath.removeLast(4)

#if os(Linux)
_ = dlopen("libB."+dylibSuffix, RTLD_NOW)
_ = dlopen("libC."+dylibSuffix, RTLD_NOW)
_ = dlopen(target_library_name("B"), RTLD_NOW)
_ = dlopen(target_library_name("C"), RTLD_NOW)
#elseif os(Windows)
_ = LoadLibraryA(target_library_name("B"))
_ = LoadLibraryA(target_library_name("C"))
#else
_ = dlopen(executablePath+"libB."+dylibSuffix, RTLD_NOW)
_ = dlopen(executablePath+"libC."+dylibSuffix, RTLD_NOW)
_ = dlopen(executablePath+target_library_name("B"), RTLD_NOW)
_ = dlopen(executablePath+target_library_name("C"), RTLD_NOW)
#endif

#if CHAINING
Expand Down
2 changes: 1 addition & 1 deletion test/Interpreter/extended_grapheme_cluster_literal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private struct Expressible
}
}

private func string(_ characters: UInt32...) -> String {
public func string(_ characters: UInt32...) -> String {
return String(characters.map { Character(UnicodeScalar($0)!) })
}
private func expressible<T>(_ literal: Expressible<T>, as type: T.Type)
Expand Down
4 changes: 3 additions & 1 deletion test/Interpreter/unions-and-bitfields.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// RUN: %target-build-swift %s -import-objc-header %S/Inputs/unions-and-bitfields.h -disable-bridging-pch -o %t
// RUN: %target-build-swift %s -Xfrontend -enable-objc-interop -Xfrontend -disable-objc-attr-requires-foundation-module -import-objc-header %S/Inputs/unions-and-bitfields.h -disable-bridging-pch -o %t
// RUN: %target-codesign %t
// RUN: %target-run %t

// REQUIRES: executable_test
// REQUIRES: objc_interop

// The -disable-bridging-pch above isn't actually relevant to the test; however,
// precompiled headers don't play nice with the way we include the platform
Expand Down