New Update with example

master
rifki sadikin 6 years ago
parent 8b1bf8d29e
commit 79aebf71e2
  1. 1
      CMakeLists.txt
  2. 35
      example/CMakeLists.txt
  3. 226
      example/PoissonSolver3DGPUTest.cpp
  4. 18
      example/PoissonSolver3DGPUTest.h
  5. 14020
      example/external/catch2/catch.hpp
  6. 62
      example/external/catch2/catch_reporter_automake.hpp
  7. 253
      example/external/catch2/catch_reporter_tap.hpp
  8. 220
      example/external/catch2/catch_reporter_teamcity.hpp
  9. 2
      example/main.cpp
  10. 22
      example/poissonsolver.test.cpp
  11. 6
      gpuapp/CMakeLists.txt
  12. 6
      gpuapp/PoissonSolver3DGPUTest.C
  13. 8
      gpuapp/PoissonSolver3DGPUTest.h

@ -38,5 +38,4 @@ set(BUILD_SHARED_LIBS ON)
list(APPEND CUDA_NVCC_FLAGS)
add_subdirectory (gpulib)
add_subdirectory (gpuapp)

@ -44,5 +44,36 @@ INCLUDE_DIRECTORIES(
set(CPP_SOURCE PoissonSolver3DGPUTest.cpp)
set(HEADERS PoissonSolver3DGPUTest.h)
add_executable(poissonsolvergputest ${CPP_SOURCE} ${PSLIB})
install(TARGETS poissonsolvergputest DESTINATION bin)
enable_testing()
set(TARGET_NAME poissonsolvergputest)
#set(UNIT_TEST_LIST
# poissonsolver)
#foreach(NAME IN LISTS UNIT_TEST_LIST)
# list(APPEND UNIT_TEST_SOURCE_LIST ${NAME}.test.cpp)
#endforeach()
add_executable(${TARGET_NAME}
PoissonSolver3DGPUTest.cpp
#main.cpp
#${UNIT_TEST_SOURCE_LIST}
)
target_link_libraries(${TARGET_NAME} ${PSLIB} ${LIBCUDA_SO_PATH})
install(TARGETS ${TARGET_NAME} DESTINATION bin)
#target_link_libraries(${TARGET_NAME}
# PUBLIC string_utils)i
#target_include_directories(${TARGET_NAME}
# PUBLIC external/catch2/)
#add_test(
# NAME ${TARGET_NAME}
# COMMAND ${TARGET_NAME} -o report.xml -r junit)

@ -1,13 +1,229 @@
#include <iostream>
#include <math.h>
#include "PoissonSolver3DGPUTest.h"
#include "PoissonSolver3DGPU.h"
///
/// DoPoissonSolverExperiments
///
void DoPoissonSolverExperiment(const int kRows, const int kColumns, const int kPhiSlices, const int kIterations, const int kSymmetry) {
int kPhiSlicesPerSector = kPhiSlices/18;
const float gridSizeR = (fgkOFCRadius-fgkIFCRadius) / (kRows-1) ;
const float gridSizeZ = fgkTPCZ0 / (kColumns-1) ;
const float gridSizePhi = (M_PI * 2)/ ( 18.0 * kPhiSlicesPerSector);
int size = kRows * kColumns * kPhiSlices;
void testCase1();
float * VPotential = new float[size];
float * VPotentialExact = new float[size];
float * RhoCharge = new float[size];
float * errorConv = new float[200];
float * errorExact = new float[200];
InitVoltandCharge3D(VPotentialExact,VPotential,RhoCharge,kRows,kColumns,kPhiSlices,gridSizeR,gridSizeZ,gridSizePhi);
// test case test
int main()
{
testCase1();
const float ratioPhi = gridSizeR*gridSizeR / (gridSizePhi*gridSizePhi) ; // ratio_{phi} = gridsize_{r} / gridsize_{phi}
const float ratioZ = gridSizeR*gridSizeR / (gridSizeZ*gridSizeZ) ; // ratio_{Z} = gridsize_{r} / gridsize_{z}
const float convErr = fgConvergenceError;
const float IFCRadius = fgkIFCRadius;
const int fparamsize = 8;
float * fparam = new float[fparamsize];
fparam[0] = gridSizeR;
fparam[1] = gridSizePhi;
fparam[2] = gridSizeZ;
fparam[3] = ratioPhi;
fparam[4] = ratioZ;
fparam[5] = convErr;
fparam[6] = IFCRadius;
int iparamsize = 4;
int * iparam = new int[iparamsize];
iparam[0] = 2;//nPre
iparam[1] = 2;//nPost;
iparam[2] = 6;//maxLoop;
iparam[3] = 200; //nMGCycle;
for (int k=0;k<kPhiSlices;k++) {
for (int i=0;i<kRows;i++) {
for (int j=0;j< kColumns;j++) printf("%.3f\t",RhoCharge[k * (kRows * kColumns) + i * kColumns + j]);
printf("\n");
}
printf("\n");
}
// VCycle
PoissonMultigrid3DSemiCoarseningGPUError(VPotential, RhoCharge, kRows, kColumns ,kPhiSlices, 0 , fparam, iparam, true, errorConv,errorExact, VPotentialExact);
// Call poisson solver
for (int k=0;k<kPhiSlices;k++) {
for (int i=0;i<kRows;i++) {
for (int j=0;j< kColumns;j++) printf("%.3f\t",VPotential[k * (kRows * kColumns) + i * kColumns + j] - VPotentialExact[k* (kRows * kColumns) + i * kColumns + j]);
printf("\n");
}
printf("\n");
}
/**
TVectorD *error[5];
TVectorD *errorConv[5];
int iterations[5];
// memory allocation
TMatrixD *arrayofArrayV[kPhiSlices], *arrayofCharge[kPhiSlices] ;
TMatrixD *arrayofArrayVGrid[kPhiSlices], *arrayofChargeGrid[kPhiSlices] ;
TMatrixD *arrayofArrayVExact[kPhiSlices];
for ( int k = 0 ; k < kPhiSlices ; k++ ) {
arrayofArrayV[k] = new TMatrixD(kRows,kColumns) ;
arrayofArrayVExact[k] = new TMatrixD(kRows,kColumns) ;
arrayofCharge[k] = new TMatrixD(kRows,kColumns) ;
arrayofArrayVGrid[k] = new TMatrixD(kRows,kColumns) ;
arrayofChargeGrid[k] = new TMatrixD(kRows,kColumns) ;
}
// side in TPC chamber
int side = 0;
/// Generate exact problems -- solutios pair
InitVoltandCharge3D(arrayofArrayVExact,arrayofChargeGrid,kRows,kColumns,kPhiSlices,side,gridSizeR,gridSizeZ,gridSizePhi,1);
/// zeroing potential for inital guess
for ( int k = 0 ; k < kPhiSlices ; k++ ) {
*arrayofArrayVGrid[k] = *arrayofArrayVExact[k];
*arrayofArrayV[k] = *arrayofArrayVExact[k];
for ( int i = 1 ; i < kRows-1 ; i++ ) {
for ( int j = 1 ; j < kColumns-1 ; j++ ) {
(*arrayofArrayVGrid[k])(i,j) = 0.0;
(*arrayofArrayV[k])(i,j) = 0.0;
}
}
}
// create poissonSolver
AliTPCPoissonSolverCuda *poissonSolver = new AliTPCPoissonSolverCuda();
AliTPCPoissonSolverCuda::fgConvergenceError = 1e-8;
// zeroring array of error
poissonSolver->SetExactSolution(arrayofArrayVExact,kRows,kColumns, kPhiSlices);
// Case 1. Set the strategy as multigrid, fullmultigrid, and full 3d
poissonSolver->SetStrategy(kMultiGrid);
poissonSolver->SetCycleType(kFCycle);
TStopwatch w;
w.Start();
poissonSolver->PoissonSolver3D(arrayofArrayVGrid,arrayofChargeGrid,kRows,kColumns,kPhiSlices, kIterations,kSymmetry) ;
w.Stop();
TMatrixD vError(kRows,kColumns);
arrayofArrayVGrid[0]->Print();
::Info("testAliTPCPoissonSolverMem3D_Consistency",Form("Time Poisson Multigrid F-Cycle 3D: = %f \n",w.CpuTime()));
delete poissonSolver;
for ( int k = 0 ; k < kPhiSlices ; k++ ) {
delete arrayofArrayV[k];
delete arrayofArrayVExact[k];
delete arrayofCharge[k];
delete arrayofArrayVGrid[k];
delete arrayofChargeGrid[k];
}
**/
delete VPotential;
delete VPotentialExact;
delete RhoCharge;
delete[] iparam;
delete[] fparam;
}
// set init
void InitVoltandCharge3D(float * VPotentialExact,float *VPotential,float * RhoCharge,const int kRows, const int kColumns,const int kPhiSlices,float gridSizeR,float gridSizeZ,float gridSizePhi) {
double rlist[kRows], zedlist[kColumns] , philist[kPhiSlices];
float phi0,radius0,z0;
double a,b,c;
a = fgkOFCRadius*fgkOFCRadius;
a*= (fgkOFCRadius - fgkIFCRadius);
a*= (fgkOFCRadius - fgkIFCRadius);
a = (100.0/a);
b = 0.5;
c = M_E / (fgkTPCZ0 * fgkTPCZ0 );
int index;
// list points on grid in cm
for ( int k = 0 ; k < kPhiSlices ; k++ )
philist[k] = gridSizePhi * k;
for ( int i = 0 ; i < kRows ; i++ )
rlist[i] = fgkIFCRadius + i*gridSizeR ;
for ( int j = 0 ; j < kColumns ; j++ )
zedlist[j] = j * gridSizeZ ;
for ( int k = 0 ; k < kPhiSlices ; k++ ) {
phi0 = philist[k];
for ( int i = 0 ; i < kRows ; i++ ) {
radius0 = rlist[i] ;
for ( int j = 0 ; j < kColumns ; j++ ) {
index = k * kRows * kColumns + i * kColumns + j;
z0 = zedlist[j];
VPotentialExact[index] = TestFunction1PotentialEval(a,b,c,radius0,phi0,z0);
RhoCharge[index] = TestFunction1ChargeEval(a,b,c,radius0,phi0,z0);
if (j == 0) VPotential[index] = VPotentialExact[index];
else if (j == kColumns-1) VPotential[index] = VPotentialExact[index];
else if (i == 0) VPotential[index] = VPotentialExact[index];
else if (i == kRows - 1) VPotential[index] = VPotentialExact[index];
else VPotential[index ] = 0.0;
} // end j
} // end i
} // end phi
}
//
float TestFunction1PotentialEval(double a, double b, double c, float radius0,float phi0,float z0) {
float ret = a * (pow(radius0,4) - 338.0 * pow(radius0,3) + 21250.75 * pow(radius0,2));
ret *= cos(b*phi0);
ret *= exp ( -1 * c * z0*z0);
return ret;
}
//
float TestFunction1ChargeEval(double a, double b, double c, float radius0,float phi0,float z0) {
float ret = a * (((16.0 * pow(radius0,2) - 9.0 * 338.0 * radius0 + 4.0*21250.75 ) * pow(cos (b * phi0),2.0) *exp(-1 * c * z0 * z0) ) - ((pow(radius0,2.0) - 338.0 * radius0 + 21250.75) *2 * b*b* cos(2 * b * phi0) * exp(-1 * c *z0 * z0) ) + ((pow(radius0,4.0) - 338.0 * pow(radius0,3.0) + 21250.75 * pow(radius0,2.0)) * pow(cos(b * phi0),2.0) * (4 *c*c *z0*z0 - 2 *c) * exp(-1 * c * z0 * z0))) ;
return ret;
}
int main() {
DoPoissonSolverExperiment(17, 17, 18, 200, 0);
return 0;
}

@ -4,5 +4,23 @@
#include <iostream>
#include "PoissonSolver3DGPU.h"
const double fgkTPCZ0 = 249.7; ///< nominal gating grid position
const double fgkIFCRadius = 83.5; ///< radius which renders the "18 rod manifold" best -> compare calc. of Jim Thomas
const double fgkOFCRadius = 254.5; ///< Mean Radius of the Outer Field Cage (252.55 min, 256.45 max) (cm)
const double fgkZOffSet = 0.2; ///< Offset from CE: calculate all distortions closer to CE as if at this point
const double fgkCathodeV = -100000.0; ///< Cathode Voltage (volts)
const double fgkGG = -70.0; ///< Gating Grid voltage (volts)
const double fgkdvdE = 0.0024; ///< [cm/V] drift velocity dependency on the E field (from Magboltz for NeCO2N2 at standard environment)
const double fgkEM = -1.602176487e-19 / 9.10938215e-31; ///< charge/mass in [C/kg]
const double fgke0 = 8.854187817e-12; ///< vacuum permittivity [A·s/(V·m)]
const double fgConvergenceError = 1e-6; ///< vacuum permittivity [A·s/(V·m)]
void DoPoissonSolverExperiment(const int kRows, const int kColumns, const int kPhiSlices, const int kIterations, const int kSymmetry);
void InitVoltandCharge3D(float * VPotentialExact,float * VPotential,float * RhoCharge,const int kRows, const int kColumns,const int kPhiSlices,float gridSizeR,float gridSizeZ,float gridSizePhi);
float TestFunction1PotentialEval(double a, double b, double c,float radius0, float phi0, float z0);
float TestFunction1ChargeEval(double a, double b, double c, float radius0,float phi0,float z0);
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,62 @@
/*
* Created by Justin R. Wilson on 2/19/2017.
* Copyright 2017 Justin R. Wilson. All rights reserved.
*
* 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)
*/
#ifndef TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED
// Don't #include any Catch headers here - we can assume they are already
// included before this header.
// This is not good practice in general but is necessary in this case so this
// file can be distributed as a single header that works with the main
// Catch single header.
namespace Catch {
struct AutomakeReporter : StreamingReporterBase<AutomakeReporter> {
AutomakeReporter( ReporterConfig const& _config )
: StreamingReporterBase( _config )
{}
~AutomakeReporter() override;
static std::string getDescription() {
return "Reports test results in the format of Automake .trs files";
}
void assertionStarting( AssertionInfo const& ) override {}
bool assertionEnded( AssertionStats const& /*_assertionStats*/ ) override { return true; }
void testCaseEnded( TestCaseStats const& _testCaseStats ) override {
// Possible values to emit are PASS, XFAIL, SKIP, FAIL, XPASS and ERROR.
stream << ":test-result: ";
if (_testCaseStats.totals.assertions.allPassed()) {
stream << "PASS";
} else if (_testCaseStats.totals.assertions.allOk()) {
stream << "XFAIL";
} else {
stream << "FAIL";
}
stream << ' ' << _testCaseStats.testInfo.name << '\n';
StreamingReporterBase::testCaseEnded( _testCaseStats );
}
void skipTest( TestCaseInfo const& testInfo ) override {
stream << ":test-result: SKIP " << testInfo.name << '\n';
}
};
#ifdef CATCH_IMPL
AutomakeReporter::~AutomakeReporter() {}
#endif
CATCH_REGISTER_REPORTER( "automake", AutomakeReporter)
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED

@ -0,0 +1,253 @@
/*
* Created by Colton Wolkins on 2015-08-15.
* Copyright 2015 Martin Moene. All rights reserved.
*
* 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)
*/
#ifndef TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED
// Don't #include any Catch headers here - we can assume they are already
// included before this header.
// This is not good practice in general but is necessary in this case so this
// file can be distributed as a single header that works with the main
// Catch single header.
#include <algorithm>
namespace Catch {
struct TAPReporter : StreamingReporterBase<TAPReporter> {
using StreamingReporterBase::StreamingReporterBase;
~TAPReporter() override;
static std::string getDescription() {
return "Reports test results in TAP format, suitable for test harnesses";
}
ReporterPreferences getPreferences() const override {
return m_reporterPrefs;
}
void noMatchingTestCases( std::string const& spec ) override {
stream << "# No test cases matched '" << spec << "'" << std::endl;
}
void assertionStarting( AssertionInfo const& ) override {}
bool assertionEnded( AssertionStats const& _assertionStats ) override {
++counter;
AssertionPrinter printer( stream, _assertionStats, counter );
printer.print();
stream << " # " << currentTestCaseInfo->name ;
stream << std::endl;
return true;
}
void testRunEnded( TestRunStats const& _testRunStats ) override {
printTotals( _testRunStats.totals );
stream << "\n" << std::endl;
StreamingReporterBase::testRunEnded( _testRunStats );
}
private:
std::size_t counter = 0;
class AssertionPrinter {
public:
AssertionPrinter& operator= ( AssertionPrinter const& ) = delete;
AssertionPrinter( AssertionPrinter const& ) = delete;
AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, std::size_t _counter )
: stream( _stream )
, result( _stats.assertionResult )
, messages( _stats.infoMessages )
, itMessage( _stats.infoMessages.begin() )
, printInfoMessages( true )
, counter(_counter)
{}
void print() {
itMessage = messages.begin();
switch( result.getResultType() ) {
case ResultWas::Ok:
printResultType( passedString() );
printOriginalExpression();
printReconstructedExpression();
if ( ! result.hasExpression() )
printRemainingMessages( Colour::None );
else
printRemainingMessages();
break;
case ResultWas::ExpressionFailed:
if (result.isOk()) {
printResultType(passedString());
} else {
printResultType(failedString());
}
printOriginalExpression();
printReconstructedExpression();
if (result.isOk()) {
printIssue(" # TODO");
}
printRemainingMessages();
break;
case ResultWas::ThrewException:
printResultType( failedString() );
printIssue( "unexpected exception with message:" );
printMessage();
printExpressionWas();
printRemainingMessages();
break;
case ResultWas::FatalErrorCondition:
printResultType( failedString() );
printIssue( "fatal error condition with message:" );
printMessage();
printExpressionWas();
printRemainingMessages();
break;
case ResultWas::DidntThrowException:
printResultType( failedString() );
printIssue( "expected exception, got none" );
printExpressionWas();
printRemainingMessages();
break;
case ResultWas::Info:
printResultType( "info" );
printMessage();
printRemainingMessages();
break;
case ResultWas::Warning:
printResultType( "warning" );
printMessage();
printRemainingMessages();
break;
case ResultWas::ExplicitFailure:
printResultType( failedString() );
printIssue( "explicitly" );
printRemainingMessages( Colour::None );
break;
// These cases are here to prevent compiler warnings
case ResultWas::Unknown:
case ResultWas::FailureBit:
case ResultWas::Exception:
printResultType( "** internal error **" );
break;
}
}
private:
static Colour::Code dimColour() { return Colour::FileName; }
static const char* failedString() { return "not ok"; }
static const char* passedString() { return "ok"; }
void printSourceInfo() const {
Colour colourGuard( dimColour() );
stream << result.getSourceInfo() << ":";
}
void printResultType( std::string const& passOrFail ) const {
if( !passOrFail.empty() ) {
stream << passOrFail << ' ' << counter << " -";
}
}
void printIssue( std::string const& issue ) const {
stream << " " << issue;
}
void printExpressionWas() {
if( result.hasExpression() ) {
stream << ";";
{
Colour colour( dimColour() );
stream << " expression was:";
}
printOriginalExpression();
}
}
void printOriginalExpression() const {
if( result.hasExpression() ) {
stream << " " << result.getExpression();
}
}
void printReconstructedExpression() const {
if( result.hasExpandedExpression() ) {
{
Colour colour( dimColour() );
stream << " for: ";
}
std::string expr = result.getExpandedExpression();
std::replace( expr.begin(), expr.end(), '\n', ' ');
stream << expr;
}
}
void printMessage() {
if ( itMessage != messages.end() ) {
stream << " '" << itMessage->message << "'";
++itMessage;
}
}
void printRemainingMessages( Colour::Code colour = dimColour() ) {
if (itMessage == messages.end()) {
return;
}
// using messages.end() directly (or auto) yields compilation error:
std::vector<MessageInfo>::const_iterator itEnd = messages.end();
const std::size_t N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) );
{
Colour colourGuard( colour );
stream << " with " << pluralise( N, "message" ) << ":";
}
for(; itMessage != itEnd; ) {
// If this assertion is a warning ignore any INFO messages
if( printInfoMessages || itMessage->type != ResultWas::Info ) {
stream << " '" << itMessage->message << "'";
if ( ++itMessage != itEnd ) {
Colour colourGuard( dimColour() );
stream << " and";
}
}
}
}
private:
std::ostream& stream;
AssertionResult const& result;
std::vector<MessageInfo> messages;
std::vector<MessageInfo>::const_iterator itMessage;
bool printInfoMessages;
std::size_t counter;
};
void printTotals( const Totals& totals ) const {
if( totals.testCases.total() == 0 ) {
stream << "1..0 # Skipped: No tests ran.";
} else {
stream << "1.." << counter;
}
}
};
#ifdef CATCH_IMPL
TAPReporter::~TAPReporter() {}
#endif
CATCH_REGISTER_REPORTER( "tap", TAPReporter )
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED

@ -0,0 +1,220 @@
/*
* Created by Phil Nash on 19th December 2014
* Copyright 2014 Two Blue Cubes Ltd. All rights reserved.
*
* 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)
*/
#ifndef TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
// Don't #include any Catch headers here - we can assume they are already
// included before this header.
// This is not good practice in general but is necessary in this case so this
// file can be distributed as a single header that works with the main
// Catch single header.
#include <cstring>
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wpadded"
#endif
namespace Catch {
struct TeamCityReporter : StreamingReporterBase<TeamCityReporter> {
TeamCityReporter( ReporterConfig const& _config )
: StreamingReporterBase( _config )
{
m_reporterPrefs.shouldRedirectStdOut = true;
}
static std::string escape( std::string const& str ) {
std::string escaped = str;
replaceInPlace( escaped, "|", "||" );
replaceInPlace( escaped, "'", "|'" );
replaceInPlace( escaped, "\n", "|n" );
replaceInPlace( escaped, "\r", "|r" );
replaceInPlace( escaped, "[", "|[" );
replaceInPlace( escaped, "]", "|]" );
return escaped;
}
~TeamCityReporter() override;
static std::string getDescription() {
return "Reports test results as TeamCity service messages";
}
void skipTest( TestCaseInfo const& /* testInfo */ ) override {
}
void noMatchingTestCases( std::string const& /* spec */ ) override {}
void testGroupStarting( GroupInfo const& groupInfo ) override {
StreamingReporterBase::testGroupStarting( groupInfo );
stream << "##teamcity[testSuiteStarted name='"
<< escape( groupInfo.name ) << "']\n";
}
void testGroupEnded( TestGroupStats const& testGroupStats ) override {
StreamingReporterBase::testGroupEnded( testGroupStats );
stream << "##teamcity[testSuiteFinished name='"
<< escape( testGroupStats.groupInfo.name ) << "']\n";
}
void assertionStarting( AssertionInfo const& ) override {}
bool assertionEnded( AssertionStats const& assertionStats ) override {
AssertionResult const& result = assertionStats.assertionResult;
if( !result.isOk() ) {
ReusableStringStream msg;
if( !m_headerPrintedForThisSection )
printSectionHeader( msg.get() );
m_headerPrintedForThisSection = true;
msg << result.getSourceInfo() << "\n";
switch( result.getResultType() ) {
case ResultWas::ExpressionFailed:
msg << "expression failed";
break;
case ResultWas::ThrewException:
msg << "unexpected exception";
break;
case ResultWas::FatalErrorCondition:
msg << "fatal error condition";
break;
case ResultWas::DidntThrowException:
msg << "no exception was thrown where one was expected";
break;
case ResultWas::ExplicitFailure:
msg << "explicit failure";
break;
// We shouldn't get here because of the isOk() test
case ResultWas::Ok:
case ResultWas::Info:
case ResultWas::Warning:
CATCH_ERROR( "Internal error in TeamCity reporter" );
// These cases are here to prevent compiler warnings
case ResultWas::Unknown:
case ResultWas::FailureBit:
case ResultWas::Exception:
CATCH_ERROR( "Not implemented" );
}
if( assertionStats.infoMessages.size() == 1 )
msg << " with message:";
if( assertionStats.infoMessages.size() > 1 )
msg << " with messages:";
for( auto const& messageInfo : assertionStats.infoMessages )
msg << "\n \"" << messageInfo.message << "\"";
if( result.hasExpression() ) {
msg <<
"\n " << result.getExpressionInMacro() << "\n"
"with expansion:\n" <<
" " << result.getExpandedExpression() << "\n";
}
if( currentTestCaseInfo->okToFail() ) {
msg << "- failure ignore as test marked as 'ok to fail'\n";
stream << "##teamcity[testIgnored"
<< " name='" << escape( currentTestCaseInfo->name )<< "'"
<< " message='" << escape( msg.str() ) << "'"
<< "]\n";
}
else {
stream << "##teamcity[testFailed"
<< " name='" << escape( currentTestCaseInfo->name )<< "'"
<< " message='" << escape( msg.str() ) << "'"
<< "]\n";
}
}
stream.flush();
return true;
}
void sectionStarting( SectionInfo const& sectionInfo ) override {
m_headerPrintedForThisSection = false;
StreamingReporterBase::sectionStarting( sectionInfo );
}
void testCaseStarting( TestCaseInfo const& testInfo ) override {
m_testTimer.start();
StreamingReporterBase::testCaseStarting( testInfo );
stream << "##teamcity[testStarted name='"
<< escape( testInfo.name ) << "']\n";
stream.flush();
}
void testCaseEnded( TestCaseStats const& testCaseStats ) override {
StreamingReporterBase::testCaseEnded( testCaseStats );
if( !testCaseStats.stdOut.empty() )
stream << "##teamcity[testStdOut name='"
<< escape( testCaseStats.testInfo.name )
<< "' out='" << escape( testCaseStats.stdOut ) << "']\n";
if( !testCaseStats.stdErr.empty() )
stream << "##teamcity[testStdErr name='"
<< escape( testCaseStats.testInfo.name )
<< "' out='" << escape( testCaseStats.stdErr ) << "']\n";
stream << "##teamcity[testFinished name='"
<< escape( testCaseStats.testInfo.name ) << "' duration='"
<< m_testTimer.getElapsedMilliseconds() << "']\n";
stream.flush();
}
private:
void printSectionHeader( std::ostream& os ) {
assert( !m_sectionStack.empty() );
if( m_sectionStack.size() > 1 ) {
os << getLineOfChars<'-'>() << "\n";
std::vector<SectionInfo>::const_iterator
it = m_sectionStack.begin()+1, // Skip first section (test case)
itEnd = m_sectionStack.end();
for( ; it != itEnd; ++it )
printHeaderString( os, it->name );
os << getLineOfChars<'-'>() << "\n";
}
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
if( !lineInfo.empty() )
os << lineInfo << "\n";
os << getLineOfChars<'.'>() << "\n\n";
}
// if string has a : in first line will set indent to follow it on
// subsequent lines
static void printHeaderString( std::ostream& os, std::string const& _string, std::size_t indent = 0 ) {
std::size_t i = _string.find( ": " );
if( i != std::string::npos )
i+=2;
else
i = 0;
os << Column( _string )
.indent( indent+i)
.initialIndent( indent ) << "\n";
}
private:
bool m_headerPrintedForThisSection = false;
Timer m_testTimer;
};
#ifdef CATCH_IMPL
TeamCityReporter::~TeamCityReporter() {}
#endif
CATCH_REGISTER_REPORTER( "teamcity", TeamCityReporter )
} // end namespace Catch
#ifdef __clang__
# pragma clang diagnostic pop
#endif
#endif // TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED

@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN
#include <catch.hpp>

@ -0,0 +1,22 @@
#include <catch.hpp>
#include "PoissonSolver3DGPUTest.h"
TEST_CASE( "INFO and WARN do not abort tests", "[messages][.]" ) {
INFO( "this is a " << "message" ); // This should output the message if a failure occurs
WARN( "this is a " << "warning" ); // This should always output the message but then continue
}
TEST_CASE( "SUCCEED counts as a test pass", "[messages]" ) {
SUCCEED( "this is a " << "success" );
}
TEST_CASE( "Correctness for Poisson Solver ", "[classic]" ) {
INFO( "this message should be logged" );
INFO( "so should this" );
DoPoissonSolverExperiment(17, 17, 18, 200, 0);
REQUIRE( 1== 1 );
}

@ -1,6 +0,0 @@
cuda_add_executable(poissonsolvertest
PoissonSolver3DGPUTest.C
)
target_link_libraries(poissonsolvertest PoissonSolver3DGPU)

@ -1,6 +0,0 @@
#include "PoissonSolver3DGPUTest.h"
int main()
{
return 1;
}

@ -1,8 +0,0 @@
#ifndef POISSONSOLVERGPU3DGPUTEST_H
#define POISSONSOLVERGPU3DGPUTEST_H
#include <iostream>
#include "../gpulib/PoissonSolver3DGPU.h"
#endif
Loading…
Cancel
Save