diff --git a/diskimage_builder/elements/ubuntu-minimal/test-elements/xenial-build-succeeds/README.rst b/diskimage_builder/elements/ubuntu-minimal/test-elements/xenial-build-succeeds/README.rst index b7190827..624e34e4 100644 --- a/diskimage_builder/elements/ubuntu-minimal/test-elements/xenial-build-succeeds/README.rst +++ b/diskimage_builder/elements/ubuntu-minimal/test-elements/xenial-build-succeeds/README.rst @@ -1 +1,4 @@ Verify we can build a ubuntu-minimal image. + +Note this test includes the vm element to test the bootloader install, +and specifies to output a .qcow2 diff --git a/diskimage_builder/elements/ubuntu-minimal/test-elements/xenial-build-succeeds/element-deps b/diskimage_builder/elements/ubuntu-minimal/test-elements/xenial-build-succeeds/element-deps new file mode 100644 index 00000000..d4000391 --- /dev/null +++ b/diskimage_builder/elements/ubuntu-minimal/test-elements/xenial-build-succeeds/element-deps @@ -0,0 +1 @@ +vm \ No newline at end of file diff --git a/diskimage_builder/elements/ubuntu-minimal/test-elements/xenial-build-succeeds/test-output-formats b/diskimage_builder/elements/ubuntu-minimal/test-elements/xenial-build-succeeds/test-output-formats new file mode 100644 index 00000000..c780936b --- /dev/null +++ b/diskimage_builder/elements/ubuntu-minimal/test-elements/xenial-build-succeeds/test-output-formats @@ -0,0 +1 @@ +tar,qcow2 \ No newline at end of file diff --git a/tests/run_functests.sh b/tests/run_functests.sh index 66e83a1d..a93a406f 100755 --- a/tests/run_functests.sh +++ b/tests/run_functests.sh @@ -35,6 +35,10 @@ DEFAULT_SKIP_TESTS=( centos/build-succeeds ) +# The default output formats (specified to disk-image-create's "-t" +# command. Elements can override with a test-output-formats file +DEFAULT_OUTPUT_FORMATS="tar" + function log_with_prefix { local pr=$1 local log @@ -82,13 +86,15 @@ function wait_minus_n { fi } -# run_disk_element_test -# Run a disk-image-build .tar build of ELEMENT including any elements -# specified by TEST_ELEMENT +# run_disk_element_test +# Run a disk-image-build build of ELEMENT including any elements +# specified by TEST_ELEMENT. Pass OUTPUT_FORMAT to "-t" function run_disk_element_test() { local test_element=$1 local element=$2 local dont_use_tmp=$3 + local output_format="$4" + local use_tmp_flag="" local dest_dir=$(mktemp -d) @@ -102,12 +108,17 @@ function run_disk_element_test() { break_cmd="cp -v \$TMP_MOUNT_PATH/tmp/dib-test-should-fail ${dest_dir} || true" \ DIB_SHOW_IMAGE_USAGE=1 \ ELEMENTS_PATH=$DIB_ELEMENTS/$element/test-elements \ - $DIB_CMD -x -t tar,qcow2 ${use_tmp_flag} -o $dest_dir/image -n $element $test_element 2>&1 \ + $DIB_CMD -x -t ${output_format} \ + ${use_tmp_flag} \ + -o $dest_dir/image -n $element $test_element 2>&1 \ | log_with_prefix "${element}/${test_element}"; then - if ! [ -f "$dest_dir/image.qcow2" ]; then - echo "Error: qcow2 build failed for element: $element, test-element: $test_element." - echo "No image $dest_dir/image.qcow2 found!" + if [[ "qcow2" =~ "$output_format" ]]; then + if ! [ -f "$dest_dir/image.qcow2" ]; then + echo "Error: qcow2 build failed for element: $element, test-element: $test_element." + echo "No image $dest_dir/image.qcow2 found!" + exit 1 + fi fi # check inside the tar for sentinel files @@ -305,16 +316,25 @@ for test in "${TESTS_TO_RUN[@]}"; do element=${test%/*} test_element=${test#*/} + element_dir=$DIB_ELEMENTS/${element}/test-elements/${test_element}/ + # tests default to disk-based, but "element-type" can optionally # override that element_type=disk - element_type_override=$DIB_ELEMENTS/${element}/test-elements/${test_element}/element-type + element_type_override=${element_dir}/element-type if [ -f ${element_type_override} ]; then element_type=$(cat ${element_type_override}) fi + # override the output format if specified + element_output=${DEFAULT_OUTPUT_FORMATS} + element_output_override=${element_dir}/test-output-formats + if [ -f $element_output_override ]; then + element_output=$(cat ${element_output_override}) + fi + echo "Running $test ($element_type)" - run_${element_type}_element_test $test_element $element ${DONT_USE_TMP} & + run_${element_type}_element_test $test_element $element ${DONT_USE_TMP} "${element_output}" & done # Wait for the rest of the jobs