}
1;
+
+# Remove or uncomment the next line to run the testsuite.
+__END__
+
+sub testsuite() {
+ # Test the volume status function.
+ my %test = &volumes_status(
+ "devices" => "all",
+ "uuids" => "True",
+ "df" => "True"
+ );
+
+ # Check the hash contains anything.
+ if (%test) {
+ print "volumes_status() - PASSED!\n";
+ }
+
+ # Drop the test hash
+ undef(%test);
+
+ # BTRFS RELATED TESTS!
+ if (&is_btrfs("/")) {
+ print "&is_btrfs() - Performing BTRFS tests!\n";
+
+ &btrfs_tests();
+ } else {
+ print "&is_btrfs() - Skipped BTRFS tests!\n";
+ }
+}
+
+sub btrfs_tests() {
+ # Name of the snapshot.
+ my $test_snapshot_name = "xxxTESTSUITE_SNAPSHOTxxx";
+
+ # Try to get a list of known subvolumes.
+ my %subvolumes = &btrfs_get_subvolumes();
+
+ # Check if at least one subvolume could be obtained.
+ if (%subvolumes) {
+ print "&btrfs_get_subvolumes() - PASSED!\n";
+ }
+
+ # Drop the subvolumes hash.
+ undef(%subvolumes);
+
+ # Create a snapshot.
+ my $ret = &btrfs_create_snapshot($test_snapshot_name);
+
+ # Check the function returned a return code.
+ if ($ret) {
+ print "&btrfs_create_snapshot() - FAILED! (Ret: $ret)\n";
+ } else {
+ print "&btrfs_create_snapshot() - PASSED!\n";
+ }
+
+ # Try to get a list of all known snapshots.
+ my %snapshots = &btrfs_get_snapshots();
+
+ # Check if at least one snapshot could be obtained.
+ if (%snapshots) {
+ print "&btrfs_get_snapshots() - PASSED!\n";
+ }
+
+ # Value to store the ID of the test snapshot.
+ my $test_snapshot_id;
+
+ # Loop through the hash of snapshots.
+ foreach my $id (sort keys %snapshots) {
+ # Grab the snapshot name.
+ my $snapshot = $snapshots{$id};
+
+ # Skip found snapshot until we found our test snapshot.
+ next unless $snapshot eq $test_snapshot_name;
+
+ # Store the ID of the test snapshot.
+ $test_snapshot_id = $id;
+
+ print "SUCESSFULLY GOT THE ID ($id) OF $test_snapshot_name\n";
+
+ # Break the loop.
+ last;
+ }
+
+ # Check if an ID for the test snapshot could be obtained.
+ if ($test_snapshot_id) {
+ # Try to delete the snapshot.
+ $ret = &btrfs_remove_snapshot($test_snapshot_id);
+
+ # Check if the function returned a code.
+ if ($ret) {
+ print "&btrfs_remove_snapshot() - FAILED (Ret: $ret)\n";
+ } else {
+ print "&btrfs_remove_snapshot() - PASSED!\n";
+ }
+ } else {
+ print "&btrfs_remove_snapshot() - SKIPPED NO ID!\n";
+ }
+}
+
+&testsuite();