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

Enable Integration tests #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions integration_test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/test
/report
stderr.txt
stdout.txt
/edk2/
119 changes: 119 additions & 0 deletions integration_test/Shared_Keywords.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
*** Settings ***
Documentation A shared set of common keywords for stuart operations and git operations
#
# Copyright (c), Microsoft Corporation
# SPDX-License-Identifier: BSD-2-Clause-Patent

Library Process
Library OperatingSystem

# Suite Setup

*** Variables ***

#Test output location
${TEST_OUTPUT} ${TEST_OUTPUT_BASE}

*** Keywords ***

### Git operations ###
Clone the git repo
[Arguments] ${git_url} ${ws_name}

Log To console cloning ${git_url} to ${TEST_OUTPUT}
${result}= Run Process git clone ${git_url} ${ws_name}
... cwd=${TEST_OUTPUT} stdout=stdout.txt stderr=stderr.txt
Log Many stdout: ${result.stdout} stderr: ${result.stderr}

${result}= Run Process git fetch --all --prune
... cwd=${TEST_OUTPUT}${/}${ws_name} stdout=stdout.txt stderr=stderr.txt
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Should Be Equal As Integers ${result.rc} 0

Reset git repo to default branch
[Arguments] ${ws} ${default_branch_name}

# checkout remote tag for origin/<default branch>
${result}= Run Process git checkout origin/${default_branch_name}
... cwd=${ws} stdout=stdout.txt stderr=stderr.txt
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Should Be Equal As Integers ${result.rc} 0

# clean non ignored files quietly to avoid log overflow
${result}= Run Process git clean -qfd cwd=${ws}
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Should Be Equal As Integers ${result.rc} 0

# reset to restore files
${result}= Run Process git reset --hard
... cwd=${ws} stdout=stdout.txt stderr=stderr.txt
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Should Be Equal As Integers ${result.rc} 0

Get default branch from remote
[Arguments] ${ws}

# Set origin head to auto
${result}= Run Process git remote set-head origin --auto
... cwd=${ws}
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Should Be Equal As Integers ${result.rc} 0

# get the head
${result}= Run Process git rev-parse --abbrev-ref origin/HEAD
... cwd=${ws}
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Should Be Equal As Integers ${result.rc} 0

# Strip off origin/ from the branch because all other commands
# add the remote name.
${branch}= Get Substring ${result.stdout} 7

[Return] ${branch}

### Stuart operations ###
Stuart setup
[Arguments] ${setting_file} ${arch} ${target} ${packages} ${tool_chain} ${ws}
Log to console Stuart Setup
${result}= Run Process stuart_setup
... -c ${setting_file} -a ${arch} TOOL_CHAIN_TAG\=${tool_chain} -t ${target} -p ${packages} TARGET\=${target}
... cwd=${ws} stdout=stdout.txt stderr=stderr.txt
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Should Be Equal As Integers ${result.rc} 0

Stuart update
[Arguments] ${setting_file} ${arch} ${target} ${packages} ${tool_chain} ${ws}
Log to console Stuart Update
${result}= Run Process stuart_update
... -c ${setting_file} -a ${arch} TOOL_CHAIN_TAG\=${tool_chain} -t ${target} -p ${packages} TARGET\=${target}
... cwd=${ws} stdout=stdout.txt stderr=stderr.txt
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Should Be Equal As Integers ${result.rc} 0

Stuart platform build
[Arguments] ${setting_file} ${arch} ${target} ${tool_chain} ${ws}
Log to console Stuart Build
${result}= Run Process stuart_build
... -c ${setting_file} -a ${arch} TOOL_CHAIN_TAG\=${tool_chain} TARGET\=${target}
... cwd=${ws} stdout=stdout.txt stderr=stderr.txt
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Should Be Equal As Integers ${result.rc} 0

Stuart platform run
[Arguments] ${setting_file} ${arch} ${target} ${tool_chain} ${addtional_flags} ${ws}
Log to console Stuart Build Run
${result}= Run Process stuart_build
... -c ${setting_file} -a ${arch} TOOL_CHAIN_TAG\=${tool_chain} TARGET\=${target} --FlashOnly ${addtional_flags}
... cwd=${ws} stdout=stdout.txt stderr=stderr.txt
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Should Be Equal As Integers ${result.rc} 0

### Edk2 BaseTools Build operations ###
Build BaseTools
[Arguments] ${tool_chain} ${ws}
Log to console Compile basetools
${result}= Run Process python
... BaseTools/Edk2ToolsBuild.py -t ${tool_chain}
... cwd=${ws} shell=True stdout=stdout.txt stderr=stderr.txt
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
101 changes: 101 additions & 0 deletions integration_test/azure-pipelines/robot-integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
##
# Azure Pipeline integration test using robot framework
# and edk2 / Project Mu public repositories
#

# Copyright (c) 2019, Microsoft Corporation
# SPDX-License-Identifier: BSD-2-Clause-Patent
##

jobs:
- job: Integration_Test

#Use matrix to speed up the build process
strategy:
matrix:
EDK2_VS2019:
Tag: 'Windows'
Image: 'windows-2019'
EDK2_GCC5:
Tag: 'Ubuntu'
Image: 'ubuntu-18.04'

workspace:
clean: all

pool:
vmImage: $(Image)

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.10.x'
architecture: 'x64'

- script: pip install --upgrade -r requirements.txt
displayName: 'Install requirements'

- script: pip install --upgrade -r integration_test/pip-requirements.txt
displayName: 'Install Integration test requirements'

- script: pip install -e .
displayName: 'Install from Source'

- powershell: choco install qemu --version=2020.08.14; Write-Host "##vso[task.prependpath]c:\Program Files\qemu"
displayName: Install QEMU and Set QEMU on path # friendly name displayed in the UI
condition: contains(variables.Tag, 'Windows')

- script: sudo dpkg --add-architecture i386
displayName: EmulatorPkg - Add i386 Arch
condition: contains(variables.Tag, 'Ubuntu')

- script: sudo apt-get update
displayName: Update for dependencies
condition: contains(variables.Tag, 'Ubuntu')

- script: sudo apt-get install uuid-dev
displayName: Install General dependencies
condition: contains(variables.Tag, 'Ubuntu')

- script: sudo apt-get install libc6-dev:i386 libx11-dev:i386 libxext-dev:i386 lib32gcc-7-dev
displayName: EmulatorPkg - Install dependencies
condition: contains(variables.Tag, 'Ubuntu')

- script: git config --global user.email "[email protected]"
displayName: Configure git user user.email

- script: git config --global user.name "Your Name"
displayName: Configure git user user.name

- script: python -m robot.run -v TEST_OUTPUT_BASE:$(Build.BinariesDirectory) -d report --xunit xunittestresults.xml --include $(Tag) -L TRACE .
displayName: 'Run Robot Tests'
workingDirectory: "integration_test"

# Copy the build logs to the artifact staging directory
- task: CopyFiles@2
displayName: "Copy logs"
inputs:
targetFolder: '$(Build.ArtifactStagingDirectory)'
SourceFolder: 'integration_test/report'
contents: |
log.html
output.xml
report.html
flattenFolders: true
condition: succeededOrFailed()

# Publish build artifacts to Azure Artifacts/TFS or a file share
- task: PublishBuildArtifacts@1
continueOnError: true
displayName: "Publish logs"
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'Logs $(System.JobName)'
condition: succeededOrFailed()

- task: PublishTestResults@2
inputs:
testResultsFiles: xunittestresults.xml
searchFolder: 'integration_test/report'
condition: succeededOrFailed()
displayName: 'Publish Test Results'
Loading