diff --git a/README.md b/README.md index ffff7bc..3ab3aaf 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Currently we have following images - - [nodejs6](containers/nodejs6) - [nodejs](containers/nodejs8) - [perl](containers/perl) + - [php7](containers/php7) - [py2](containers/py2) - [py3](containers/py3) - [ruby](containers/ruby) diff --git a/containers/php7/Dockerfile b/containers/php7/Dockerfile new file mode 100644 index 0000000..d0f81de --- /dev/null +++ b/containers/php7/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:3.6 + +RUN apk add --no-cache musl-dev php7="7.1.17-r0" bash + +COPY ./compile.sh /bin/compile.sh +COPY ./run.sh /bin/run.sh + +RUN chmod 777 /bin/compile.sh; \ + chmod 777 /bin/run.sh diff --git a/containers/php7/compile.sh b/containers/php7/compile.sh new file mode 100644 index 0000000..f1f641a --- /dev/null +++ b/containers/php7/compile.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash diff --git a/containers/php7/run.sh b/containers/php7/run.sh new file mode 100644 index 0000000..6f8228a --- /dev/null +++ b/containers/php7/run.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +php script.php < run.stdin 1> run.stdout 2> run.stderr diff --git a/test.sh b/test.sh index 290a453..29c6590 100755 --- a/test.sh +++ b/test.sh @@ -4,9 +4,9 @@ bash tests/c/test_worker.sh } -#@test "test cpp" { -# bash tests/cpp/test_worker.sh -#} +@test "test cpp" { + bash tests/cpp/test_worker.sh +} @test "test csharp" { bash tests/csharp/test_worker.sh @@ -28,10 +28,14 @@ bash tests/nodejs8/test_worker.sh } -@test "test perl" { - bash tests/perl/test_worker.sh +@test "test php7" { + bash tests/php7/test_worker.sh } +# @test "test perl" { +# bash tests/perl/test_worker.sh +# } + @test "test py2" { bash tests/py2/test_worker.sh } diff --git a/tests/php7/run.stdin b/tests/php7/run.stdin new file mode 100644 index 0000000..216e97c --- /dev/null +++ b/tests/php7/run.stdin @@ -0,0 +1 @@ +World diff --git a/tests/php7/script.php b/tests/php7/script.php new file mode 100644 index 0000000..03f6068 --- /dev/null +++ b/tests/php7/script.php @@ -0,0 +1,6 @@ + diff --git a/tests/php7/test_worker.sh b/tests/php7/test_worker.sh new file mode 100644 index 0000000..26ea292 --- /dev/null +++ b/tests/php7/test_worker.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +pushd $(dirname "$0") +DIR=$(pwd) +RUNBOX="${DIR}/runbox" + +echo $RUNBOX +# Remove RUNBOX +rm -rf $RUNBOX + +# Create runbox +mkdir -p $RUNBOX + +# Copy source to runbox +cp -fv $DIR/script.php $RUNBOX/script.php +cp -fv $DIR/run.stdin $RUNBOX/run.stdin + +# Test Compile +docker run \ + --cpus="0.5" \ + --memory="20m" \ + --ulimit nofile=64:64 \ + --rm \ + --read-only \ + -v "$RUNBOX":/usr/src/runbox \ + -v "$RUNBOX":/tmp \ + -w /usr/src/runbox codingblocks/judge-worker-php7 \ + bash -c "/bin/compile.sh && /bin/run.sh" + +ls -lh ${RUNBOX} + +expected="Hello World" +actual="$(cat ${RUNBOX}/run.stdout)" +if [ "$expected" == "$actual" ] ;then + : +else + echo "MISMATCH: Expected = $expected; Actual = $actual" + exit 1 +fi + +# Delete runbox +rm -rf $RUNBOX