From ac45dfd75823b230572f78dfd5c59d5a967abdcb Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Wed, 15 Nov 2023 02:24:13 -0800 Subject: [PATCH] add additional tests --- tests/c/Dockerfile | 16 ++++++++++++++++ tests/c/main.c | 5 +++++ {examples/go_hello => tests/go}/Dockerfile | 0 {examples/go_hello => tests/go}/main.go | 0 tests/perl/Dockerfile | 14 ++++++++++++++ tests/perl/main.pl | 4 ++++ tests/python/Dockerfile | 14 ++++++++++++++ tests/python/main.py | 1 + {examples => tests}/rust_pcsc_static/Cargo.lock | 0 {examples => tests}/rust_pcsc_static/Cargo.toml | 0 {examples => tests}/rust_pcsc_static/Dockerfile | 0 {examples => tests}/rust_pcsc_static/main.rs | 0 12 files changed, 54 insertions(+) create mode 100644 tests/c/Dockerfile create mode 100644 tests/c/main.c rename {examples/go_hello => tests/go}/Dockerfile (100%) rename {examples/go_hello => tests/go}/main.go (100%) create mode 100644 tests/perl/Dockerfile create mode 100644 tests/perl/main.pl create mode 100644 tests/python/Dockerfile create mode 100644 tests/python/main.py rename {examples => tests}/rust_pcsc_static/Cargo.lock (100%) rename {examples => tests}/rust_pcsc_static/Cargo.toml (100%) rename {examples => tests}/rust_pcsc_static/Dockerfile (100%) rename {examples => tests}/rust_pcsc_static/main.rs (100%) diff --git a/tests/c/Dockerfile b/tests/c/Dockerfile new file mode 100644 index 0000000..99b8c45 --- /dev/null +++ b/tests/c/Dockerfile @@ -0,0 +1,16 @@ +FROM ocirep/busybox as build +COPY --from=ocirep/gcc . / +COPY --from=ocirep/musl . / +COPY --from=ocirep/binutils . / +COPY . . +RUN set -eux; \ + gcc main.c -static -o main; \ + mkdir -p $HOME/rootfs/etc; \ + echo "nogroup:*:100:nobody" > ~/rootfs/etc/group; \ + echo "nobody:*:100:100:::" > ~/rootfs/etc/passwd; \ + cp main $HOME/rootfs/ + +FROM scratch +COPY --from=build --chown=100:100 /home/user/rootfs / +USER 100:100 +ENTRYPOINT ["/main"] diff --git a/tests/c/main.c b/tests/c/main.c new file mode 100644 index 0000000..b906db4 --- /dev/null +++ b/tests/c/main.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Success\n"); + return 0; +} diff --git a/examples/go_hello/Dockerfile b/tests/go/Dockerfile similarity index 100% rename from examples/go_hello/Dockerfile rename to tests/go/Dockerfile diff --git a/examples/go_hello/main.go b/tests/go/main.go similarity index 100% rename from examples/go_hello/main.go rename to tests/go/main.go diff --git a/tests/perl/Dockerfile b/tests/perl/Dockerfile new file mode 100644 index 0000000..188953f --- /dev/null +++ b/tests/perl/Dockerfile @@ -0,0 +1,14 @@ +FROM ocirep/busybox as build +COPY . . +RUN set -eux; \ + mkdir -p $HOME/rootfs/etc; \ + echo "nogroup:*:100:nobody" > ~/rootfs/etc/group; \ + echo "nobody:*:100:100:::" > ~/rootfs/etc/passwd; \ + cp main.py $HOME/rootfs/ + +FROM scratch +COPY --from=build --chown=100:100 /home/user/rootfs / +COPY --from=ocirep/perl . / +USER 100:100 +ENTRYPOINT ["/usr/bin/perl"] +CMD ["/main.pl"] diff --git a/tests/perl/main.pl b/tests/perl/main.pl new file mode 100644 index 0000000..548467c --- /dev/null +++ b/tests/perl/main.pl @@ -0,0 +1,4 @@ +use strict; +use warnings; + +print("Success\n"); diff --git a/tests/python/Dockerfile b/tests/python/Dockerfile new file mode 100644 index 0000000..8a1612e --- /dev/null +++ b/tests/python/Dockerfile @@ -0,0 +1,14 @@ +FROM ocirep/busybox as build +COPY . . +RUN set -eux; \ + mkdir -p $HOME/rootfs/etc; \ + echo "nogroup:*:100:nobody" > ~/rootfs/etc/group; \ + echo "nobody:*:100:100:::" > ~/rootfs/etc/passwd; \ + cp main.py $HOME/rootfs/ + +FROM scratch +COPY --from=build --chown=100:100 /home/user/rootfs / +COPY --from=ocirep/python . / +USER 100:100 +ENTRYPOINT ["/usr/bin/python"] +CMD ["/main.py"] diff --git a/tests/python/main.py b/tests/python/main.py new file mode 100644 index 0000000..e6d1399 --- /dev/null +++ b/tests/python/main.py @@ -0,0 +1 @@ +print("Success") diff --git a/examples/rust_pcsc_static/Cargo.lock b/tests/rust_pcsc_static/Cargo.lock similarity index 100% rename from examples/rust_pcsc_static/Cargo.lock rename to tests/rust_pcsc_static/Cargo.lock diff --git a/examples/rust_pcsc_static/Cargo.toml b/tests/rust_pcsc_static/Cargo.toml similarity index 100% rename from examples/rust_pcsc_static/Cargo.toml rename to tests/rust_pcsc_static/Cargo.toml diff --git a/examples/rust_pcsc_static/Dockerfile b/tests/rust_pcsc_static/Dockerfile similarity index 100% rename from examples/rust_pcsc_static/Dockerfile rename to tests/rust_pcsc_static/Dockerfile diff --git a/examples/rust_pcsc_static/main.rs b/tests/rust_pcsc_static/main.rs similarity index 100% rename from examples/rust_pcsc_static/main.rs rename to tests/rust_pcsc_static/main.rs