Project restart

This commit is contained in:
2025-12-29 10:46:05 +01:00
commit 59d19cb48c
388 changed files with 48020 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
- unittest_file:
name: Test 5
test_file: dummy.py

View File

@@ -0,0 +1,16 @@
sequence: &endurance_test
!include endurance.tum
sequence:
- unittest_file:
name: Test 3
test_file: dummy.py
test_method: test_01_pass
- loop:
iterator: 10
steps:
*endurance_test
- unittest_file:
name: Test 4
test_file: dummy.py

View File

@@ -0,0 +1,10 @@
def setTemperature(param):
print('Tempe set : %s'%param)
def temperatureAtteinte(param):
if int(param) > 50:
return True
else:
return False

View File

@@ -0,0 +1,40 @@
import unittest
from time import sleep
def donothing():
return 0
class DummyTests(unittest.TestCase):
@unittest.skip("test skipped")
def test_00_skipped(self):
''' Test 00 is skipped
'''
sleep(0.5)
def test_01_pass(self):
''' Test 01 is passed and adds a report key
'''
self.reported_values['key reported']= 'value_reported'
sleep(0.5)
def test_02_pass(self):
''' Test 02 is passed and adds a report key
'''
self.reported_values['key reported']= 'toto'
sleep(0.5)
def test_03_fail(self):
''' Test 03 is fail by unittest method
'''
sleep(0.5)
self.fail(msg='Fail message')
def test_04_disabled(self):
''' Test 04 is disabled
'''
sleep(0.5)
def test_05_crash(self):
''' Test 05 crashes
'''
print(crash)

View File

@@ -0,0 +1,51 @@
sequence: &temperature_step_sequence
!include tum/temperature.tum
main:
name: Test Sample number one
version: 0.1
steps:
- dialog_references:
name: Ask for reference
question: Please give the reference of the product
reference:
- $(reference_1)
- $(reference_2)
report_show_success: true
- unittest_file:
name: Test 1
test_file: dummy.py
doc: |
Ceci est le test n°1
Voilà...
- sleep:
{name: Sleep between one and two, timeout: 10, dialog: true}
- unittest_file:
{name: Test 2, test_file: dummy.py,execute_on_stop: true}
- loop:
name: Cycle Temperature
iterator : [10,20]
steps:
- py_func:
name: set temperature
file: cycle_temperature.py
func_name: setTemperature
param : $(loop_param)
- *temperature_step_sequence
- py_func:
name: temperature reached
file: cycle_temperature.py
func_name: temperatureAtteinte
param : $(loop_param)
####### REPORT ######
report:
module: test_report_text.py
class: TestReportTxt
title: My Dummy Tests
headers: False
banners: False

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" ?>
<root>
<parameter name="func_param" value="param"/>
</root>

View File

@@ -0,0 +1,13 @@
import random
import libs.testium as tm
from libs.testium import FunctionItem
def random_value():
return random.random()
class LastValues(FunctionItem):
def exec(self, name):
res = tm.last_plot_value(name)
self.reportValue('my_reported_value', res)
print("Last plot value: {}".format(res))
return res

View File

@@ -0,0 +1,10 @@
import libs.testium as tm
def post_exec():
print('Success !!!!')
print(str(tm.gd('test_outputs')))
def post_exec_fail():
print('Failure :(')
print(str(tm.gd('test_outputs')))

View File

@@ -0,0 +1,18 @@
import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)

View File

@@ -0,0 +1,110 @@
main:
name: Test conditionals
version: 0.1
stop_on_failure: False
steps:
- group:
name: Set test variables depending on the OS
steps:
- let:
name: Set test variables for Linux
condition: "'$(os)' == 'Linux'"
values:
- terminal_prompt: $(linux_prompt)
- let:
name: Set test variables for Windows
condition: "'$(os)' == 'Windows'"
values:
- terminal_prompt: $(windows_prompt)
# This loop illustrate the way to exit the loop upon operator answer
- loop:
doc: This loop illustrate the way to exit the loop upon operator answer.
name: Infine loop with conditional exit
stop_on_failure: False
steps:
- sleep:
name: sleep item
timeout: 5
- dialog_question:
name: Question to continue
question: Answer yes to exit the loop
no_fail: True
exit_condition:
value: "'$(last_test_result)' == 'PASS'"
- let:
name: let
eval:
- conditional_exec: "random.randint(1, 4)"
- console:
name: Console creation
condition: "$(conditional_exec) == 1"
console_name: consname
doc: Opening the console
steps:
- open:
protocol: terminal
terminal_path: $(test_directory)
- console:
name: Console read_until with timeout
condition: "$(conditional_exec) == 1"
console_name: consname
steps:
- read_until: {expected: "$(terminal_prompt)", timeout: 10}
- console:
name: Console write
condition: "$(conditional_exec) == 1"
console_name: consname
steps:
- writeln: echo 0
- sleep:
name: sleep item
condition: "$(conditional_exec) == 1"
timeout: 5
- console:
name: Console read_until immediate
condition: "$(conditional_exec) == 1"
console_name: consname
steps:
- read_until: {expected: "0", timeout: 0}
- console:
name: Console read_until immediate (2)
condition: "$(conditional_exec) == 1"
console_name: consname
steps:
- read_until: {expected: "$(terminal_prompt)", timeout: 0}
- console:
name: Console closure
condition: "$(conditional_exec) == 1"
console_name: consname
steps:
- close: consname
- sleep:
name: sleep item
condition: "$(conditional_exec) == 2"
timeout: 5
- dialog_image:
name: dialog image item
condition: "$(conditional_exec) == 3"
question: click ok if you see the image
filename: image.jpg
- dialog_value:
name: dialog_value item
condition: "$(conditional_exec) == 4"
question: enter something and click ok

View File

@@ -0,0 +1,278 @@
#This suite make the simplest call to each item.
#
main:
name: Test Sample number one
version: 0.1
stop_on_failure: False
steps:
# This loop contains a failing step and exits.
- loop:
doc: This loop contains a failing step and exits.
name: Infine loop step fails
key: report-key-2
stop_on_failure: True
steps:
- unittest_file:
name: unittest item
doc: |
The purpose of this unittest test item is to demonstrate
its various features.
test_file: dummy/dummy.py
test_method: test_01_pass
- py_func:
name: function test item
doc: The purpose of this step is to demonstrate func test item
file: utils.py
func_name: funcToBeExecuted
param:
- 123
- py_func:
name: function test item
doc: |
The purpose of this step is to demonstrate func test item
and the report key feature.
key: report-key-1
file: utils.py
func_name: funcToBeExecuted
param:
- 123
- unittest_file:
name: Unittest item
test_file: dummy/dummy.py
test_method:
- test_04_disabled
- test_03_fail
exit_condition:
file: utils.py
func_name: dummy_exit
# This loop contains a crashing function and exits.
- loop:
doc: This loop contains a crashing function and exits.
name: Infinite loop func crashes
stop_on_failure: True
steps:
- py_func:
name: function crash
file: utils.py
func_name: funcToBeExecuted2
param:
- 123
# This function crashes and does not fail because of expected result.
- py_func:
name: function crash but no fail
file: utils.py
func_name: funcToBeExecuted2
expected_result: FAIL
param:
- 123
- report:
name: Intermediate report
doc: |
The purpose of this step is to demonstrate the report test item
and its various export features.
export:
- junit:
path: $(home)/reports/report-key-1.junit
pattern:
- Unittest%
key: report-key-1
- text:
file_name: report-key-1.txt
path: $(home)/reports
key:
- report-key-1
# This loop contains a crashing unittest step and exits.
- loop:
doc: This loop contains a crashing unittest step and exits.
name: Infine loop unittest step crashes
stop_on_failure: True
steps:
- unittest_file:
name: Unittest item
test_file: dummy/dummy.py
test_method:
- test_05_crash
# This loop is an example of simple iterator.
- !include seq_cycle.tum
# This loop is an example of time exit condition.
- loop:
doc: This loop is an example of time exit condition.
name: Elapsed time exit condition
steps:
- py_func:
name: function test item
file: utils.py
func_name: funcToBeExecuted
param:
- $(loop_param)
- sleep:
name: Sleep
timeout: 0.2
dialog: false
exit_condition:
time: 0.2
# This loop is an example of value exit condition.
- loop:
doc: This loop is an example of value exit condition
name: Loop exits on a condition
steps:
- let:
name: Set a variable to the loop index
values:
- variable: $(loop_index)
- sleep:
name: Sleep
timeout: 0.2
dialog: false
exit_condition:
value: "$(variable) >= 10"
# This loop must fail du to an exception in exit condition.
- loop:
doc: This loop must fail du to an exception in exit condition.
name: Loop exit_condition crash
steps:
- py_func:
name: function test item
file: utils.py
func_name: funcToBeExecuted
param:
- 123
exit_condition:
file: utils.py
func_name: exit_exc
# This loops include complex iterator composed by global variables
- loop:
doc: This loop includes a complex iterator composed by global variables
name: Loop complex iterator
iterator:
- $(global_loop_param_txt)
- $(global_loop_param_num)
- $(global_loop_param_list)
steps:
- loop:
doc: Loop which print the iterators
name: Simple loop
iterator: $(loop_param)
steps:
- py_func:
name: function test item
file: utils.py
func_name: funcToBeExecuted
param:
- $(loop_param)
- sleep:
name: Sleep be
timeout: 0.5
dialog: false
# Loop with function having a number element of a list as expected result
- loop:
doc: Loop with function having a number element of a list as expected result
name: num list loop
iterator: $(global_loop_param_num)
steps:
- py_func:
name: function test item
file: utils.py
func_name: funcToBeExecuted
param:
- $(loop_param)
expected_result: ($(global_loop_param_num))[$(loop_index)]
- sleep:
name: Sleep be
timeout: 0.5
dialog: false
# Loop with function having a text element of a list as expected result
- loop:
doc: Loop with function having a text element of a list as expected result
name: text list loop
iterator: $(global_loop_param_txt)
steps:
- py_func:
name: function test item
file: utils.py
func_name: funcToBeExecuted
param:
- $(loop_param)
expected_result: ($(global_loop_param_txt))[$(loop_index)]
- sleep:
name: Sleep be
timeout: 0.5
dialog: false
# Loop with function having a list element of a list as expected result
- loop:
doc: Loop with function having a list element of a list as expected result
name: list of list loop
iterator: $(global_loop_param_list)
steps:
- py_func:
name: function test item
file: utils.py
func_name: funcToBeExecuted
param:
- $(loop_param)
expected_result: ($(global_loop_param_list))[$(loop_index)]
- sleep:
name: Sleep be
key: report-key-3
timeout: 0.5
dialog: false
# This is an infinite loop to be stopped manually
- loop:
doc: This is an infinite loop to be stopped manually
name: Infinite loop
skipped: True
steps:
- unittest_file:
name: Unittest item
test_file: dummy/dummy.py
test_method: test_01_pass
- sleep:
name: Sleep between one and two
timeout: 0.5
dialog: false
report:
enabled: True
# log_stored: True
export:
- sqlite:
file_name: $(test_name).sqlite
path: $(home)/reports
# - junit:
# file_name: $(test_name)_report-key-1.junit
# path: $(home)/reports
# pattern:
# - function%
# - Unittest%
# key: report-key-1
# - text:
# file_name: $(test_name)_report-key-2_3.txt
# path: $(home)/reports
# pattern: function%
# key:
# - report-key-2
# - report-key-3

View File

@@ -0,0 +1,190 @@
#This suite make the simplest call to each item.
#
config_file:
- param.xml
- param.yaml
- param.json
- $(test_directory)/dummy/param_func.xml
main:
name: Test Sample number one
version: 0.1
steps:
- unittest_file:
name: Unittest item
test_file: dummy/unittest_str.py
doc: Unittest test
- group:
name: Set test variables for Linux
condition: "'$(os)' == 'Linux'"
steps:
- let:
name: Set test variables for Linux
values:
- terminal_prompt: $(linux_prompt)
- group:
name: Set test variables for Windows
condition: "'$(os)' == 'Windows'"
steps:
- let:
name: Set test variables for Windows
values:
- terminal_prompt: $(windows_prompt)
- group:
name: Console test group
steps:
- console:
name: Console creation
console_name: consname
doc: Opening the console
steps:
- open:
protocol: terminal
terminal_path: $(test_directory)
- console:
name: Console read_until with timeout
console_name: consname
steps:
- read_until: {expected: "$(terminal_prompt)", timeout: 10}
- console:
name: Console write
console_name: consname
steps:
- writeln: echo 0
- sleep:
name: sleep item
timeout: 5
- console:
name: Console read_until immediate
console_name: consname
steps:
- read_until: {expected: "0", timeout: 0}
- console:
name: Console read_until immediate (2)
console_name: consname
steps:
- read_until: {expected: "$(terminal_prompt)", timeout: 0}
- console:
name: Console closure
console_name: consname
steps:
- close: consname
- loop:
name: cycle item
iterator : 3
steps:
- unittest_file:
name: Unittest item
test_file: dummy/dummy.py
test_method: test_01_pass
- sleep:
name: sleep item
timeout: 1
- loop:
name: cycle item
iterator : 3
steps:
- unittest_file:
name: Unittest item
test_file: dummy/dummy.py
test_method: test_01_pass
- sleep:
name: sleep item
timeout: 1
- py_func:
name: func item
file: dummy/dummy.py
func_name: donothing
- dialog_choices:
name: Choices
question: Select the items you want
icon: $(test_directory)/../../src/testium/main_win/resources/black/document.png
choices:
- name: choice 1
description: My first choice description
icon: $(test_directory)/../../src/testium/main_win/resources/black/document-save.png
choices:
- name: choice 1.1
description: My choice 1 first subchoice description
icon: $(test_directory)/../../src/testium/main_win/resources/black/Label.png
- name: choice 1.2
description: My choice 1 first subchoice description
- name: choice 2
description: My second choice description
icon: $(test_directory)/../../src/testium/main_win/resources/black/image.png
- name: choice 3
description: My third choice description
icon: $(test_directory)/../../src/testium/main_win/resources/black/image.png
choices:
- name: choice 3.1
description: My choice 3 first subchoice description
- name: choice 3.2
description: My choice 3 second subchoice description
icon: $(test_directory)/../../src/testium/main_win/resources/black/Label.png
- dialog_image:
name: dialog image item
question: click ok if you see the image
filename: image.jpg
- sleep:
name: sleep item
timeout: 3
dialog: true
- git:
name: Testium repo
repo: $(test_directory)
- group:
name: group item
steps:
- sleep:
name: sleep item
timeout: 1
- sleep:
name: sleep item
timeout: 1
- dialog_references:
name: dialog_reference item
question: click ok
# reference:
# - ref 1
# - ref 2/rev
# - ref 3/rev/01
- dialog_value:
name: dialog_value item
question: enter something and click ok
- dialog_message:
name: dialog_message item
question: click ok
- dialog_question:
name: dialog_question item
question: click yes
report:
enabled: True
file_name: $(test_name).rep
path: $(home)/reports
pattern: "Console%"
log_stored: False

View File

@@ -0,0 +1,87 @@
config_file:
- param.yaml
main:
name: Example of plot item usage
version: 0.1
steps:
- console:
name: Creation of the log dir
console_name: console
steps:
- open:
protocol: terminal
terminal_path: $(test_directory)
- writeln: mkdir -p "$(plot_log_path)" && echo Fini
- read_until: {expected: Fini, timeout: 5}
- console:
name: Console closure
execute_on_stop: true
console_name: console
steps:
- close:
- plot:
name: Open the plot
plot_name: Mon Plot
steps:
- open:
log_path: $(plot_log_path)
- plot:
name: Add periodic to the plot
plot_name: Mon Plot
steps:
- periodic:
period: 1
file: $(test_directory)/dummy/plot.py
func_name: random_value
eval: '{"periodic": $(result)}'
- sleep:
name: sleep
dialog: true
timeout: 3
- loop:
name: Add of other data in the plot
iterator: 10
steps:
- plot:
name: Add to the plot
plot_name: Mon Plot
steps:
- add:
value1: $(loop_index)
value2: $(loop_index)+2
- sleep:
name: sleep between values
timeout: 1
- py_func:
name: last plot values
file: $(test_directory)/dummy/plot.py
func_name: LastValues
param:
- Mon Plot
- plot:
name: Export
execute_on_stop: True
plot_name: Mon Plot
steps:
- export: $(plot_log_path)/plot_export.pdf
- export: $(plot_log_path)/plot_export.csv
- plot:
name: Close the plot
execute_on_stop: True
plot_name: Mon Plot
steps:
- close:
wait_dialog_exit: True
timeout: 60

View File

@@ -0,0 +1,11 @@
main:
name: Test run Item
steps:
- run:
name: Execute TUM
tum_file: example_cycle.tum
python_path: python3
testium_path: /home/francois/Projets/testium/src/testium
log_file: $(home)/reports/test.log
report_file: $(home)/reports/test.rep

View File

@@ -0,0 +1,27 @@
#This suite use a sequence as a macro to repeat items
#
sequence: &seq_sleep
!include $(sequence)
main:
name: Test Sample number one
version: 0.1
stop_on_failure: False
steps:
# This loop is an example of value exit condition.
- loop:
doc: This loop is an example of value exit condition
name: Loop exits on a condition
steps:
- let:
name: Set a variable to the loop index
values:
- variable: $(loop_index)
- sleep_timeout: $(loop_index)
- *seq_sleep
exit_condition:
value: "$(variable) >= 3"
- !include {file: seq2.tum, is_dialog: True, sleep_timeout: 12, func_para: truc}

View File

@@ -0,0 +1,18 @@
main:
name: Test conditionals
version: 0.1
stop_on_failure: False
steps:
- py_func:
name: function test item
doc: The purpose of this step is to demonstrate func test item
file: utils.py
func_name: funcToBeExecuted
param:
- 123
- sleep:
name: sleep item
dialog: True
timeout: 3600

View File

@@ -0,0 +1,40 @@
main:
name: Test ssh
version: 0.1
stop_on_failure: False
steps:
- console:
name: Console creation
console_name: consname
doc: Opening the console
steps:
- open:
protocol: ssh
ssh_host: "my_hostname"
ssh_user: "francois"
- console:
name: Console read
console_name: consname
doc: Opening the console
steps:
- writeln: rm -f /tmp/toto.txt && echo done
- read_until: {expected: "done", timeout: 10}
- read_until: {expected: "$ ", timeout: 1}
- writeln: touch /tmp/toto.txt && echo done
- read_until: {expected: "done", timeout: 10}
- read_until: {expected: "$ ", timeout: 1}
- writeln: echo "blablabla" >> /tmp/toto.txt && echo done
- read_until: {expected: "done", timeout: 10}
- read_until: {expected: "$ ", timeout: 1}
- writeln: cat /tmp/toto.txt && echo done
- read_until: {expected: "done", timeout: 10}
- read_until: {expected: "$ ", timeout: 1}
- console:
name: Console deletion
console_name: consname
doc: Closing the console
steps:
- close: consname

View File

@@ -0,0 +1,29 @@
main:
name: Test illustrating string manipulation
version: 0.1
stop_on_failure: False
steps:
- let:
name: Set string value
values:
- rand_text: |
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 005: ID 0bda:0487 Realtek Semiconductor Corp. Dell dock
Bus 002 Device 006: ID 0bda:0413 Realtek Semiconductor Corp. Dell dock
Bus 002 Device 007: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 003: ID 04f2:b684 Chicony Electronics Co., Ltd Chicony USB2.0 Camera
Bus 003 Device 004: ID 8087:0029 Intel Corp. AX200 Bluetooth
- text_searched: "0bda:8153"
- let:
name: Extract data
eval:
- text_extract: "[l for l in '''$(rand_text)'''.splitlines() if '$(text_searched)' in l][0]"
- dialog_message:
condition: len('$(text_extract)') > 0
name: dialog value test item
question: Tataaaaa !

BIN
doc/examples/image.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

4
doc/examples/param.json Normal file
View File

@@ -0,0 +1,4 @@
{
"global_loop_param_list": [["one", "two", "three"],[1, 2, 3]]
}

9
doc/examples/param.xml Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" ?>
<root>
<!-- ****************************************************************************
Test configuration
**************************************************************************** -->
<parameter name="windows_prompt" value=">"/>
<parameter name="linux_prompt" value="$"/>
<parameter name="sequence" value="tm.tum"/>
</root>

10
doc/examples/param.yaml Normal file
View File

@@ -0,0 +1,10 @@
#****************************************************************************
# Test configuration
#**************************************************************************** -->
# loops parameters
global_loop_param_txt: ['one', 'two', 'three']
global_loop_param_num: [1, 2, 3]
# Plot parameters
plot_log_path: /tmp/testium_plot/$(testrun_date)/$(testrun_time)/

View File

@@ -0,0 +1,7 @@
import py_func.tm as tm
def post_exec():
print("post_exec PASS")
def post_exec_fail():
print("post_exec_fail PASS")

17
doc/examples/seq.tum Normal file
View File

@@ -0,0 +1,17 @@
# This sequence uses a parameter defined at the upper level in the file including this sequence
- sequence:
- sleep:
name: Sleep
timeout: $(sleep_timeout)
dialog: false
- dialog_message:
name: dialog_message item
question: value is $(sleep_timeout)
- py_func:
name: function test item
file: utils.py
func_name: funcToBeExecuted
param:
- $(loop_param)

16
doc/examples/seq2.tum Normal file
View File

@@ -0,0 +1,16 @@
- sleep:
name: Sleep {{ sleep_timeout }} sec
timeout: {{ sleep_timeout }}
dialog: {{ is_dialog }}
- dialog_message:
name: dialog_message item
question: value is {{ sleep_timeout }}
- py_func:
name: function test item
file: utils.py
func_name: funcToBeExecuted
param:
- {{ func_param }}

View File

@@ -0,0 +1,14 @@
# This loop is an example of simple iterator.
- loop:
doc: This loop is an example of simple iterator.
name: Simple iterator
iterator: 25
steps:
- py_func:
name: function test item
file: utils.py
func_name: funcToBeExecuted
param:
- $(loop_param)
expected_result: $(loop_param)

13
doc/examples/utils.py Normal file
View File

@@ -0,0 +1,13 @@
def dummy_exit(useless1, useless2):
return True
def exit_exc(useless1, useless2):
raise Exception('Crash of exit function')
def funcToBeExecuted (bla):
print(bla)
return bla
def funcToBeExecuted2 (bla):
print(bla)
return blo