Exemplo n.º 1
0
// RunTask executes task with input.
// It checks that the execution time and output length are within the specified
// limits.
func runTask(t *testing.T, task pythia.Task, input string) (status pythia.Status, output string) {
	job := newTestJob(task, input)
	wd := testutils.Watchdog(t, task.Limits.Time+1)
	status, output = job.Execute()
	wd.Stop()
	if len(output) > task.Limits.Output {
		t.Errorf("Job output is too large: max %d, got %d.", task.Limits.Output,
			len(output))
	}
	return
}
Exemplo n.º 2
0
// Aborting a job shall be immediate.
func TestJobAbort(t *testing.T) {
	job := newTestJob(pytest.ReadTask(t, "timeout"), "")
	done := make(chan bool)
	go func() {
		wd := testutils.Watchdog(t, 2)
		status, output := job.Execute()
		wd.Stop()
		testutils.Expect(t, "status", pythia.Abort, status)
		testutils.Expect(t, "output", "Start\n", output)
		done <- true
	}()
	time.Sleep(1 * time.Second)
	job.Abort()
	<-done
}
Exemplo n.º 3
0
// This task is a fork bomb. It should succeed, but not take the whole time.
func TestJobForkbomb(t *testing.T) {
	wd := testutils.Watchdog(t, 2)
	run(t, "forkbomb", "", pythia.Success, "Start\nDone\n")
	wd.Stop()
}
Exemplo n.º 4
0
// This task should overflow and be killed before the end.
func TestJobOverflowKill(t *testing.T) {
	wd := testutils.Watchdog(t, 2)
	run(t, "overflow-kill", "", pythia.Overflow, "abcde")
	wd.Stop()
}