Skip to content

Commit

Permalink
Add tests to compilers image
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Dmitrichenko <errordeveloper@gmail.com>
  • Loading branch information
errordeveloper committed Jun 22, 2020
1 parent b249922 commit ec2162e
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tester-image: .buildx_builder
TEST=true scripts/build-image.sh image-tester images/tester linux/amd64,linux/arm64 $(OUTPUT) "$$(cat .buildx_builder)" $(REGISTRIES)

compilers-image: .buildx_builder
scripts/build-image.sh image-compilers images/compilers linux/amd64 $(OUTPUT) "$$(cat .buildx_builder)" $(REGISTRIES)
TEST=true scripts/build-image.sh image-compilers images/compilers linux/amd64 $(OUTPUT) "$$(cat .buildx_builder)" $(REGISTRIES)

update-compilers-image:
scripts/update-compilers-image.sh $(firstword $(REGISTRIES))
Expand Down
10 changes: 10 additions & 0 deletions images/compilers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

ARG UBUNTU_IMAGE=docker.io/library/ubuntu:20.04@sha256:8bce67040cd0ae39e0beb55bcb976a824d9966d2ac8d2e4bf6119b45505cee64
ARG CST_IMAGE=docker.io/errordeveloper/cst:adc3aa03d5c5f73bee371b3190ee1f7659e0362b-dev

FROM ${UBUNTU_IMAGE} as builder

Expand All @@ -10,3 +11,12 @@ RUN /tmp/install-deps.sh

COPY install-bazel.sh /tmp/install-bazel.sh
RUN /tmp/install-bazel.sh

FROM ${CST_IMAGE} as test
COPY --from=builder / /
COPY test /test
RUN /test/bin/cst

FROM scratch
LABEL maintainer="maintainer@cilium.io"
COPY --from=builder / /
97 changes: 97 additions & 0 deletions images/compilers/test/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
schemaVersion: "2.0.0"

commandTests:
- name: "gcc command is in path"
command: "which"
args: ["gcc"]
expectedOutput: ["/usr/bin/gcc"]
- name: "gcc version"
command: "gcc"
args: ["-v"]
expectedError:
- 'Target:\ x86_64-linux-gnu'
- 'gcc\ version\ 9\.3\.0'
- name: "aarch64-linux-gnu-gcc command is in path"
command: "which"
args: ["aarch64-linux-gnu-gcc"]
expectedOutput: ["/usr/bin/aarch64-linux-gnu-gcc"]
- name: "aarch64-linux-gnu-gcc version"
command: "aarch64-linux-gnu-gcc"
args: ["-v"]
expectedError:
- 'Target:\ aarch64-linux-gnu'
- 'gcc\ version\ 9\.3\.0'

- name: "which bazel-2.0.0-linux-x86_64"
command: "which"
args: ["bazel-2.0.0-linux-x86_64"]
expectedOutput: ["/usr/local/bin/bazel-2.0.0-linux-x86_64"]
- name: "which bazel-2.0.0-linux-x86_64 version"
command: "bazel-2.0.0-linux-x86_64"
args: ["version"]
expectedOutput: ['Build\ label:\ 2\.0\.0']
- name: "bazel 2.0.0 version"
command: "bazel"
envVars: [{ key: "USE_BAZEL_VERSION", value: "2.0.0" }]
args: ["version"]
expectedOutput: ['Build\ label:\ 2\.0\.0']

- name: "which bazel-2.2.0-linux-x86_64"
command: "which"
args: ["bazel-2.2.0-linux-x86_64"]
expectedOutput: ["/usr/local/bin/bazel-2.2.0-linux-x86_64"]
- name: "bazel-2.2.0-linux-x86_64 version"
command: "bazel-2.2.0-linux-x86_64"
args: ["version"]
expectedOutput: ['Build\ label:\ 2\.2\.0']
- name: "bazel 2.2.0 version"
command: "bazel"
envVars: [{ key: "USE_BAZEL_VERSION", value: "2.2.0" }]
args: ["version"]
expectedOutput: ['Build\ label:\ 2\.2\.0']

- name: "which bazel-3.1.0-linux-x86_64"
command: "which"
args: ["bazel-3.1.0-linux-x86_64"]
expectedOutput: ["/usr/local/bin/bazel-3.1.0-linux-x86_64"]
- name: "bazel-3.1.0-linux-x86_64 version"
command: "bazel-3.1.0-linux-x86_64"
args: ["version"]
expectedOutput: ['Build\ label:\ 3\.1\.0']
- name: "bazel 3.1.0 version"
command: "bazel"
envVars: [{ key: "USE_BAZEL_VERSION", value: "3.1.0" }]
args: ["version"]
expectedOutput: ['Build\ label:\ 3\.1\.0']

- name: "which bazel-3.2.0-linux-x86_64"
command: "which"
args: ["bazel-3.2.0-linux-x86_64"]
expectedOutput: ["/usr/local/bin/bazel-3.2.0-linux-x86_64"]
- name: "bazel-3.2.0-linux-x86_64 version"
command: "bazel-3.2.0-linux-x86_64"
args: ["version"]
expectedOutput: ['Build\ label:\ 3\.2\.0']
- name: "bazel 3.2.0 version"
command: "bazel"
envVars: [{ key: "USE_BAZEL_VERSION", value: "3.2.0" }]
args: ["version"]
expectedOutput: ['Build\ label:\ 3\.2\.0']

- name: "bazel version"
command: "bazel"
args: ["version"]
expectedOutput: ['Build\ label:\ 3\.2\.0']

fileExistenceTests:
- name: '/usr/local/bin/bazel'
path: '/usr/local/bin/bazel'
shouldExist: true
permissions: '-rwxr-xr-x'

fileContentTests:
- name: '/usr/local/bin/bazel'
path: '/usr/local/bin/bazel'
expectedContents:
- '#!/bin/bash'
- '# Copyright 2019 The Bazel Authors. All rights reserved.'

0 comments on commit ec2162e

Please sign in to comment.