示例#1
0
            public void GetQueuedCompletionStatus_ForkBomb_DoesHaveLimitViolation()
            {
                using (var jobObject = new JobObject())
                {
                    jobObject.SetActiveProcessLimit(2);

                    var process = IFTestHelper.ExecuteWithWait("fork-bomb");
                    jobObject.AssignProcessToJob(process);
                    IFTestHelper.Continue(process);
                    process.WaitForExit(1000);

                    var msgs = jobObject.GetQueuedCompletionStatus();
                    Assert.Contains(msgs, x => x == JobObject.CompletionMsg.ActiveProcessLimit);
                }
            }
示例#2
0
        public void SetActiveProcessLimit_StopsForkBomb()
        {
            using (var jobObject = new JobObject())
            {
                jobObject.SetActiveProcessLimit(2);

                var process = IFTestHelper.ExecuteWithWait("fork-bomb");
                jobObject.AssignProcessToJob(process);
                IFTestHelper.Continue(process);
                process.WaitForExit(1000);
                var hasExited = process.HasExited;
                if (!hasExited)
                {
                    process.Kill();
                }
                if (!hasExited)
                {
                    Console.WriteLine(process.StandardOutput.ReadToEnd());
                    Console.Error.WriteLine(process.StandardError.ReadToEnd());
                }
                Assert.True(hasExited, "Active process limit was not enforced");
            }
        }