forked from swiftlang/swift-build
- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSWBQNXPlatformTests.swift
150 lines (137 loc) · 6.67 KB
/
SWBQNXPlatformTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import Testing
import SWBProtocol
import SWBTestSupport
import SWBTaskExecution
import SWBUtil
@Suite
fileprivatestructQNXBuildOperationTests:CoreBasedTests{
@Test(.requireSDKs(.qnx),.skipHostOS(.macOS),.requireThreadSafeWorkingDirectory, arguments:["aarch64","x86_64"])
func qnxCommandLineTool(arch:String)asyncthrows{
tryawaitwithTemporaryDirectory{(tmpDir:Path)in
lettestProject=TestProject(
"TestProject",
sourceRoot: tmpDir,
groupTree:TestGroup(
"SomeFiles",
children:[
TestFile("main.c"),
TestFile("dynamic.c"),
TestFile("static.c"),
]),
buildConfigurations:[
TestBuildConfiguration("Debug", buildSettings:[
"ARCHS": arch,
"CODE_SIGNING_ALLOWED":"NO",
"DEFINES_MODULE":"YES",
"PRODUCT_NAME":"$(TARGET_NAME)",
"SDKROOT":"qnx",
"SUPPORTED_PLATFORMS":"qnx",
])
],
targets:[
TestStandardTarget(
"tool",
type:.commandLineTool,
buildConfigurations:[
TestBuildConfiguration("Debug", buildSettings:[:])
],
buildPhases:[
TestSourcesBuildPhase(["main.c"]),
TestFrameworksBuildPhase([
TestBuildFile(.target("dynamiclib")),
TestBuildFile(.target("staticlib")),
])
],
dependencies:[
"dynamiclib",
"staticlib",
]
),
TestStandardTarget(
"dynamiclib",
type:.dynamicLibrary,
buildConfigurations:[
TestBuildConfiguration("Debug", buildSettings:[
"DYLIB_INSTALL_NAME_BASE":"$ORIGIN",
// FIXME: Find a way to make these default
"EXECUTABLE_PREFIX":"lib",
])
],
buildPhases:[
TestSourcesBuildPhase(["dynamic.c"]),
],
productReferenceName:"libdynamiclib.so"
),
TestStandardTarget(
"staticlib",
type:.staticLibrary,
buildConfigurations:[
TestBuildConfiguration("Debug", buildSettings:[
// FIXME: Find a way to make these default
"EXECUTABLE_PREFIX":"lib",
])
],
buildPhases:[
TestSourcesBuildPhase(["static.c"]),
]
),
])
letcore=tryawaitgetCore()
lettester=tryawaitBuildOperationTester(core, testProject, simulated:false)
letprojectDir= tester.workspace.projects[0].sourceRoot
tryawait tester.fs.writeFileContents(projectDir.join("main.c")){ stream in
stream <<<"int main() { }\n"
}
tryawait tester.fs.writeFileContents(projectDir.join("dynamic.c")){ stream in
stream <<<"void dynamicLib() { }"
}
tryawait tester.fs.writeFileContents(projectDir.join("static.c")){ stream in
stream <<<"void staticLib() { }"
}
letarchName= arch =="aarch64"?"aarch64le": arch
letdestination:RunDestinationInfo=.qnx
tryawait tester.checkBuild(runDestination: destination){ results in
results.checkNoErrors()
letcompiler=Path("bin").join(core.hostOperatingSystem.imageFormat.executableName(basename:"qcc"))
results.checkTask(.matchRuleType("Ld"),.matchRuleItemPattern(.suffix(Path("build/Debug-qnx/libdynamiclib.so").str))){ task in
task.checkCommandLineMatches([
.suffix(compiler.str),
"-V","gcc_nto\(archName)",
"-shared",
"-Os",
.pathEqual(prefix:"-L", tmpDir.join("build/EagerLinkingTBDs/Debug-qnx")),
.pathEqual(prefix:"-L", tmpDir.join("build/Debug-qnx")),
.pathEqual(prefix:"@", tmpDir.join("build/TestProject.build/Debug-qnx/dynamiclib.build/Objects-normal/\(arch)/dynamiclib.LinkFileList")),
"-Wl,-h$ORIGIN/libdynamiclib.so",
"-o",.path(tmpDir.join("build/Debug-qnx/libdynamiclib.so"))
])
}
results.checkTask(.matchRuleType("Ld"),.matchRuleItemPattern(.suffix(Path("build/Debug-qnx/tool").str))){ task in
task.checkCommandLineMatches([
.suffix(compiler.str),
"-V","gcc_nto\(archName)",
"-Os",
.pathEqual(prefix:"-L", tmpDir.join("build/EagerLinkingTBDs/Debug-qnx")),
.pathEqual(prefix:"-L", tmpDir.join("build/Debug-qnx")),
.pathEqual(prefix:"@", tmpDir.join("build/TestProject.build/Debug-qnx/tool.build/Objects-normal/\(arch)/tool.LinkFileList")),
"-ldynamiclib",
"-lstaticlib",
"-o",.path(tmpDir.join("build/Debug-qnx/tool"))
])
}
#expect(tester.fs.exists(projectDir.join("build").join("Debug\(destination.builtProductsDirSuffix)").join("tool")))
}
}
}
}