From 529eff1e846d8b88dda1627eff5f2cb6bcc0d805 Mon Sep 17 00:00:00 2001 From: AlanMarshall Date: Tue, 12 Nov 2024 19:27:36 +0000 Subject: [PATCH] Disk tests added --- tests/applications/disks/aaa_setup.pm | 65 +++++++++++++++++++ tests/applications/disks/about.pm | 33 ++++++++++ tests/applications/disks/delete_partition.pm | 22 +++++++ tests/applications/disks/edit_filesystem.pm | 21 ++++++ tests/applications/disks/edit_partition.pm | 21 ++++++ tests/applications/disks/format_partition.pm | 23 +++++++ tests/applications/disks/mount_partitions.pm | 38 +++++++++++ tests/applications/disks/resize_partition.pm | 28 ++++++++ .../disks/standard_partitioning.pm | 38 +++++++++++ 9 files changed, 289 insertions(+) create mode 100644 tests/applications/disks/aaa_setup.pm create mode 100644 tests/applications/disks/about.pm create mode 100644 tests/applications/disks/delete_partition.pm create mode 100644 tests/applications/disks/edit_filesystem.pm create mode 100644 tests/applications/disks/edit_partition.pm create mode 100644 tests/applications/disks/format_partition.pm create mode 100644 tests/applications/disks/mount_partitions.pm create mode 100644 tests/applications/disks/resize_partition.pm create mode 100644 tests/applications/disks/standard_partitioning.pm diff --git a/tests/applications/disks/aaa_setup.pm b/tests/applications/disks/aaa_setup.pm new file mode 100644 index 00000000..3dcf78cf --- /dev/null +++ b/tests/applications/disks/aaa_setup.pm @@ -0,0 +1,65 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will prepare a disk image with the size of +# 1 GB and will add two partitions to it. This will serve as +# a milestone for other follow-up tests. +# + +# This script will test if Disks can create new partitions +# in an empty disk. + +sub run { + my $self = shift; + + # Switch to the console and perform some pre-settings. + # Switch to the console + $self->root_console(tty => 3); + # Create a disk image in the home folder. We have decided + # to use truncate to be able to create bigger partitions + # that would not require as much space on the disk when + # empty. + script_run("truncate -s 1G /root/disk.img"); + # Connect the created partition to the system as a loop device + # using losetup which will make it accessible to the Disks application + # later. + script_run("losetup -P -f --show /root/disk.img"); + + # Go back to graphics. + desktop_vt(); + # Set the update notification_timestamp + set_update_notification_timestamp(); + + menu_launch_type("disks"); + wait_still_screen(3); + + # Make it fill the entire window. + send_key("super-up"); + wait_still_screen(2); + assert_screen("apps_run_disks"); + + # Click on the listed icon of the new loop device. + assert_and_click("disks_diskloop_listed"); + # Check that the file has been correctly attached. + assert_screen("disks_diskloop_status"); + + # Format the entire disk with a GPT. + wipe_disk(); + + # Add partitions. + add_partitions(); +} + +sub test_flags { + # If this test fails, there is no need to continue. + return {fatal => 1, milestone => 1}; +} + +1; + +# vim: set sw=4 et: + + diff --git a/tests/applications/disks/about.pm b/tests/applications/disks/about.pm new file mode 100644 index 00000000..29bd0ac6 --- /dev/null +++ b/tests/applications/disks/about.pm @@ -0,0 +1,33 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# This script will open the About dialogue and check +# that it works. + +sub run { + # Open the menu + assert_and_click("gnome_burger_menu"); + + # Click on the About item + assert_and_click("gnome_menu_about"); + + # Check that the dialogue is shown. + assert_screen("disks_about_shown"); + + # Click on the Credits button. + assert_and_click("gnome_button_credits"); + + # Check that Credits are shown. + assert_screen("disks_credits_shown"); + + # Dismiss the About window using the Esc key. + send_key("esc"); +} + +sub test_flags { + return {fatal => 0}; +} + +1; diff --git a/tests/applications/disks/delete_partition.pm b/tests/applications/disks/delete_partition.pm new file mode 100644 index 00000000..cb393ee9 --- /dev/null +++ b/tests/applications/disks/delete_partition.pm @@ -0,0 +1,22 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can delete a partition +# and add a new partition instead. + +sub run { + # Select the test disk. + assert_and_click("disks_loopdisk_listed"); + # Delete the second partition. + delete_partition("two"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/edit_filesystem.pm b/tests/applications/disks/edit_filesystem.pm new file mode 100644 index 00000000..bd618565 --- /dev/null +++ b/tests/applications/disks/edit_filesystem.pm @@ -0,0 +1,21 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can edit the filesystem name. + +sub run { + # Click on the test disk to select it. + assert_and_click("disks_loopdisk_listed"); + # Edit the filesystem name. + edit_filesystem("one", "renamed"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/edit_partition.pm b/tests/applications/disks/edit_partition.pm new file mode 100644 index 00000000..ca5772ec --- /dev/null +++ b/tests/applications/disks/edit_partition.pm @@ -0,0 +1,21 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can edit the partition name. + +sub run { + # Open the menu + assert_and_click("disks_loopdisk_listed"); + # Change the type of the partition. + edit_partition("one", "linuxroot", "partroot"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/format_partition.pm b/tests/applications/disks/format_partition.pm new file mode 100644 index 00000000..1b613638 --- /dev/null +++ b/tests/applications/disks/format_partition.pm @@ -0,0 +1,23 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can format an empty +# partition. + +sub run { + # Select the test loop disk. + assert_and_click("disks_loopdisk_listed"); + + # Format partition + format_partition("one", "swap", "backup"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/mount_partitions.pm b/tests/applications/disks/mount_partitions.pm new file mode 100644 index 00000000..46c21452 --- /dev/null +++ b/tests/applications/disks/mount_partitions.pm @@ -0,0 +1,38 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if current partitions can be mounted +# via the Disks application. + + +sub run { + my $self = shift; + + # Wipe the entire disk, recreate partitions + wipe_disk(); + add_partitions(); + + + # Mount the first partition. + mount_partition("one"); + + # Mount the second partition. + mount_partition("two"); + + # Check in the system that the partitions have been mounted. + $self->root_console(tty => 3); + # First partition + assert_script_run("findmnt /dev/loop0p1"); + # Second partition + assert_script_run("findmnt /dev/loop0p2"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/resize_partition.pm b/tests/applications/disks/resize_partition.pm new file mode 100644 index 00000000..845b8d83 --- /dev/null +++ b/tests/applications/disks/resize_partition.pm @@ -0,0 +1,28 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can resize a partition and +# put a new partition after the resized one. + +sub run { + # Select the test loop disk. + assert_and_click("disks_loopdisk_listed"); + # Resize the second partition + resize_partition("two", "320"); + + # Add a new partition to the remainaing space + assert_and_click("disks_free_space"); + + # Create another partition in the remaining space. + create_partition("terciavolta", "full"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/standard_partitioning.pm b/tests/applications/disks/standard_partitioning.pm new file mode 100644 index 00000000..3026b2c3 --- /dev/null +++ b/tests/applications/disks/standard_partitioning.pm @@ -0,0 +1,38 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can delete all partitions and +# create three partitions for Standard partitioning, a small boot +# partition, a bigger root partition, and a home partition that +# takes the rest of the space. All partitions will be formatted +# as ext4. + +sub run { + # Select the test loop disk. + assert_and_click("disks_loopdisk_listed"); + + # Remove partitions + wipe_disk(); + + # Create the partitions (they are formatted as ext4) + create_partition("boot", "200"); + assert_and_click("disks_free_space"); + create_partition("root", "300"); + assert_and_click("disks_free_space"); + create_partition("home", "full"); + + # Mount the partitions + mount_partition("one"); + mount_partition("two"); + mount_partition("three"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; +