File: hardware_order.t

package info (click to toggle)
systemconfigurator 2.0.10-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 724 kB
  • ctags: 313
  • sloc: perl: 7,423; makefile: 48
file content (398 lines) | stat: -rw-r--r-- 11,273 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
use Test;
use Data::Dumper;
use Carp;
use strict;
use vars qw($config);

BEGIN {
    
    # Set up 20 tests to run
    
    plan tests => 57;
    
    # Here is a trick to make it look like this was called with those args
    # on the command line before SCConfig runs.

    @ARGV = qw(--confighw --cfgfile t/cfg/order.cfg);
}

eval {
    use SCConfig;
    return 1;
};

ok($@,'') or croak("No point in going any further");

eval {
    use Hardware;
    return 1;
};

ok($@,'') or croak("No point in going any further");

# We loaded the file... now lets setup a fake directory to use

my $root = $config->root();

if(!$root) {
    croak("Running this not chroot is way too dangerous");
}

my $proc = $root . "/proc/bus/pci";

my $dir = $root . "/etc";

my $sbin = $root . "/sbin";

system("mkdir -p $dir");
system("mkdir -p $dir/sysconfig");
system("mkdir -p $proc");
system("mkdir -p $sbin");

if(!-d $dir) {
    croak("No directory $dir exists");
}


### Start SuSE testing

# TEST 1 - x5500 default
reset_test();

setup_x5500();

croak() unless (-e "$proc/devices");

# Now we are ready to run tests.

Hardware::setup($config);

ok(-e "$dir/modules.conf");

{
    local($/) = undef;
    open(IN,"<$dir/modules.conf") or croak("Can't open $dir/conf.modules");
    my $mcfile = <IN>;
    
    ok($mcfile,'/(^|\n)alias eth0 pcnet32/');
    ok($mcfile,'/\nalias eth1 eepro100/');
    ok($mcfile,'/\nalias scsi_hostadapter ips/');
    ok($mcfile,'/\nalias scsi_hostadapter1 aic7xxx/');
    
    close(IN);
}


# TEST 2 - x5500 order change
reset_test();

$config->hardware_order("aic7xxx");

setup_x5500();

croak() unless (-e "$proc/devices");

# Now we are ready to run tests.

Hardware::setup($config);

ok(-e "$dir/modules.conf");

{
    local($/) = undef;
    open(IN,"<$dir/modules.conf") or croak("Can't open $dir/conf.modules");
    my $mcfile = <IN>;
    
    ok($mcfile,'/(^|\n)alias eth0 pcnet32/');
    ok($mcfile,'/\nalias eth1 eepro100/');
    ok($mcfile,'/\nalias scsi_hostadapter aic7xxx/');
    ok($mcfile,'/\nalias scsi_hostadapter1 ips/');
    
    close(IN);
}


# TEST 3 - x5500 order change
reset_test();

$config->hardware_order("eepro100 aic7xxx");

setup_x5500();

croak() unless (-e "$proc/devices");

# Now we are ready to run tests.

Hardware::setup($config);

ok(-e "$dir/modules.conf");

{
    local($/) = undef;
    open(IN,"<$dir/modules.conf") or croak("Can't open $dir/conf.modules");
    my $mcfile = <IN>;
    
    ok($mcfile,'/\nalias eth0 eepro100/');
    ok($mcfile,'/(^|\n)alias eth1 pcnet32/');
    ok($mcfile,'/\nalias scsi_hostadapter aic7xxx/');
    ok($mcfile,'/\nalias scsi_hostadapter1 ips/');
    
    close(IN);
}

# TEST 4 - x5500 order change
reset_test();

$config->hardware_order("eepro100 pcnet32 aic7xxx ips");

setup_x5500();

croak() unless (-e "$proc/devices");

# Now we are ready to run tests.

Hardware::setup($config);

ok(-e "$dir/modules.conf");

{
    local($/) = undef;
    open(IN,"<$dir/modules.conf") or croak("Can't open $dir/conf.modules");
    my $mcfile = <IN>;
    
    ok($mcfile,'/\nalias eth0 eepro100/');
    ok($mcfile,'/(^|\n)alias eth1 pcnet32/');
    ok($mcfile,'/\nalias scsi_hostadapter aic7xxx/');
    ok($mcfile,'/\nalias scsi_hostadapter1 ips/');
    
    close(IN);
}


# TEST 5 - x5500 explicitly specify default
reset_test();

$config->hardware_order("pcnet32 eepro100 ips aic7xxx");

setup_x5500();

croak() unless (-e "$proc/devices");

# Now we are ready to run tests.

Hardware::setup($config);

ok(-e "$dir/modules.conf");

{
    local($/) = undef;
    open(IN,"<$dir/modules.conf") or croak("Can't open $dir/conf.modules");
    my $mcfile = <IN>;
    
    ok($mcfile,'/(^|\n)alias eth0 pcnet32/');
    ok($mcfile,'/\nalias eth1 eepro100/');
    ok($mcfile,'/\nalias scsi_hostadapter ips/');
    ok($mcfile,'/\nalias scsi_hostadapter1 aic7xxx/');
    
    close(IN);
}

# TEST 6 - x345 normal

reset_test();

setup_x345();

croak() unless (-e "$proc/devices");

# Now we are ready to run tests.

Hardware::setup($config);

ok(-e "$dir/modules.conf");

{
    local($/) = undef;
    open(IN,"<$dir/modules.conf") or croak("Can't open $dir/modules.conf");
    my $mcfile = <IN>;
    
    ok($mcfile,'/\nalias eth0 e1000/');
    ok($mcfile,'/\nalias eth1 e1000/');
    ok($mcfile,'/\nalias eth2 e1000/');
    ok($mcfile,'/\nalias scsi_hostadapter ips/');
    ok($mcfile,'/\nalias scsi_hostadapter1 mptscsih/');
    ok($mcfile,'/\nalias scsi_hostadapter2 mptscsih/');

    close(IN);
    
    open(IN,"<$dir/sysconfig/kernel") or croak("Can't open suse kernel file");
    my $kernel = <IN>;
    ok($kernel,'/\nINITRD_MODULES="ips mptscsih mptscsih"/');
    close(IN);
    
}


# TEST 7 - x345 order change

reset_test();

$config->hardware_order("mptscsih");

setup_x345();

croak() unless (-e "$proc/devices");

# Now we are ready to run tests.

Hardware::setup($config);

ok(-e "$dir/modules.conf");

{
    local($/) = undef;
    open(IN,"<$dir/modules.conf") or croak("Can't open $dir/modules.conf");
    my $mcfile = <IN>;
    
    ok($mcfile,'/\nalias eth0 e1000/');
    ok($mcfile,'/\nalias eth1 e1000/');
    ok($mcfile,'/\nalias eth2 e1000/');
    ok($mcfile,'/\nalias scsi_hostadapter mptscsih/');
    ok($mcfile,'/\nalias scsi_hostadapter1 mptscsih/');
    ok($mcfile,'/\nalias scsi_hostadapter2 ips/');
    
    close(IN);
}

# TEST 8 - x345 order change

reset_test();

$config->hardware_order("mptscsih ips");

setup_x345();

croak() unless (-e "$proc/devices");

# Now we are ready to run tests.

Hardware::setup($config);

ok(-e "$dir/modules.conf");

{
    local($/) = undef;
    open(IN,"<$dir/modules.conf") or croak("Can't open $dir/modules.conf");
    my $mcfile = <IN>;
    
    ok($mcfile,'/\nalias eth0 e1000/');
    ok($mcfile,'/\nalias eth1 e1000/');
    ok($mcfile,'/\nalias eth2 e1000/');
    ok($mcfile,'/\nalias scsi_hostadapter mptscsih/');
    ok($mcfile,'/\nalias scsi_hostadapter1 mptscsih/');
    ok($mcfile,'/\nalias scsi_hostadapter2 ips/');
    
    close(IN);
}

# TEST 9 - x345 order change

reset_test();

$config->hardware_order("ips mptscsih");

setup_x345();

croak() unless (-e "$proc/devices");

# Now we are ready to run tests.

Hardware::setup($config);

ok(-e "$dir/modules.conf");

{
    local($/) = undef;
    open(IN,"<$dir/modules.conf") or croak("Can't open $dir/modules.conf");
    my $mcfile = <IN>;
    
    ok($mcfile,'/\nalias eth0 e1000/');
    ok($mcfile,'/\nalias eth1 e1000/');
    ok($mcfile,'/\nalias eth2 e1000/');
    ok($mcfile,'/\nalias scsi_hostadapter ips/');
    ok($mcfile,'/\nalias scsi_hostadapter1 mptscsih/');
    ok($mcfile,'/\nalias scsi_hostadapter2 mptscsih/');
    
    close(IN);
}


ok(system("rm -rf $root"),0);

sub reset_test {
    open(OUT,">$dir/modules.conf");
    close(OUT);
    open(OUT,">$dir/sysconfig/kernel");
    close(OUT);
    open(OUT,">$sbin/SuSEconfig");
    print OUT "#!/bin/sh\n";
    print OUT "echo done";
    close(OUT);
    chmod 0755, "$sbin/SuSEconfig";
    
    unlink "$proc/devices";
}

sub setup_x5500 {
    open(OUT,">$proc/devices");

# The following is a proc dump from one of the lab machines.

print OUT <<END;
0000    808671a2        0       00000008        00000000        00000000 00000000        00000000        00000000        00000000
0018    1014002e        b       00002001        febfe000        00000000 00000000        00000000        00000000        00000000
0020    10140022        0       00000000        00000000        00000000 00000000        00000000        00000000        00000000
0070    10222000        a       00002181        febfdc00        00000000 00000000        00000000        00000000        00000000
0078    53338901        9       f4000000        00000000        00000000 00000000        00000000        00000000        00000000
0098    80867110        0       00000000        00000000        00000000 00000000        00000000        00000000        00000000
0099    80867111        0       00000000        00000000        00000000 00000000        0000ffa1        00000000        00000000
009a    80867112        a       00000000        00000000        00000000 00000000        0000ff01        00000000        00000000
009b    80867113        0       00000000        00000000        00000000 00000000        00000000        00000000        00000000
0110    90048178        b       00005101        fd820000        00000000 00000000        00000000        00000000        00000000
0120    80861229        9       fd821000        00005201        fd800000 00000000        00000000        00000000        00000000
END

close(OUT);

}

sub setup_x345 {

# Setup for test x345 

open(OUT,">$proc/devices");

print OUT <<END;
0000	11660014	0	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	
0001	11660014	0	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	
0002	11660014	0	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	
0030	10024752	1a	fd000000	00002401	febff000	00000000	00000000	00000000	00000000	01000000	00000100	00001000	00000000	00000000	00000000	00020000	
0078	11660201	0	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	
0079	11660212	0	000001f1	000003f7	00000171	00000377	00000701	00000000	00000000	00000008	00000000	00000008	00000000	00000010	00000000	00000000	
007a	11660220	3	febfe000	00000000	00000000	00000000	00000000	00000000	00000000	00001000	00000000	00000000	00000000	00000000	00000000	00000000	
007b	11660225	0	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	
0080	11660101	0	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	
0082	11660101	0	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	
0088	11660101	0	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	
008a	11660101	0	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	00000000	
0218	80861008	14	fbfe0004	00000000	fbfc0004	00000000	00002501	00000000	00000000	00020000	00000000	00020000	00000000	00000020	00000000	00020000	
0420	101401bd	16	f9ffe008	00000000	00000000	00000000	00000000	00000000	00000000	00002000	00000000	00000000	00000000	00000000	00000000	00080000	ips
0640	80861010	1d	f7fe0004	00000000	00000000	00000000	00002541	00000000	00000000	00020000	00000000	00000000	00000000	00000040	00000000	00000000	e1000
0641	80861010	1e	f7fc0004	00000000	00000000	00000000	00002581	00000000	00000000	00020000	00000000	00000000	00000000	00000040	00000000	00000000	e1000
0838	10000030	1b	00002601	f5ff0004	00000000	f5fe0004	00000000	00000000	00000000	00000100	00010000	00000000	00010000	00000000	00000000	00100000	
0839	10000030	1c	00002701	f5fd0004	00000000	f5fc0004	00000000	00000000	00000000	00000100	00010000	00000000	00010000	00000000	00000000	00100000	
END

close(OUT);

}