aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaarten Vanraes <alien@mageia.org>2016-02-01 20:05:04 +0100
committerMaarten Vanraes <alien@mageia.org>2016-05-14 09:25:23 +0200
commit7b4c597b0b993d7aec0f5a7deab87f76fe1bf24d (patch)
treebcb0900017a595fd436178a14b6212b2b5431368
parentdeb2a17be4faac7bd241a0f5045a75f8750f0453 (diff)
downloadmanatools-7b4c597b0b993d7aec0f5a7deab87f76fe1bf24d.tar
manatools-7b4c597b0b993d7aec0f5a7deab87f76fe1bf24d.tar.gz
manatools-7b4c597b0b993d7aec0f5a7deab87f76fe1bf24d.tar.bz2
manatools-7b4c597b0b993d7aec0f5a7deab87f76fe1bf24d.tar.xz
manatools-7b4c597b0b993d7aec0f5a7deab87f76fe1bf24d.zip
add a test script for the backend
-rw-r--r--lib/test-diskbe.pl83
1 files changed, 83 insertions, 0 deletions
diff --git a/lib/test-diskbe.pl b/lib/test-diskbe.pl
new file mode 100644
index 00000000..1b753f4c
--- /dev/null
+++ b/lib/test-diskbe.pl
@@ -0,0 +1,83 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use ManaTools::Shared::disk_backend;
+use Data::Dumper;
+
+sub sp {
+ my $level = shift;
+ return '' if ($level <= 0);
+ return " ". sp($level - 1);
+}
+
+sub dumpio {
+ my ($db_man, $io, $level) = @_;
+ print sp($level) ."- IO(". $io->type() ."): ". $io->label() ."\n";
+ # indent
+ $level = $level + 1;
+
+ print sp($level) ."Properties:\n" if scalar($io->properties()) > 0;
+ for my $key (sort $io->properties()) {
+ print sp($level) ."- ". $key ." --> ". $io->prop($key) ."\n";
+ }
+
+ # find parts that contain this
+ my @parts = $db_man->findin($io);
+ print sp($level) ."Parts:\n" if scalar(@parts) > 0;
+ for my $part (sort { $a->label() cmp $b->label() } @parts) {
+ dumppart($db_man, $part, $level);
+ }
+}
+
+sub dumppart {
+ my ($db_man, $part, $level) = @_;
+ print sp($level) ."- PART(". $part->type() ."): (". $part->label() .")\n";
+ # indent
+ $level = $level + 1;
+
+ print sp($level) ."Properties:\n" if scalar($part->properties()) > 0;
+ for my $key (sort $part->properties()) {
+ print sp($level) ."- ". $key ." --> ". $part->prop($key) ."\n";
+ }
+
+ my @ios = $part->get_outs();
+ print sp($level) ."IOs:\n" if scalar(@ios) > 0;
+ for my $io (sort { $a->label() cmp $b->label() } @ios) {
+ dumpio($db_man, $io, $level);
+ }
+ if ($part->type() eq 'Mount') {
+ my @parts = $db_man->findpartprop('Mount', 'parent', $part->prop('id'));
+ print sp($level) ."Child Mounts:\n" if scalar(@parts) > 0;
+ for my $part (sort { $a->label() cmp $b->label() } @parts) {
+ dumppart($db_man, $part, $level);
+ }
+ }
+}
+
+
+my $db_man = ManaTools::Shared::disk_backend->new();
+
+$db_man->probe();
+
+my $mode = 'disks';
+if (defined $ARGV[0]) {
+ $mode = $ARGV[0];
+}
+
+if ($mode eq 'fs') {
+ my @parts = $db_man->findpart('Mount');
+ for my $part (@parts) {
+ my $pm = $part->parentmount();
+ dumppart($db_man, $part, 0) if !(defined $pm);
+ }
+}
+else {
+
+ my @parts = $db_man->findoutnoin();
+ for my $part (@parts) {
+ dumppart($db_man, $part, 0);
+ }
+}
+
+print "End\n";