Skip to content

Commit

Permalink
Use ctest for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lwinkler committed Nov 10, 2019
1 parent ce39b6a commit ba28dc9
Show file tree
Hide file tree
Showing 21 changed files with 173 additions and 73 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
project(poplite)
cmake_minimum_required(VERSION 3.2.1)

Expand Down Expand Up @@ -86,7 +92,7 @@ function(pop_add_objects classnames dependencies)

endfunction(pop_add_objects)

# Function used to add several parallel objects to the compilation. Class names are read automatically by cmake
# Function used to add several parallel objects to the compilation. Class names are read automatically by cmake (experimental)
function(pop_add_all_classes header_name)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

Expand All @@ -102,7 +108,7 @@ function(pop_add_all_classes header_name)
pop_add_objects(${all_classes} "${header_name};${ARGN}")
endfunction(pop_add_all_classes)


enable_testing()
add_subdirectory(examples)
add_subdirectory(tests)
add_subdirectory(popc_tests)
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ cd /usr/lib/llvm-6.0/lib
sudo ln -s libclang-6.0.so.1 libclang.so
```

Tests
-----
To run the tests use the command:
```
ctest
```

Example of parallel class
-------------------------
An example of a parallel class can be found in the directory **examples/ping_pong**.
Expand Down
6 changes: 6 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
add_subdirectory(chat)

add_subdirectory(ping_pong)
Expand Down
8 changes: 8 additions & 0 deletions examples/chat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# A simple chat client.
#
project(chat)

# pop_add_object(chat_client chat_client.hpp chat_client.cpp)
Expand Down
12 changes: 10 additions & 2 deletions examples/ping_pong/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Objects sending notifications to each others.
#
project(ping_pong)

# pop_add_object(ping_pong ping_pong.hpp ping_pong.cpp)
pop_add_object(pop::mutex mutex.hpp)
pop_add_object(ping_pong ping_pong.hpp ping_pong.cpp)
# pop_add_all_classes(mutex.hpp)
# pop_add_all_classes(ping_pong.hpp ping_pong.cpp ${CMAKE_CURRENT_BINARY_DIR}/pop/mutex.iface.hpp)
add_executable(main_ping main.cpp ${CMAKE_CURRENT_BINARY_DIR}/ping_pong.iface.hpp ${CMAKE_CURRENT_BINARY_DIR}/pop/mutex.iface.hpp ${CMAKE_CURRENT_BINARY_DIR}/pop/mutex.brok.cpp)
target_link_libraries(main_ping ${Boost_LIBRARIES})

add_custom_target(run_ping_pong ./main_ping async 100 localhost --pop-path `pwd` DEPENDS main_ping ping_pong.obj pop.mutex.obj)
add_test(NAME run_ping_pong COMMAND ./main_ping async 100 localhost --pop-path ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
12 changes: 10 additions & 2 deletions examples/templates/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# An example illustrating the use of templates for parallel classes and methods.
#
project(templates)
pop_add_object(template_ns::printer printer.hpp)
pop_add_object(template_ns::storage storage.hpp)
pop_add_object(template_ns::proxy_storage proxy_storage.hpp ${CMAKE_CURRENT_BINARY_DIR}/template_ns/storage.iface.hpp ${CMAKE_CURRENT_BINARY_DIR}/template_ns/storage.iface.cpp)
Expand All @@ -16,5 +24,5 @@ add_executable(main_templates main.cpp

target_link_libraries(main_templates ${Boost_LIBRARIES})

add_custom_target(run_templates ./main_templates DEPENDS main_templates template_ns.storage.obj template_ns.map_storage.obj template_ns.proxy_storage.obj template_ns.printer.obj)
add_test(NAME run_templates COMMAND ./main_templates WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

12 changes: 11 additions & 1 deletion examples/word_list_game/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# A game for 2 players. Guess words of the category starting with the right letter.
#
project(word_list_game)

find_package( Boost 1.40 COMPONENTS serialization system thread serialization context log filesystem program_options REQUIRED )
include_directories(${Boost_INCLUDE_DIR})

pop_add_objects("client;server" "client.hpp;client.cpp;server.hpp;server.cpp")
# alternative:
# pop_add_object(server server.hpp server.cpp ${CMAKE_CURRENT_BINARY_DIR}/client.iface.hpp)
# pop_add_object(client client.hpp client.cpp ${CMAKE_CURRENT_BINARY_DIR}/server.iface.hpp)
pop_add_objects("client;server" "client.hpp;client.cpp;server.hpp;server.cpp")
add_executable(word_list_game word_list_game.cpp ${CMAKE_CURRENT_BINARY_DIR}/client.iface.hpp ${CMAKE_CURRENT_BINARY_DIR}/server.iface.hpp)
target_link_libraries(word_list_game ${Boost_LIBRARIES})
10 changes: 8 additions & 2 deletions popc_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
project(poplite_examples)

#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Code samples adapted from the POP-C++ project (https://github.com/pop-team/pop-cpp).
#
add_subdirectory(asynccreation)
add_subdirectory(bigdata)
add_subdirectory(callback)
Expand Down
10 changes: 9 additions & 1 deletion popc_tests/asynccreation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Example of asynchronous object creation.
#
project(popc_tests_asynccreation)

pop_add_object(PopObject3 PopObject.h PopObject.cpp)
add_executable(main_asynccreation main.cpp ${CMAKE_CURRENT_BINARY_DIR}/PopObject3.iface.hpp)
target_link_libraries(main_asynccreation ${Boost_LIBRARIES})

add_custom_target(run_asynccreation ./main_asynccreation DEPENDS main_asynccreation PopObject3.obj)
add_test(NAME run_asynccreation COMMAND ./main_asynccreation WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

10 changes: 9 additions & 1 deletion popc_tests/bigdata/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Tests with large amounts of data.
#
project(popc_tests_bigdata)

pop_add_object(POPObject POPObject.hpp)
add_executable(main_bigdata main.cc ${CMAKE_CURRENT_BINARY_DIR}/POPObject.iface.hpp)
target_link_libraries(main_bigdata ${Boost_LIBRARIES})

add_custom_target(run_bigdata ./main_bigdata DEPENDS main_bigdata POPObject.obj)
add_test(NAME run_bigdata COMMAND ./main_bigdata WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

10 changes: 9 additions & 1 deletion popc_tests/callback/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Example using callback functions.
#
project(popc_tests_callback)

pop_add_objects("Titi;Toto" "titi.hpp;titi.cc;toto.hpp;toto.cc")
add_executable(main_callback main.cc ${CMAKE_CURRENT_BINARY_DIR}/Titi.iface.hpp ${CMAKE_CURRENT_BINARY_DIR}/Toto.iface.hpp)
target_link_libraries(main_callback ${Boost_LIBRARIES})

add_custom_target(run_callback ./main_callback DEPENDS main_callback Titi.obj Toto.obj)
add_test(NAME run_callback COMMAND ./main_callback WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

10 changes: 9 additions & 1 deletion popc_tests/exception/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Example on how to return and send exceptions.
#
project(popc_tests_exception)

#pop_add_objects("ClassExcep" "ClassExcep.hpp;ClassExcep.cpp;IOExceptions.cc")
Expand All @@ -8,5 +16,5 @@ add_executable(main_exception main.cc ${CMAKE_CURRENT_BINARY_DIR}/ClassExcep.ifa

target_link_libraries(main_exception ${Boost_LIBRARIES} popc_tests_exception)

add_custom_target(run_exception ./main_exception DEPENDS main_exception ClassExcep.obj)
add_test(NAME run_exception COMMAND ./main_exception WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

10 changes: 9 additions & 1 deletion popc_tests/heritage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Demonstrate the use of inheritence for parallel objects.
#
project(popc_tests_heritage)

pop_add_objects("Child;Mother" "child.hpp;child.cc;mother.hpp;mother.cc")
add_executable(main_heritage main.cc ${CMAKE_CURRENT_BINARY_DIR}/Child.iface.hpp ${CMAKE_CURRENT_BINARY_DIR}/Mother.iface.hpp)
target_link_libraries(main_heritage ${Boost_LIBRARIES})

add_custom_target(run_heritage ./main_heritage DEPENDS main_heritage Child.obj Mother.obj)
add_test(NAME run_heritage COMMAND ./main_heritage WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

10 changes: 9 additions & 1 deletion popc_tests/stdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Example with different C++ classes from stdlib.
#
project(popc_tests_stdlib)

pop_add_object(TestMethod method.hpp method.cc)
add_executable(main_stdlib main.cc ${CMAKE_CURRENT_BINARY_DIR}/TestMethod.iface.hpp)
target_link_libraries(main_stdlib ${Boost_LIBRARIES})

add_custom_target(run_stdlib ./main_stdlib DEPENDS main_stdlib TestMethod.obj)
add_test(NAME run_stdlib COMMAND ./main_stdlib WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

10 changes: 9 additions & 1 deletion popc_tests/stresstest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Test poplite in difficult cases.
#
project(popc_tests_stresstest)

pop_add_object(stress_test::POPObject POPObject.hpp POPObject.cc)
add_executable(main_stresstest main.cc ${CMAKE_CURRENT_BINARY_DIR}/stress_test/POPObject.iface.hpp)
target_link_libraries(main_stresstest ${Boost_LIBRARIES})

add_custom_target(run_stresstest ./main_stresstest 200 DEPENDS main_stresstest stress_test.POPObject.obj)
add_test(NAME run_stresstest COMMAND ./main_stresstest 200 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

10 changes: 9 additions & 1 deletion popc_tests/tree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Example using tree-like structures.
#
project(popc_tests_tree)

pop_add_object(Tree tree.hpp tree.cc)
add_executable(main_tree main.cc ${CMAKE_CURRENT_BINARY_DIR}/Tree.iface.hpp)
target_link_libraries(main_tree ${Boost_LIBRARIES})

add_custom_target(run_tree ./main_tree 3 4 DEPENDS main_tree Tree.obj)
add_test(NAME run_tree COMMAND ./main_tree 3 4 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

50 changes: 0 additions & 50 deletions run_tests.py

This file was deleted.

8 changes: 6 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
project(poplite_examples)

#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
add_subdirectory(default_values)
add_subdirectory(get_and_set)
add_subdirectory(inheritance)
10 changes: 9 additions & 1 deletion tests/default_values/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Test the use of default values for C++ methods.
#
project(tests_default_values)

pop_add_object(tester_default tester_default.hpp)
add_executable(main_default_values main.cpp ${CMAKE_CURRENT_BINARY_DIR}/tester_default.iface.hpp)
target_link_libraries(main_default_values ${Boost_LIBRARIES})

add_custom_target(run_default_values ./main_default_values DEPENDS main_default_values tester_default.obj)
add_test(NAME run_default_values COMMAND ./main_default_values WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

10 changes: 9 additions & 1 deletion tests/get_and_set/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#
# Copyright (c) Laurent Winkler 2019
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Test getting and setting different types.
#

# pop_add_object(TestClass test_class.hpp)
# pop_add_object(TestChildClass test_child_class.hpp ${CMAKE_CURRENT_BINARY_DIR}/TestClass.iface.hpp)
Expand All @@ -9,5 +17,5 @@ add_executable(main_get_set

target_link_libraries(main_get_set ${Boost_LIBRARIES})

add_custom_target(run_get_and_set ./main_get_set DEPENDS main_get_set TestClass.obj TestChildClass.obj)
add_test(NAME run_get_and_set COMMAND ./main_get_set WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

Loading

0 comments on commit ba28dc9

Please sign in to comment.