Skip to content

Commit

Permalink
Adding test to verify that '#1173: hpx::cout output lost' is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Jul 3, 2014
1 parent b30c0e7 commit 4c1c705
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/regressions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(subdirs
agas
actions
block_matrix
iostreams
lcos
performance_counters
threads
Expand Down
38 changes: 38 additions & 0 deletions tests/regressions/iostreams/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (c) 2007-2014 Hartmut Kaiser
#
# 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)

set(tests
no_output_1173
)

set(no_output_1173_PARAMETERS LOCALITIES 2)
set(no_output_1173_FLAGS DEPENDENCIES iostreams_component)

foreach(test ${tests})
set(sources
${test}.cpp)

source_group("Source Files" FILES ${sources})

# add example executable
add_hpx_executable(${test}_test
SOURCES ${sources}
${${test}_FLAGS}
FOLDER "Tests/Regressions/Iostreams")

add_hpx_regression_test("iostreams" ${test} ${${test}_PARAMETERS})

# add a custom target for this example
add_hpx_pseudo_target(tests.regressions.iostreams.${test})

# make pseudo-targets depend on master pseudo-target
add_hpx_pseudo_dependencies(tests.regressions.iostreams
tests.regressions.iostreams.${test})

# add dependencies to pseudo-target
add_hpx_pseudo_dependencies(tests.regressions.iostreams.${test}
${test}_test_exe)
endforeach()

47 changes: 47 additions & 0 deletions tests/regressions/iostreams/no_output_1173.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) 2014 Luis Ayuso
//
// 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)

#include <hpx/hpx.hpp>
#include <hpx/hpx_init.hpp>
#include <hpx/include/iostreams.hpp>
#include <hpx/util/lightweight_test.hpp>

///////////////////////////////////////////////////////////////////////////////
void worker()
{
hpx::consolestream << "hello!" << hpx::endl;
}
HPX_PLAIN_ACTION(worker, worker_action);

///////////////////////////////////////////////////////////////////////////////
int hpx_main(boost::program_options::variables_map& vm)
{
typedef hpx::future<void> wait_for_worker;
std::vector<wait_for_worker> futures;

// get locations and start workers
std::string expected;
for(auto l: hpx::find_all_localities())
{
futures.push_back(hpx::async(worker_action(), l));
expected += "hello!\n";
}
hpx::wait_all(futures);

std::stringstream const& console_strm = hpx::get_consolestream();

HPX_TEST_EQ(hpx::finalize(), 0);
HPX_TEST_EQ(console_strm.str(), expected);

return 0;
}

int main(int argc, char* argv[])
{
HPX_TEST_EQ_MSG(hpx::init(argc, argv), 0,
"HPX main exited with non-zero status");

return hpx::util::report_errors();
}

0 comments on commit 4c1c705

Please sign in to comment.