diff --git a/tests/.fmf/version b/.fmf/version similarity index 100% rename from tests/.fmf/version rename to .fmf/version diff --git a/plans/test-parted.fmf b/plans/test-parted.fmf new file mode 100644 index 0000000..2b22c58 --- /dev/null +++ b/plans/test-parted.fmf @@ -0,0 +1,8 @@ +summary: Run a basic parted test +prepare: + how: install + package: + - parted + - jq +execute: + script: ./tests/scripts/run_tests.sh diff --git a/tests/provision.fmf b/tests/provision.fmf deleted file mode 100644 index dd69f34..0000000 --- a/tests/provision.fmf +++ /dev/null @@ -1,5 +0,0 @@ ---- - -standard-inventory-qcow2: - qemu: - m: 4G diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh new file mode 100755 index 0000000..0161a84 --- /dev/null +++ b/tests/scripts/run_tests.sh @@ -0,0 +1,30 @@ +#!/usr/bin/bash +set -eux + +DISK=/var/tmp/parted-disk.img + +# Make a temporary disk image to use for tests +fallocate -l 100MiB $DISK + +# Make a disklabel and a couple of partitions +parted -s $DISK mklabel gpt +parted -s $DISK mkpart vfat 1MiB 10MiB +parted -s $DISK mkpart ext4 10MiB 50MiB +parted -s $DISK mkpart ext4 50MiB 75MiB +parted -s $DISK set 1 boot +parted -s $DISK set 3 linux-home + +# Check p1 for ESP UUID c12a7328-f81f-11d2-ba4b-00a0c93ec93b +P1_TYPE=$(parted -s $DISK --json u MiB p | jq -r '.disk.partitions[0]."type-uuid"') +[ "$P1_TYPE" == "c12a7328-f81f-11d2-ba4b-00a0c93ec93b" ] || exit 1 + +# Check p2 for linux data type 0fc63daf-8483-4772-8e79-3d69d8477de4 +P2_TYPE=$(parted -s $DISK --json u MiB p | jq -r '.disk.partitions[1]."type-uuid"') +[ "$P2_TYPE" == "0fc63daf-8483-4772-8e79-3d69d8477de4" ] || exit 1 + +# Check p3 for linux home type 933ac7e1-2eb4-4f13-b844-0e14e2aef915 +P3_TYPE=$(parted -s $DISK --json u MiB p | jq -r '.disk.partitions[2]."type-uuid"') +[ "$P3_TYPE" == "933ac7e1-2eb4-4f13-b844-0e14e2aef915" ] || exit 1 + +echo "PASS" +exit 0 diff --git a/tests/simple/run_tests.sh b/tests/simple/run_tests.sh deleted file mode 100755 index 9d40419..0000000 --- a/tests/simple/run_tests.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -set -eux - -: ${1?"Usage: $0 TESTSDIR"} - -TESTSDIR="$1" -SOURCEDIR="${TESTSDIR}/source/" -PACKAGE=parted - -cd "${TESTSDIR}" -if [ ! -e ${PACKAGE}.spec ]; then - echo "Missing ${PACKAGE}.spec" - pwd - ls - exit 1 -fi - -# This runs from the ./tests/ directory -# Install the dependencies from the spec which MUST be copied over by tests.yml -dnf -y build-dep ${PACKAGE}.spec - -# Flattened sources from standard-role-sources -cd "${SOURCEDIR}" || exit - -# Rebuild the package in place, also runs the %check -# skip %prep, it was already run on the source before it was copied over -rpmbuild --noprep --nodeps -bb --build-in-place "${TESTSDIR}/${PACKAGE}.spec" -RET=$? -exit ${RET} diff --git a/tests/tests.yml b/tests/tests.yml deleted file mode 100644 index 5fde476..0000000 --- a/tests/tests.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- hosts: localhost - tags: - - classic - roles: - - role: standard-test-source - required_packages: - - dnf - - rpm-build - - git - - role: standard-test-basic - tests: - - simple: - run: "./run_tests.sh {{ tenv_workdir }}"