Coder Social home page Coder Social logo

developer22-university / test-runner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from raydwaipayan/test-runner

0.0 0.0 0.0 517 KB

Go module for evaluating correctness of programs in a sandboxed environment

License: Other

Go 94.88% Dockerfile 1.16% Shell 3.95%

test-runner's Introduction


Test-Runner
Go Report Card

Test-Runner is a Go module which can be used to execute programs against particular test cases and get corresponding outputs. The goal is to provide an easy module for testing programs for their correctness. This is one of the many modules required to create a completely functional backend for an "Online Judge".

  • Runs programs in a completely isolated environment using containers
  • Set and record memory and time limits using cgroups
  • Easy to use interface

Table of Contents

  1. Installation
  2. Example
  3. To-do
  4. Contributing
  5. Working

1. Installation

go get github.com/codeiiest/test-runner

2. Example

import (
	"io/ioutil"
	"log"
	"github.com/codeiiest/test-runner/runner/run"
)

func test(code string, lang string, filename string){
	in := []string{"2", "4", "5"}
	out := []string{"4", "16", "25"}
	timeLimit := 2              // Time in seconds
	memLimit := 500*1024*1024   // Memory in bytes

	res := run.Evaluate(code, lang, filename, in, out,
        len(in), timeLimit, memLimit)
	log.Print(res)
}

3. To-do

  • Limit Cpu count through cgroups (perhaps choose CPU?)
  • Support for more languages (compilation and run scripts)
  • Unit Tests
  • Makefile

4. Contributing

Please use the issue tracker. All contributions are more than welcome :)

5. Working

The gist of this module is that it runs the code passed to it in a docker container, evaluates it by comparing the output of the sent program against the expected output.


  • Code is first compiled using their respective compilers here in the function Compile(), or if it is interpreted, directly Run()

  • The compilation takes place inside the container via a bind mounts and the executable is produced

  • That executable is then run with the evaluate script with parameters of time limit, memory limit, number of test cases, and finally the runner script, which depends on whether the language is compiled or interpreted (for example, directly run python scripts, but C/C++ needs compialtion)

  • For a thorough understanding of how to use this module, have a look at the tests created for each language.

test-runner's People

Contributors

raydwaipayan avatar sadn1ck avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.