3 # Test -- test routines, mostly printing hw inventory.
4 # Copyright (C) 2005 Erik van Konijnenburg
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 use ActiveBlockDevTab;
27 use BlockSpecialFileTab;
28 use LabeledPartitionTab;
42 print "Entries in fstab:\n";
43 for my $entry (@{FsTab->all}) {
44 my $str = $entry->string;
45 my $cmd = $entry->opts->cmdLineVersion;
52 sub testActiveBlockDevs () {
53 print "Block devices in /sys:\n";
54 for my $abd (@{ActiveBlockDevTab::all()}) {
55 my $str = $abd->string;
60 sub testActiveBlockDevPartitions () {
61 print "Partitions for block devices in /sys:\n";
62 for my $abd (@{ActiveBlockDevTab::all()}) {
63 my $str = $abd->string;
64 my $hp = $abd->hasPartitions() ? "yes" : "no";
65 my $partitions = $abd->partitions();
67 . join (',', (map {$_->name} @{$partitions})) . ']';
69 print "\t\tpartitioned:\t$hp\n";
70 print "\t\tpartitions:\t$partList\n";
75 sub testBlockSpecialFiles () {
76 print "Block special files /dev:\n";
77 for my $bsf (@{BlockSpecialFileTab::all()}) {
78 my $str = $bsf->string;
84 sub testLabeledPartitions () {
85 print "Labeled partitions detected:\n";
86 for my $lp (@{LabeledPartitionTab::all()}) {
87 my $str = $lp->string;
94 print "LVM Logical Volumes:\n";
95 for my $lv (@{LvmTab::allLogicalVolumes()}) {
96 my $str = $lv->string;
100 print "LVM Volume Groups:\n";
101 for my $vg (@{LvmTab::allVolumeGroups()}) {
102 my $str = $vg->string;
106 print "LVM Physical Volumes:\n";
107 for my $pv (@{LvmTab::allPhysicalVolumes()}) {
108 my $str = $pv->string;
114 sub testHardware () {
115 print "Hardware modules needed for devices in /sys:\n";
116 for my $abd (@{ActiveBlockDevTab::all()}) {
117 my $str = $abd->string;
119 next unless defined ($hw);
121 my $moduleList = Hardware::moduleList ($hw);
122 print "\t\t[" . join(',', @{$moduleList}) . "]\n";
127 print "Module dependencies:\n";
128 for my $modDep (@{ModDepTab::all()}) {
129 my $str = ModDepTab::findByModnam($modDep)->string;
134 sub testModResolve () {
135 print "Hardware modules with resolved dependencies:\n";
136 for my $abd (@{ActiveBlockDevTab::all()}) {
137 my $str = $abd->string;
139 next unless defined ($hw);
141 my $moduleList = Hardware::moduleList ($hw);
142 print "\t\t[" . join(',', @{$moduleList}) . "]\n";
143 my $resolveList = ModDepTab::resolve ($moduleList);
144 print "\t\t[" . join(',', @{$resolveList}) . "]\n";
148 sub testRaidDevices () {
149 print "Raid devices:\n";
150 for my $rd (@{RaidTab::all()}) {
151 my $str = $rd->string;
157 print "Input devices:\n";
158 for my $inp (@{InputTab::all()}) {
159 my $str = $inp->string;
164 sub testInterpretation () {
165 print "Interpreted Fstab Entries:\n";
166 for my $fse (@{FsTab->all}) {
167 my $fseStr = $fse->string;
168 my $active = $fse->isRequiredAtBoot ? "yes": "no";
169 my $path = $fse->blockDevPath();
176 if (defined ($path) && -b $path) {
177 $devno = Base::devno ($path);
178 my $lvmFiles = LvmTab::findPVPathsByLVDevno ($devno);
179 if (defined ($lvmFiles)) {
180 $lvmStr = '[' . join (',', @{$lvmFiles}) . ']';
183 my $abd = ActiveBlockDevTab::findByDevno($devno);
184 if (defined ($abd)) {
185 $name = $abd->name();
186 my $parent = $abd->parent();
187 if (defined ($parent)) {
188 $hardware = $parent->hw();
191 $hardware = $abd->hw();
195 if (defined ($hardware)) {
196 my $moduleList = Hardware::moduleList ($hardware);
197 $modules = "[" . join(',', @{$moduleList}) . "]";
198 my $resolveList = ModDepTab::resolve ($moduleList);
199 $resolved = "[" . join(',', @{$resolveList}) . "]";
202 $hardware = "--" unless defined ($hardware);
203 $modules = "--" unless defined ($modules);
204 $resolved = "--" unless defined ($resolved);
205 $path = "--" unless defined ($path);
207 print "\t\tactive:\t$active\n";
208 print "\t\tdevno:\t$devno\n";
209 print "\t\tpath:\t$path\n";
210 print "\t\tname:\t$name\n";
211 print "\t\thw:\t$hardware\n";
212 print "\t\tmods:\t$modules\n";
213 print "\t\tresolv:\t$resolved\n";
214 print "\t\tlvm:\t$lvmStr\n";
216 if (defined ($path)) {
217 my $abd = ActiveBlockDevTab::findByPath($path);
218 if (defined ($abd)) {
219 my $list = ActionList->new();
220 Plan::addDevicePlan ($list, $abd, [], []);
221 # the output provided by addDevicePlan
223 # print $list->string();
230 print "Kernel Builtin Modules:\n";
231 for my $module (@{KConfig::allKnownModules()}) {
232 my $builtIn = KConfig::isBuiltIn($module) ? "BUILTIN" : "--";
233 print "\t$module:\t$builtIn\n";
238 # testAll -- run various interesting subroutines
239 # that may trigger errors.
244 testBlockSpecialFiles ();
245 testLabeledPartitions ();
246 testActiveBlockDevs ();
247 testActiveBlockDevPartitions ();
253 testInterpretation ();