Skip to content

Commit 0eba841

Browse files
authored
Move a few moar tests from fsharpqa to fsharp.compiler.componenttests (#15237)
* Move a few moar tests from fsharpqa to fsharp.compiler.componenttests * Update highentropyva.fs * feedback
1 parent b456cec commit 0eba841

File tree

15 files changed

+96
-76
lines changed

15 files changed

+96
-76
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+
namespace FSharp.Compiler.ComponentTests.CompilerOptions
4+
5+
open System
6+
7+
open Xunit
8+
open FSharp.Test.Compiler
9+
10+
11+
//# Sanity check - simply check that the option is valid
12+
module crossoptimize =
13+
14+
// SOURCE=crossoptimize.fs SCFLAGS="--crossoptimize"
15+
[<InlineData("--crossoptimize")>]
16+
[<InlineData("--crossoptimize+")>]
17+
[<InlineData("--crossoptimize-")>]
18+
[<Theory>]
19+
let ``crossoptimize_flag_fs`` option =
20+
Fs """printfn "Hello, World!!!" """
21+
|> asExe
22+
|> withOptions (if String.IsNullOrWhiteSpace option then [] else [option])
23+
|> compile
24+
|> shouldSucceed
25+
26+
[<InlineData("--crossoptimize")>]
27+
[<InlineData("--crossoptimize+")>]
28+
[<InlineData("--crossoptimize-")>]
29+
[<Theory>]
30+
let ``crossoptimize_flag_fsx`` option =
31+
Fsx """printfn "Hello, World!!!" """
32+
|> asExe
33+
|> withOptions (if String.IsNullOrWhiteSpace option then [] else [option])
34+
|> compile
35+
|> shouldSucceed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+
namespace FSharp.Compiler.ComponentTests.CompilerOptions
4+
5+
open System
6+
open System.Reflection.PortableExecutable
7+
8+
open Xunit
9+
open FSharp.Test.Compiler
10+
11+
12+
module highentropyva =
13+
14+
let shouldHaveFlag (expected: DllCharacteristics) (result: DllCharacteristics) =
15+
if not (result.HasFlag expected) then
16+
raise (new Exception $"CoffHeader.Characteristics does not contain expected flag:\nFound: {result}\n Expected: {expected}")
17+
18+
let shouldNotHaveFlag (notexpected: DllCharacteristics) (result: DllCharacteristics) =
19+
if result.HasFlag notexpected then
20+
raise (new Exception $"DllCharacteristics contains the unexpected flag:\nFound: {result}\nNot expected: {notexpected}")
21+
22+
[<InlineData(ExecutionPlatform.X64, null)>]
23+
[<InlineData(ExecutionPlatform.X86, null)>]
24+
[<InlineData(ExecutionPlatform.Arm64, null)>]
25+
[<InlineData(ExecutionPlatform.Arm, null)>]
26+
[<InlineData(ExecutionPlatform.X64, "--highentropyva-")>]
27+
[<InlineData(ExecutionPlatform.X86, "--highentropyva-")>]
28+
[<InlineData(ExecutionPlatform.Arm64, "--highentropyva-")>]
29+
[<InlineData(ExecutionPlatform.Arm, "--highentropyva-")>]
30+
[<Theory>]
31+
let shouldNotGenerateHighEntropyVirtualAddressSpace platform option =
32+
Fs """printfn "Hello, World!!!" """
33+
|> asExe
34+
|> withPlatform platform
35+
|> withOptions (if String.IsNullOrWhiteSpace option then [] else [option])
36+
|> compile
37+
|> shouldSucceed
38+
|> withPeReader(fun rdr -> rdr.PEHeaders.PEHeader.DllCharacteristics)
39+
|> shouldNotHaveFlag DllCharacteristics.HighEntropyVirtualAddressSpace
40+
41+
[<InlineData(ExecutionPlatform.X64, "--highentropyva")>]
42+
[<InlineData(ExecutionPlatform.X64, "--highentropyva+")>]
43+
[<InlineData(ExecutionPlatform.X86, "--highentropyva")>]
44+
[<InlineData(ExecutionPlatform.X86, "--highentropyva+")>]
45+
[<InlineData(ExecutionPlatform.Arm64, "--highentropyva+")>]
46+
[<InlineData(ExecutionPlatform.Arm64, "--highentropyva")>]
47+
[<InlineData(ExecutionPlatform.Arm, "--highentropyva")>]
48+
[<InlineData(ExecutionPlatform.Arm, "--highentropyva+")>]
49+
[<Theory>]
50+
let shouldGenerateHighEntropyVirtualAddressSpace platform option =
51+
Fs """printfn "Hello, World!!!" """
52+
|> asExe
53+
|> withPlatform platform
54+
|> withOptions (if String.IsNullOrWhiteSpace option then [] else [option])
55+
|> compile
56+
|> shouldSucceed
57+
|> withPeReader(fun rdr -> rdr.PEHeaders.PEHeader.DllCharacteristics)
58+
|> shouldHaveFlag DllCharacteristics.HighEntropyVirtualAddressSpace

tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@
210210
<Compile Include="CompilerOptions\fsc\checked\checked.fs" />
211211
<Compile Include="CompilerOptions\fsc\cliversion.fs" />
212212
<Compile Include="CompilerOptions\fsc\codepage\codepage.fs" />
213+
<Compile Include="CompilerOptions\fsc\crossoptimize.fs" />
213214
<Compile Include="CompilerOptions\fsc\debug.fs" />
215+
<Compile Include="CompilerOptions\fsc\highentropyva.fs" />
214216
<Compile Include="CompilerOptions\fsc\langversion.fs" />
215217
<Compile Include="CompilerOptions\fsc\misc\misc.fs" />
216218
<Compile Include="CompilerOptions\fsc\noframework\noframework.fs" />
@@ -221,7 +223,7 @@
221223
<Compile Include="CompilerOptions\fsc\reference.fs" />
222224
<Compile Include="CompilerOptions\fsc\reflectionfree.fs" />
223225
<Compile Include="CompilerOptions\fsc\refonlyrefout.fs" />
224-
<Compile Include="CompilerOptions\fsc\sourceFiles.fs" />
226+
<Compile Include="CompilerOptions\fsc\sourceFiles.fs" />
225227
<Compile Include="CompilerService\RangeModule.fs" />
226228
<Compile Include="Debugger\PortablePdbs.fs" />
227229
<Compile Include="Diagnostics\async.fs" />

tests/FSharp.Test.Utilities/Compiler.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ open System.Reflection.PortableExecutable
2424

2525
open FSharp.Test.CompilerAssertHelpers
2626
open TestFramework
27-
open System.Reflection.Metadata
2827

2928
module rec Compiler =
3029
type BaselineFile =

tests/fsharpqa/Source/CompilerOptions/fsc/crossoptimize/crossoptimize01.fs

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/fsharpqa/Source/CompilerOptions/fsc/crossoptimize/env.lst

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/CheckHighEntropyASLR.bat

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/dummy.fs

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/env.lst

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion-culture.fsx

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)