add gcc compile demo

This commit is contained in:
virusdefender 2016-02-01 18:39:17 +08:00
parent b2bf385d5c
commit 0e5021b33d
2 changed files with 13 additions and 2 deletions

2
.gitignore vendored
View File

@ -5,4 +5,4 @@ limit
runner runner
CMakeLists.txt CMakeLists.txt
main main
demo/out demo

View File

@ -5,8 +5,19 @@ import judger
base_path = os.path.dirname(os.path.abspath(__file__)) base_path = os.path.dirname(os.path.abspath(__file__))
def _compile():
return judger.run(path="/usr/bin/gcc",
in_file=os.path.join(base_path, "in"),
out_file=os.path.join(base_path, "gcc_out"),
max_cpu_time=2000,
max_memory=200000000,
args=[os.path.join(base_path, "demo.c"), "-o", os.path.join(base_path, "demo")],
env=["PATH=" + os.environ["PATH"]],
use_sandbox=False)
def run(use_sandbox): def run(use_sandbox):
os.system("gcc demo.c -o demo") _compile()
path = os.path.join(base_path, "demo") path = os.path.join(base_path, "demo")
return judger.run(path=path, return judger.run(path=path,
in_file=os.path.join(base_path, "in"), in_file=os.path.join(base_path, "in"),