diff options
Diffstat (limited to 'integration-tests/script-test')
14 files changed, 179 insertions, 0 deletions
diff --git a/integration-tests/script-test/elements/dependencies/base-platform.bst b/integration-tests/script-test/elements/dependencies/base-platform.bst new file mode 100644 index 000000000..09c95acb4 --- /dev/null +++ b/integration-tests/script-test/elements/dependencies/base-platform.bst @@ -0,0 +1,23 @@ +kind: import +description: Import the base freedesktop platform +config: + source: files +public: + bst: + integration-commands: + - ldconfig +arches: + x86_64: + sources: + - kind: ostree + url: gnomesdk:repo/ + track: runtime/org.freedesktop.BasePlatform/x86_64/1.4 + gpg-key: keys/gnome-sdk.gpg + ref: c9d09b7250a12ef09d95952fc4f49a35e5f8c2c1dd7141b7eeada4069e6f6576 + i386: + sources: + - kind: ostree + url: gnomesdk:repo/ + track: runtime/org.freedesktop.BasePlatform/i386/1.4 + gpg-key: keys/gnome-sdk.gpg + ref: 27ebae91839a454596a273391b0e53063eaa8aca4fc9cb64654582bfbc338c96 diff --git a/integration-tests/script-test/elements/script-cwd-test.bst b/integration-tests/script-test/elements/script-cwd-test.bst new file mode 100644 index 000000000..48b25fb07 --- /dev/null +++ b/integration-tests/script-test/elements/script-cwd-test.bst @@ -0,0 +1,14 @@ +kind: script +description: Write to root using a script element + +variables: + cwd: /buildstream + +depends: + - filename: dependencies/base-platform.bst + type: build + +config: + commands: + - "echo 'test' > test" + - "cp /buildstream/test %{install-root}" diff --git a/integration-tests/script-test/elements/script-layout-test.bst b/integration-tests/script-test/elements/script-layout-test.bst new file mode 100644 index 000000000..bb623a88f --- /dev/null +++ b/integration-tests/script-test/elements/script-layout-test.bst @@ -0,0 +1,23 @@ +kind: script +description: Write to root using a script element + +variables: + install-root: /buildstream/nstall + build-root: /buildstream/uild + +depends: + - filename: dependencies/base-platform.bst + type: build + - filename: script-test.bst + type: build + +config: + layout: + - element: dependencies/base-platform.bst + destination: / + + - element: script-test.bst + destination: "%{build-root}" + + commands: + - "cp %{build-root}/test %{install-root}" diff --git a/integration-tests/script-test/elements/script-no-root-test.bst b/integration-tests/script-test/elements/script-no-root-test.bst new file mode 100644 index 000000000..2a40202d5 --- /dev/null +++ b/integration-tests/script-test/elements/script-no-root-test.bst @@ -0,0 +1,12 @@ +kind: script +description: Write to root using a script element + +depends: + - filename: dependencies/base-platform.bst + type: build + +config: + commands: + - "mkdir -p /buildstream/install" + - "echo 'I can not write to root' > /test" + - "cp /test /buildstream/install" diff --git a/integration-tests/script-test/elements/script-root-test.bst b/integration-tests/script-test/elements/script-root-test.bst new file mode 100644 index 000000000..4b2045e6f --- /dev/null +++ b/integration-tests/script-test/elements/script-root-test.bst @@ -0,0 +1,14 @@ +kind: script +description: Write to root using a script element + +depends: + - filename: dependencies/base-platform.bst + type: build + +config: + root-read-only: False + + commands: + - "mkdir -p /buildstream/install" + - "echo 'I can write to root' > /test" + - "cp /test /buildstream/install" diff --git a/integration-tests/script-test/elements/script-test.bst b/integration-tests/script-test/elements/script-test.bst new file mode 100644 index 000000000..8ea31e0fe --- /dev/null +++ b/integration-tests/script-test/elements/script-test.bst @@ -0,0 +1,11 @@ +kind: script +description: Script test + +depends: + - filename: dependencies/base-platform.bst + type: build + +config: + commands: + - "mkdir -p /buildstream/install" + - "echo 'Hi' > /buildstream/install/test" diff --git a/integration-tests/script-test/expected/script-cwd-test/test b/integration-tests/script-test/expected/script-cwd-test/test new file mode 100644 index 000000000..9daeafb98 --- /dev/null +++ b/integration-tests/script-test/expected/script-cwd-test/test @@ -0,0 +1 @@ +test diff --git a/integration-tests/script-test/expected/script-layout-test/test b/integration-tests/script-test/expected/script-layout-test/test new file mode 100644 index 000000000..b14df6442 --- /dev/null +++ b/integration-tests/script-test/expected/script-layout-test/test @@ -0,0 +1 @@ +Hi diff --git a/integration-tests/script-test/expected/script-no-root-test/test b/integration-tests/script-test/expected/script-no-root-test/test new file mode 100644 index 000000000..520aaba9b --- /dev/null +++ b/integration-tests/script-test/expected/script-no-root-test/test @@ -0,0 +1 @@ +I can not write to root diff --git a/integration-tests/script-test/expected/script-root-test/test b/integration-tests/script-test/expected/script-root-test/test new file mode 100644 index 000000000..0987e6f11 --- /dev/null +++ b/integration-tests/script-test/expected/script-root-test/test @@ -0,0 +1 @@ +I can write to root diff --git a/integration-tests/script-test/expected/script-test/test b/integration-tests/script-test/expected/script-test/test new file mode 100644 index 000000000..b14df6442 --- /dev/null +++ b/integration-tests/script-test/expected/script-test/test @@ -0,0 +1 @@ +Hi diff --git a/integration-tests/script-test/keys/gnome-sdk.gpg b/integration-tests/script-test/keys/gnome-sdk.gpg Binary files differnew file mode 100644 index 000000000..8434b686c --- /dev/null +++ b/integration-tests/script-test/keys/gnome-sdk.gpg diff --git a/integration-tests/script-test/project.conf b/integration-tests/script-test/project.conf new file mode 100644 index 000000000..4212ca3d1 --- /dev/null +++ b/integration-tests/script-test/project.conf @@ -0,0 +1,14 @@ +# Import-test BuildStream project configuration. + +# Project name +# +name: script-test + +aliases: + gnomesdk: https://sdk.gnome.org/ + +# Base project relative element path, elements will be loaded +# from this base. + +element-path: elements + diff --git a/integration-tests/script-test/run-script-test.sh b/integration-tests/script-test/run-script-test.sh new file mode 100644 index 000000000..3b4472ff5 --- /dev/null +++ b/integration-tests/script-test/run-script-test.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# A script to run a BuildStream test case. + + +TEST_DIR="elements/" +RESULTS="results/" +EXPECTED="expected/" + +set -eu + +# run_test +# +# Run tests for this test case. +# +# This should create a set of directories that match the directories +# in 'results/', as well as a log of the BuildStream output in +# 'test_log.log'. +# +run_test () { + local element + local elements + local element_name + local test_dir + + local successes=0 + local total=0 + local exit + + source ../lib.sh + + mkdir -p "$TEST_DIR" + elements="$(find "$TEST_DIR" -maxdepth 1 -type f)" + + for element in $elements; + do + total=$((total + 1)) + + element_name="$(basename "$element")" + element_name="${element_name%.*}" + + test_dir="$RESULTS/$element_name" + + echo "Running test '$element_name'" + + bst_with_flags build "$element_name".bst + bst_with_flags checkout "$element_name".bst "$test_dir" + + exit=0 + compare_results "$element_name" "$RESULTS" "$EXPECTED" || exit=$? + if [ $exit == 0 ] + then + successes=$((successes + 1)) + fi + done + + if [ $total != $successes ] + then + return 1 + fi +} + +run_test "$@" |