eval

package
v0.0.0-...-a5025f8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2021 License: MIT Imports: 10 Imported by: 0

README

Code Execution Enviroment

Requirements:
Installation:
sudo apt-get update
sudo apt-get install libcap-dev asciidoc-base
cd ~/Downloads
git clone https://github.com/ioi/isolate.git
cd isolate
make
sudo make install
Documentation:

http://www.ucw.cz/moe/isolate.1.html

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileFile

func CompileFile(ctx context.Context, sandbox Sandbox, sourceCode []byte, lang models.Language) (string, error)

func CopyFromSandbox

func CopyFromSandbox(sandbox Sandbox, path string, w io.Writer) error

func CopyInSandbox

func CopyInSandbox(sandbox Sandbox, path string, data []byte) error

func GetBinaryName

func GetBinaryName(config *models.Config, submissionId int) string

func GetOutputFileName

func GetOutputFileName(config *models.Config, submission *models.Submission, test *models.Test) string

func RandomString

func RandomString(size int) string

Types

type CheckerServices

type CheckerServices struct {
	ProblemService services.ProblemService
	TestService    services.TestService

	SubmissionService     services.SubmissionService
	SubmissionTestService services.SubmissionTestService

	TestManager managers.TestManager
}

type CompileRequest

type CompileRequest struct {
	ID   int // ID is the file-managers ID.
	Code []byte
	Lang string
}

type CompileResponse

type CompileResponse struct {
	Message string
	Success bool
}

type CompileServices

type CompileServices struct {
	SubmissionService services.SubmissionService
}

type EvaluatorServices

type EvaluatorServices struct {
	ProblemService services.ProblemService
	TestService    services.TestService

	SubmissionService     services.SubmissionService
	SubmissionTestService services.SubmissionTestService

	TestManager managers.TestManager
}

func (*EvaluatorServices) CheckerServices

func (s *EvaluatorServices) CheckerServices() *CheckerServices

func (*EvaluatorServices) CompileServices

func (s *EvaluatorServices) CompileServices() *CompileServices

func (*EvaluatorServices) ExecuteServices

func (s *EvaluatorServices) ExecuteServices() *ExecuteServices

type ExecuteRequest

type ExecuteRequest struct {
	ID int

	SubmissionId int
	TestId       int

	Limit

	Lang        string
	ProblemName string

	IsConsole bool
	Input     []byte

	BinaryPath string
}

type ExecuteResponse

type ExecuteResponse struct {
	TimeUsed   float64
	MemoryUsed int

	ExitCode int
	Message  string
}

type ExecuteServices

type ExecuteServices struct {
	ProblemService services.ProblemService
	TestService    services.TestService

	SubmissionService     services.SubmissionService
	SubmissionTestService services.SubmissionTestService

	TestManager managers.TestManager
}

type Handler

type Handler interface {
	Handle(next chan *models.Submission)
}

type Limit

type Limit struct {
	Time   float64
	Memory int
	Stack  int
}

type RunConfig

type RunConfig struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer

	MemoryLimit int
	StackLimit  int

	InputPath  string
	OutputPath string

	TimeLimit     float64
	WallTimeLimit float64

	MaxProcesses int
}

RunConfig represents the configuration for a Task.

type RunStatus

type RunStatus struct {
	Memory int `json:"memory"`

	ExitCode   int  `json:"exitCode"`
	ExitSignal int  `json:"exitSignal"`
	Killed     bool `json:"killed"`

	Message string `json:"message"`
	Status  string `json:"status"`

	Time     float64 `json:"time"`
	WallTime float64 `json:"wallTime"`
}

RunStatus is what is returned after a task has been run.

func ExecuteFile

func ExecuteFile(ctx context.Context, sandbox Sandbox, lang models.Language, problemName string, limit Limit, console bool) (*RunStatus, error)

type Sandbox

type Sandbox interface {
	GetID() int
	GetPath(path string) string

	CreateDirectory(path string, perm fs.FileMode) error
	DeleteDirectory(path string) error

	CreateFile(path string, perm fs.FileMode) error
	WriteToFile(path string, data []byte, perm fs.FileMode) error
	ReadFile(path string) ([]byte, error)
	DeleteFile(path string) error

	ExecuteCommand(ctx context.Context, command []string, config *RunConfig) (*RunStatus, error)
	Cleanup() error
}

type SandboxManager

type SandboxManager interface {
	// RunTask runs a task within a sandbox
	RunTask(ctx context.Context, task Task) error

	// Stop waits for all sandboxes to stop running
	Stop(ctx context.Context) error
}

type Task

type Task interface {
	Run(ctx context.Context, sandbox Sandbox) error
}

Task represents a task to be executed in the sandbox.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL