| 1 | using Zipelo.SecurityTests; |
| 2 | |
| 3 | namespace Zipelo.RuntimeTests; |
| 4 | |
| 5 | internal static class Program |
| 6 | { |
| 7 | public static async Task<int> Main(string[] arguments) |
| 8 | { |
| 9 | // 인수 없는 자식 실행은 프로토콜 실패 주입 전용임. |
| 10 | if (arguments.Length == 0) { return await ProtocolPeer.Run(); } |
| 11 | if (arguments.Length != 2) { return 2; } |
| 12 | var root = Path.GetFullPath(arguments[0]); |
| 13 | var sandbox = Path.GetFullPath(arguments[1]); |
| 14 | var work = Path.Combine(root, "tests", "security", ".work"); |
| 15 | if (!File.Exists(Path.Combine(root, "src", "Zipelo.Runtime", "Zipelo.Runtime.csproj")) || |
| 16 | !sandbox.StartsWith(work + Path.DirectorySeparatorChar, StringComparison.Ordinal) || |
| 17 | !Directory.Exists(sandbox)) |
| 18 | { |
| 19 | return 2; |
| 20 | } |
| 21 | for (DirectoryInfo? directory = new(sandbox); directory is not null; directory = directory.Parent) |
| 22 | { |
| 23 | if ((directory.Attributes & FileAttributes.ReparsePoint) != 0) { return 2; } |
| 24 | } |
| 25 | var tests = new RuntimeTests(root, sandbox); |
| 26 | var passed = 0; |
| 27 | var failed = 0; |
| 28 | var skipped = 0; |
| 29 | foreach (var (name, run) in tests.Cases()) |
| 30 | { |
| 31 | try |
| 32 | { |
| 33 | await run(); |
| 34 | Console.WriteLine($"PASS {name}"); |
| 35 | passed++; |
| 36 | } |
| 37 | catch (CaseSkippedException exception) |
| 38 | { |
| 39 | Console.WriteLine($"SKIP {name}: {exception.Message}"); |
| 40 | skipped++; |
| 41 | } |
| 42 | catch (Exception exception) |
| 43 | { |
| 44 | Console.Error.WriteLine($"FAIL {name}: {exception.GetType().Name}"); |
| 45 | failed++; |
| 46 | } |
| 47 | } |
| 48 | Console.WriteLine($"런타임 회귀 검사: {passed} 통과, {failed} 실패, {skipped} 미실행"); |
| 49 | Console.WriteLine($"실행 환경: {System.Runtime.InteropServices.RuntimeInformation.OSDescription}, " + |
| 50 | System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture); |
| 51 | return failed == 0 ? 0 : 1; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | internal sealed class CaseSkippedException(string message) : Exception(message) { } |