Example #1
0
 /// <summary>
 /// Creates a new instance of the single compile tests source request.
 /// </summary>
 /// <param name="id">The id of the request.</param>
 /// <param name="timeoutSeconds">The total number of time out seconds for the container.</param>
 /// <param name="memoryConstraint">The memory constraint in mb.</param>
 /// <param name="sourceCode">The source code being used.</param>
 /// <param name="compilerName">The name of the compiler being used.</param>
 /// <param name="testCase">The test case used in the request.</param>
 public CompileTestSourceRequest(Guid id, uint timeoutSeconds, uint memoryConstraint,
                                 IReadOnlyList <string> sourceCode, string compilerName, CompilerTestCase testCase) : base(id, timeoutSeconds,
                                                                                                                           memoryConstraint, sourceCode, testCase.StandardInputIn, compilerName)
 {
     this.TestCase = testCase;
     this.Type     = CompileRequestType.SingleTest;
 }
Example #2
0
        public void TestTwoPhaseCommit()
        {
            var tempDir   = Directory.CreateDirectory(Path.Combine(Constants.ScratchParentDirectory, "TestTwoPhaseCommit"));
            var allPFiles = new[]
            {
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "TwoPhaseCommit", "Client.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "TwoPhaseCommit", "Coordinator.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "TwoPhaseCommit", "Events.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "TwoPhaseCommit", "Participant.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "TwoPhaseCommit", "TestDriver.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "TwoPhaseCommit", "Timer.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "TwoPhaseCommit", "Spec.p"))
            };

            var foreignCode = new[]
            {
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "TwoPhaseCommit", "ForeignCode.cs"))
            };

            var testCase = new CompilerTestCase(
                tempDir,
                new PSharpRunner(allPFiles, foreignCode),
                new CompileSuccessValidator());

            TestAssertions.AssertTestCase(testCase);
        }
Example #3
0
        public void TestRegressions(DirectoryInfo testDir)
        {
            DirectoryInfo    scratchDir     = Directory.CreateDirectory(Constants.ScratchParentDirectory);
            TestCaseFactory  factory        = new TestCaseFactory(scratchDir);
            CompilerTestCase testCaseCoyote = factory.CreateTestCase(testDir, CompilerOutput.Coyote);

            TestAssertions.AssertTestCase(testCaseCoyote);
        }
Example #4
0
        public void TestTimer()
        {
            DirectoryInfo tempDir =
                Directory.CreateDirectory(Path.Combine(Constants.ScratchParentDirectory, nameof(TestForeignTypes)));
            FileInfo tempFilePath = new FileInfo(Path.Combine(Constants.SolutionDirectory, "Src", "Samples", "Timer",
                                                              "TimerHeader.p"));

            CompilerTestCase testCase = new CompilerTestCase(
                tempDir,
                new CompileOnlyRunner(CompilerOutput.C, new[] { tempFilePath }),
                new CompileSuccessValidator());

            TestAssertions.AssertTestCase(testCase);
        }
Example #5
0
        public void TestPingPong()
        {
            DirectoryInfo tempDir =
                Directory.CreateDirectory(Path.Combine(Constants.ScratchParentDirectory, nameof(TestForeignTypes)));
            FileInfo pingPongPath = new FileInfo(Path.Combine(Constants.SolutionDirectory, "Src", "Samples", "PingPong",
                                                              "PingPong.p"));
            FileInfo prtDistPath = new FileInfo(Path.Combine(Constants.SolutionDirectory, "Src", "Samples", "PingPong",
                                                             "PrtDistHelp.p"));
            CompilerTestCase testCase = new CompilerTestCase(
                tempDir,
                new CompileOnlyRunner(CompilerOutput.C, new[] { pingPongPath, prtDistPath }),
                new CompileSuccessValidator());

            TestAssertions.AssertTestCase(testCase);
        }
Example #6
0
        public static void AssertTestCase(CompilerTestCase testCase)
        {
            if (!testCase.EvaluateTest(out var stdout, out var stderr, out var exitCode))
            {
                Console.WriteLine("Test failed!\n");
                WriteOutput(stdout, stderr, exitCode);
                Assert.Fail($"EXIT: {exitCode}\n{stderr}");
            }

            Console.WriteLine("Test succeeded!\n");
            WriteOutput(stdout, stderr, exitCode);

            // Delete ONLY if inside the solution directory
            SafeDeleteDirectory(testCase.ScratchDirectory);
        }
Example #7
0
        public void TestTemp()
        {
            var tempDir      = Directory.CreateDirectory(Path.Combine(Constants.ScratchParentDirectory, "TestTemp"));
            var tempFilePath = new FileInfo(Path.Combine(Constants.SolutionDirectory, "tmp", "test.p"));
            var nativeFiles  = tempFilePath.Directory.GetFiles("*.c");

            if (!tempFilePath.Exists)
            {
                return;
            }

            var testCase = new CompilerTestCase(tempDir, new PrtRunner(new[] { tempFilePath }, nativeFiles),
                                                new ExecutionOutputValidator(0, null, null));

            TestAssertions.AssertTestCase(testCase);
        }
Example #8
0
        public void TestCompileCoyoteTemp()
        {
            DirectoryInfo tempDir      = Directory.CreateDirectory(Path.Combine(Constants.ScratchParentDirectory, "TestCoyoteTemp"));
            FileInfo      tempFilePath = new FileInfo(Path.Combine(Constants.SolutionDirectory, "tmp", "test.p"));

            //var foreignFilePath = new FileInfo(Path.Combine(Constants.SolutionDirectory, "tmp", "Foreign.cs"));

            if (!tempFilePath.Exists)
            {
                return;
            }

            CompilerTestCase testCase = new CompilerTestCase(
                tempDir,
                new CoyoteRunner(new[] { tempFilePath }),
                new CompileSuccessValidator());

            TestAssertions.AssertTestCase(testCase);
        }
Example #9
0
        public void TestModuleSystem()
        {
            var tempDir  = Directory.CreateDirectory(Path.Combine(Constants.ScratchParentDirectory, "TestPSharpTemp"));
            var allFiles = new[]
            {
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "PingPong", "Main.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "PingPong", "PingPong.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "PingPong", "Safety.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "PingPong", "Liveness.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "PingPong", "Testscript.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "Env", "Env.p")),
                new FileInfo(Path.Combine(Constants.SolutionDirectory, "Tutorial", "Timer", "Timer.p"))
            };

            var testCase = new CompilerTestCase(
                tempDir,
                new PSharpRunner(allFiles),
                new CompileSuccessValidator());

            TestAssertions.AssertTestCase(testCase);
        }
Example #10
0
        public void TestFailureDetector()
        {
            DirectoryInfo tempDir =
                Directory.CreateDirectory(Path.Combine(Constants.ScratchParentDirectory, nameof(TestForeignTypes)));
            FileInfo driverPath = new FileInfo(Path.Combine(Constants.SolutionDirectory, "Src", "Samples", "FailureDetector",
                                                            "Driver.p"));
            FileInfo failureDetectorPath = new FileInfo(Path.Combine(Constants.SolutionDirectory, "Src", "Samples",
                                                                     "FailureDetector",
                                                                     "FailureDetector.p"));
            FileInfo prtDistPath = new FileInfo(Path.Combine(Constants.SolutionDirectory, "Src", "Samples",
                                                             "FailureDetector",
                                                             "PrtDistHelp.p"));
            FileInfo timerPath = new FileInfo(Path.Combine(Constants.SolutionDirectory, "Src", "Samples", "Timer",
                                                           "TimerHeader.p"));
            CompilerTestCase testCase = new CompilerTestCase(
                tempDir,
                new CompileOnlyRunner(CompilerOutput.C,
                                      new[] { driverPath, failureDetectorPath, prtDistPath, timerPath }),
                new CompileSuccessValidator());

            TestAssertions.AssertTestCase(testCase);
        }