Skip to content

Commit

Permalink
Merge pull request #1704
Browse files Browse the repository at this point in the history
Add lp robot tests
  • Loading branch information
Neverlord committed Jan 24, 2024
2 parents 5125196 + bd40476 commit 6e3791d
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ freebsd13_task:
prepare_script: .ci/freebsd-13/prepare.sh
build_script: .ci/run.sh build .ci/debug-flags.cmake . build
test_script: .ci/run.sh test build net.udp_datagram_socket
always:
robot_artifacts:
path: "build/robot-output/**"
<< : *BRANCH_FILTER

# FreeBSD 14 EOL: November 2028
Expand All @@ -28,5 +31,8 @@ freebsd14_task:
prepare_script: .ci/freebsd-14/prepare.sh
build_script: .ci/run.sh build .ci/debug-flags.cmake . build
test_script: .ci/run.sh test build net.udp_datagram_socket
always:
robot_artifacts:
path: "build/robot-output/**"
<< : *BRANCH_FILTER

8 changes: 7 additions & 1 deletion .github/workflows/check-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: build-caf
on:
pull_request:
push:
branches:
branches:
- master
jobs:
Windows:
Expand All @@ -20,3 +20,9 @@ jobs:
run: .ci/windows/build.cmd
- name: Test
run: .ci/windows/test.cmd
- name: Archive Robot logs
uses: actions/upload-artifact@v4
if: always()
with:
name: robot-logs
path: build/robot-output/
11 changes: 10 additions & 1 deletion robot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ find_package(Python COMPONENTS Interpreter)

function(add_robot_test dir name)
set(test_name caf-robot-${dir}-${name})
set(test_wdir "${CMAKE_BINARY_DIR}/robot-output/${dir}/${name}")
file(MAKE_DIRECTORY "${test_wdir}")
add_test(
NAME ${test_name}
COMMAND
${Python_EXECUTABLE}
-m robot
${ARGN}
"${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${name}.robot")
"${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${name}.robot"
WORKING_DIRECTORY "${test_wdir}")
set_tests_properties(${test_name} PROPERTIES TIMEOUT 300)
endfunction()

Expand Down Expand Up @@ -127,4 +130,10 @@ if(TARGET CAF::net AND CAF_ENABLE_EXAMPLES)
client
--variable BINARY_PATH:$<TARGET_FILE:client>)

add_robot_test(
lp
communication
--variable SERVER_PATH:$<TARGET_FILE:chat-server>
--variable CLIENT_PATH:$<TARGET_FILE:chat-client>)

endif()
70 changes: 70 additions & 0 deletions robot/lp/communication.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
*** Settings ***
Documentation A test suite for the length previx framing communication
Library Process
Library String
Library OperatingSystem

Test Setup Start Chat Server
Test Teardown Terminate All Processes


*** Variables ***
${SERVER_HOST} localhost
${SERVER_PORT} 55519
${SERVER_PATH} /path/to/the/server
${CLIENT_PATH} /path/to/the/client

${INPUT} Hello\nToday is a wonderful day!\n
${BASELINE} bob: Hello\nbob: Today is a wonderful day!


*** Test Cases ***
Send Some message
Start Chat Client alice PIPE
Wait For Client ${1}
Start Chat Client bob ${INPUT}
Wait For Client ${2}
Wait Until Contains Baseline alice.out


*** Keywords ***
Start Chat Server
Start Process
... ${SERVER_PATH}
... -p ${SERVER_PORT}
... --caf.logger.file.verbosity trace
... --caf.logger.file.path server.log
... stdout=server.out
... stderr=server.err

Start Chat Client
[Arguments] ${name} ${stdin}
Start Process
... ${CLIENT_PATH}
... -p ${SERVER_PORT}
... -n ${name}
... --caf.logger.file.verbosity trace
... --caf.logger.file.path ${name}.log
... stdin=${stdin}
... stdout=${name}.out
... stderr=${name}.err

Has Baseline
[Arguments] ${file_path}
${output} Get File ${file_path}
Should Contain ${output} ${BASELINE}

Wait Until Contains Baseline
[Arguments] ${file_path}
Wait Until Keyword Succeeds 5s 125ms Has Baseline ${file_path}

Count Connected Clients
[Arguments] ${client_count}
${output}= Grep File server.out accepted new connection
${lc}= Get Line Count ${output}
Should Be True ${lc} >= ${client_count}

Wait For Client
[Arguments] ${client_count}
Wait Until Keyword Succeeds 5s 125ms Count Connected Clients ${client_count}

0 comments on commit 6e3791d

Please sign in to comment.