-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
keywords.robot
1696 lines (1551 loc) · 71.7 KB
/
keywords.robot
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
*** Settings ***
Library Collections
Library OperatingSystem
Resource pikvm-rest-api/pikvm_comm.robot
Resource lib/bios/menus.robot
Resource lib/secure-boot-lib.robot
Resource lib/usb-hid-msc-lib.robot
Resource lib/dts-lib.robot
Resource lib/terminal.robot
Resource lib/esp-scanning-lib.robot
Resource lib/dl-cache.robot
Resource lib/dmidecode-lib.robot
Resource lib/docks.robot
Resource lib/flash.robot
Resource lib/self-tests.robot
Resource lib/sleep-lib.robot
Resource lib/CPU-performance-lib.robot
Resource lib/framework.robot
Resource lib/me.robot
Resource lib/network.robot
Variables platform-configs/fan-curve-config.yaml
*** Keywords ***
# TODO: split this file into some manageable modules
Serial Setup
[Documentation] Setup serial communication via telnet. Takes host and
... ser2net port as an arguments.
[Arguments] ${host} ${s2n_port}
# provide ser2net port where serial was redirected
Telnet.Open Connection
... ${host}
... port=${s2n_port}
... newline=LF
... terminal_emulation=True
... terminal_type=vt100
... window_size=400x100
Telnet.Set Timeout 180s
Login To Linux
[Documentation] Universal login to one of the supported linux systems:
... Ubuntu or Debian.
IF '${DUT_CONNECTION_METHOD}' == 'pikvm'
# On laptopts, we have serial over EC from firmware only, so we will
# not have Linux prompt. We try logging in multiple times anyway, so
# this should not be a huge problem.
# Read From Terminal Until login:
Set Global Variable ${DUT_CONNECTION_METHOD} SSH
END
IF '${DUT_CONNECTION_METHOD}' == 'SSH'
Wait Until Keyword Succeeds
... 3x
... 0
... Login To Linux Via SSH
... ${DEVICE_UBUNTU_USERNAME}
... ${DEVICE_UBUNTU_PASSWORD}
ELSE IF '${DUT_CONNECTION_METHOD}' == 'open-bmc'
Login To Linux Via OBMC root root
ELSE
Login To Linux Over Serial Console ${DEVICE_UBUNTU_USERNAME} ${DEVICE_UBUNTU_PASSWORD}
END
Login To Linux Via OBMC
[Documentation] Login to Linux via OBMC
[Arguments] ${username} ${password} ${timeout}=300s
Set DUT Response Timeout ${timeout}
Read From Terminal Until debian login:
Write Into Terminal ${username}
Read From Terminal Until Password:
Write Into Terminal ${password}
Set Prompt For Terminal root@debian:~#
Read From Terminal Until Prompt
Login To Windows
[Documentation] Universal login to Windows.
Boot System Or From Connected Disk ${OS_WINDOWS}
# TODO: We need a better way of switching between SSH and serial inside tests
IF '${DUT_CONNECTION_METHOD}' == 'pikvm'
Set Test Variable ${DUT_CONNECTION_METHOD} SSH
END
IF '${DUT_CONNECTION_METHOD}' == 'Telnet'
Set Test Variable ${DUT_CONNECTION_METHOD} SSH
END
IF '${DUT_CONNECTION_METHOD}' == 'SSH'
Login To Windows Via SSH ${DEVICE_WINDOWS_USERNAME} ${DEVICE_WINDOWS_PASSWORD}
ELSE
Fail Login to Windows not supported. DUT_CONNECTION_METHOD must be set to SSH.
END
Serial Root Login Linux
[Documentation] Universal telnet login to one of supported linux systems:
... Ubuntu, Voyage, Xen or Debian.
[Arguments] ${password}
Telnet.Set Timeout 300
Telnet.Set Prompt \~#
${output}= Telnet.Read Until login:
${status1}= Evaluate "voyage" in """${output}"""
${status2}= Evaluate "debian login" in """${output}"""
${status3}= Evaluate "ubuntu login" in """${output}"""
${passwd}= Set Variable If ${status1} voyage
... ${status2} debian
... ${status3} ubuntu
... ${password}
Telnet.Write Bare \n
Telnet.Login root ${passwd}
Serial User Login Linux
[Documentation] Universal telnet login to Linux system
[Arguments] ${password}
Telnet.Set Prompt :~$
Telnet.Set Timeout 300
Telnet.Login user ${password}
# To Do: unify with keyword: Serial root login Linux
Login To Linux Over Serial Console
[Documentation] Login to Linux over serial console, using provided
... arguments as username and password respectively. The
... optional timeout parameter can be used to specify how
... long we want to wait for the login prompt.
[Arguments] ${username}
... ${password}
... ${device_ubuntu_user_prompt}=${device_ubuntu_user_prompt}
... ${timeout}=300
Set DUT Response Timeout ${timeout} seconds
Telnet.Read Until login:
Telnet.Write ${username}
Telnet.Read Until Password:
Telnet.Write ${password}
Telnet.Set Prompt ${device_ubuntu_user_prompt} prompt_is_regexp=False
Telnet.Read Until Prompt
Login To Linux Via SSH
[Documentation] Login to Linux via SSH by using provided arguments as
... username and password respectively. The optional timeout
... parameter can be used to specify how long we want to
... wait for the login prompt.
[Arguments] ${username} ${password} ${timeout}=180 ${prompt}=${DEVICE_UBUNTU_USER_PROMPT}
Should Not Be Empty ${DEVICE_IP} msg=DEVICE_IP variable must be defined
# We need this when switching from PiKVM to SSH
Remap Keys Variables From PiKVM
SSHLibrary.Open Connection ${DEVICE_IP} prompt=${prompt}
SSHLibrary.Set Client Configuration
... timeout=${timeout}
... term_type=vt100
... width=400
... height=100
... escape_ansi=True
... newline=LF
Wait Until Keyword Succeeds 120x 1s
... SSHLibrary.Login ${username} ${password}
Login To Windows Via SSH
[Documentation] Login to Windows via SSH by using provided arguments as
... username and password respectively. The optional timeout
... parameter can be used to specify how long we want to
... wait for the login prompt.
[Arguments] ${username}=${DEVICE_WINDOWS_USERNAME} ${password}=${DEVICE_WINDOWS_PASSWORD} ${timeout}=180
SSHLibrary.Open Connection ${DEVICE_IP} prompt=${DEVICE_WINDOWS_USER_PROMPT}
SSHLibrary.Set Client Configuration
... timeout=${timeout}
... term_type=vt100
... width=400
... height=100
... escape_ansi=True
... newline=CRLF
FOR ${reboot_count} IN RANGE 3
${login}= Run Keyword And Return Status
... Wait Until Keyword Succeeds 5x 10s
... SSHLibrary.Login ${username} ${password}
IF ${login} == ${TRUE}
BREAK
ELSE
IF ${reboot_count} == 2
Fail
... SSH: Unable to connect - The platform may be in Windows "Recovery Mode" - Rebooted ${reboot_count} times.
END
Power On
# TODO: This keyword needs improved. We could simply lock the whole
# power on - login procedure in single keyword, and use
# Run Keyword Until Succeeds?
Restore Initial DUT Connection Method
Boot System Or From Connected Disk ${OS_WINDOWS}
Set Test Variable ${DUT_CONNECTION_METHOD} SSH
END
END
IF ${reboot_count} >= 1
Log Windows "Recovery Mode" Workaround - Rebooted ${reboot_count} times. WARN
END
Login To Linux Via SSH Without Password
[Documentation] Login to Linux via SSH without password
[Arguments] ${username} ${prompt}
Login To Linux Via SSH ${username} ${EMPTY} prompt=${prompt}
Switch To Root User
[Documentation] Switch to the root environment.
# the "sudo -S" to pass password from stdin does not work correctly with
# the su command and we need to type in the password
Write Into Terminal sudo su
Read From Terminal Until [sudo] password for ${DEVICE_UBUNTU_USERNAME}:
Write Into Terminal ${DEVICE_UBUNTU_PASSWORD}
Set Prompt For Terminal ${DEVICE_UBUNTU_ROOT_PROMPT}
Read From Terminal Until Prompt
Exit From Root User
[Documentation] Exit from the root environment
Write Into Terminal exit
Set Prompt For Terminal ${DEVICE_UBUNTU_USER_PROMPT}
Read From Terminal Until Prompt
Open Connection And Log In
[Documentation] Open SSH connection and login to session. Setup RteCtrl
... REST API, serial connection and checkout used asset in
... SnipeIt
Check Provided Ip
# FIXME: some stands do not have RTE connected, this should be better handled
# by reworking variables.robot
IF '${MANUFACTURER}' != 'QEMU' and '${CONFIG}' != 'no-rte'
SSHLibrary.Set Default Configuration timeout=60 seconds
SSHLibrary.Open Connection ${RTE_IP} prompt=~#
SSHLibrary.Login ${USERNAME} ${PASSWORD}
END
IF 'sonoff' == '${POWER_CTRL}'
IF '${SNIPEIT}' == 'yes'
${sonoff_ip}= SnipeIT Get Sonoff IP ${RTE_IP}
ELSE
# If snipeit is set to "no", it should provided in the command line
Variable Should Exist ${sonoff_ip}
END
Import Library osfv.rf.sonoff_robot.Sonoff ${sonoff_ip}
END
Serial Setup ${RTE_IP} ${RTE_S2_N_PORT}
IF '${SNIPEIT}'=='no' RETURN
${already_checked_out_manually}= SnipeIt Checkout ${RTE_IP}
Set Global Variable ${SNIPEIT_ALREADY_CHECKED_OUT_MANUALLY} ${already_checked_out_manually}
Check Provided Ip
[Documentation] Check the correctness of the provided ip address, if the
... address is not found in the RTE list, fail the test.
${index}= Set Variable ${0}
FOR ${item} IN @{RTE_LIST}
${result}= Evaluate ${item}.get("ip")
IF '${result}'=='${RTE_IP}' RETURN
${index}= Set Variable ${index+1}
END
Fail rte_ip:${RTE_IP} not found in the hardware configuration.
Open Connection And Log In OpenBMC
[Documentation] Keyword logs in OpenBMC via SSH.
SSHLibrary.Open Connection ${DEVICE_IP} prompt=${OPEN_BMC_ROOT_PROMPT}
SSHLibrary.Login ${OPEN_BMC_USERNAME} ${OPEN_BMC_PASSWORD}
Set DUT Response Timeout 300s
Establish Host Connection
[Documentation] Keyword allows to establish connection with the host
... system from the OBMC console.
Write Into Terminal obmc-console-client
Log Out And Close Connection
[Documentation] Close all opened SSH, serial connections and check in used
... asset in SnipeIt.
SSHLibrary.Close All Connections
Telnet.Close All Connections
IF '${PLATFORM}'=='raptor-cs_talos2' RETURN
IF '${SNIPEIT}'=='no' RETURN
IF ${SNIPEIT_ALREADY_CHECKED_OUT_MANUALLY} == ${TRUE}
Log To Console
... Since the asset has been checkout manually by you prior running this script, it will NOT be checked in automatically. Please return the device when work is finished.
ELSE
Log To Console
... The asset has been checked out automatically. It is now automatically checked in as well. If you want to keep using it, reserve it manually first.
SnipeIt Checkin ${RTE_IP}
END
Enter Petitboot And Return Menu
[Documentation] Keyword allows to enter the petitboot menu and returns
... it contents
Set DUT Response Timeout 500s
Write Into Terminal obmc-console-client
Read From Terminal Until Petitboot
Sleep 1s
Write Bare Into Terminal ${ARROW_UP}
Set DUT Response Timeout 20s
Sleep 2s
${menu}= Read From Terminal Until Processing DHCP lease response
RETURN ${menu}
Get Firmware Version From Binary
[Documentation] Return firmware version from local firmware binary file.
... Takes binary file path as an argument.
[Arguments] ${binary_path}
${coreboot_version1}= Run strings ${binary_path}|grep COREBOOT_ORIGIN_GIT_TAG|cut -d" " -f 3|tr -d '"'
${coreboot_version2}= Run strings ${binary_path}|grep CONFIG_LOCALVERSION|cut -d"=" -f 2|tr -d '"'
${coreboot_version3}= Run strings ${binary_path}|grep -w COREBOOT_VERSION|cut -d" " -f 3|tr -d '"'
${version_length1}= Get Length ${coreboot_version1}
${coreboot_version}= Set Variable If ${version_length1} == 0 ${coreboot_version2} ${coreboot_version1}
${version_length}= Get Length ${coreboot_version}
${coreboot_version}= Set Variable If ${version_length} == 0 ${coreboot_version3} ${coreboot_version}
RETURN ${coreboot_version}
Get Firmware Version From UEFI Shell
[Documentation] Return firmware version from UEFI shell.
Set DUT Response Timeout 90s
Set Prompt For Terminal Shell>
${output}= Execute Command In Terminal smbiosview -t 0
${version}= Get Lines Containing String ${output} BiosVersion
RETURN ${version.replace('BiosVersion: ', '')}
Get Firmware Version From Dmidecode
${output}= Execute Linux Command dmidecode -t bios
${version_string}= Get Lines Containing String ${output} Version:
${version}= Fetch From Right ${version_string} ${SPACE}
RETURN ${version}
Get Firmware Version
[Documentation] Return firmware version via method supported by the
... platform.
# Boot platform into payload allowing to read flashed firmware version
IF '${FLASH_VERIFY_METHOD}'=='iPXE-boot'
Boot Debian From IPXE ${PXE_IP} ${HTTP_PORT} ${FILENAME} ${DEBIAN_STABLE_VER}
ELSE IF '${FLASH_VERIFY_METHOD}'=='tianocore-shell'
${boot_menu}= Enter Boot Menu Tianocore And Return Construction
Enter Submenu From Snapshot ${boot_menu} ${FLASH_VERIFY_OPTION}
ELSE IF '${FLASH_VERIFY_METHOD}'=='none'
No Operation
END
# Read firmware version
IF '${FLASH_VERIFY_METHOD}'=='iPXE-boot'
${version}= Get Firmware Version From Dmidecode
ELSE IF '${FLASH_VERIFY_METHOD}'=='tianocore-shell'
${version}= Get Firmware Version From UEFI Shell
ELSE IF '${FLASH_VERIFY_METHOD}'=='none'
${version}= Get Firmware Version From Binary ${FW_FILE}
ELSE
${version}= Set Variable ${NONE}
END
RETURN ${version}
Check The Presence Of WiFi Card
[Documentation] Checks the if WiFi card is visible for operating system.
... Returns True if presence is detected.
${terminal_result}= Execute Command In Terminal lspci | grep '${WIFI_CARD_UBUNTU}'
${result}= Run Keyword And Return Status
... Should Not Be Empty ${terminal_result}
RETURN ${result}
Check The Presence Of Bluetooth Card
[Documentation] Checks the if Bluetooth card is visible for OS.
... Returns True if presence is detected.
${terminal_result}= Execute Command In Terminal lsusb | grep '${BLUETOOTH_CARD_UBUNTU}'
${result}= Run Keyword And Return Status
... Should Not Be Empty ${terminal_result}
RETURN ${result}
Get Current RTE
[Documentation] Returns RTE index from RTE list taken as an argument.
... Returns -1 if CPU ID not found in variables.robot.
[Arguments] @{rte_list}
${index}= Set Variable ${0}
FOR ${item} IN @{rte_list}
IF '${item.ip}' == '${RTE_IP}' RETURN ${index}
${index}= Set Variable ${index+1}
END
RETURN ${-1}
Get Current RTE Param
[Documentation] Returns current RTE parameter value specified in the argument.
[Arguments] ${param}
${idx}= Get Current RTE @{RTE_LIST}
Should Not Be Equal ${idx} ${-1} msg=RTE not found in hw-matrix
&{rte}= Get From List ${RTE_LIST} ${idx}
RETURN ${rte}[${param}]
Get Current CONFIG Start Index
[Documentation] Returns current CONFIG start index from CONFIG_LIST
... specified in the argument required for slicing list.
... Returns -1 if CONFIG not found in variables.robot.
[Arguments] ${config_list}
${rte_ip}= Get Current RTE Param ip
Should Not Be Equal ${rte_ip} ${-1} msg=RTE not found in hw-matrix
${index}= Set Variable ${0}
FOR ${config} IN @{config_list}
${result}= Evaluate ${config}.get("ip")
IF '${result}'=='${rte_ip}' RETURN ${index}
${index}= Set Variable ${index+1}
END
RETURN ${-1}
Get Current CONFIG Stop Index
[Documentation] Returns current CONFIG stop index from CONFIG_LIST
... specified in the argument required for slicing list.
... Returns -1 if CONFIG not found in variables.robot.
[Arguments] ${config_list} ${start}
${length}= Get Length ${config_list}
${index}= Set Variable ${start+1}
FOR ${config} IN @{config_list[${index}:]}
${result}= Evaluate ${config}.get("ip")
IF '${result}'!='None' RETURN ${index}
IF '${index}'=='${length-1}' RETURN ${index+1}
${index}= Set Variable ${index+1}
END
RETURN ${-1}
Get Current CONFIG
[Documentation] Returns current config as a list variable based on start
... and stop indexes.
[Arguments] ${config_list}
${start}= Get Current CONFIG Start Index ${config_list}
Should Not Be Equal ${start} ${-1} msg=Current CONFIG not found in hw-matrix
${stop}= Get Current CONFIG Stop Index ${config_list} ${start}
Should Not Be Equal ${stop} ${-1} msg=Current CONFIG not found in hw-matrix
${config}= Get Slice From List ${config_list} ${start} ${stop}
RETURN ${config}
Get Current CONFIG Item
[Documentation] Returns current CONFIG item specified in the argument.
... Returns -1 if CONFIG item not found in variables.robot.
[Arguments] ${item}
${config}= Get Current CONFIG ${CONFIG_LIST}
${length}= Get Length ${config}
Should Be True ${length} > 1
FOR ${element} IN @{config[1:]}
IF '${element.type}'=='${item}' RETURN ${element}
END
RETURN ${-1}
Get Current CONFIG Item Param
[Documentation] Returns current CONFIG item parameter specified in the
... arguments.
[Arguments] ${item} ${param}
${device}= Get Current CONFIG Item ${item}
RETURN ${device.${param}}
Get Slot Count
[Documentation] Returns count parameter value from slot key specified in
... the argument if found, otherwise return 0.
[Arguments] ${slot}
${is_found}= Evaluate "count" in """${slot}"""
${return}= Set Variable If
... ${is_found}==False 0
... ${is_found}==True ${slot.count}
RETURN ${return}
Get USB Slot Count
[Documentation] Returns count parameter value from USB slot key specified
... in the argument if found, otherwise return 0.
[Arguments] ${slots}
${is_found1}= Evaluate "USB_Storage" in """${slots.slot1}"""
${is_found2}= Evaluate "USB_Storage" in """${slots.slot2}"""
IF ${is_found1}==True
${count1}= Get Slot Count ${slots.slot1}
ELSE
${count1}= Evaluate 0
END
IF ${is_found2}==True
${count2}= Get Slot Count ${slots.slot2}
ELSE
${count2}= Evaluate 0
END
${sum}= Evaluate ${count1}+${count2}
RETURN ${sum}
Get All USB
[Documentation] Returns number of attached USB storages in current CONFIG.
${conf}= Get Current CONFIG ${CONFIG_LIST}
${is_found}= Evaluate "USB_Storage" in """${conf}"""
IF ${is_found}==True
${usb_count}= Get Current CONFIG Item Param USB_Storage count
${count_usb}= Evaluate ${usb_count}
ELSE
${usb_count}= Evaluate ""
${count_usb}= Evaluate 0
END
${is_found}= Evaluate "USB_Expander" in """${conf}"""
IF ${is_found}==True
${external}= Get Current CONFIG Item USB_Expander
${external_count}= Get USB Slot Count ${external}
ELSE
${external}= Evaluate ""
${external_count}= Evaluate 0
END
${count}= Evaluate ${count_usb}+${external_count}
RETURN ${count}
Prepare Lm-sensors
[Documentation] Install lm-sensors and probe sensors.
Detect Or Install Package lm-sensors
Execute Command In Terminal sudo sensors-detect --auto
IF '${PLATFORM}' == 'raptor-cs_talos2'
Execute Command In Terminal modprobe w83795
END
Get Fan Speed
[Documentation] Returns current fan speed as int.
# Detect or Install Package lm-sensors
# Execute Command In Terminal yes | sudo sensors-detect
# Execute Command In Terminal modprobe w83795
${speed}= Execute Command In Terminal sensors | grep fan1
${speed}= Get Lines Containing String ${speed} RPM)
${speed_split}= Split String ${speed}
${rpm}= Get From List ${speed_split} 1
${rpm}= Convert To Number ${rpm}
RETURN ${rpm}
Prepare Test Suite
[Documentation] Keyword prepares Test Suite by importing specific
... platform configuration keywords and variables and
... preparing connection with the DUT based on used
... transmission protocol. Keyword used in all [Suite Setup]
... sections.
# Add some metadata to track test version
${revision}= Run git describe --dirty --always --tags
Set Suite Metadata OSFV revision ${revision}
${revision}= Run git describe --always
${url}= Run git remote get-url origin
# Change SSH link to HTTPS one
${url}= Replace String ${url} [email protected]: https://github.com/
${url}= Remove String Using Regexp ${url} .git$
# Relative path from repository base, assumes that directory has the same name as repository
${dir_name_split}= Split String ${url} /
${dir_name}= Get From List ${dir_name_split} -1
${path}= Remove String Using Regexp ${SUITE_SOURCE} ^.*/${dir_name}/
Set Suite Metadata Remote source (maybe) ${url}/blob/${revision}/${path}
IF '${CONFIG}' == 'crystal'
Import Resource ${CURDIR}/platform-configs/vitro_crystal.robot
ELSE IF '${CONFIG}' == 'pv30'
Import Resource ${CURDIR}/dev-tests/operon/configs/pv30.robot
ELSE IF '${CONFIG}' == 'yocto'
Import Resource ${CURDIR}/dev-tests/operon/configs/yocto.robot
ELSE IF '${CONFIG}' == 'raspbian'
Import Resource ${CURDIR}/dev-tests/operon/configs/raspbian.robot
ELSE IF '${CONFIG}' == 'rpi-3b'
Import Resource ${CURDIR}/platform-configs/rpi-3b.robot
ELSE
Import Resource ${CURDIR}/platform-configs/${CONFIG}.robot
END
IF '${MANUFACTURER}' != 'QEMU' and '${CONFIG}' != 'no-rte'
Import Osfv Libraries
END
IF '${DUT_CONNECTION_METHOD}' == 'SSH'
Prepare To SSH Connection
ELSE IF '${DUT_CONNECTION_METHOD}' == 'Telnet'
Prepare To Serial Connection
ELSE IF '${DUT_CONNECTION_METHOD}' == 'open-bmc'
Prepare To OBMC Connection
ELSE IF '${DUT_CONNECTION_METHOD}' == 'pikvm'
Prepare To PiKVM Connection
ELSE
FAIL Unknown connection method: ${DUT_CONNECTION_METHOD} for config: ${CONFIG}
END
IF '${CONFIG}' == 'rpi-3b' Verify Number Of Connected SD Wire Devices
Import Osfv Libraries
[Documentation] Import osfv_cli libraries based on config and command
... line variables
IF '${OPTIONS_LIB}'=='dcu' RETURN
Log ${SNIPEIT}
IF '${SNIPEIT}' == 'yes'
Import Library osfv.rf.snipeit_robot
Import Library osfv.rf.rte_robot.RobotRTE ${RTE_IP} True
ELSE IF 'sonoff' == '${POWER_CTRL}'
Variable Should Exist ${SONOFF_IP}
# The last parameter is the DUT config name. It needs to be provided if
# it SnipeIT is not used; otherwise the library would not be able to
# determine the platform type.
Import Library osfv.rf.rte_robot.RobotRTE ${RTE_IP} False
... ${SONOFF_IP} ${CONFIG}
ELSE
Import Library osfv.rf.rte_robot.RobotRTE ${RTE_IP} False
... config=${CONFIG}
END
Prepare To SSH Connection
[Documentation] Keyword prepares Test Suite by setting current platform
... and its ip to the global variables, configuring the
... SSH connection, Setup RteCtrl REST API and checkout used
... asset in SnipeIt . Keyword used in [Suite Setup]
... sections if the communication with the platform based on
... the SSH protocol
# tu leci zmiana, musimy brać platformy zgodnie z tym co zostało pobrane w dasharo
Set Global Variable ${PLATFORM} ${CONFIG}
SSHLibrary.Set Default Configuration timeout=60 seconds
IF '${SNIPEIT}'=='no' RETURN
Prepare To Serial Connection
[Documentation] Keyword prepares Test Suite by opening SSH connection to
... the RTE, opening serial connection with the DUT, setting
... current platform to the global variable and setting the
... DUT to start state. Keyword used in [Suite Setup]
... sections if the communication with the platform based on
... the serial connection
Open Connection And Log In
IF '${MANUFACTURER}' == 'QEMU'
Set Global Variable ${PLATFORM} qemu
ELSE IF '${CONFIG}' == 'no-rte'
Set Global Variable ${PLATFORM} ${CONFIG}
ELSE
${platform}= Get Current RTE Param platform
Set Global Variable ${PLATFORM}
END
Get DUT To Start State
# the following TRY/EXCEPT exposes telnet connection error pre-emptively
TRY
Telnet.Read
EXCEPT EOFError: telnet connection closed
${err_msg}= Catenate SEPARATOR=\n
... - telnet (or minicom on RTE) connection might be opened - either by you or someone else
... - Verify and close your connections before starting tests
... - stop minicom processes on RTE, restart ser2net service (systemctl restart ser2net)
Fail ${err_msg}
END
Prepare To OBMC Connection
[Documentation] Keyword prepares Test Suite by opening open-bmc
... connection, setting current platform to the global
... variable and setting the DUT to start state. Keyword
... used in [Suite Setup] sections if the communication with
... the platform based on the open-bmc
Set Global Variable ${PLATFORM} ${CONFIG}
Set Global Variable ${OPENBMC_HOST} ${DEVICE_IP}
Import Resource ${CURDIR}/openbmc-test-automation/lib/rest_client.robot
Import Resource ${CURDIR}/openbmc-test-automation/lib/utils.robot
Import Resource ${CURDIR}/openbmc-test-automation/lib/state_manager.robot
Set Platform Power State
Open Connection And Log In OpenBMC
Set DUT Response Timeout 300s
Set Chassis Power State on
Establish Host Connection
Prepare To PiKVM Connection
[Documentation] Keyword prepares Test Suite by opening SSH connection to
... the RTE, opening serial connection with the DUT (for
... gathering output from platform), configuring PiKVM,
... setting current platform to the global variable and
... setting the DUT to start state. Keyword used in
... [Suite Setup] sections if the communication with the
... platform based on the serial connection (platform
... output) and PiKVM (platform input)
Remap Keys Variables To PiKVM
Open Connection And Log In
${platform}= Get Current RTE Param platform
IF '${SNIPEIT}' == 'yes'
${pikvm_ip}= Snipeit Get PiKVM IP ${RTE_IP}
Set Global Variable ${PIKVM_IP}
END
# If snipeit is set to "no", fetch it from command line
Variable Should Exist
... ${PIKVM_IP}
... PiKVM IP cannot be fetched from SnipeIT. Please provide it in the 'PIKVM_IP' variable
Set Global Variable ${PLATFORM}
Get DUT To Start State
Remap Keys Variables To PiKVM
[Documentation] Updates keys variables from keys.robot to be compatible
... with PiKVM
Set Global Variable ${ARROW_UP} ArrowUp
Set Global Variable ${ARROW_DOWN} ArrowDown
Set Global Variable ${ARROW_RIGHT} ArrowRight
Set Global Variable ${ARROW_LEFT} ArrowLeft
Set Global Variable ${F1} F1
Set Global Variable ${F2} F2
Set Global Variable ${F3} F3
Set Global Variable ${F4} F4
Set Global Variable ${F5} F5
Set Global Variable ${F6} F6
Set Global Variable ${F7} F7
Set Global Variable ${F8} F8
Set Global Variable ${F9} F9
Set Global Variable ${F10} F10
Set Global Variable ${F11} F11
Set Global Variable ${F12} F12
Set Global Variable ${ESC} Escape
Set Global Variable ${ENTER} Enter
Set Global Variable ${BACKSPACE} Backspace
Set Global Variable ${KEY_SPACE} Space
Set Global Variable ${DELETE} Delete
Set Global Variable ${DIGIT0} Digit0
Set Global Variable ${DIGIT1} Digit1
Set Global Variable ${DIGIT2} Digit2
Set Global Variable ${DIGIT3} Digit3
Set Global Variable ${DIGIT4} Digit4
Set Global Variable ${DIGIT5} Digit5
Set Global Variable ${DIGIT6} Digit6
Set Global Variable ${DIGIT7} Digit7
Set Global Variable ${DIGIT8} Digit8
Set Global Variable ${DIGIT9} Digit9
Remap Keys Variables From PiKVM
[Documentation] Updates keys variables from PiKVM ones to the ones
... as defined in keys.robot
Import Resource ${CURDIR}/keys.robot
Get DUT To Start State
[Documentation] Clears telnet buffer and get Device Under Test to start
... state (RTE Relay On).
Telnet.Read
IF '${MANUFACTURER}' != 'QEMU' and '${CONFIG}' != 'no-rte'
${state}= Get Power Supply State
IF '${state}'=='OFF' Turn On Power Supply
END
Turn On Power Supply
Rte Psu On
Power Cycle On
[Documentation] Clears telnet buffer and performs full power cycle
... by setting power supply to OFF, and then to ON. If platform needs
... additional power button press, it will be used as well, so at the
... end of this keyword platform starts booting. This is controlled via
... the DEFAULT_POWER_STATE_AFTER_FAIL variable defined in platform config.
Variable Should Exist ${DEFAULT_POWER_STATE_AFTER_FAIL}
IF "${OPTIONS_LIB}"=="dcu" and "${POWER_CTRL}"=="none"
Execute Reboot Command
Sleep 5s
RETURN
END
Restore Initial DUT Connection Method
${pc}= Get Variable Value ${POWER_CTRL}
IF 'obmcutil' == '${pc}'
OBMC Power Cycle On
ELSE
Rte Psu Off
Sleep 10
TRY
Read From Terminal
EXCEPT
Log Could not clear terminal buffer
END
Rte Psu On
END
IF '${DEFAULT_POWER_STATE_AFTER_FAIL}' == 'Powered Off' Rte Power On
OBMC Power Cycle On
[Documentation] Clears obmc-console-client buffer and perform full power
... cycle with Chassis and Host State Control
${host_state}= Get Host State
${chassis_state}= Get Chassis Power State
IF '${host_state.lower()}'=='on' or '${chassis_state.lower()}'=='on'
Set Chassis Power State off
Sleep 15s
END
Read From Terminal
Power On
Get Power Supply State
[Documentation] Returns the power supply state.
${state}= Rte Psu Get
RETURN ${state}
Get Sound Devices Windows
[Documentation] Get and return all sound devices in Windows OS using
... PowerShell
${out}= Execute Command In Terminal
... Get-PnpDevice -PresentOnly | Where-Object {$_.Class -match "Audio" -or $_.Name -match "Audio"} | Select-Object Name, Status
RETURN ${out}
Get USB Devices Windows
[Documentation] Get and return all USB devices in Windows OS using
... PowerShell
${out}= Execute Command In Terminal Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' }
RETURN ${out}
Get CPU Temperature And CPU Fan Speed
[Documentation] Get the current CPU temperature in Celsius degrees and
... the current CPU fan speed in rpms.
${output}= Telnet.Execute Command sensors w83795g-i2c-1-2f |grep fan1 -A 16
${rpm}= Get Lines Containing String ${output} fan1
${rpm}= Split String ${rpm} ${SPACE}
${rpm}= Get Substring ${rpm} -8 -7
${rpm}= Get From List ${rpm} 0
${rpm_value}= Convert To Integer ${rpm}
${temperature}= Get Lines Containing String ${output} temp7
${temperature}= Split String ${temperature} ${SPACE}
${temperature}= Get Substring ${temperature} -8 -7
${temperature}= Get From List ${temperature} 0
${temperature}= Remove String ${temperature} +
${temperature}= Remove String ${temperature} °
${temperature}= Remove String ${temperature} C
${temperature_value}= Convert To Number ${temperature}
RETURN ${rpm_value} ${temperature_value}
Execute Linux Command Without Output
[Documentation] Execute linux command over serial console. Do not return
... standard output. There is one optional argument. The
... timeout_before defines how long we wait till we have a
... clear prompt to enter the command.
[Arguments] ${cmd} ${timeout}=10
Set DUT Response Timeout ${timeout} seconds
# Make sure that we have a clear prompt before executing next command
# Clear the buffer as well
Read From Terminal
Write Into Terminal echo
Read From Terminal Until Prompt
Write Into Terminal ${cmd}
Execute Linux Command
[Documentation] Execute linux command over serial console and return the
... standard output. There are two optional arguments. The
... timeout_before defines how long we wait till we have a
... clear prompt to enter the command. The timeout_after
... defines for how long we wait until the next prompt (until
... the executed command finishes).
[Arguments] ${cmd} ${timeout}=30
Write Into Terminal ${cmd}
Set DUT Response Timeout ${timeout} seconds
${out}= Read From Terminal Until Prompt
RETURN ${out}
Execute Linux Tpm2 Tools Command
[Documentation] Execute linux tpm2_tools command, check that no errors
... and warnings apper and return the standard output.
... There are two optional arguments. The timeout_before
... defines how long we wait till we have a clear prompt to
... enter the command. The timeout_after defines for how long
... we wait until the next prompt (until the executed command
... finishes).
[Arguments] ${cmd} ${timeout}=30
Write Into Terminal ${cmd}
Set DUT Response Timeout ${timeout} seconds
${out}= Read From Terminal Until Prompt
Should Not Contain Any ${out} WARN ERROR
RETURN ${out}
Restore Initial DUT Connection Method
[Documentation] We need to go back to pikvm control when going back from OS to firmware
${initial_method_defined}= Get Variable Value ${INITIAL_DUT_CONNECTION_METHOD}
IF '${initial_method_defined}' == 'None' RETURN
Set Global Variable ${DUT_CONNECTION_METHOD} ${INITIAL_DUT_CONNECTION_METHOD}
IF '${INITIAL_DUT_CONNECTION_METHOD}' == 'pikvm'
# We need this when going back from SSH to PiKVM
Remap Keys Variables To PiKVM
END
Execute Poweroff Command
Write Into Terminal poweroff
Set DUT Response Timeout 180 seconds
Restore Initial DUT Connection Method
Execute Reboot Command
[Documentation] Executes reboot command in given os
[Arguments] ${os}=linux
IF '${os}' == 'linux'
Write Into Terminal reboot
ELSE IF '${os}' == 'windows'
Write Into Terminal shutdown /r /f /t 0
ELSE
Fail Unknown OS: ${os} given as an argument.
END
IF '${DUT_CONNECTION_METHOD}' == 'SSH' Sleep 30s
Set DUT Response Timeout 180 seconds
Restore Initial DUT Connection Method
Check Displays Windows
[Documentation] Check and return all displays with PowerShell in Windows.
# '-2' = 'Unknown'
# '-1' = 'Unknown'
# '0' = 'VGA'
# '1' = 'S-Video'
# '2' = 'Composite'
# '3' = 'Component'
# '4' = 'DVI'
# '5' = 'HDMI'
# '6' = 'LVDS'
# '8' = 'D-Jpn'
# '9' = 'SDI'
# '10' = 'DisplayPort (external)'
# '11' = 'DisplayPort (internal)'
# '12' = 'Unified Display Interface'
# '13' = 'Unified Display Interface (embedded)'
# '14' = 'SDTV dongle'
# '15' = 'Miracast'
# '16' = 'Internal'
# '2147483648' = 'Internal'
${out}= Execute Command In Terminal Get-WmiObject WmiMonitorConnectionParams -Namespace root/wmi
RETURN ${out}
Check HDMI Windows
[Documentation] Check if HDMI display is recognized by Windows OS.
${out}= Check Displays Windows
Should Contain ${out} VideoOutputTechnology : 5
Check DP Windows
[Documentation] Check if DP display is recognized by Windows OS.
${out}= Check Displays Windows
IF '${PLATFORM}' == 'protectli-vp4630' or '${PLATFORM}' == 'protectli-vp4650' or '${PLATFORM}' == 'protectli-vp4670'
Should Contain Any
... ${out}
... VideoOutputTechnology : 10
... VideoOutputTechnology : 11
... VideoOutputTechnology : 2147483648
ELSE
Should Contain Any ${out} VideoOutputTechnology : 10 VideoOutputTechnology : 11
END
Check Internal LCD Linux
[Documentation] Check if internal LCD is recognized by Linux OS.
# Assumption: Intel iGPU
${out}= Execute Linux Command cat /sys/devices/pci0000:00/0000:00:02.0/drm/card*/*eDP-1/status
Should Contain ${out} connected
Check Internal LCD Windows
[Documentation] Check if internal LCD is recognized by Windows OS.
${out}= Check Displays Windows
Should Contain Any ${out} VideoOutputTechnology : 2147483648 VideoOutputTechnology : 16
Check External HDMI In Linux
[Documentation] Keyword checks if an external HDMI device is visible
... in Linux OS.
${out}= Execute Linux Command cat /sys/class/drm/card*/*
Should Contain ${out} connected
Check External DP In Linux
[Documentation] Keyword checks if an external Display Port device is
... visible in Linux OS.
${out}= Execute Linux Command cat /sys/class/drm/card0-DP-1/status
Should Not Contain ${out} disconnected
Should Contain ${out} connected
Device Detection In Linux
[Documentation] Keyword checks if a given device name as a parameter is
... visible in Linux OS.
[Arguments] ${device}
${out}= Execute Linux Command libinput list-devices | grep ${device}
Should Contain ${out} ${device}
Check Charge Level In Linux
[Documentation] Keyword checks the charge level in Linux OS.
Set Local Variable ${cmd} cat /sys/class/power_supply/BAT0/charge_now
${out}= Execute Linux Command ${cmd}
# capacity in uAh
${capacity}= Convert To Integer ${out}
Should Be True ${capacity} <= ${CLEVO_BATTERY_CAPACITY}
Should Be True ${capacity} > 0
Check Charging State In Linux
[Documentation] Keyword checks the charging state in Linux OS.
${out}= Execute Linux Command cat /sys/class/power_supply/BAT0/status
Should Contain Any ${out} Charging Full
Check Charging State Not Charging In Linux
[Documentation] Keyword checks if the battery state is Not charging
... in Linux OS.
${out}= Execute Linux Command cat /sys/class/power_supply/BAT0/status
Should Contain Any ${out} Not charging
Check Charging State In Windows
[Documentation] Keyword checks the charging state in Windows OS.
${out}= Execute Command In Terminal Get-WmiObject win32_battery
Should Contain ${out} BatteryStatus${SPACE*15}: 2
Discharge The Battery Until Target Level In Linux
[Documentation] Keyword stresses the CPU to discharge the battery until
... the target charge level is reached.
[Arguments] ${target}
Detect Or Install Package stress-ng
WHILE True
${out}= Execute Command In Terminal cat /sys/class/power_supply/BAT0/capacity
IF ${out} <= ${target} BREAK
Execute Command In Terminal stress-ng --cpu 0 --timeout 10s
END
Check Battery Percentage In Linux
[Documentation] Keyword check the battery percentage in Linux OS.
${percentage}= Execute Command In Terminal cat /sys/class/power_supply/BAT0/capacity
RETURN ${percentage}
Charge Battery Until Target Level In Linux
[Documentation] Keyword periodically checks battery charge level until it
... reaches defined target in Linux OS.
[Arguments] ${target}
FOR ${i} IN RANGE 2000
${out}= Check Battery Percentage In Linux
Sleep 5
IF ${out} == ${target} BREAK
END
Run Keyword Unless ${out} == ${target}
Log Could not charge battery to specified level within timeout.
Turn On ACPI CALL Module In Linux
[Documentation] Keyword turns on acpi_call module in Linux OS.
Execute Linux Command modprobe acpi_call
Set Brightness In Linux
[Documentation] Keyword sets desired brightness in Linux OS.
... Brightness value range depends on platform.
[Arguments] ${brightness}
Execute Linux Command echo ${brightness} > /sys/class/backlight/acpi_video0/brightness
Get Current Brightness In Linux
[Documentation] Keyword gets current brightness in Linux OS and returns
... it as an integer.
Set Local Variable ${cmd} cat /sys/class/backlight/acpi_video0/brightness
${out1}= Execute Linux Command ${cmd}
${brightness}= Convert To Integer ${out1}
RETURN ${brightness}