use docker to run tests

This commit is contained in:
virusdefender 2018-06-09 12:37:45 +08:00
parent d4e15b7c35
commit b6414e7a67
6 changed files with 34 additions and 21 deletions

View File

@ -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"

View File

@ -1,6 +0,0 @@
rm -rf build && mkdir build && cd build && cmake ..
make || exit 1
make install
cd ../bindings/Python && rm -rf build
python setup.py install || exit 1
cd ../../tests/Python_and_core && python test.py

View File

@ -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;
}

3
tests/Dockerfile-16.04 Normal file
View File

@ -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
tests/Dockerfile-18.04 Normal file
View File

@ -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
tests/runtest.sh Executable file
View File

@ -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