Skip to content

Commit

Permalink
less tests
Browse files Browse the repository at this point in the history
  • Loading branch information
soumeh01 committed Jul 24, 2024
1 parent 3725ad7 commit 048ac2f
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 155 deletions.
1 change: 1 addition & 0 deletions .github/workflows/e2e_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
- name: Run Test
shell: bash
continue-on-error: true
run: |
robot --outputdir reports-${{ matrix.target }}-${{ matrix.arch }} \
--settag ${{ matrix.target }}-${{ matrix.arch }} \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ jobs:
--variable TEST_ENV_FILE:test-env-${{ matrix.target }}-${{ matrix.arch }}.md \
--consolewidth=150 --settag ${{ matrix.target }}-${{ matrix.arch }} \
--name ${{ matrix.target }}-${{ matrix.arch }} \
./test/pack_example_tests.robot
./test
- name: Archieve test results
if: always()
Expand Down
21 changes: 17 additions & 4 deletions test/lib/elf_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import subprocess
from robot.api import logger
from robot.utils import asserts
from pathlib import Path

def compare_elf_information(input_file, cbuildgen_out_dir, cbuild2cmake_out_dir):
logger.debug('Input file: %s' % input_file)
logger.debug('Cbuildgen out dir: %s' % cbuildgen_out_dir)
logger.debug('Cbuild2cmake out dir: %s' % cbuild2cmake_out_dir)
logger.info('Input file: %s' % input_file)
logger.info('Cbuildgen out dir: %s' % cbuildgen_out_dir)
logger.info('Cbuild2cmake out dir: %s' % cbuild2cmake_out_dir)
return CompareELF(input_file, cbuildgen_out_dir, cbuild2cmake_out_dir).compare_elf_files()

class Context:
Expand Down Expand Up @@ -34,7 +35,7 @@ class Utils:
def run_command(exe_path, args):
try:
command = exe_path + ' ' + ' '.join(args)
logger.info(f"Running Command: {' '.join(command)}")
logger.info('Running Command: %s' % command)
processOut = subprocess.run(command, check=True, shell=True, universal_newlines=True, capture_output=True, timeout=300)
return True, processOut.stdout
except subprocess.CalledProcessError as e:
Expand Down Expand Up @@ -66,6 +67,18 @@ def compare_elf_files(self):
if path != '':
cbuildgen_elf_file = os.path.join(self.cbuildgen_out_dir, path)
cbuild2cmake_elf_file = os.path.join(self.cbuild2cmake_out_dir, path)
cbuildgenPath = Path(cbuildgen_elf_file)
cbuild2cmakePath = Path(cbuild2cmake_elf_file)
if cbuildgenPath.exists():
logger.info('Path Exist: %s' % cbuildgenPath)
else:
logger.info('Path doesnot Exist: %s' % cbuildgenPath)

if cbuild2cmakePath.exists():
logger.info('Path Exist: %s' % cbuild2cmakePath)
else:
logger.info('Path doesnot Exist: %s' % cbuild2cmakePath)

res1, stdout1 = self.get_elf_info(cbuildgen_elf_file)
res2, stdout2 = self.get_elf_info(cbuild2cmake_elf_file)
logger.info('Object Info %s' % stdout1)
Expand Down
5 changes: 3 additions & 2 deletions test/lib/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import glob
from pathlib import Path
# import stat
import subprocess
import re
# import os
Expand All @@ -14,7 +13,9 @@ def get_parent_directory_name(file_path:str):
return parent_dir.name

def get_parent_directory_path(file_path:str):
return Path(file_path).parent.absolute()
absPath = Path(file_path).parent.absolute()
path = str(absPath).replace('\\', '/')
return path

def write_test_environment(test_env_file:str):
toolList = ["cbuild", "cpackget", "csolution", "cbuild2cmake", "cbuildgen"]
Expand Down
20 changes: 7 additions & 13 deletions test/local_example_tests.robot
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Resource resources${/}global.resource
Resource resources${/}utils.resource
Library String
Library Collections
Library lib${/}elf_compare.py
Library lib${/}utils.py
Test Template Run CSolution Project
Library lib${/}elf_compare.py
Test Template Build Local CSolution Example
*** Variables ***
# The directory name of the example to be built
# The directory name of the examples to be built
${build-asm} build-asm
${build-c} build-c
${build-cpp} build-cpp
Expand Down Expand Up @@ -55,13 +55,7 @@ Validate trustzone Example
${TEST_DATA_DIR}${/}${trustzone}${/}solution.csolution.yml ${Pass}
*** Keywords ***
Run Csolution Project
[Arguments] ${input_file} ${expect} ${args}=@{EMPTY}
Run Project With cbuildgen ${input_file} ${expect} ${args}
Run Project with cbuild2cmake ${input_file} ${expect} ${args}
${parent_path}= Get Parent Directory Path ${input_file}
${result}= Run Keyword And Return
... Compare Elf Information ${input_file}
... ${parent_path}${/}${Out_Dir}${/}${Default_Out_Dir}
... ${parent_path}${/}${Default_Out_Dir}
Should Be True ${result}
Build Local CSolution Example
[Arguments] ${input_file} ${expect} ${args}=@{EMPTY}
${result}= Build CSolution Example ${input_file} ${expect} ${args}
Should Be True ${result}
1 change: 1 addition & 0 deletions test/pack_example_tests.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*** Test Cases ***;${pack_id};${expect};[Tags];[Documentation]
NXP::FRDM-K32L3A6_BSP.17.0.0;NXP::FRDM-K32L3A6_BSP@17.0.0;${0};;
NXP::LPCXpresso55S69_BSP.18.0.0;NXP::LPCXpresso55S69_BSP@18.0.0;${0};;
NXP::LPCXpresso55S69_USB_Examples.1.0.0;NXP::LPCXpresso55S69_USB_Examples@1.0.0;${0};;
NXP::FRDM-K32L3A6_BSP.18.0.0;NXP::FRDM-K32L3A6_BSP@18.0.0;${0};;
Expand Down
49 changes: 16 additions & 33 deletions test/pack_example_tests.robot
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
*** Settings ***
Documentation Tests to compile & execute remote csolution examples
Documentation Tests to build pack csolution examples
Suite Setup Global Setup
Suite Teardown Global Teardown
Library lib${/}utils.py
Library BuiltIn
Library String
Library Collections
Library lib${/}elf_compare.py
Library DataDriver
Library OperatingSystem
Library String
Library lib${/}elf_compare.py
Library lib${/}utils.py
Resource resources${/}global.resource
Resource resources${/}utils.resource
Test Template Test packs examples
Expand All @@ -23,7 +23,7 @@ Test pack example ${pack_id} and expect ${expect} Default UserData
*** Keywords ***
Test packs examples
[Arguments] ${pack_id} ${expect}
${pack_root_dir}= Join And Normalize Path ${TEST_DATA_DIR} ${Local_Pack_Root_Dir}
${pack_root_dir}= Join Paths ${TEST_DATA_DIR} ${Local_Pack_Root_Dir}
Create Directory ${pack_root_dir}
Cpackget Init ${pack_root_dir}
Cpackget Install Pack ${pack_id} ${pack_root_dir}
Expand All @@ -36,27 +36,22 @@ Test packs examples
Run Csolution Project
[Arguments] ${input_file} ${expect} ${args}=@{EMPTY}
${contexts}= Get Contexts From Project ${input_file} ${expect} ${args}
${filcontexts}= Convert And Filter Contexts ${contexts}
Log Many ${args}
Log Many ${filcontexts}
# Append To List ${args} ${filcontexts}
@{MERGED_LIST} Create List @{args} @{filcontexts}
Log Many ${MERGED_LIST}
Run Project With cbuildgen ${input_file} ${expect} ${MERGED_LIST}
Run Project with cbuild2cmake ${input_file} ${expect} ${args}
${parent_path}= Get Parent Directory Path ${input_file}
${result}= Run Keyword And Return
... Compare Elf Information ${input_file}
... ${parent_path}${/}${Out_Dir}${/}${Default_Out_Dir}
... ${parent_path}${/}${Default_Out_Dir}
Should Be True ${result}
${contexts}= Get Contexts From Project ${input_file} ${expect} ${args}
${filcontexts}= Convert And Filter Contexts ${contexts}
@{MERGED_LIST} Create List @{args} @{filcontexts}
Build Example With cbuildgen ${input_file} ${expect} ${MERGED_LIST}
Build Example with cbuild2cmake ${input_file} ${expect} ${MERGED_LIST}
${parent_path}= Get Parent Directory Path ${input_file}
${result}= Run Keyword And Return
... Compare Elf Information ${input_file}
... ${parent_path}${/}${Out_Dir}${/}${Default_Out_Dir}
... ${parent_path}${/}${Default_Out_Dir}
Should Be True ${result}
Convert And Filter Contexts
[Documentation] Example test to convert a string to an array, filter it, and join it
[Arguments] ${all_contexts}
@{lines}= Split String ${all_contexts} \n
Log ${lines}
# Filter out items containing '+iar'
@{filtered_lines}= Create List
Expand All @@ -65,23 +60,11 @@ Convert And Filter Contexts
${result}= Run Keyword And Return Status Should Contain ${line} iar
Run Keyword If ${result}==False Append To List ${filtered_lines} ${line}
END
Log Many ${filtered_lines}
# # Prefix remaining items with '-c ' and join them
# ${context_string}= Set Variable ${EMPTY}
# FOR ${line} IN @{filtered_lines}
# Append To List
# ${context_string}= Evaluate "-c ${line} ${context_string}"
# END
# Log Many ${context_string}
# RETURN ${context_string}
# Prefix remaining items with '-c ' and join them
@{context_list_args}= Create List
FOR ${line} IN @{filtered_lines}
Append To List ${context_list_args} -c ${line}
END
Log Many ${context_list_args}
RETURN ${context_list_args}
32 changes: 11 additions & 21 deletions test/remote_example_tests.robot
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
Documentation Tests to compile & execute remote csolution examples
Suite Setup Global Setup
Suite Teardown Global Teardown
Library lib${/}utils.py
Library String
Library Collections
Library lib${/}elf_compare.py
Library DataDriver
Library Collections
Library String
Library lib${/}utils.py
Resource resources${/}global.resource
Resource resources${/}utils.resource
Test Template Test github examples
Expand All @@ -17,24 +16,15 @@ Test remote example ${github_url} and expect ${expect} Default UserData
*** Keywords ***
Test github examples
[Arguments] ${github_url} ${expect}
[Arguments] ${github_url} ${expect}
${dest_dir}= Get Destination Path ${github_url}
# ${dest_dir}= Evaluate "${github_url}".split('/')[-1]
# ${dest_dir}= Set Variable ${TEST_DATA_DIR}${/}${Remote_Example_Dir}${/}${dest_dir}
Checkout GitHub Repository ${github_url} ${dest_dir}
${files} Glob Files In Directory ${dest_dir} *.csolution.* ${True}
Checkout GitHub Repository ${github_url} ${dest_dir}
${files} Glob Files In Directory ${dest_dir} *.csolution.* ${True}
FOR ${file} IN @{files}
# ${example_name}= Get Parent Directory Name ${file}
Run Csolution Project ${file} ${expect}
Build Remote CSolution Example ${file} ${expect}
END
Run Csolution Project
[Arguments] ${input_file} ${expect} ${args}=@{EMPTY}
Run Project With cbuildgen ${input_file} ${expect} ${args}
Run Project with cbuild2cmake ${input_file} ${expect} ${args}
${parent_path}= Get Parent Directory Path ${input_file}
${result}= Run Keyword And Return
... Compare Elf Information ${input_file}
... ${parent_path}${/}${Out_Dir}${/}${Default_Out_Dir}
... ${parent_path}${/}${Default_Out_Dir}
Should Be True ${result}
Build Remote CSolution Example
[Arguments] ${input_file} ${expect} ${args}=@{EMPTY}
${result}= Build CSolution Example ${input_file} ${expect} ${args}
Should Be True ${result}
Loading

0 comments on commit 048ac2f

Please sign in to comment.