Skip to content

Commit

Permalink
Add simple Containerfile
Browse files Browse the repository at this point in the history
This adds a regular container (or Docker) file which builds LTP from
source. This is initially intended for testing the LTP itself.

The resulting container has just the LTP installation and runtime
dependencies. However it is still quite large, probably due to debug
symbols.

The container can be built with a command like:

podman build -t tumbleweed/ltp \
       --build-arg PREFIX=registry.opensuse.org/opensuse/ \
       --build-arg DISTRO_NAME=tumbleweed \
       --build-arg DISTRO_RELEASE=20230925 .

Or just

podman build .

which will create an Alpine container.

It contains Kirk in /opt/kirk. So

cd /opt/kirk && ./kirk -f ltp -r syscalls

will run some tests.

Note a much smaller container can be found at:
https://registry.opensuse.org/cgi-bin/cooverview?srch_term=project%3D%5Ebenchmark+container%3D.*
This is created with SUSE's build system which does not use container files

Signed-off-by: Richard Palethorpe <[email protected]>
Reviewed-by: Petr Vorel <[email protected]>
Cc: Marius Kittler <[email protected]>
  • Loading branch information
Richard Palethorpe committed Oct 10, 2023
1 parent 00921d0 commit eb012b0
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Containerfile
35 changes: 35 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2023 SUSE LLC

ARG PREFIX=docker.io/
ARG DISTRO_NAME=alpine
ARG DISTRO_RELEASE=3.18

FROM $PREFIX$DISTRO_NAME:$DISTRO_RELEASE AS build
ARG LTPROOT=/opt/ltp
ARG DISTRO_NAME=alpine
ARG DISTRO_RELEASE=3.18

RUN mkdir /build
WORKDIR /build
COPY . /build
RUN ./ci/${DISTRO_NAME}.sh
RUN git clean -fdX
RUN ./build.sh -p $LTPROOT -i

FROM $PREFIX$DISTRO_NAME:$DISTRO_RELEASE
ARG LTPROOT=/opt/ltp
ARG KIRKROOT=/opt/kirk
ARG DISTRO_NAME=alpine

COPY --from=build /build/ci/${DISTRO_NAME}-runtime.sh $LTPROOT/runtime-deps.sh
RUN $LTPROOT/runtime-deps.sh

COPY --from=build $LTPROOT $LTPROOT
ENV LTPROOT=$LTPROOT
ENV PATH=$LTPROOT/testcases/bin:$LTPROOT/bin:$PATH

RUN mkdir -p $KIRKROOT
COPY --from=build /build/tools/kirk $KIRKROOT

USER ltp
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,37 @@ Network tests
Network tests require certain setup, described in `testcases/network/README.md`
(online at https://github.com/linux-test-project/ltp/tree/master/testcases/network).

Containers
----------

*Presently running the LTP inside a container is not a shortcut. It
will make things much harder for you.*

There is a Containerfile which can be used with Docker or
Podman. Currently it can build Alpine and OpenSUSE images.

The container can be built with a command like:

```
$ podman build -t tumbleweed/ltp \
--build-arg PREFIX=registry.opensuse.org/opensuse/ \
--build-arg DISTRO_NAME=tumbleweed \
--build-arg DISTRO_RELEASE=20230925 .
```

Or just `podman build .` which will create an Alpine container.

It contains Kirk in /opt/kirk. So the following will run some tests.

```
$ podman run -it --rm tumbleweed/ltp:latest
$ cd /opt/kirk && ./kirk -f ltp -r syscalls
```

SUSE also publishes a
[smaller LTP container](https://registry.opensuse.org/cgi-bin/cooverview?srch_term=project%3D%5Ebenchmark+container%3D.*)
that is not based on the Containerfile.

Developers corner
=================

Expand Down
18 changes: 18 additions & 0 deletions ci/alpine-runtime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh -eux
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2023 SUSE LLC

apk add \
acl \
keyutils \
libaio \
libacl \
libcap \
libselinux \
libsepol \
libtirpc \
numactl \
openssl \
py3-msgpack

adduser -D -g "Unprivileged LTP user" ltp
15 changes: 15 additions & 0 deletions ci/tumbleweed-runtime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh -eux
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2023 SUSE LLC

zyp="zypper --non-interactive install --force-resolution --no-recommends"

$zyp \
iproute2 \
keyutils \
libaio1 \
libmnl0 \
libnuma1 \
libtirpc3

useradd ltp

0 comments on commit eb012b0

Please sign in to comment.