From 96ab54c98f45ab3d246d719d17b790be2363e3ad Mon Sep 17 00:00:00 2001 From: Ron <45816308+rjaegers@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:47:19 +0000 Subject: [PATCH] test: add test for docker cli --- .github/workflows/ci.yml | 2 +- .vscode/tasks.json | 22 ++++++++++++++++------ README.md | 2 +- test/testsuite.bats | 19 +++++++++++++------ 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47b4d7d2..c0901d46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: - name: Run Tests run: | set -Eeuo pipefail - docker run --rm --mount type=bind,src="$(pwd)/test",dst=/ws -w /ws ${{ github.repository }}:test bats --formatter junit testsuite.bats | tee test-report.xml + docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock --mount type=bind,src="$(pwd)/test",dst=/ws -w /ws ${{ github.repository }}:test bats --formatter junit testsuite.bats | tee test-report.xml - uses: EnricoMi/publish-unit-test-result-action@ca89ad036b5fcd524c1017287fb01b5139908408 # v2.11.0 if: always() with: diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 16d6146f..b7a846e9 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,25 +1,35 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "Run Tests", "type": "shell", - "group": "test", + "group": { + "kind": "test", + "isDefault": true + }, "command": "bats", - "args": ["testsuite.bats"], + "args": [ + "testsuite.bats" + ], "options": { "cwd": "${workspaceFolder}/test" }, + "presentation": { + "reveal": "always", + "panel": "dedicated", + "showReuseMessage": false, + "clear": true + }, "problemMatcher": { - "owner": "bats", "source": "bats", + "owner": "bats", + "fileLocation": ["relative", "${workspaceFolder}/test"], "pattern": [ { "regexp": "^.*test file(.*), line (\\d+)", "file": 1, - "location": 2 + "line": 2 }, { "regexp": "^(.*failed)", diff --git a/README.md b/README.md index cbd8948a..a7969f2f 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ For the full list of all included tools and tool versions see the [Dependency Gr The container can be built and tested locally by importing this repository in VS Code with the `Dev Containers` (ms-vscode-remote.remote-containers) plug-in installed. As a prerequisite Docker needs to be installed on the host system. As an alternative a GitHub Codespace can be started. -A test task is available to run the included `bats` tests. Choose `Tasks: Run Task` from the command pallette and choose `Run Tests`. +A test task is available to run the included `bats` tests. Choose `Tasks: Run Test Task` from the command pallette. ## Verify image signature diff --git a/test/testsuite.bats b/test/testsuite.bats index 6e6d67b1..e72a988d 100644 --- a/test/testsuite.bats +++ b/test/testsuite.bats @@ -16,11 +16,11 @@ setup_file() { xwin --accept-license splat --preserve-ms-arch-notation fi - cp -r .xwin-cache/splat/ /winsdk + cp -r .xwin-cache/splat/* /winsdk/ } teardown_file() { - rm -rf .xwin-hash/ /winsdk + rm -rf .xwin-hash/ /winsdk/* } setup() { @@ -160,7 +160,7 @@ teardown() { } # bats test_tags=tc:9 -@test "coverage information should be generated when running tests" { +@test "coverage information should be generated when running a testsuite" { run cmake --preset coverage assert_success @@ -177,7 +177,7 @@ teardown() { } # bats test_tags=tc:10 -@test "fuzzing an executable should be supported" { +@test "crashes should be detected when fuzzing an executable" { run cmake --preset clang assert_success @@ -190,7 +190,7 @@ teardown() { } # bats test_tags=tc:11 -@test "mutation testing an executable should be supported" { +@test "a mutation score should be calculated when mutation testing a testsuite" { run cmake --preset mutation assert_success @@ -213,7 +213,7 @@ teardown() { assert_success } -# bats test_tags=tc14 +# bats test_tags=tc:14 @test "clangd should be able to analyze source files" { run clangd --check=gcc/main.cpp assert_success @@ -235,3 +235,10 @@ teardown() { assert_success assert_output "Hello World!" } + +# bats test_tags=tc:18 +@test "when the docker socket is mounted, using the docker cli should give access to the host docker daemon" { + run docker info + assert_success + assert_output --partial "Server Version:" +}