Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LenovoX1 target #57

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Robot-Framework/config/variables.robot
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ Set Variables
Set Global Variable ${THREADS_NUMBER} ${config['addresses']['${DEVICE}']['threads']}
Set Global Variable ${NETVM_NAME} net-vm
Set Global Variable ${NETVM_SERVICE} microvm@${NETVM_NAME}.service
Set Global Variable ${NETVM_IP} 192.168.101.1
Set Global Variable ${GUI_VM} gui-vm.ghaf
Set Global Variable ${CHROMIUM_VM} chromium-vm.ghaf
Set Global Variable ${GALA_VM} gala-vm.ghaf
Set Global Variable ${ZATHURA_VM} zathura-vm.ghaf


Read Config
[Arguments] ${file_path}=../config/test_config.json
Expand Down
10 changes: 10 additions & 0 deletions Robot-Framework/lib/output_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,13 @@ def get_qspi_versions(output):
raise Exception(f"Couldn't parse current software version, pattern: {rx_pattern}")

return fw_version, sw_version

def get_app_path(output, app):
pattern = rf"path=(.*{app}.*)\n"
match = re.search(pattern, output)
if match:
result = match.group(1)
else:
raise Exception(f"Couldn't parse chromium path from /etc/xdg/weston/weston.ini, pattern: {pattern}")
path = result.replace('"', '\\"')
return path
46 changes: 37 additions & 9 deletions Robot-Framework/resources/ssh_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,38 @@ Connect
Should Contain ${output} ${target_output}
[Return] ${connection}

Connect to ghaf host
[Documentation] Open ssh connection to ghaf host
Log To Console Connecting to Ghaf Host
${connection} Connect
Set Global Variable ${ghaf_host_ssh} ${connection}
[Return] ${connection}

Connect to netvm
[Documentation] Connect to netvm directly from test run machine, using
... jumphost, this allows using standard SSHLibrary
... commands, like 'Execute Command'
Connect to ghaf host
Log To Console Connecting to NetVM
${connection} Open Connection ${NETVM_IP} port=22
${output} Login username=${LOGIN} password=${PASSWORD} jumphost_index_or_alias=${ghaf_host_ssh}
Set Global Variable ${netvm_ssh} ${connection}
[Return] ${netvm_ssh}

Connect to guivm
Log To Console Connecting to GuiVM
${connection}= Open Connection ${GUI_VM} port=22
${output}= Login username=${LOGIN} password=${PASSWORD} jumphost_index_or_alias=${netvm_ssh}
Set Global Variable ${guivm_ssh} ${connection}
[Return] ${guivm_ssh}

Connect to chromium vm
Log To Console Connecting to Chromium VM
${connection}= Open Connection ${CHROMIUM_VM} port=22
${output}= Login username=${LOGIN} password=${PASSWORD} jumphost_index_or_alias=${netvm_ssh}
Set Global Variable ${chromium_vm} ${connection}
[Return] ${chromium_vm}

Verify Systemctl status
[Arguments] ${range}=60
[Documentation] Check is systemctl running with given loop ${range}
Expand All @@ -79,8 +111,9 @@ Verify Systemctl status

Start Chromium
Log To Console ${\n}Starting Chromium
${command}= Set Variable chromium-browser --enable-features=UseOzonePlatform --ozone-platform=wayland
${command_output}= Execute Command nohup ${command} > output.log 2>&1 &
${output} Execute Command cat /etc/xdg/weston/weston.ini
${path} Get App Path ${output} chromium
Execute Command nohup sh -c '$(${path})' > output.log 2>&1 &

Start Firefox
[Documentation] It's needed to set display variable manually because there is no real monitor connected to DUT
Expand All @@ -91,11 +124,6 @@ Is process started
[Arguments] ${pid}
${rc}= Execute Command ps -p ${pid} return_rc=True
${status}= Run Keyword And Return Status Should Be Equal As Integers ${rc[1]} 0
IF ${status}
Log To Console Process ${pid} exists
ELSE
Log To Console Process ${pid} doesn't exist
END
[Return] ${status}

Find pid by name
Expand All @@ -104,13 +132,12 @@ Find pid by name
${output}= Execute Command sh -c 'ps aux | grep "${proc_name}" | grep -v grep'
Log ${output}
@{pids}= Find Pid ${output} ${proc_name}
Log To Console Found PIDs: ${pids}
Log To Console Found PIDs for process '${proc_name}':\n${pids}
[Return] @{pids}

Kill process
[Arguments] @{pids} ${sig}=15
FOR ${pid} IN @{pids}
Log To Console Send kill -${sig} to ${pid}
Execute Command kill -${sig} ${pid}
FOR ${i} IN RANGE 5
${ps_exists}= Is Process Started ${pid}
Expand All @@ -122,6 +149,7 @@ Kill process
END
IF ${ps_exists} FAIL Process ${pid} haven't stopped
END
Log To Console Killed processes: @{pids}

Verify service status
[Documentation] Check if service is running with given loop ${range}
Expand Down
31 changes: 20 additions & 11 deletions Robot-Framework/test-suites/bat-tests/apps.robot
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,33 @@ Resource ../../resources/ssh_keywords.resource
Resource ../../config/variables.robot
Suite Teardown Close All Connections


*** Test Cases ***

Start Firefox
[Documentation] Start Firefox and verify process started
[Tags] bat SP-T45 nuc orin-agx
Connect
Start Firefox
@{pid}= Find pid by name firefox
Should Not Be Empty ${pid} Firefox is not started
[Teardown] Kill process @{pid}

Check that the application was started firefox
[Teardown] Kill process @{app_pids}

Start Chromium
[Documentation] Start Chromium and verify process started
[Tags] depricated
Connect
Start Chromium on LenovoX1
[Documentation] Start Chromium in dedicated VM and verify process started
[Tags] bat SP-T97 lenovoX1
[Setup] Connect to netvm
Connect to guivm
Start Chromium
@{pid}= Find pid by name chromium
Should Not Be Empty ${pid} Chromium is not started
[Teardown] Kill process @{pid}
Connect to chromium vm
Check that the application was started chromium
[Teardown] Kill process @{app_pids}


*** Keywords ***

Check that the application was started
[Arguments] ${app_name}
@{found_pids} Find pid by name ${app_name}
Set Global Variable @{app_pids} @{found_pids}
Should Not Be Empty ${app_pids} ${app_name} is not started
Log To Console ${app_name} is started
48 changes: 16 additions & 32 deletions Robot-Framework/test-suites/bat-tests/netvm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,50 @@ ${SSID} test_network
${wifi_pswd} test1234
${netwotk_ip} 192.168.1.1
${netvm_state} ${EMPTY}
${ghaf_host} ${EMPTY}
${netvm} ${EMPTY}
${ghaf_host_ssh} ${EMPTY}
${netvm_ssh} ${EMPTY}


*** Test Cases ***

Verify NetVM is started
[Documentation] Verify that NetVM is active and running
[Tags] bat SP-T49 nuc orin-agx orin-nx
[Tags] bat SP-T49 nuc orin-agx orin-nx lenovoX1
[Setup] Connect to ghaf host
Verify service status service=${netvm_service}
Check Network Availability ${netvm_ip} expected_result=True range=5
[Teardown] Close All Connections

Wifi passthrought into NetVM
[Documentation] Verify that wifi works inside netvm
[Tags] bat SP-T50 nuc orin-agx
[Tags] bat SP-T50 nuc orin-agx lenovoX1
... test:retry(1)
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm AND
... Verify service status service=wpa_supplicant.service
Configure wifi ${netvm} ${SSID} ${wifi_pswd}
Configure wifi ${netvm_ssh} ${SSID} ${wifi_pswd}
Get wifi IP
Check Network Availability ${netwotk_ip} expected_result=True
Log To Console Switch connection to Ghaf Host
Switch Connection ${ghaf_host}
Switch Connection ${ghaf_host_ssh}
Check Network Availability ${netwotk_ip} expected_result=False
[Teardown] Run Keywords Remove Wifi configuration AND Close All Connections

NetVM stops and starts successfully
[Documentation] Verify that NetVM stops properly and starts after that
[Tags] bat SP-T52 nuc orin-agx orin-nx
[Tags] bat SP-T52 nuc orin-agx orin-nx lenovoX1
[Setup] Connect to ghaf host
Restart NetVM
[Teardown] Run Keywords Start NetVM if dead AND Close All Connections

NetVM is wiped after restarting
[Documentation] Verify that created file will be removed after restarting VM
[Tags] bat SP-T53 nuc orin-agx orin-nx
[Tags] bat SP-T53 nuc orin-agx orin-nx lenovoX1
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm
Switch Connection ${netvm}
Switch Connection ${netvm_ssh}
Create file /etc/test.txt
Switch Connection ${ghaf_host}
Switch Connection ${ghaf_host_ssh}
Restart NetVM
Close All Connections
Connect to ghaf host
Expand All @@ -71,10 +71,10 @@ NetVM is wiped after restarting

Verify wpa_supplicant.service is running
[Documentation] Verify that wpa_supplicant.service exists and is running
[Tags] bat SP-T82 nuc orin-agx
[Tags] bat SP-T82 nuc orin-agx lenovoX1
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm
Switch Connection ${netvm}
Switch Connection ${netvm_ssh}
Verify service status service=wpa_supplicant.service
[Teardown] Run Keywords Close All Connections

Expand All @@ -83,7 +83,7 @@ Verify NetVM PCI device passthrough
[Tags] bat SP-T101 nuc orin-agx orin-nx
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm
Verify microvm PCI device passthrough host_connection=${ghaf_host} vm_connection=${netvm} vmname=${NETVM_NAME}
Verify microvm PCI device passthrough host_connection=${ghaf_host_ssh} vm_connection=${netvm_ssh} vmname=${NETVM_NAME}
[Teardown] Run Keywords Close All Connections


Expand All @@ -98,31 +98,15 @@ Restart NetVM
Start NetVM
Check if ssh is ready on netvm

Connect to ghaf host
[Documentation] Open ssh connection to ghaf host
${connection}= Connect
Set Global Variable ${ghaf_host} ${connection}
[Return] ${connection}

Connect to netvm
[Documentation] Connect to netvm directly from test run machine, using
... jumphost, this allows using standard SSHLibrary
... commands, like 'Execute Command'
Log To Console Connecting to NetVM
${connection}= Open Connection ${NETVM_IP} port=22
${output}= Login username=${LOGIN} password=${PASSWORD} jumphost_index_or_alias=${ghaf_host}
Set Global Variable ${netvm} ${connection}
[Return] ${netvm}

Configure wifi
[Arguments] ${netvm} ${SSID} ${passw}
Switch Connection ${netvm}
[Arguments] ${netvm_ssh} ${SSID} ${passw}
Switch Connection ${netvm_ssh}
Log To Console Configuring Wifi
Execute Command sh -c "wpa_passphrase ${SSID} ${passw} > /etc/wpa_supplicant.conf" sudo=True sudo_password=${PASSWORD}
Execute Command systemctl restart wpa_supplicant.service sudo=True sudo_password=${PASSWORD}

Remove Wifi configuration
Switch Connection ${netvm}
Switch Connection ${netvm_ssh}
Log To Console Removing Wifi configuration
Execute Command rm /etc/wpa_supplicant.conf sudo=True sudo_password=${PASSWORD}
Execute Command systemctl restart wpa_supplicant.service sudo=True sudo_password=${PASSWORD}
Expand Down
4 changes: 2 additions & 2 deletions Robot-Framework/test-suites/bat-tests/others.robot
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ Resource ../../resources/ssh_keywords.resource
Test ghaf version format
[Documentation] Test getting Ghaf version and verify its format:
... Expected format: major.minor.yyyymmdd.commit_hash
[Tags] bat SP-T59 nuc orin-agx orin-nx riscv
[Tags] bat SP-T59 nuc orin-agx orin-nx riscv lenovoX1
[Setup] Connect
Verify Ghaf Version Format
[Teardown] Close All Connections

Test nixos version format
[Documentation] Test getting Nixos version and verify its format:
... Expected format: major.minor.yyyymmdd.commit_hash (name)
[Tags] bat SP-T60 nuc orin-agx orin-nx riscv
[Tags] bat SP-T60 nuc orin-agx orin-nx riscv lenovoX1
[Setup] Connect
Verify Nixos Version Format
[Teardown] Close All Connections
Expand Down