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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
|
#!/bin/sh
# Source the common test script helpers
. /usr/bin/rhts_environment.sh
. ../../kernel/include/runtest.sh
CUR_TIME=$(date --date="$(date --utc)" +%s)
# control where to log debug messages to:
# devnull = 1 : log to /dev/null
# devnull = 0 : log to file specified in ${DEBUGLOG}
devnull=0
# Create debug log
DEBUGLOG=`mktemp -p /mnt/testarea -t DeBug.XXXXXX`
# locking to avoid races
lck=$OUTPUTDIR/$(basename $0).lck
# Functions
# Log a message to the ${DEBUGLOG} or to /dev/null
function DeBug ()
{
local msg="$1"
local timestamp=$(date '+%F %T')
if [ "$devnull" = "0" ]; then
(
flock -x 200 2>/dev/null
echo -n "${timestamp}: " >>$DEBUGLOG 2>&1
echo "${msg}" >>$DEBUGLOG 2>&1
) 200>$lck
else
echo "${msg}" >/dev/null 2>&1
fi
}
function RHTSAbort ()
{
# Abort the rhts recipe if we are running the wrong kernel
DeBug "Abort recipe"
rhts-abort -t recipe
}
function SysReport ()
{
DeBug "Enter SysReport"
OUTPUTFILE=`mktemp /tmp/tmp.XXXXXX`
grep -q "release 3 " /etc/redhat-release
if [ $? -eq 0 ]; then
modarg=-d
modarg2=
else
modarg="-F description"
modarg2="-F version"
fi
sysnode=$(/bin/uname -n)
syskernel=$(/bin/uname -r)
sysmachine=$(/bin/uname -m)
sysprocess=$(/bin/uname -p)
sysuname=$(/bin/uname -a)
sysswap=$(/usr/bin/free -m | /bin/awk '{if($1=="Swap:") {print $2,"MB"}}')
sysmem=$(/usr/bin/free -m | /bin/awk '{if($1=="Mem:") {print $2,"MB"}}')
syscpu=$(/bin/cat /proc/cpuinfo | /bin/grep processor | wc -l)
# Bios Info
biosVendor=$(dmidecode --type=0 | /bin/grep -i vendor | /bin/awk -F: '{print $2}')
biosVersion=$(dmidecode --type=0 | /bin/grep -i version | /bin/awk -F: '{print $2}')
biosRelease=$(dmidecode --type=0 | /bin/grep -i release | /bin/awk -F: '{print $2}')
biosRevision=$(dmidecode --type=0 | /bin/grep -i revision | /bin/awk -F: '{print $2}')
#
syslspci=$(/sbin/lspci -nn > $OUTPUTDIR/lspci.$kernbase)
if [ -f /etc/fedora-release ]; then
sysrelease=$(/bin/cat /etc/fedora-release)
else
sysrelease=$(/bin/cat /etc/redhat-release)
fi
syscmdline=$(/bin/cat /proc/cmdline)
sysnmiint=$(/bin/cat /proc/interrupts | /bin/grep -i nmi)
sysmodprobe=$(/bin/cat /etc/modprobe.conf > $OUTPUTDIR/modprobe.$kernbase)
for x in $(/sbin/lsmod | /bin/cut -f1 -d" " 2>/dev/null | /bin/grep -v Module 2>/dev/null ); do
echo "Checking module information $x:" >> $OUTPUTDIR/modinfo.$kernbase
/sbin/modinfo $modarg $x >> $OUTPUTDIR/modinfo.$kernbase
if [ -n "$modarg2" ]; then
/sbin/modinfo $modarg2 $x >> $OUTPUTDIR/modinfo.$kernbase
fi
done
if [ -x /usr/sbin/sestatus ]; then
syssestatus=$(/usr/sbin/sestatus >> $OUTPUTDIR/selinux.$kernbase)
fi
if [ -x /usr/sbin/xm ]; then
syshypervisor=$(/usr/sbin/xm info >> $OUTPUTDIR/hypervisor.$kernbase)
fi
if [ -x /usr/sbin/semodule ]; then
echo "********* SELinux Module list **********" >> $OUTPUTDIR/selinux.$kernbase
syssemodulelist=$(/usr/sbin/semodule -l >> $OUTPUTDIR/selinux.$kernbase)
fi
sysderror=$(/bin/cat $OUTPUTDIR/boot.$kernbase | grep -i error | grep -v BIOS >> $OUTPUTDIR/derror.$kernbase)
sysderror1=$(/bin/grep -i collision $OUTPUTDIR/boot.$kernbase >> $OUTPUTDIR/derror.$kernbase)
sysderror2=$(/bin/grep -i fail $OUTPUTDIR/boot.$kernbase >> $OUTPUTDIR/derror.$kernbase)
sysderror3=$(/bin/grep -i temperature $OUTPUTDIR/boot.$kernbase >> $OUTPUTDIR/derror.$kernbase)
sysderror4=$(/bin/grep BUG: $OUTPUTDIR/boot.$kernbase >> $OUTPUTDIR/derror.$kernbase)
sysderror5=$(/bin/grep INFO: $OUTPUTDIR/boot.$kernbase >> $OUTPUTDIR/derror.$kernbase)
sysderror6=$(/bin/grep FATAL: $OUTPUTDIR/boot.$kernbase >> $OUTPUTDIR/derror.$kernbase)
sysderror7=$(/bin/grep WARNING: $OUTPUTDIR/boot.$kernbase >> $OUTPUTDIR/derror.$kernbase)
sysderror8=$(/bin/grep -i "command not found" $OUTPUTDIR/boot.$kernbase >> $OUTPUTDIR/derror.$kernbase)
sysderror9=$(/bin/cat $OUTPUTDIR/boot.$kernbase | grep avc: | grep -v granted >> $OUTPUTDIR/avcerror.$kernbase)
sysderror10=$(/bin/grep -i "Unknown symbol" $OUTPUTDIR/boot.$kernbase >> $OUTPUTDIR/serror.$kernbase)
echo "********** System Information **********" >> $OUTPUTFILE
echo "Hostname = $sysnode" >> $OUTPUTFILE
echo "Kernel Version = $syskernel" >> $OUTPUTFILE
echo "Machine Hardware Name = $sysmachine" >> $OUTPUTFILE
echo "Processor Type = $sysprocess" >> $OUTPUTFILE
echo "uname -a output = $sysuname" >> $OUTPUTFILE
echo "Swap Size = $sysswap" >> $OUTPUTFILE
echo "Mem Size = $sysmem" >> $OUTPUTFILE
echo "Number of Processors = $syscpu" >> $OUTPUTFILE
echo "System Release = $sysrelease" >> $OUTPUTFILE
echo "Command Line = $syscmdline" >> $OUTPUTFILE
echo "System NMI Interrupts = $sysnmiint" >> $OUTPUTFILE
echo "*********** BIOS Information ***********" >> $OUTPUTFILE
echo "Vendor = $biosVendor" >> $OUTPUTFILE
echo "Version = $biosVersion" >> $OUTPUTFILE
echo "Release = $biosRelease" >> $OUTPUTFILE
echo "Revision = $biosRevision" >> $OUTPUTFILE
echo "**************** LSPCI *****************" >> $OUTPUTFILE
/bin/cat $OUTPUTDIR/lspci.$kernbase >> $OUTPUTFILE
echo "*************** Modprob ****************" >> $OUTPUTFILE
/bin/cat $OUTPUTDIR/modprobe.$kernbase >> $OUTPUTFILE
echo "********** Module Information **********" >> $OUTPUTFILE
/bin/cat $OUTPUTDIR/modinfo.$kernbase >> $OUTPUTFILE
if [ -x /usr/sbin/sestatus ]; then
echo "************ SELinux Status ************" >> $OUTPUTFILE
/bin/cat $OUTPUTDIR/selinux.$kernbase >> $OUTPUTFILE
fi
echo "********** Interfaces Information **********" > ifcinfo
echo "-- /etc/resolv.conf --" >> ifcinfo
cat /etc/resolv.conf >> ifcinfo
echo "-- END of /etc/resolv.conf --" >> ifcinfo
echo "ip a" >> ifcinfo
ip a 2>&1 >> ifcinfo
echo "ip route" >> ifcinfo
ip route 2>&1 >> ifcinfo
local interfaces=`ip link show | grep '^[0-9]\+' | sed 's/^[0-9]\+: \([a-zA-Z0-9]\+\):.*/\1/'`
for i in $interfaces; do
echo "ethtool -i $i" >> ifcinfo
ethtool -i $i 2>&1 >> ifcinfo
done
cat ifcinfo >> $OUTPUTFILE
cat ifcinfo > /dev/console
if [ -x /usr/sbin/xm ]; then
echo "*********** Hypervisor info ************" >> $OUTPUTFILE
/bin/cat $OUTPUTDIR/hypervisor.$kernbase >> $OUTPUTFILE
fi
FAILURE=FALSE
# Check dmesg log for issues
dresult_count=0
if [ -s $OUTPUTDIR/derror.$kernbase ]; then
dresult_count=$(/usr/bin/wc -l $OUTPUTDIR/derror.$kernbase | awk '{print $1}')
echo "******** Potential Issues dmesg ********" >> $OUTPUTFILE
/bin/cat $OUTPUTDIR/derror.$kernbase >> $OUTPUTFILE
fi
# Check dmesg log for failures
if [ -s $OUTPUTDIR/serror.$kernbase ]; then
dresult_count=$(/usr/bin/wc -l $OUTPUTDIR/serror.$kernbase | awk '{print $1}')
echo "********** Failures in dmesg ***********" >> $OUTPUTFILE
/bin/cat $OUTPUTDIR/serror.$kernbase >> $OUTPUTFILE
FAILURE=TRUE
fi
# Check dmesg log for avc failures
if [ -s $FILEAREA/avcerror.$kernbase ]; then
echo "********* SElinux AVC Failures *********" >> $OUTPUTFILE
/bin/cat $FILEAREA/avcerror.$kernbase >> $OUTPUTFILE
FAILURE=TRUE
fi
echo "******** End System Information ********" >> $OUTPUTFILE
if [ -s $OUTPUTDIR/derror.$kernbase -o -s $OUTPUTDIR/serror.$kernbase -o -s $OUTPUTDIR/avcerror.$kernbase ]; then
result_count=$(/usr/bin/printf "%03d%03d%03d\n" $dresult_count 0 0)
if [ $FAILURE = TRUE ]; then
report_result $TEST/Sysinfo FAIL $result_count
else
report_result $TEST/Sysinfo PASS $result_count
fi
else
report_result $TEST/Sysinfo PASS 0
fi
DeBug "Exit SysReport"
}
function DiffDmesg ()
{
DeBug "Enter DiffDmesg"
DMESGDIFFLOG=`mktemp -p /mnt/testarea -t DMSGDIFF.XXXXXX`
filelist=`ls $OUTPUTDIR/boot.*`
hit=0
for l in $filelist ; do
hit=`expr $hit + 1`
export FILE$hit=$l
DeBug "$FILE$l"
done
echo "
===================================================================
diff -u $FILE1 $FILE2
===================================================================" | tee -a $DMESGDIFFLOG
/usr/bin/diff -u $FILE1 $FILE2 | tee -a $DMESGDIFFLOG
DeBug "/usr/bin/diff -u $FILE1 $FILE2"
sleep 3
SubmitLog $DMESGDIFFLOG
DeBug "Exit DiffDmesg"
}
function DiffLspci ()
{
DeBug "Enter DiffLspci"
LSPCIDIFFLOG=`mktemp -p /mnt/testarea -t LSPCIDIFF.XXXXXX`
filelist=`ls $OUTPUTDIR/lspci.*`
hit=0
for l in $filelist ; do
hit=`expr $hit + 1`
export FILE$hit=$l
DeBug "$FILE$l"
done
echo "
===================================================================
diff -u $FILE1 $FILE2
===================================================================" | tee -a $LSPCIDIFFLOG
/usr/bin/diff -u $FILE1 $FILE2 | tee -a $LSPCIDIFFLOG
DeBug "/usr/bin/diff -u $FILE1 $FILE2"
sleep 3
SubmitLog $LSPCIDIFFLOG
DeBug "Exit DiffLspci"
}
function RprtRslt ()
{
ONE=$1
TWO=$2
THREE=$3
# File the results in the database
report_result $ONE $TWO $THREE
if [ "$TWO" == "FAIL" ]; then
SubmitLog $DEBUGLOG
fi
}
function SubmitLog ()
{
LOG=$1
rhts_submit_log -l $LOG
}
function XendLogging ()
{
XENDCONF=/etc/sysconfig/xend
DeBug "Enter XendLogging"
if [ -e $XENDCONF ]; then
DeBug "$XENDCONF exists"
sed -i 's/#XENCONSOLED_LOG_HYPERVISOR=no/XENCONSOLED_LOG_HYPERVISOR=yes/g' $XENDCONF
sed -i 's/#XENCONSOLED_LOG_GUESTS=no/XENCONSOLED_LOG_GUESTS=yes/g' $XENDCONF
sed -i 's/#XENCONSOLED_LOG_DIR/XENCONSOLED_LOG_DIR/g' $XENDCONF
fi
DeBug "Exit XendLogging"
}
function LogBootloaderConfig ()
{
conf_files="/boot/grub2/grub.cfg /boot/grub/grub.conf /boot/efi/efi/redhat/elilo.conf
/boot/etc/yaboot.conf /etc/yaboot.conf /etc/zipl.conf"
for conf_file in $conf_files; do
if [ -f $conf_file ]; then
echo "----- $conf_file -----" | tee -a $DEBUGLOG
cat $conf_file | tee -a $DEBUGLOG
echo "----- $conf_file END -----" | tee -a $DEBUGLOG
fi
done
}
function SelectKernel ()
{
DeBug "Enter SelectKernel"
VR=$1
EXTRA=$2
DeBug "VR=$VR EXTRA=$EXTRA"
# If not version or Extra selected then choose the latest installed version
if [ -z "$EXTRA" -a -z "$VR" ]; then
DeBug "ERROR: missing args"
return 1
fi
# Workaround for broken RT kernel spec file, part 1
if [ "$EXTRA" = "rt" ]; then
DeBug "EXTRA=$EXTRA"
EXTRA=""
fi
# Workaround for broken RT kernel spec file, part 2
if [ "$EXTRA" = "rt-vanilla" -o "$EXTRA" = "rt-debug" -o "$EXTRA" = "rt-trace" ]; then
DeBug "Before EXTRA=$EXTRA"
# if it is MRG-2.x RHEL6
if $(rpm -qf /etc/redhat-release | grep -q "redhat-release-server-6"); then
if [ "${KVER::2}" = "3." ]; then
ZZZ=${EXTRA:3}
if [ "${KVER::3}" = "3.0" ]; then
# MRG-2.1
EXTRA=$ZZZ
else
# MRG-2.2 or newer
EXTRA=".x86_64.$ZZZ"
fi
else
# MRG-2.0
EXTRA=$(echo $EXTRA | awk -F- '{print $1 $2}')
fi
else
# MRG-1.x on RHEL 5
EXTRA=$(echo $EXTRA | awk -F- '{print $2}')
fi
DeBug "After EXTRA=$EXTRA"
fi
# Workaround for UP kernel spec file
if [ "$EXTRA" = "up" ]; then
DeBug "EXTRA=$EXTRA"
EXTRA=""
fi
echo "***** Attempting to switch boot kernel to ($VR$EXTRA) *****" | tee -a $OUTPUTFILE
DeBug "Attempting to switch boot kernel to ($VR$EXTRA)"
# if we have grubby, then let's use that
if command -v grubby >/dev/null 2>&1; then
SelectKernelGrubby $VR $EXTRA
ret=$?
else
SelectKernelLegacy $VR $EXTRA
ret=$?
fi
sync
sleep 5
DeBug "Exit SelectKernel"
return $ret
}
# Bug 798577 - ppc64: grubby/new-kernel-pkg fails to install new kernel
# There seem to be 2 issues, one in anaconda, one in grubby
function WorkaroundBug798577 ()
{
local VR=$1
local EXTRA=$2
local vmlinuz=$3
DeBug "WorkaroundBug798577: start <$VR> <$EXTRA> <$vmlinuz>"
uname -r | grep ppc64
if [ $? -ne 0 ]; then
DeBug "WorkaroundBug798577: this is not ppc64"
return 0
fi
cat /etc/redhat-release | grep "release 7"
if [ $? -ne 0 ]; then
DeBug "WorkaroundBug798577: this is not RHEL7"
return 0
fi
local initrd=$(rpm -ql $testkernbase.$kernarch | grep -e /initramfs-$VR | grep "$EXTRA" | awk '{print length"\t"$0}' | sort -n | cut -f2- | head -1)
DeBug "WorkaroundBug798577: vmlinuz=$vmlinuz"
DeBug "WorkaroundBug798577: initrd=$initrd"
if [ -n "$vmlinuz" -a -n "$initrd" ]; then
sed -i 's/image=vmlinu/image=\/vmlinu/' /etc/yaboot.conf
DeBug "/sbin/new-kernel-pkg --package kernel --install $VR.ppc64 --initrdfile=$initrd"
/sbin/new-kernel-pkg --package kernel --install $VR.ppc64 --initrdfile=$initrd
grubby --set-default "$vmlinuz"
cp -f /etc/yaboot.conf /boot/etc/yaboot.conf
ybin -v
default_vmlinuz=$(grubby --default-kernel)
DeBug "WorkaroundBug798577: grubby --default-kernel: $default_vmlinuz"
fi
DeBug "WorkaroundBug798577: end"
}
function update_console ()
{
# Xen uses com1 for ttyS0 and com2 for ttyS1
# com1 might be setup automatically *if* you installed xen from anaconda
# com2 is never set up correctly by anaconda.
# Take first serial console entry
console=$(awk '/console=ttyS/{for(i=1;i<=NF;++i)if($i~/console=ttyS[^ ]*/)print $i; exit}' /etc/grub.conf)
# Find our defult kernel
default_kernel=$(grubby --default-kernel)
# Get the serial settings
settings=$(echo $console | awk -F, '{ print $2 }' | sed -e 's/\([0-9]*\)\(.*\)/\1,\2/; s/n81/8n1/')
DeBug $console
if echo $console | grep -q ttyS0 ; then
# Configure com1, may already be done if installed xen from anaconda
DeBug "ttyS0 = com1"
grubby --mbargs com1=$settings --update-kernel=$default_kernel
elif echo $console | grep -q ttyS1 ; then
# Configure com2, change linux kernel console=ttyS1 to console=ttyS0
DeBug "ttyS1 = com2"
ttyS0=$(echo $console | sed -e 's/ttyS1/ttyS0/')
grubby --remove-mbargs com1=$settings --update-kernel=$default_kernel
grubby --mbargs com2=$settings --update-kernel=$default_kernel
grubby --mbargs console=com2L --update-kernel=$default_kernel
grubby --remove-args $console --update-kernel=$default_kernel
grubby --args $ttyS0 --update-kernel=$default_kernel
else
DeBug "Non-standard serial console"
fi
}
function SelectKernelGrubby ()
{
DeBug "Enter SelectKernelGrubby"
VR=$1
EXTRA=$2
DeBug "VR=$VR EXTRA=$EXTRA"
# We can only have one kernel on arm right now and grubby is busted
# until bz 751608 is fixed.
if [ "${ARCH}" = "armhfp" -o "${ARCH}" = "arm" ]; then
return 0
fi
# match vmlinuz with $VR and $EXTRA, take first shortest match
# try to find vmlinuz in kernel and kernel-core packages
local vmlinuz_kernel="$(rpm -ql $testkername-$KERNELARGVERSION.$kernarch | grep -e /vmlinu.-$VR | grep "$EXTRA" | awk '{print length"\t"$0}' | sort -n | cut -f2-)"
local vmlinuz_kernel_core="$(rpm -ql $testkername-core-$KERNELARGVERSION.$kernarch | grep -e /vmlinu.-$VR | grep "$EXTRA" | awk '{print length"\t"$0}' | sort -n | cut -f2-)"
if [ -e "/etc/grub.conf" ]; then
# If /etc/grub.conf exists, make sure the requested kernel exists in /etc/grub.conf
vmlinuz=$(for kernel in $vmlinuz_kernel $vmlinuz_kernel_core; do grep -q ${kernel#/boot} /etc/grub.conf && echo $kernel; done | head -1)
else
vmlinuz=$(echo $vmlinuz_kernel $vmlinuz_kernel_core | head -1)
fi
if [ -n "$vmlinuz" ]; then
grubby --set-default "$vmlinuz"
ret=$?
DeBug "grubby --set-default $vmlinuz returned: $ret"
default_vmlinuz=$(grubby --default-kernel)
DeBug "grubby --default-kernel: $default_vmlinuz"
LogBootloaderConfig
if [ "$EXTRA" == "xen" ]; then
update_console
fi
if [ "$default_vmlinuz" == "$vmlinuz" ]; then
DeBug "grubby reports correct kernel as default: $default_vmlinuz"
else
DeBug "grubby reports default kernel as: $default_vmlinuz, expected: $vmlinuz"
DeBug "trying WorkaroundBug798577"
WorkaroundBug798577 "$VR" "$EXTRA" "$vmlinuz"
LogBootloaderConfig
fi
if [ $ret -eq 0 ]; then
test "${ARCH}" = "s390" -o "${ARCH}" = "s390x" && zipl
fi
return $ret
fi
DeBug "ERROR: failed to find vmlinuz in rpm: $testkernbase.$kernarch"
return 1
}
function SelectKernelLegacy ()
{
DeBug "Enter SelectKernelLegacy"
VR=$1
EXTRA=$2
DeBug "VR=$VR EXTRA=$EXTRA"
grub_file=/boot/grub/grub.conf
if [ -f $grub_file ]; then
DeBug "Using: $grub_file"
COUNT=0
DEFAULT=undefined
for i in $(grep '^title' $grub_file | sed -e 's/.*(\(.*\)).*/\1/' -e "s/\.$(uname -m)*.//g"); do
DeBug "COUNT=$COUNT VR=$VR EXTRA=$EXTRA i=$i"
if [ "$VR$EXTRA" = "$i" ]; then
DEFAULT=$COUNT;
fi
COUNT=$(expr $COUNT + 1)
done
if [ $DEFAULT != "undefined" ]; then
DeBug "DEFAULT=$DEFAULT"
/bin/ed -s $grub_file <<EOF
/default/
d
i
default=$DEFAULT
.
w
q
EOF
fi
DeBug "$grub_file"
cat $grub_file | tee -a $DEBUGLOG
fi
elilo_file=/boot/efi/efi/redhat/elilo.conf
if [ -f $elilo_file ]; then
DeBug "Using: $elilo_file"
DEFAULT=$(grep -A 2 "image=vmlinuz-$VR$EXTRA$" $elilo_file | awk -F= '/label=/ {print $2}')
DeBug "DEFAULT=$DEFAULT"
if [ -n "$DEFAULT" ]; then
DeBug "DEFAULT=$DEFAULT"
/bin/ed -s $elilo_file <<EOF
/default/
d
i
default=$DEFAULT
.
w
q
EOF
fi
DeBug "$elilo_file"
cat $elilo_file | tee -a $DEBUGLOG
fi
yaboot_file=/boot/etc/yaboot.conf
if [ -f $yaboot_file ] ; then
DeBug "Using: $yaboot_file"
grep vmlinuz $yaboot_file
if [ $? -eq 0 ] ; then
VM=z
else
VM=x
fi
DeBug "VM=$VM"
DEFAULT=$(grep -A 1 "image=/vmlinu$VM-$VR.*$EXTRA" $yaboot_file | awk -F= '/label=/ {print $2}')
DeBug "DEFAULT=$DEFAULT"
if [ -n "$DEFAULT" ] ; then
sed -i 's/label=linux/label=orig-linux/g' $yaboot_file
sed -i 's/label='$DEFAULT'/label=linux/g' $yaboot_file
DeBug "DEFAULT=$DEFAULT"
grep -q label=linux $yaboot_file
if [ $? -ne 0 ] ; then
sed -i 's/label=orig-linux/label=linux/g' $yaboot_file
DeBug "Reverted back to original kernel"
fi
fi
DeBug "$yaboot_file"
cat $yaboot_file | tee -a $DEBUGLOG
fi
zipl_file=/etc/zipl.conf
if [ -f $zipl_file ] ; then
DeBug "Using: $zipl_file"
DEFAULT=$(grep "image=/boot/vmlinuz-$VR.*$EXTRA" $zipl_file | awk -Fvmlinuz- '/vmlinuz/ {printf "%.15s\n",$2}')
DeBug "DEFAULT=$DEFAULT"
if [ -n "$DEFAULT" ] ; then
DeBug "$VR$EXTRA"
tag=$(grep "\[$DEFAULT\]" $zipl_file)
DeBug "tag=$tag"
if [ -z "$tag" ] ; then
# This was added because BZ 426992 was fixed
DEFAULT=$(grep "image=/boot/vmlinuz-$VR.*$EXTRA" $zipl_file | awk -Fvmlinuz- '/vmlinuz/ {printf "%s\n",$2}')
DeBug "Second DEFAULT=$DEFAULT"
tag=$(grep "\[$DEFAULT\]" $zipl_file)
DeBug "Second tag=$tag"
if [ -z "$tag" ] ; then
DeBug "Setting it back to default"
DEFAULT=linux
fi
fi
/bin/ed -s $zipl_file <<EOF
/default=/
d
i
default=$DEFAULT
.
w
q
EOF
zipl
fi
DeBug "$zipl_file"
cat $zipl_file | tee -a $DEBUGLOG
fi
return 0
}
function CheckKernel ()
{
DeBug "Enter CheckKernel"
KVER=$1
KVAR=$2
DeBug "Before KVER=$KVER KVAR=$KVAR"
# Workaround for broken RT kernel spec file, part 1
if [ "$KVAR" = "rt" ]; then
DeBug "KVAR=$KVAR"
KVAR=""
fi
# Workaround for broken RT kernel spec file, part 2
if [ "$KVAR" = "rt-vanilla" -o "$KVAR" = "rt-debug" -o "$KVAR" = "rt-trace" ]; then
DeBug "Before KVAR=$KVAR"
# if it is MRG-2.x RHEL6
if $(rpm -qf /etc/redhat-release | grep -q "redhat-release-server-6"); then
if [ "${KVER::2}" = "3." ]; then
# MRG-2.1 or newer
KVAR="${KVAR:3}"
else
# MRG-2.0
KVAR=$(echo $KVAR | awk -F- '{print $1 $2}')
fi
else
# MRG-1.x o RHEL 5
KVAR=$(echo $KVAR | awk -F- '{print $2}')
fi
DeBug "After KVAR=$KVAR"
fi
# Workaround for UP kernel spec file
if [ "$KVAR" = "up" ]; then
DeBug "KVAR=$KVAR"
KVAR=""
fi
DeBug "After KVER=$KVER KVAR=$KVAR"
if [ "$KVER$KVAR" != "$runkernel" ]; then
DeBug "Requested kernel != Running kernel"
DeBug " $KVER$KVAR != $runkernel"
return 1
else
DeBug "Requested kernel = Running kernel"
DeBug " $KVER$KVAR = $runkernel"
return 0
fi
DeBug "Exit CheckKernel"
}
function YumInstallKernel ()
{
# Check and see if the kernel available for install from a repo
# yum list available checks nvr, and will refuse to show older one by default
# so let's use yum list all instead
DeBug "Enter YumInstallPackage"
echo "***** Install kernel via yum $testkernbase.$kernarch *****" | tee -a $OUTPUTFILE
DeBug "Yum install $testkernbase.$kernarch"
$yumcmd list all $testkernbase.$kernarch | grep -q $testkername.$kernarch
if [ "$?" -eq "0" ]; then
# Install the kernel from yum repo
$yumcmd -y install $testkernbase.$kernarch
if [ "$?" -ne "0" ]; then
echo "***** Yum returned an error while trying to install $testkernbase.$kernarch *****" | tee -a $OUTPUTFILE
DeBug "Exit YumInstallPackage FAIL 3 (YUM exited with a failure)"
return 3
else
# Check to see if the kernel is now installed, using yum
$yumcmd list installed $testkernbase.$kernarch | grep -q installed
if [ "$?" -ne "0" ]; then
# Double check, this time using rpm
rpm -qa --queryformat '%{name}-%{version}-%{release}.%{arch}\n' | grep -q $testkernbase.$kernarch
if [ "$?" -ne "0" ]; then
echo "***** Failed to find $testkernbase.$kernarch in installed *****" | tee -a $OUTPUTFILE
DeBug "Exit YumInstallPackage FAIL 4 (Thought we installed but can't find it)"
return 4
fi
fi
fi
$yumcmd -y install $testkerndevel.$kernarch
else
DeBug "Exit YumInstallPackage FAIL 5 (Can't find kernel in repo)"
return 5
fi
DeBug "Exit YumInstallPackage SUCCESS"
return 0
}
function BrewInstallKernel ()
{
# Is the kernel available for install from a BREW
DeBug "Enter BrewInstallPackage"
# install kernel-firmware first if there is one.
if curl -s $httpbase/noarch/$testkernfirmware.noarch.rpm -o /dev/null -f; then
kernfwprpm="$httpbase/noarch/$testkernfirmware.noarch.rpm"
elif curl -s $archbase/noarch/$testkernfirmware.noarch.rpm -o /dev/null -f; then
kernfwprpm="$archbase/noarch/$testkernfirmware.noarch.rpm"
fi
yum -y localinstall --nogpgcheck $kernfwprpm
DeBug "$httpbase/$kernarch/$testkernbase.$kernarch.rpm"
echo "***** Install kernel via BREW $testkernbase.$kernarch.rpm *****" | tee -a $OUTPUTFILE
if curl -s $httpbase/$kernarch/$testkernbase.$kernarch.rpm -o /dev/null -f; then
rpm -ivh $httpbase/$kernarch/$testkernbase.$kernarch.rpm
if [ "$?" -ne "0" ]; then
DeBug "Forcing the rpm command --force"
rpm -ivh --force $httpbase/$kernarch/$testkernbase.$kernarch.rpm
if [ "$?" -ne "0" ]; then
DeBug "Exit BrewInstallPackage FAIL 6"
return 6
fi
fi
rpm -ivh $httpbase/$kernarch/$testkerndevel.$kernarch.rpm
DeBug "Exit BrewInstallPackage SUCCESS"
elif curl -s $archbase/$kernarch/$testkernbase.$kernarch.rpm -o /dev/null -f; then
DeBug "Installing the rpm from the kernelarchive."
rpm -ivh $archbase/$kernarch/$testkernbase.$kernarch.rpm
if [ "$?" -ne "0" ]; then
DeBug "Forcing the rpm command --force"
rpm -ivh --force $archbase/$kernarch/$testkernbase.$kernarch.rpm
if [ "$?" -ne "0" ]; then
DeBug "Exit BrewInstallPackage FAIL 6"
return 6
fi
fi
rpm -ivh $archbase/$kernarch/$testkerndevel.$kernarch.rpm
DeBug "Exit BrewInstallPackage SUCCESS"
else
DeBug "can't find the package in brew ... FAIL"
return 1
fi
return 0
}
function YumUpgradeKernelHeaders ()
{
KERNELHEADERS=kernel-headers-$testkernver-$testkernrel
# Check and see if the kernel-headers are available for install from a repo
# yum list available checks nvr, and will refuse to show older one by default,
# so let's use yum list all instead
DeBug "Enter YumUpgradeKernelHeaders"
echo "***** Upgrade $KERNELHEADERS via yum *****" | tee -a $OUTPUTFILE
REBOOT_TIME=$(cat /mnt/testarea/kernelinstall_reboottime.log)
DIFF=$(expr ${CUR_TIME} - ${REBOOT_TIME})
if [[ ${DIFF} -gt 480 ]]; then
let DIFF_MIN=$DIFF/60
let DIFF_SEC=$DIFF%60
echo "***** WARN: Task took ${DIFF_MIN} minutes and ${DIFF_SEC} second(s) to run *****" >> $OUTPUTFILE
fi
DeBug "Yum upgrade $KERNELHEADERS"
$yumcmd list all $KERNELHEADERS | grep -q $testkernver-$testkernrel
if [ "$?" -eq "0" ]; then
# Install the kernel-headers from yum repo
$yumcmd -y upgrade $KERNELHEADERS
if [ "$?" -ne "0" ]; then
echo "***** Yum returned an error while trying to upgrade $KERNELHEADERS *****" | tee -a $OUTPUTFILE
DeBug "Exit YumUpgradeKernelHeaders FAIL 3 (YUM exited with a failure)"
return 3
else
# Check to see if the kernel-headers is now installed, using yum
$yumcmd list installed $KERNELHEADERS | grep -q installed
if [ "$?" -ne "0" ]; then
# Double check, this time using rpm
rpm -qa --queryformat '%{name}-%{version}-%{release}\n' | grep -q $KERNELHEADERS
if [ "$?" -ne "0" ]; then
echo "***** Failed to find $KERNELHEADERS in installed *****" | tee -a $OUTPUTFILE
DeBug "Exit YumInstallPackage FAIL 4 (Thought we installed but can't find it)"
return 4
fi
fi
fi
else
DeBug "Exit YumUpgradeKernelHeaders FAIL 5 (Can't find kernel in repo)"
return 5
fi
DeBug "Exit YumUpgradeKernelHeaders SUCCESS"
return 0
}
function DepmodChk ()
{
DeBug "Enter DepmodChk"
DEPCHKFILE=`mktemp /tmp/tmp.XXXXXX`
DeBug "DEPCHKFILE=$DEPCHKFILE"
/sbin/depmod -ae -F /boot/System.map-`uname -r` `uname -r` > $DEPCHKFILE 2>&1
if [ -s $DEPCHKFILE ] ; then
DeBug "$DEPCHKFILE > 0"
total=`cat $DEPCHKFILE | wc -l`
OUTPUTFILE=`mktemp /tmp/tmp.XXXXXX`
echo "***** List of Warnings/Errors reported by depmod *****" | tee -a $OUTPUTFILE
cat $DEPCHKFILE | tee -a $OUTPUTFILE
echo "***** End of list *****" | tee -a $OUTPUTFILE
report_result $TEST/depmod FAIL $total
fi
DeBug "Exit DepmodChk"
}
function NukeRepo ()
{
DeBug "Enter NukeRepo"
if [ -e /etc/yum.repos.d/rhel-beta.repo ] ; then
DeBug "beta repo existed, moving it to tmp"
mv -f /etc/yum.repos.d/rhel-beta.repo /tmp
yum clean all
fi
DeBug "Exit NukeRepo"
}
fix_bootif ()
{
local macaddr=${1}
local IFS='-'
macaddr=$(for i in ${macaddr} ; do echo -n $i:; done)
macaddr=${macaddr%:}
# strip hardware type field from pxelinux
[ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:}
# return macaddr with lowercase alpha characters expected by udev
echo $macaddr | sed 'y/ABCDEF/abcdef/'
}
function workaround_bug905918 ()
{
echo "Enter workaround_bug905918" >> $OUTPUTFILE
cat /etc/redhat-release | grep "release 7"
if [ $? -ne 0 ]; then
echo "This is not RHEL7, exiting"
return
fi
local cmdline=`grep "Command line" /var/log/anaconda/syslog | head -1`
local BOOTIF=`echo $cmdline | grep -o "BOOTIF=[0-9a-zA-Z:-]\+" | sed 's/BOOTIF=//'`
# command line
echo $cmdline | grep "ip=" 2>&1 >/dev/null
if [ $? -eq 0 ]; then
echo "ip= present on command line, exiting" >> $OUTPUTFILE
return
fi
# kickstart
if [ ! -f /root/anaconda-ks.cfg ]; then
echo "Could not find /root/anaconda-ks.cfg, exiting" >> $OUTPUTFILE
return
fi
grep "^network" /root/anaconda-ks.cfg | grep device
if [ $? -eq 0 ]; then
echo "device= present in kickstart network option, exiting" >> $OUTPUTFILE
return
fi
if [ -z "$BOOTIF" ]; then
echo "Could not find BOOTIF in /var/log/anaconda/syslog" >> $OUTPUTFILE
return
fi
BOOTIF=$(fix_bootif "$BOOTIF")
echo "Fixed up BOOTIF: $BOOTIF" >> $OUTPUTFILE
ip a s up | grep $BOOTIF 2>&1 >/dev/null
if [ $? -ne 0 ]; then
echo "Could not find any interface with this MAC, exiting" >> $OUTPUTFILE
return
fi
local ifcfg_mask="/etc/sysconfig/network-scripts/ifcfg-"
for ifcfg in $ifcfg_mask*; do
local ifc=`echo $ifcfg | sed "s|$ifcfg_mask||"`
if [ "$ifc" == "lo" ]; then
continue
fi
grep -l -i "$BOOTIF" $ifcfg 2>&1 >/dev/null
if [ $? -ne 0 ]; then
echo "Setting ONBOOT=no for $ifcfg" >> $OUTPUTFILE
sed -i 's/ONBOOT=.*/ONBOOT=no/' $ifcfg
restorecon $ifcfg
echo "Turning off interface (ip link set down): $ifc" >> $OUTPUTFILE
ip link set down $ifc
fi
done
#wait for NetworkManager to process new config
sleep 60
date >> $OUTPUTFILE
ls -la /etc/resolv.conf >> $OUTPUTFILE
echo "-- /etc/resolv.conf --"
cat /etc/resolv.conf >> $OUTPUTFILE
echo "-- END of /etc/resolv.conf --"
echo "Exiting workaround_bug905918" >> $OUTPUTFILE
}
function workaround_bug905910 ()
{
# Bug 905910 - X.509: Cert # is not yet valid
local ret=0
OUTPUTFILE=`mktemp /tmp/tmp.XXXXXX`
echo "Enter workaround_bug905910" >> $OUTPUTFILE
if [ -f $OUTPUTDIR/boot.$kernbase ]; then
grep -e "X.509: Cert [0-9a-fA-F]* is not yet valid" $OUTPUTDIR/boot.$kernbase > /dev/null
if [ $? -eq 0 ]; then
echo "Changing hwclock to UTC" | tee -a $OUTPUTFILE
hwclock --systohc --utc >> $OUTPUTFILE 2>&1
ret=$?
cat /etc/adjtime | tee -a $OUTPUTFILE
echo "Exiting workaround_bug905910" >> $OUTPUTFILE
RprtRslt $TEST/set-hwclock WARN $ret
if [ $ret -eq 0 ]; then
rhts-reboot
fi
else
echo "Kernel seems happy about Cert start date, not doing anything" | tee -a $OUTPUTFILE
fi
fi
echo "Exiting workaround_bug905910" >> $OUTPUTFILE
}
function CheckCPUcount ()
{
# BZ1050040 http://patchwork.lab.bos.redhat.com/patch/74358/
# This function checks to see if the CPU count value
# has changed between the base kernel and test kernel.
# If the maxcpu option is used on the
# kernel command line, then skip this check.
local maxcpuCheck=$(/bin/cat /proc/cmdline | grep -q maxcpu)$?
local system=$(/bin/uname -n)
DeBug "Enter CheckCPUcount"
# Check for use of kernel commandline maxcpu option
if [ "$maxcpuCheck" -gt "0" ]; then
# The maxcpu option is not in use.
# Lets check the CPU count.
if [ "$REBOOTCOUNT" -eq "0" ]; then
# Lets get the CPU count for the base kernel.
# We will save the base kernel variables, in order to survive a reboot.
/bin/uname -r > /mnt/testarea/base_kernelSaved
/bin/cat /proc/cpuinfo | /bin/grep ^processor | wc -l > /mnt/testarea/cpuCountSaved
local base_kernel=$(/bin/cat /mnt/testarea/base_kernelSaved)
local base_kernel_cpuCount=$(/bin/cat /mnt/testarea/cpuCountSaved)
DeBug " Check the system CPU count for kernel-${base_kernel}"
echo "" >> $OUTPUTFILE
echo "***** Check the system CPU count for kernel-${base_kernel} *****" >> $OUTPUTFILE
echo "***** CPU count for kernel-${base_kernel} is: $base_kernel_cpuCount *****" >> $OUTPUTFILE
echo "" >> $OUTPUTFILE
else
# A reboot was expected, as we are booting a new kernel for testing.
# Lets get the CPU count for the test kernel.
# Then lets compare the base kernel and test kernel values.
local test_kernel=$(/bin/uname -r)
local test_kernel_cpuCount=$(/bin/cat /proc/cpuinfo | /bin/grep ^processor | wc -l)
# Lets restore the saved base_kernel variables
local base_kernel=$(/bin/cat /mnt/testarea/base_kernelSaved)
local base_kernel_cpuCount=$(/bin/cat /mnt/testarea/cpuCountSaved)
DeBug " Check and compare base_kernel_cpuCount and test_kernel_cpuCount values"
echo "" >> $OUTPUTFILE
echo "***** Comparing the CPU counts taken for the base kernel and test kernel *****" >> $OUTPUTFILE
if [ "$base_kernel_cpuCount" -eq "$test_kernel_cpuCount" ]; then
DeBug " INFO: $system CPU count has not changed"
echo "***** INFO: $system CPU count has not changed *****" >> $OUTPUTFILE
echo "" >> $OUTPUTFILE
else
# Lets WARN the user, report the status, and continue testing.
DeBug " WARN: CPU count has changed"
echo "***** kernel-${base_kernel} showed a CPU count of: $base_kernel_cpuCount *****" >> $OUTPUTFILE
echo "***** kernel-${test_kernel} showed a CPU count of: $test_kernel_cpuCount *****" >> $OUTPUTFILE
K_ReportStatus "Warn" "$system CPU count has changed" "CheckCPUcount"
echo "" >> $OUTPUTFILE
fi
fi
else
# The kernel command line contains the maxcpu option.
# Display a notification and continue testing.
DeBug " INFO: /proc/cmdline has the maxcpu option"
echo "" >> $OUTPUTFILE
echo "***** INFO: /proc/cmdline has the maxcpu option *****" >> $OUTPUTFILE
echo "" >> $OUTPUTFILE
fi
DeBug "Exit CheckCPUcount"
}
function Main ()
{
DeBug "Enter Main"
# Seed the log with an initial entry
echo "***** Start of kernel install test *****" | tee -a $OUTPUTFILE
# RHEL6-Beta repo workaround
NukeRepo
# Enable the Hypervisor and Console logging for xen tests
XendLogging
# workaround Bug 905918 - set ONBOOT=yes only for interfaces used during installation
workaround_bug905918
# CheckCPU count with base kernel
CheckCPUcount
# Check to see if the kernel we want to test is already running
CheckKernel $KERNELARGVERSION $KERNELARGVARIANT
if [ "$?" = "1" ]; then
# Check to see if the kernel we want to test is already installed
rpm -qa --queryformat '%{name}-%{version}-%{release}.%{arch}\n' | grep -q $testkernbase.$kernarch
if [ "$?" -ne "0" ]; then
# Install kernel variant from yum repo
YumInstallKernel
if [ "$?" -ne "0" ]; then
echo "***** Could not install from yum repo trying rpm -ivh from BREW *****" | tee -a $OUTPUTFILE
# Install from yum failed lets try direct from brew
BrewInstallKernel
if [ "$?" -ne "0" ]; then
RprtRslt $TEST/BrewInstallkernel FAIL $?
RHTSAbort
fi
fi
fi
# Lets make it our default boot kernel the kernel we want to test
SelectKernel $KERNELARGVERSION $KERNELARGVARIANT
if [ "$?" -ne "0" ]; then
RprtRslt $TEST/SelectKernel FAIL $?
else
# Now that the kernel is our default... Let's reboot
echo "***** End of kernel install test *****" | tee -a $OUTPUTFILE
if [ -f $OUTPUTDIR/boot.$kernbase ]; then
SubmitLog $OUTPUTDIR/boot.$kernbase
fi
SubmitLog $DEBUGLOG
RprtRslt $TEST/rhts-reboot PASS 0
date --date="$(date --utc)" +%s > /mnt/testarea/kernelinstall_reboottime.log
rhts-reboot
fi
else
echo "***** The running kernel is the kernel we want to test *****" | tee -a $OUTPUTFILE
echo "***** End of kernel install test *****" | tee -a $OUTPUTFILE
if [ -f $OUTPUTDIR/boot.$kernbase ]; then
SubmitLog $OUTPUTDIR/boot.$kernbase
fi
RprtRslt $TEST/$kernbase PASS $REBOOTCOUNT
DepmodChk
SysReport
exit 0
fi
}
# Record the test version in the debuglog
testver=$(rpm -qf $0)
DeBug "$testver"
# Current kernel variables
runkernel=$K_RUNNING_VR
kernbase=$(rpm -q --queryformat '%{name}-%{version}-%{release}\n' -qf /boot/config-$(uname -r))
kernver=$(rpm -q --queryformat '%{version}\n' -qf /boot/config-$(uname -r))
kernrel=$(rpm -q --queryformat '%{release}\n' -qf /boot/config-$(uname -r))
kernarch=$(rpm -q --queryformat '%{arch}\n' -qf /boot/config-$(uname -r))
kernvariant=$(uname -r | sed -e "s/${kernver}-${kernrel}//g" -e "s/\.$(uname -m).//g")
# drop -core- from name if present, this is to deal with meta-style
# packaging of kernel RPMs. Removing it here should be OK
# because kernbase is used only for naming of log/result files
kernbase=$(echo $kernbase | sed 's/-core-/-/')
DeBug "Running kernel variables"
DeBug "RUNNINGKERNEL=$runkernel"
DeBug "1=$kernbase 2=$kernver 3=$kernrel 4=$kernarch 5=$kernvariant"
# Test ARGS that are defined
DeBug "TEST ARGS (Environment variables)"
DeBug "1=$KERNELARGNAME 2=$KERNELARGVARIANT 3=$KERNELARGVERSION"
# New kernel variables
if [ "$KERNELARGVARIANT" == "up" ]; then
DeBug "Running up variant, or newer smp"
testkernbase=$KERNELARGNAME-$KERNELARGVERSION
testkername=$KERNELARGNAME
testkernver=$(echo $KERNELARGVERSION | awk -F- '{print $1}')
testkernrel=$(echo $KERNELARGVERSION | awk -F- '{print $2}')
testkerndevel=$KERNELARGNAME-devel-$KERNELARGVERSION
testkerneluname=$KERNELARGVERSION
DeBug "Test kernel variables"
DeBug "1=$testkernbase 2=$testkername 3=$testkernver 4=$testkernrel 5=$testkerndevel"
else
testkernbase=$KERNELARGNAME-$KERNELARGVARIANT-$KERNELARGVERSION
testkername=$KERNELARGNAME-$KERNELARGVARIANT
testkernver=$(echo $KERNELARGVERSION | awk -F- '{print $1}')
testkernrel=$(echo $KERNELARGVERSION | awk -F- '{print $2}')
testkernvariant=$KERNELARGVARIANT
testkerndevel=$KERNELARGNAME-$KERNELARGVARIANT-devel-$KERNELARGVERSION
testkerneluname=$KERNELARGVERSION$KERNELARGVARIANT
DeBug "Test kernel variables, in the else statement"
DeBug "1=$testkernbase 2=$testkername 3=$testkernver 4=$testkernrel 5=$testkernvariant 6=$testkerndevel"
fi
testkernfirmware=kernel-firmware-$KERNELARGVERSION
# Determine if we are on RHEL5 distro
DeBug "Setting the default yum command"
yumcmd="yum"
DeBug "Setting the default CheckKernel Options"
OPTIONSCheckKernel="$KERNELARGVERSION $KERNELARGVARIANT"
RHEL5TREE=$(rpm -qf /etc/redhat-release | grep -q "redhat-release-5")
if [ "$RHE5TREE" == "0" ] ; then
DeBug "Running on RHEL5 Distribution"
DeBug "Override yum command"
yumcmd="yum --noplugins"
fi
RHEL6TREE=$(cat /etc/redhat-release | grep -q "Santiago")
if [ "$RHEL6TREE" == "0" ] ; then
DeBug "Running on RHEL6 Distribution"
DeBug "Override yum command"
yumcmd="yum --noplugins"
fi
# Generic test variables
httpbase=http://download.lab.bos.redhat.com/brewroot/packages/$KERNELARGNAME/$testkernver/$testkernrel
archbase=http://download.lab.bos.redhat.com/brewroot/vol/kernelarchive/packages/$KERNELARGNAME/$testkernver/$testkernrel
if [ "$KERNELARGVARIANT" = "rt-vanilla" -o "$KERNELARGVARIANT" = "rt-debug" -o "$KERNELARGVARIANT" = "rt-trace" -o "$KERNELARGVARIANT" = "rt" ]; then
DeBug "Setting up HTTPBASE and Firmware for RT kernels"
httpbase=http://download.lab.bos.redhat.com/brewroot/packages/$KERNELARGNAME-rt/$testkernver/$testkernrel
testkernfirmware=kernel-rt-firmware-$KERNELARGVERSION
fi
if [ -z "$OUTPUTDIR" ]; then
OUTPUTDIR=/mnt/testarea
fi
# Record lspci -xxx -vv
if [ -x /sbin/lspci ]; then
/sbin/lspci -xxx -vv > $OUTPUTDIR/lspci.hexdump.$kernbase
SubmitLog $OUTPUTDIR/lspci.hexdump.$kernbase
fi
# Record the boot messages
/bin/dmesg > $OUTPUTDIR/boot.$kernbase
if [ ! -s $OUTPUTDIR/boot.$kernbase ]; then
# Workaround for /distribution/install zeroing out the dmesg file
cp $OUTPUTDIR/boot.messages $OUTPUTDIR/boot.$kernbase
fi
if [ -z "$KERNELARGNAME" -o -z "$KERNELARGVARIANT" -o -z "$KERNELARGVERSION" ]; then
echo "***** Test argument(s) are empty! Can't continue. *****" | tee -a $OUTPUTFILE
DeBug "name=$KERNELARGNAME variant=$KERNELARGVARIANT version=$KERNELARGVERSION"
RprtRslt $TEST/$kernbase FAIL 1
exit 0
else
if [ "$REBOOTCOUNT" == "0" ]; then
Main
elif [ "$REBOOTCOUNT" == "1" ]; then
if [ -f $OUTPUTDIR/boot.$kernbase ]; then
SubmitLog $OUTPUTDIR/boot.$kernbase
fi
DeBug "Running CheckKernel $OPTIONSCheckKernel"
CheckKernel $OPTIONSCheckKernel
if [ "$?" = "1" ]; then
DeBug "After reboot we are still not running the correct kernel"
RprtRslt $TEST/$kernbase FAIL $REBOOTCOUNT
RHTSAbort
else
DeBug "After reboot we are running the correct kernel"
# CheckCPU count with test kernel
CheckCPUcount
YumUpgradeKernelHeaders
REBOOT_TIME=$(cat /mnt/testarea/kernelinstall_reboottime.log)
DIFF=$(expr ${CUR_TIME} - ${REBOOT_TIME})
if [[ ${DIFF} -gt 480 ]]; then
DeBug "rhts-reboot took ${DIFF} seconds..."
RprtRslt $TEST/${kernbase}_boot WARN $DIFF
fi
RprtRslt $TEST/$kernbase PASS $DIFF
DepmodChk
DiffDmesg
if [ -x /sbin/lspci ]; then
DiffLspci
fi
SysReport
fi
SubmitLog $DEBUGLOG
workaround_bug905910
else
if [ -f $OUTPUTDIR/boot.$kernbase ]; then
SubmitLog $OUTPUTDIR/boot.$kernbase
fi
RprtRslt $TEST/boot PASS 0
fi
fi
|