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 2d0079c..0000000 --- a/tests/simple/run_tests.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -eux - -# make a small disk image -fallocate -l 100M ./disk.img -parted -s ./disk.img mklabel gpt -parted -s ./disk.img 'mkpart root 1MiB 100%' -parted -m -s ./disk.img u s p diff --git a/tests/tests.yml b/tests/tests.yml deleted file mode 100644 index fd6548d..0000000 --- a/tests/tests.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -# Run a simple parted test -- hosts: localhost - roles: - - role: standard-test-basic - tags: - - classic - required_packages: - - parted - - tests: - - simple: - run: ./run_tests.sh