Skip to content

Commit

Permalink
use docker to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
virusdefender committed Jun 9, 2018
1 parent d4e15b7 commit b6414e7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 21 deletions.
24 changes: 9 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
language: python
dist: trusty
python:
- "2.7"
- "3.5"
sudo: required
before_install:
- sudo apt-get -qq update
- sudo apt-get install libseccomp-dev cmake
install:
- mkdir build && cd build
- cmake .. && make && sudo make install
- cd ../bindings/Python && sudo `which python` setup.py install

services:
- docker

script:
- cd ../../tests/Python_and_core && sudo `which python` test.py
notifications:
slack: onlinejudgeteam:BzBz8UFgmS5crpiblof17K2W
- docker build -t judger-test -f tests/Dockerfile-16.04 .
- docker run -it --rm -v $PWD:/src judger-test /bin/bash -c "chmod +x tests/runtest.sh && ./tests/runtest.sh"

- docker build -t judger-test -f tests/Dockerfile-18.04 .
- docker run -it --rm -v $PWD:/src judger-test /bin/bash -c "chmod +x tests/runtest.sh && ./tests/runtest.sh"
6 changes: 0 additions & 6 deletions runtest.sh

This file was deleted.

3 changes: 3 additions & 0 deletions src/rules/c_cpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ int c_cpp_seccomp_rules(struct config *_config) {
if (seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open), 1, SCMP_CMP(1, SCMP_CMP_MASKED_EQ, O_WRONLY | O_RDWR, 0)) != 0) {
return LOAD_SECCOMP_FAILED;
}
if (seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(openat), 1, SCMP_CMP(2, SCMP_CMP_MASKED_EQ, O_WRONLY | O_RDWR, 0)) != 0) {
return LOAD_SECCOMP_FAILED;
}
if (seccomp_load(ctx) != 0) {
return LOAD_SECCOMP_FAILED;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/Dockerfile-16.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y cmake python python3 libseccomp-dev gcc g++
WORKDIR /src
3 changes: 3 additions & 0 deletions tests/Dockerfile-18.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y cmake python python3 python3-pip libseccomp-dev gcc g++ strace && pip3 install setuptools --upgrade
WORKDIR /src
16 changes: 16 additions & 0 deletions tests/runtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/bash
set -ex
dir=$PWD
python -V
gcc -v
g++ -v

for py in python2 python3; do
cd $dir
rm -rf build && mkdir build && cd build && cmake ..
make
make install
cd ../bindings/Python && rm -rf build
$py setup.py install
cd ../../tests/Python_and_core && $py test.py
done

0 comments on commit b6414e7

Please sign in to comment.