Skip to content

Bash support #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All workers are built on top of [alpine linux](https://alpinelinux.org/) 3.6

Currently we have following images -

- [bash](containers/bash)
- [c](containers/c)
- [cpp](containers/cpp)
- [c#](containers/csharp)
Expand Down
9 changes: 9 additions & 0 deletions containers/bash/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM alpine:3.6

RUN apk add --no-cache musl-dev bash="4.3.48-r1" bash

COPY ./compile.sh /bin/compile.sh
COPY ./run.sh /bin/run.sh

RUN chmod 777 /bin/compile.sh; \
chmod 777 /bin/run.sh
1 change: 1 addition & 0 deletions containers/bash/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/usr/bin/env bash
3 changes: 3 additions & 0 deletions containers/bash/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

sh script.sh < run.stdin 1> run.stdout 2> run.stderr
9 changes: 6 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/usr/bin/env bats
@test "test bash" {
bash tests/bash/test_worker.sh
}

@test "test c" {
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
Expand Down
1 change: 1 addition & 0 deletions tests/bash/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
2 changes: 2 additions & 0 deletions tests/bash/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
read input
echo Hello $input
41 changes: 41 additions & 0 deletions tests/bash/test_worker.sh
Original file line number Diff line number Diff line change
@@ -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.sh $RUNBOX/script.sh
cp -fv $DIR/run.stdin $RUNBOX/run.stdin

# Test Compile
docker run \
--cpus="1" \
--memory="100m" \
--ulimit nofile=64:64 \
--rm \
--read-only \
-v "$RUNBOX":/usr/src/runbox \
-v "$RUNBOX":/tmp \
-w /usr/src/runbox codingblocks/judge-worker-bash \
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