From afc37c2d1b9be69f103ddf6d0f7572660949c648 Mon Sep 17 00:00:00 2001 From: Kevin Ransom Date: Thu, 18 May 2023 18:26:35 -0700 Subject: [PATCH 1/3] Move a few moar tests from fsharpqa to fsharp.compiler.componenttests --- .../CompilerOptions/fsc/crossoptimize.fs | 65 +++++++++ .../CompilerOptions/fsc/highentropyva.fs | 126 ++++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 4 +- tests/FSharp.Test.Utilities/Compiler.fs | 1 - .../fsc/crossoptimize/crossoptimize01.fs | 3 - .../CompilerOptions/fsc/crossoptimize/env.lst | 10 -- .../highentropyva/CheckHighEntropyASLR.bat | 10 -- .../fsc/highentropyva/dummy.fs | 2 - .../CompilerOptions/fsc/highentropyva/env.lst | 15 --- .../langversion/badlangversion-culture.fsx | 5 - .../langversion/badlangversion-decimal.fsx | 5 - .../fsc/langversion/badlangversion.fsx | 5 - .../CompilerOptions/fsc/langversion/dummy.fsx | 3 - .../CompilerOptions/fsc/langversion/env.lst | 6 - .../langversion/langversionhelp.437.1033.bsl | 10 -- 15 files changed, 194 insertions(+), 76 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/crossoptimize.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/crossoptimize/crossoptimize01.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/crossoptimize/env.lst delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/CheckHighEntropyASLR.bat delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/dummy.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/env.lst delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion-culture.fsx delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion-decimal.fsx delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion.fsx delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/langversion/dummy.fsx delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/langversion/env.lst delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/langversion/langversionhelp.437.1033.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/crossoptimize.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/crossoptimize.fs new file mode 100644 index 00000000000..477f3ea0fa7 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/crossoptimize.fs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.ComponentTests.CompilerOptions + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +//# Sanity check - simply check that the option is valid +module crossoptimize = + + // SOURCE=crossoptimize.fs SCFLAGS="--crossoptimize" + [] + let ``crossoptimize_fs --crossoptimize``() = + Fs """printfn "Hello, World!!!" """ + |> asExe + |> withOptions ["--crossoptimize"] + |> compile + |> shouldSucceed + + // SOURCE=crossoptimize.fs SCFLAGS="--crossoptimize+" + [] + let ``crossoptimize_fs --crossoptimize+``() = + Fs """printfn "Hello, World!!!" """ + |> asExe + |> withOptions ["--crossoptimize+"] + |> compile + |> shouldSucceed + + // SOURCE=crossoptimize.fs SCFLAGS="--crossoptimize-" + [] + let ``crossoptimize_fs --crossoptimize-``() = + Fs """printfn "Hello, World!!!" """ + |> asExe + |> withOptions ["--crossoptimize-"] + |> compile + |> shouldSucceed + + // SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize" FSIMODE=EXEC COMPILE_ONLY=1 + [] + let ``crossoptimize_fsx --crossoptimize``() = + Fsx """printfn "Hello, World!!!" """ + |> asExe + |> withOptions ["--crossoptimize"] + |> compile + |> shouldSucceed + + // SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize+" FSIMODE=EXEC COMPILE_ONLY=1 + [] + let ``crossoptimize_fsx --crossoptimize+``() = + Fsx """printfn "Hello, World!!!" """ + |> asExe + |> withOptions ["--crossoptimize+"] + |> compile + |> shouldSucceed + + // SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize-" FSIMODE=EXEC COMPILE_ONLY=1 + [] + let ``crossoptimize_fsx --crossoptimize-``() = + Fsx """printfn "Hello, World!!!" """ + |> asExe + |> withOptions ["--crossoptimize-"] + |> compile + |> shouldSucceed + diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs new file mode 100644 index 00000000000..3fb986a63bc --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.ComponentTests.CompilerOptions + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +open System +open System.Reflection.PortableExecutable + +module highentropyva = + + let shouldHaveFlag (expected: DllCharacteristics) (result: DllCharacteristics) = + if not (result.HasFlag expected) then + raise (new Exception $"CoffHeader.Characteristics does not contain expected flag:\nFound: {result}\n Expected: {expected}") + + let shouldNotHaveFlag (expected: DllCharacteristics) (result: DllCharacteristics) = + if result.HasFlag expected then + raise (new Exception $"DllCharacteristics does not contain expected flag:\nFound: {result}\nExpected: {expected}") + + let shouldNotGenerateHighEntropyVirtualAddressSpace platform options = + Fs """printfn "Hello, World!!!" """ + |> asExe + |> withPlatform platform + |> withOptions options + |> compile + |> shouldSucceed + |> withPeReader(fun rdr -> rdr.PEHeaders.PEHeader.DllCharacteristics) + |> shouldNotHaveFlag DllCharacteristics.HighEntropyVirtualAddressSpace + + let shouldGenerateHighEntropyVirtualAddressSpace platform options = + Fs """printfn "Hello, World!!!" """ + |> asExe + |> withPlatform platform + |> withOptions options + |> compile + |> shouldSucceed + |> withPeReader(fun rdr -> rdr.PEHeaders.PEHeader.DllCharacteristics) + |> shouldHaveFlag DllCharacteristics.HighEntropyVirtualAddressSpace + + + //# Default behavior ========================================================================================================================== + + // SOURCE=dummy.fs SCFLAGS="--platform:x64" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x64 + [] + let ``CheckHighEntropyASLR_fs --platform:x64 no``() = + shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X64 [] + + // SOURCE=dummy.fs SCFLAGS="--platform:x86" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x86 + [] + let ``CheckHighEntropyASLR_fs --platform:x86 no``() = + shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X86 [] + + // SOURCE=dummy.fs SCFLAGS="--platform:arm86" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x86 + [] + let ``CheckHighEntropyASLR_fs --platform:arm86 no``() = + shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm [] + + // SOURCE=dummy.fs SCFLAGS="--platform:arm64" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x86 + [] + let ``CheckHighEntropyASLR_fs --platform:arm64 no``() = + shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm64 [] + + + //# --highentropyva / --highentropyva+ / --highentropyva ================================================================================ + + //# SOURCE=dummy.fs SCFLAGS="--platform:x64 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:x64 --highentropyva no``() = + shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X64 ["--highentropyva"] + + //# SOURCE=dummy.fs SCFLAGS="--platform:x64 --highentropyva+" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:x64 --highentropyva+ no``() = + shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X64 ["--highentropyva+"] + + //# SOURCE=dummy.fs SCFLAGS="--platform:x64 --highentropyva-" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:x64 --highentropyva- no``() = + shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X64 ["--highentropyva-"] + + //# SOURCE=dummy.fs SCFLAGS="--platform:x64 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:x86 --highentropyva no``() = + shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X86 ["--highentropyva"] + + //# SOURCE=dummy.fs SCFLAGS="--platform:x86 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:x86 --highentropyva+ no``() = + shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X86 ["--highentropyva+"] + + //# SOURCE=dummy.fs SCFLAGS="--platform:x86 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:x86 --highentropyva- no``() = + shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X86 ["--highentropyva-"] + + //# SOURCE=dummy.fs SCFLAGS="--platform:Arm64 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:arm64 --highentropyva no``() = + shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm64 ["--highentropyva"] + + //# SOURCE=dummy.fs SCFLAGS="--platform:arm64 --highentropyva+" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:arm64 --highentropyva+ no``() = + shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm64 ["--highentropyva+"] + + //# SOURCE=dummy.fs SCFLAGS="--platform:arm64 --highentropyva-" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:arm64 --highentropyva- no``() = + shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm64 ["--highentropyva-"] + + //# SOURCE=dummy.fs SCFLAGS="--platform:arm --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:arm --highentropyva no``() = + shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm ["--highentropyva"] + + //# SOURCE=dummy.fs SCFLAGS="--platform:arm --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:arm --highentropyva+ no``() = + shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm ["--highentropyva+"] + + //# SOURCE=dummy.fs SCFLAGS="--platform:arm --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva + [] + let ``CheckHighEntropyASLR_fs --platform:arm --highentropyva- no``() = + shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm ["--highentropyva-"] diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 74d8f6c22d0..a83d57f55a5 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -210,7 +210,9 @@ + + @@ -221,7 +223,7 @@ - + diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index 7045cf0c4bb..5935a533037 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -24,7 +24,6 @@ open System.Reflection.PortableExecutable open FSharp.Test.CompilerAssertHelpers open TestFramework -open System.Reflection.Metadata module rec Compiler = type BaselineFile = diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/crossoptimize/crossoptimize01.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/crossoptimize/crossoptimize01.fs deleted file mode 100644 index ab57f523a2e..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/crossoptimize/crossoptimize01.fs +++ /dev/null @@ -1,3 +0,0 @@ -// #NoMT #CompilerOptions -module crossoptimize01 -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/crossoptimize/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsc/crossoptimize/env.lst deleted file mode 100644 index 68f2e152665..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/crossoptimize/env.lst +++ /dev/null @@ -1,10 +0,0 @@ -# Sanity check - simply check that the option is valid - - SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize" - SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize+" - SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize-" - - SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize" FSIMODE=EXEC COMPILE_ONLY=1 - SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize+" FSIMODE=EXEC COMPILE_ONLY=1 - SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize-" FSIMODE=EXEC COMPILE_ONLY=1 - diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/CheckHighEntropyASLR.bat b/tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/CheckHighEntropyASLR.bat deleted file mode 100644 index d5ec99a9a23..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/CheckHighEntropyASLR.bat +++ /dev/null @@ -1,10 +0,0 @@ -@echo off - -REM Use Link.exe from the nuget package - -REM %LINK_EXE% -- Path to link.exe -REM %1 -- assembly to check -REM %2 -- expected value ("yes" or "no") -%LINK_EXE% /dump /headers %1 | find "High Entropy Virtual Addresses" > NUL -IF /I "%2"=="yes" IF ERRORLEVEL 1 EXIT /B 1 -IF /I "%2"=="no" IF NOT ERRORLEVEL 1 EXIT /B 1 \ No newline at end of file diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/dummy.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/dummy.fs deleted file mode 100644 index 3caed3d251c..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/dummy.fs +++ /dev/null @@ -1,2 +0,0 @@ -let x = 1 -x |> ignore \ No newline at end of file diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/env.lst deleted file mode 100644 index 2d18646ff07..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/highentropyva/env.lst +++ /dev/null @@ -1,15 +0,0 @@ -# Default behavior - SOURCE=dummy.fs SCFLAGS="--platform:x64" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x64 - SOURCE=dummy.fs SCFLAGS="--platform:x86" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x86 - -# --highentropyva+ and --highentropyva -# SOURCE=dummy.fs SCFLAGS="--platform:x64 --highentropyva+" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x64 highentropyva+ -# SOURCE=dummy.fs SCFLAGS="--platform:x86 --highentropyva+" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva+ -# SOURCE=dummy.fs SCFLAGS="--platform:x64 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x64 highentropyva -# SOURCE=dummy.fs SCFLAGS="--platform:x86 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva -# SOURCE=dummy.fs SCFLAGS="--platform:Itanium --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - IA64 highentropyva - -# --highentropyva- - SOURCE=dummy.fs SCFLAGS="--platform:x64 --highentropyva-" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x64 highentropyva- - SOURCE=dummy.fs SCFLAGS="--platform:x86 --highentropyva-" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x86 highentropyva- - SOURCE=dummy.fs SCFLAGS="--platform:Itanium --highentropyva-" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - IA64 highentropyva- diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion-culture.fsx b/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion-culture.fsx deleted file mode 100644 index d1e6d620d70..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion-culture.fsx +++ /dev/null @@ -1,5 +0,0 @@ -// #NoMT #CompilerOptions #RequiresENU -// Unrecognized value '4,7' for --langversion use --langversion:? for complete list -// -#light -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion-decimal.fsx b/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion-decimal.fsx deleted file mode 100644 index d92c376bc39..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion-decimal.fsx +++ /dev/null @@ -1,5 +0,0 @@ -// #NoMT #CompilerOptions #RequiresENU -// Unrecognized value '4.70000000000' for --langversion use --langversion:? for complete list -// -#light -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion.fsx b/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion.fsx deleted file mode 100644 index b41237cd0b3..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/badlangversion.fsx +++ /dev/null @@ -1,5 +0,0 @@ -// #NoMT #CompilerOptions #RequiresENU -// Unrecognized value '4.5' for --langversion use --langversion:? for complete list -// -#light -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/dummy.fsx b/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/dummy.fsx deleted file mode 100644 index c5ecbb36434..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/dummy.fsx +++ /dev/null @@ -1,3 +0,0 @@ -// #NoMT #CompilerOptions #RequiresENU -#light -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/env.lst deleted file mode 100644 index 6ecc5030f21..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/env.lst +++ /dev/null @@ -1,6 +0,0 @@ -# ReqENU means that the test is non-localized - -ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >langversionhelp.txt --langversion:? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx langversionhelp.txt langversionhelp.437.1033.bsl" # --langversion:? -ReqENU SOURCE=badlangversion.fsx SCFLAGS=" --langversion:4.5" # --langversion:4.5 -ReqENU SOURCE=badlangversion-culture.fsx SCFLAGS=" --langversion:4,7" # --langversion:4,7 -ReqENU SOURCE=badlangversion-decimal.fsx SCFLAGS=" --langversion:4.70000000000" # --langversion:4.70000000000 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/langversionhelp.437.1033.bsl b/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/langversionhelp.437.1033.bsl deleted file mode 100644 index 2e3e65520ac..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/langversion/langversionhelp.437.1033.bsl +++ /dev/null @@ -1,10 +0,0 @@ -Supported language versions: -preview -default -latest -latestmajor -4.6 -4.7 -5.0 -6.0 -7.0 (Default) \ No newline at end of file From e71e8e4a2809c23cfdf677db5cbf874749b6e231 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Thu, 18 May 2023 18:31:54 -0700 Subject: [PATCH 2/3] Update highentropyva.fs --- .../CompilerOptions/fsc/highentropyva.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs index 3fb986a63bc..8202fc1b8fb 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs @@ -15,9 +15,9 @@ module highentropyva = if not (result.HasFlag expected) then raise (new Exception $"CoffHeader.Characteristics does not contain expected flag:\nFound: {result}\n Expected: {expected}") - let shouldNotHaveFlag (expected: DllCharacteristics) (result: DllCharacteristics) = - if result.HasFlag expected then - raise (new Exception $"DllCharacteristics does not contain expected flag:\nFound: {result}\nExpected: {expected}") + let shouldNotHaveFlag (notexpected: DllCharacteristics) (result: DllCharacteristics) = + if result.HasFlag notexpected then + raise (new Exception $"DllCharacteristics contains the unexpected flag:\nFound: {result}\nNot expected: {notexpected}") let shouldNotGenerateHighEntropyVirtualAddressSpace platform options = Fs """printfn "Hello, World!!!" """ From 3cbe2ff882d99049a119afa8d40c85f74659bfb9 Mon Sep 17 00:00:00 2001 From: Kevin Ransom Date: Fri, 19 May 2023 10:55:52 -0700 Subject: [PATCH 3/3] feedback --- .../CompilerOptions/fsc/crossoptimize.fs | 60 +++------ .../CompilerOptions/fsc/highentropyva.fs | 118 ++++-------------- 2 files changed, 40 insertions(+), 138 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/crossoptimize.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/crossoptimize.fs index 477f3ea0fa7..2304e1da339 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/crossoptimize.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/crossoptimize.fs @@ -2,64 +2,34 @@ namespace FSharp.Compiler.ComponentTests.CompilerOptions +open System + open Xunit -open FSharp.Test open FSharp.Test.Compiler + //# Sanity check - simply check that the option is valid module crossoptimize = // SOURCE=crossoptimize.fs SCFLAGS="--crossoptimize" - [] - let ``crossoptimize_fs --crossoptimize``() = - Fs """printfn "Hello, World!!!" """ - |> asExe - |> withOptions ["--crossoptimize"] - |> compile - |> shouldSucceed - - // SOURCE=crossoptimize.fs SCFLAGS="--crossoptimize+" - [] - let ``crossoptimize_fs --crossoptimize+``() = - Fs """printfn "Hello, World!!!" """ - |> asExe - |> withOptions ["--crossoptimize+"] - |> compile - |> shouldSucceed - - // SOURCE=crossoptimize.fs SCFLAGS="--crossoptimize-" - [] - let ``crossoptimize_fs --crossoptimize-``() = + [] + [] + [] + [] + let ``crossoptimize_flag_fs`` option = Fs """printfn "Hello, World!!!" """ |> asExe - |> withOptions ["--crossoptimize-"] + |> withOptions (if String.IsNullOrWhiteSpace option then [] else [option]) |> compile |> shouldSucceed - // SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize" FSIMODE=EXEC COMPILE_ONLY=1 - [] - let ``crossoptimize_fsx --crossoptimize``() = + [] + [] + [] + [] + let ``crossoptimize_flag_fsx`` option = Fsx """printfn "Hello, World!!!" """ |> asExe - |> withOptions ["--crossoptimize"] + |> withOptions (if String.IsNullOrWhiteSpace option then [] else [option]) |> compile |> shouldSucceed - - // SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize+" FSIMODE=EXEC COMPILE_ONLY=1 - [] - let ``crossoptimize_fsx --crossoptimize+``() = - Fsx """printfn "Hello, World!!!" """ - |> asExe - |> withOptions ["--crossoptimize+"] - |> compile - |> shouldSucceed - - // SOURCE=crossoptimize01.fs SCFLAGS="--crossoptimize-" FSIMODE=EXEC COMPILE_ONLY=1 - [] - let ``crossoptimize_fsx --crossoptimize-``() = - Fsx """printfn "Hello, World!!!" """ - |> asExe - |> withOptions ["--crossoptimize-"] - |> compile - |> shouldSucceed - diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs index 8202fc1b8fb..bef3f6ff8b9 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/highentropyva.fs @@ -2,12 +2,12 @@ namespace FSharp.Compiler.ComponentTests.CompilerOptions +open System +open System.Reflection.PortableExecutable + open Xunit -open FSharp.Test open FSharp.Test.Compiler -open System -open System.Reflection.PortableExecutable module highentropyva = @@ -19,108 +19,40 @@ module highentropyva = if result.HasFlag notexpected then raise (new Exception $"DllCharacteristics contains the unexpected flag:\nFound: {result}\nNot expected: {notexpected}") - let shouldNotGenerateHighEntropyVirtualAddressSpace platform options = + [] + [] + [] + [] + [] + [] + [] + [] + [] + let shouldNotGenerateHighEntropyVirtualAddressSpace platform option = Fs """printfn "Hello, World!!!" """ |> asExe |> withPlatform platform - |> withOptions options + |> withOptions (if String.IsNullOrWhiteSpace option then [] else [option]) |> compile |> shouldSucceed |> withPeReader(fun rdr -> rdr.PEHeaders.PEHeader.DllCharacteristics) |> shouldNotHaveFlag DllCharacteristics.HighEntropyVirtualAddressSpace - let shouldGenerateHighEntropyVirtualAddressSpace platform options = + [] + [] + [] + [] + [] + [] + [] + [] + [] + let shouldGenerateHighEntropyVirtualAddressSpace platform option = Fs """printfn "Hello, World!!!" """ |> asExe |> withPlatform platform - |> withOptions options + |> withOptions (if String.IsNullOrWhiteSpace option then [] else [option]) |> compile |> shouldSucceed |> withPeReader(fun rdr -> rdr.PEHeaders.PEHeader.DllCharacteristics) |> shouldHaveFlag DllCharacteristics.HighEntropyVirtualAddressSpace - - - //# Default behavior ========================================================================================================================== - - // SOURCE=dummy.fs SCFLAGS="--platform:x64" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x64 - [] - let ``CheckHighEntropyASLR_fs --platform:x64 no``() = - shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X64 [] - - // SOURCE=dummy.fs SCFLAGS="--platform:x86" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x86 - [] - let ``CheckHighEntropyASLR_fs --platform:x86 no``() = - shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X86 [] - - // SOURCE=dummy.fs SCFLAGS="--platform:arm86" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x86 - [] - let ``CheckHighEntropyASLR_fs --platform:arm86 no``() = - shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm [] - - // SOURCE=dummy.fs SCFLAGS="--platform:arm64" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe no" # CheckHighEntropyALSR - x86 - [] - let ``CheckHighEntropyASLR_fs --platform:arm64 no``() = - shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm64 [] - - - //# --highentropyva / --highentropyva+ / --highentropyva ================================================================================ - - //# SOURCE=dummy.fs SCFLAGS="--platform:x64 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:x64 --highentropyva no``() = - shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X64 ["--highentropyva"] - - //# SOURCE=dummy.fs SCFLAGS="--platform:x64 --highentropyva+" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:x64 --highentropyva+ no``() = - shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X64 ["--highentropyva+"] - - //# SOURCE=dummy.fs SCFLAGS="--platform:x64 --highentropyva-" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:x64 --highentropyva- no``() = - shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X64 ["--highentropyva-"] - - //# SOURCE=dummy.fs SCFLAGS="--platform:x64 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:x86 --highentropyva no``() = - shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X86 ["--highentropyva"] - - //# SOURCE=dummy.fs SCFLAGS="--platform:x86 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:x86 --highentropyva+ no``() = - shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X86 ["--highentropyva+"] - - //# SOURCE=dummy.fs SCFLAGS="--platform:x86 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:x86 --highentropyva- no``() = - shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.X86 ["--highentropyva-"] - - //# SOURCE=dummy.fs SCFLAGS="--platform:Arm64 --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:arm64 --highentropyva no``() = - shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm64 ["--highentropyva"] - - //# SOURCE=dummy.fs SCFLAGS="--platform:arm64 --highentropyva+" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:arm64 --highentropyva+ no``() = - shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm64 ["--highentropyva+"] - - //# SOURCE=dummy.fs SCFLAGS="--platform:arm64 --highentropyva-" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:arm64 --highentropyva- no``() = - shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm64 ["--highentropyva-"] - - //# SOURCE=dummy.fs SCFLAGS="--platform:arm --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:arm --highentropyva no``() = - shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm ["--highentropyva"] - - //# SOURCE=dummy.fs SCFLAGS="--platform:arm --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:arm --highentropyva+ no``() = - shouldGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm ["--highentropyva+"] - - //# SOURCE=dummy.fs SCFLAGS="--platform:arm --highentropyva" COMPILE_ONLY=1 POSTCMD="CheckHighEntropyASLR.bat dummy.exe yes" # CheckHighEntropyALSR - x86 highentropyva - [] - let ``CheckHighEntropyASLR_fs --platform:arm --highentropyva- no``() = - shouldNotGenerateHighEntropyVirtualAddressSpace ExecutionPlatform.Arm ["--highentropyva-"]