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

Fix tests #60

Merged
merged 3 commits into from
Dec 13, 2022
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
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ if(WIN32)
add_custom_command(TARGET copy_xml_in_build
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/test
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/$<CONFIG>/test)
${PROJECT_SOURCE_DIR}/tests
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/$<CONFIG>/tests)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/$<CONFIG>/config.xml"
INPUT "${CMAKE_CURRENT_LIST_DIR}/config.xml")
else()
file(COPY ${PROJECT_SOURCE_DIR}/test
file(COPY ${PROJECT_SOURCE_DIR}/tests
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
file(COPY ${PROJECT_SOURCE_DIR}/gzworld
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
Expand All @@ -144,7 +144,7 @@ else()
endif()

# conf files
install(DIRECTORY test DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY tests DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY gzworld DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES config.xml DESTINATION ${CMAKE_INSTALL_BINDIR})

Expand Down
64 changes: 33 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
- [5.3. Prerequisite Windows](#53-prerequisite-windows)
- [5.4. Installation and compilation](#54-installation-and-compilation)
- [6. Test writing](#6-test-writing)
- [Tests structure](#tests-structure)
- [6.1. General Settings](#61-general-settings)
- [6.2. Library Settings](#62-library-settings)
- [6.3. Prerequisites](#63-prerequisites)
- [6.4. Test list](#64-test-list)
- [6.4.1. Parallel or series execution](#641-parallel-or-series-execution)
- [6.4.2. Repetitions](#642-repetitions)
- [6.5. Finally the test](#65-finally-the-test)
- [6.5.1. Generic commands](#651-generic-commands)
- [6.6. Test writing with Scriptbuilder](#66-test-writing-with-scriptbuilder)
- [6.1. Tests structure and main test file](#61-tests-structure-and-main-test-file)
- [6.2. General Settings](#62-general-settings)
- [6.3. Library Settings](#63-library-settings)
- [6.4. Prerequisites](#64-prerequisites)
- [6.5. Test list](#65-test-list)
- [6.5.1. Parallel or series execution](#651-parallel-or-series-execution)
- [6.5.2. Repetitions](#652-repetitions)
- [6.6. Finally the test](#66-finally-the-test)
- [6.6.1. Generic commands](#661-generic-commands)
- [6.7. Test writing with Scriptbuilder](#67-test-writing-with-scriptbuilder)
- [7. Parametric test](#7-parametric-test)
- [7.1. Table](#71-table)
- [7.2. Using the parameter](#72-using-the-parameter)
Expand All @@ -62,8 +62,8 @@
- [11. Gazebo](#11-gazebo)
- [11.1. Speed up model creation](#111-speed-up-model-creation)
- [11.2. World file](#112-world-file)
- [12. Authors](#12-authors)

- [12. Examples](#12-examples)
- [13. Authors](#13-authors)

# 4. Introduction

Expand Down Expand Up @@ -178,16 +178,14 @@ are stored.
If you are using the [`robotology-superbuild`](https://github.com/robotology/robotology-superbuild) with the `ROBOT_TESTING` profile enabled, the variable is already exported by the superbuild setup scripts.
# 6. Test writing


For easy test writing, you can skip directly to the section [Scriptbuilder](##5.6.-test-writing-with-scriptbuilder). You can use the test writing tool called ScriptBuilder. <br>
Otherwise, the starting point for writing a test is the file ./test/test.xml, see below.

## Tests structure
Otherwise, the starting point for writing a test is the file ./test/test.xml (`the main test file`), see below.

In figure you can see tests structure.
## 6.1. Tests structure and main test file
In the figure below, you can see the test structure.
![alt](img/teststruct.png)

The main test file is ./test/test.xml.
`The main test file` default is ./test/test.xml.

```xml
<testlist repetitions="1">a
Expand Down Expand Up @@ -228,7 +226,7 @@ This file contains:
* the prerequisites
* the tests list

## 6.1. General Settings
## 6.2. General Settings

```xml
<settings robotname="icubSim" realrobot="false" onlysimcommands="yarpcheckrobotisvertical checkRobot yarpreset applyForce" netclock="true"
Expand All @@ -250,7 +248,7 @@ This file contains:
| relativetime | true | The logging time is relative(from test start) or absolute |
| unixtime | false | If the time is absolute it can be Unix time format or string format |

## 6.2. Library Settings
## 6.3. Library Settings
In this section, it is possible to specify the plugin library to be used.

```xml
Expand Down Expand Up @@ -283,7 +281,7 @@ In this section, it is also possible to specify the plugin library settings.



## 6.3. Prerequisites
## 6.4. Prerequisites

The prerequisites are applications to be executed before the tests, if
necessary, and their parameters.
Expand All @@ -301,7 +299,7 @@ necessary, and their parameters.
| kill | true | The current prerequisite will be killed at the end of the tests. |


## 6.4. Test list
## 6.5. Test list

The test list includes all the tests written. The test list, basically,
list the tests together with the **file** in which the test has been written.
Expand All @@ -324,7 +322,7 @@ list the tests together with the **file** in which the test has been written.
| parallel | false | Should the test be executed in parallel. |
| repetitionsfortime | 0 | If specified is the time to repeat the test in seconds. |

### 6.4.1. Parallel or series execution
### 6.5.1. Parallel or series execution
It is possible to specify if some tests are executed in series or parallel.

```xml
Expand All @@ -344,11 +342,11 @@ In the above example the tests will be executed in the following way:

In the case, it is possible to insert a dummy test in series to align the following tests executions.

### 6.4.2. Repetitions
### 6.5.2. Repetitions
Repetitions can be at action or test or test list level through **"repetitions"** key (in action, test, test list).
At the test level repetitions can be also used through the key **"repetitionsfortime"**. In this case, will be executed as many repetitions as the timer in seconds will allow. Inside of test is available the key **"wait"** that indicates the time between two tests executions.

## 6.5. Finally the test
## 6.6. Finally the test

The test is written in a separate file. Here is shown an example of a
simple test. Also take a look at the following section for graphical test creation.
Expand Down Expand Up @@ -397,7 +395,7 @@ The **settings node** contains the following parameters:
| ---------- | ------- | ----------------------- |
| wait | 0 | Wait after test completion. |

### 6.5.1. Generic commands
### 6.6.1. Generic commands
These commands are contained in the generic command library plugin.

- **wait**
Expand Down Expand Up @@ -515,7 +513,7 @@ These commands are contained in the generic command library plugin.
```
The command is used to find a string in a file. If found an error is raised in the log and a backup of the file is done with the date.

## 6.6. Test writing with Scriptbuilder
## 6.7. Test writing with Scriptbuilder
Script builder is a UI for test and test list writing.
See at https://github.com/robotology/blocktest/blob/master/src/scriptbuilder/README.md
for more information.
Expand Down Expand Up @@ -845,7 +843,6 @@ Write your blocks, each block is derived from CAction.
## 10.6. XML files
Write an xml file for each block.


# 11. Gazebo
If you need to make the simulation work on Gazebo.

Expand All @@ -855,8 +852,13 @@ Be sure to add to your ./bashrc
export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:${ROBOTOLOGY_SUPERBUILD_SOURCE_DIR}/src/GazeboYARPPlugins/tutorial/model
```
## 11.2. World file
If you need you could write your own ```.world``` file take a look at the
```world``` folder
If you need you could write your own ```.world``` file take a look at the ```world``` folder

# 12. Examples

After `make install` in folder install\bin are present the following subfolders:
- tests\test-generic-command
- tests\test-yarp

# 12. Authors
# 13. Authors
* Luca Tricerri ([*personal page*](https://github.com/triccyx))
8 changes: 4 additions & 4 deletions src/genericactiondepotlib/src/actionPrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace GenericActions
{
if(target_ == "shell")
{
std::cout<<std::endl<<message_<<std::endl;
std::cout<<std::endl;
std::cerr<<std::endl<<message_<<std::endl;
std::cerr<<std::endl;

}
else if(target_ == "log")
Expand All @@ -44,8 +44,8 @@ namespace GenericActions
}
else if(target_ == "shell-log")
{
std::cout<<std::endl<<message_<<std::endl;
std::cout<<std::endl;
std::cerr<<std::endl<<message_<<std::endl;
std::cerr<<std::endl;
TXLOG(Severity::info)<<message_<<std::endl;
}

Expand Down
11 changes: 0 additions & 11 deletions test/0600.xml

This file was deleted.

11 changes: 0 additions & 11 deletions test/0601.xml

This file was deleted.

11 changes: 0 additions & 11 deletions test/0602.xml

This file was deleted.

11 changes: 11 additions & 0 deletions tests/test-generic-command/execute001.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<testbody>
<info note="Execute simple sleep." shortnote="" version="1.0" />
<logging loggingtype="" loggingpart="" loggingwrappername="" />
<settings wait="0" />

<command library="general" name="wait" seconds="1" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="execute" command="sleep" param=" 1" prefix="" tag="echo" waitafter="1" waitforend="true" expectedexitcode="0" kill="false" usetestpath="false" nobackground="true" writetofile="log/echo.log" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="wait" seconds="1" repetitions="1" wait="0" reporterror="true" />

</testbody>
11 changes: 11 additions & 0 deletions tests/test-generic-command/execute002.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<testbody>
<info note="Application execution." shortnote="" version="1.0" />
<logging loggingtype="" loggingpart="" loggingwrappername="" />
<settings wait="1" />

<command library="general" name="execute" command="xeyes" param="" prefix="" waitforend="false" expectedexitcode="0" usetestpath="false" nobackground="true" writetofile="log/echo.log" tag="xeyestag" waitafter="2" kill="false" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="wait" seconds="1" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="execute" command="" param="" prefix="" waitforend="false" expectedexitcode="0" usetestpath="false" nobackground="true" writetofile="log/echo.log" tag="xeyestag" waitafter="2" kill="true" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="wait" seconds="1" repetitions="1" wait="0" reporterror="true" />
</testbody>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0"?>
<testbody>
<info note="Execute gazebo." shortnote="" version="1.0" />
<info note="Execute simple sleep but forced to exit." shortnote="" version="1.0" />
<logging loggingtype="" loggingpart="" loggingwrappername="" />
<settings wait="0" />

<command library="general" name="wait" seconds="1" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="execute" command="sleep" param=" 10" prefix="" tag="echo" waitafter="1" waitforend="true" expectedexitcode="56" kill="false" usetestpath="false" nobackground="false" writetofile="log/echo.log" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="wait" seconds="10" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="execute" command="sleep" param=" 10" prefix="" tag="echo" waitafter="1" waitforend="true" expectedexitcode="15" kill="false" usetestpath="false" nobackground="true" writetofile="log/echo.log" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="wait" seconds="2" repetitions="1" wait="0" reporterror="true" />

</testbody>
1 change: 1 addition & 0 deletions tests/test-generic-command/files/text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a test file.
9 changes: 9 additions & 0 deletions tests/test-generic-command/findinfile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<testbody>
<info note="Find in file." shortnote="" version="1.0" />
<logging loggingtype="" loggingpart="" loggingwrappername="" />
<settings wait="0" />

<command library="general" name="findinfile" filename="./tests/test-generic-command/files/text.txt" string="test" erroronfind="false" bckiferror="false" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="findinfile" filename="./tests/test-generic-command/files/text.txt" string="notinfile" erroronfind="true" bckiferror="false" repetitions="1" wait="0" reporterror="true" />
</testbody>
12 changes: 12 additions & 0 deletions tests/test-generic-command/kill.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<testbody>
<info note="Kill a sleep command." shortnote="" version="1.0" />
<logging loggingtype="" loggingpart="" loggingwrappername="" />
<settings wait="0" />

<command library="general" name="wait" seconds="2" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="print" target="shell-log" message="******** KILLALL***************" repetitions="1" reporterror="true" />
<command library="general" name="execute" command="killall" param=" sleep" prefix="" tag="echo" waitafter="1" waitforend="true" expectedexitcode="0" kill="false" usetestpath="false" nobackground="false" writetofile="log/echo.log" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="wait" seconds="1" repetitions="1" wait="0" reporterror="true" />

</testbody>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
<librarysettings enabled="false" name="yarpactiondepot" wrappername="" robotname="" netclock="false" />

<!-- Execute command -->
<test file="execute.xml" repetitions="1" repetitionsfortime="" code="execute" parallel="false" />
<test file="executeexit.xml" repetitions="1" repetitionsfortime="" code="executeexit" parallel="true" />
<test file="kill.xml" repetitions="1" repetitionsfortime="" code="kill" parallel="true" />
<test file="execute001.xml" repetitions="1" repetitionsfortime="" code="execute001" parallel="false" />
<test file="findinfile.xml" repetitions="1" repetitionsfortime="" code="findinfile" parallel="false" />
<test file="execute002.xml" repetitions="1" repetitionsfortime="" code="execute002" parallel="false" />
<test file="writeserial.xml" repetitions="0" repetitionsfortime="" code="writeserial" parallel="false" />

</testlist>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions test/test.xml → tests/test-kuka/test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
<test file="0101.xml" repetitions="0" repetitionsfortime="" code="0101" parallel="false" />
<test file="0102.xml" repetitions="0" repetitionsfortime="" code="0102" parallel="false" />
<test file="0103.xml" repetitions="0" repetitionsfortime="" code="0103" parallel="false" />
1 <!-- Generic -->
<test file="0600.xml" repetitions="1" repetitionsfortime="" code="0600" parallel="false" />
<test file="0601.xml" repetitions="0" repetitionsfortime="" code="0601" parallel="false" />
<test file="0602.xml" repetitions="0" repetitionsfortime="" code="0602" parallel="false" />
<!-- Generic write serial-->
<test file="0610.xml" repetitions="0" repetitionsfortime="" code="0610" parallel="false" />

<!-- Kuka -->
<test file="0701.xml" repetitions="0" repetitionsfortime="" code="0701" parallel="false" />
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions tests/test-robot/1000.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<testbody>
<info note="Execute gazebo." shortnote="" version="1.0" />
<logging loggingtype="" loggingpart="" loggingwrappername="" />
<settings wait="0" />

<command library="general" name="wait" seconds="1" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="execute" command="yarpserver" param="--write" prefix="" tag="yarpserver" waitafter="2" kill="false" usetestpath="false" nobackground="false" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="wait" seconds="2" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="execute" command="gzserver" param="-e dart gzworld/icub.world" prefix="" tag="gzserver" waitafter="2" kill="false" usetestpath="false" nobackground="false" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="wait" seconds="3" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="execute" command="gzclient" param="" prefix="" tag="gzclient" waitafter="2" kill="false" usetestpath="false" nobackground="false" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="wait" seconds="4" repetitions="1" wait="0" reporterror="true" />

</testbody>
8 changes: 8 additions & 0 deletions tests/test-robot/1001.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<testbody>
<info note="Clean up." shortnote="" version="1.0" />
<logging loggingtype="" loggingpart="" loggingwrappername="" />
<settings wait="0" />
<command library="general" name="wait" seconds="4" repetitions="1" wait="0" reporterror="true" />
<command library="general" name="execute" command="killall" param="yarpserver gzclient gzserver" prefix="" tag="icubsim" waitafter="2" kill="false" usetestpath="false" nobackground="false" repetitions="1" wait="0" reporterror="true" />
</testbody>
8 changes: 8 additions & 0 deletions tests/test-robot/1002.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<testbody>
<info note="ICub right ankle roll direct position." shortnote="" version="1.0" />
<logging loggingtype="position" loggingpart="r_ankle_roll" loggingwrappername="/right_leg" />
<settings wait="0" />

<command library="yarp" name="yarpopenpolydriver" wrappername="right-leg" property="(device remote_controlboard) (local /right_legxxx) (remote /icubSim/right_leg)" repetitions="1" wait="0" reporterror="true"></command>
</testbody>
File renamed without changes.
File renamed without changes.
Loading