Launching a daemon/service using CTest

  1. goal
    I’m trying to implement automatic testing of several native apps using Appium.
    The steps would be as follow for each app:
  • configure the Appium node with name and path of executable
  • start the Appium node
  • run my tests
  • stop the node
  1. status
    I have a first version implemented, that works for a single executable. When trying to do this cycle twice the problem is that the test starting the Appium node does not return until the test that stops the node kills the underlying process. First, obviously, I always have to run with at least “-j 2”. Then I cannot DEPEND on the startAppiumTest because he is never done, and then I m getting into all kind of race conditions.

it looks like that with a single executable:
ctest -I 1,7 -j 2
Test project /Users/agouaillard/Dashboards/csmMilliCastQtClients-86-Rel-build
Start 6: CleanInstallBuildTreeIfExist
Start 1: TestMillicastPlayer
1/7 Test #6: CleanInstallBuildTreeIfExist … Passed 0.03 sec
Start 7: InstallInBuildTree
2/7 Test #1: TestMillicastPlayer … Passed 0.21 sec
3/7 Test #7: InstallInBuildTree … Passed 22.35 sec
Start 3: MillicastPlayer-KiteCompile
Start 2: MillicastPlayer-LaunchAppiumNode
4/7 Test #3: MillicastPlayer-KiteCompile … Passed 2.31 sec
Start 4: MillicastPlayer-KiteRun
5/7 Test #4: MillicastPlayer-KiteRun … Passed 0.67 sec
Start 5: MillicastPlayer-killAppiumNode
6/7 Test #5: MillicastPlayer-killAppiumNode … Passed 0.02 sec
7/7 Test #2: MillicastPlayer-LaunchAppiumNode … Passed 3.00 sec

  1. Question:
    I’m trying to find how to launch a process and have the test return, and I have been failing.
    This is what I am doing now

    set( _appium_start_CMD ./${_app_name} )
    set( _appium_stop_CMD pkill -9 -f appium )
    ${CMAKE_CURRENT_BINARY_DIR}/${_app_name} )

NAME ${_app_name}-LaunchAppiumNode
COMMAND ${_appium_start_CMD}

and this is the code of my launch command that would need some love:
appium --node ./configs/appium/node.json &

What did I miss?

I think CTest’s fixtures feature is more in line with what you’re looking for. See the docs.

Cc: @kyle.edwards @craig.scott

Please see the following thread, which discusses this area in quite a bit of detail:

Minor note, we also use fixtures to run daemons before the tests, but I enforce to run such tests in serial with

set_tests_properties(${_test_name} PROPERTIES RUN_SERIAL ON)

to avoid issues with daemons start/stop sequence.

Dear all,

thanks for your answers.

I m sorry i was not clearer in my question. I am using DEPENDS, as well as FIXTURES, and RESSOURCE_LOCK to make sure the right tests are ru in the right order, independently of the number of thread used for testing.

My problem was with the command not returning.
Since then, I solved the problem on Mac by leveraging osascript. More specifically for those who would have the same problem I replaced the first command below, by the second one:

not returning (test never ending):
appium --node my_config.json &; exit

new one: working perfectly:
osascript -e "tell application “Terminal” to do script “appium --node @CMAKE_CURRENT_BINARY_DIR@/@_app_name@-node.json;exit” "

So my original problem is solved … for mac.

I have now the same problem on windows, where the following command does not seem to return:
start appium

using extra /B or “” as arguments of start does not seem to do the trick.