/** * Use std::thread to initiate peloton server and pqxx client in separate * threads * Simple query test to guarantee both sides run correctly * Callback method to close server after client finishes */ TEST_F(SSLTests, BasicTest) { peloton::PelotonInit::Initialize(); LOG_INFO("Server initialized"); peloton::network::PelotonServer peloton_server; int port = 15721; try { peloton::network::PelotonServer::certificate_file_ = server_crt; peloton::network::PelotonServer::private_key_file_ = server_key; peloton::network::PelotonServer::root_cert_file_ = root_crt; peloton::network::PelotonServer::SSLInit(); peloton_server.SetPort(port); peloton_server.SetupServer(); } catch (peloton::ConnectionException &exception) { LOG_INFO("[LaunchServer] exception in thread"); } std::thread serverThread([&] { peloton_server.ServerLoop(); }); // server & client running correctly BasicTest(port); peloton_server.Close(); serverThread.join(); LOG_INFO("Peloton is shutting down"); peloton::PelotonInit::Shutdown(); LOG_INFO("Peloton has shut down"); }
int main(int argc, char *argv[]) { TfErrorMark mark; BasicTest(argc, argv); if (mark.IsClean()) { std::cout << "OK" << std::endl; return EXIT_SUCCESS; } else { std::cout << "FAILED" << std::endl; return EXIT_FAILURE; } }
int main() { Implement implementObj; //execute the basic test designed by TA std::cout << "TA's basic test:" << std::endl; BasicTest( implementObj ); std::cout << std::endl; //execute your tests std::cout << "Your test:" << std::endl; YourTest ( implementObj ); std::cout << std::endl; return 0; }
// ====================================================================== int main(int argc, char *argv[]) { #ifdef HAVE_MPI MPI_Init(&argc,&argv); Epetra_MpiComm Comm( MPI_COMM_WORLD ); #else Epetra_SerialComm Comm; #endif verbose = (Comm.MyPID() == 0); for (int i = 1 ; i < argc ; ++i) { if (strcmp(argv[i],"-s") == 0) { SymmetricGallery = true; Solver = AZ_cg; } } // size of the global matrix. Teuchos::ParameterList GaleriList; int nx = 30; GaleriList.set("nx", nx); GaleriList.set("ny", nx * Comm.NumProc()); GaleriList.set("mx", 1); GaleriList.set("my", Comm.NumProc()); Teuchos::RefCountPtr<Epetra_Map> Map = Teuchos::rcp( Galeri::CreateMap("Cartesian2D", Comm, GaleriList) ); Teuchos::RefCountPtr<Epetra_CrsMatrix> A; if (SymmetricGallery) A = Teuchos::rcp( Galeri::CreateCrsMatrix("Laplace2D", &*Map, GaleriList) ); else A = Teuchos::rcp( Galeri::CreateCrsMatrix("Recirc2D", &*Map, GaleriList) ); // coordinates Teuchos::RCP<Epetra_MultiVector> coord = Teuchos::rcp( Galeri::CreateCartesianCoordinates("2D",&*Map,GaleriList)); // test the preconditioner int TestPassed = true; // ======================================== // // first verify that we can get convergence // // with all point relaxation methods // // ======================================== // if(!BasicTest("Jacobi",A,false)) TestPassed = false; if(!BasicTest("symmetric Gauss-Seidel",A,false)) TestPassed = false; if(!BasicTest("symmetric Gauss-Seidel",A,false,true)) TestPassed = false; if (!SymmetricGallery) { if(!BasicTest("Gauss-Seidel",A,false)) TestPassed = false; if(!BasicTest("Gauss-Seidel",A,true)) TestPassed = false; if(!BasicTest("Gauss-Seidel",A,false,true)) TestPassed = false; if(!BasicTest("Gauss-Seidel",A,true,true)) TestPassed = false; } // ============================= // // check uses as preconditioners // // ============================= // if(!KrylovTest("symmetric Gauss-Seidel",A,false)) TestPassed = false; if(!KrylovTest("symmetric Gauss-Seidel",A,false,true)) TestPassed = false; if (!SymmetricGallery) { if(!KrylovTest("Gauss-Seidel",A,false)) TestPassed = false; if(!KrylovTest("Gauss-Seidel",A,true)) TestPassed = false; if(!KrylovTest("Gauss-Seidel",A,false,true)) TestPassed = false; if(!KrylovTest("Gauss-Seidel",A,true,true)) TestPassed = false; } // ================================== // // compare point and block relaxation // // ================================== // //TestPassed = TestPassed && // ComparePointAndBlock("Jacobi",A,1); TestPassed = TestPassed && ComparePointAndBlock("Jacobi",A,10); //TestPassed = TestPassed && //ComparePointAndBlock("symmetric Gauss-Seidel",A,1); TestPassed = TestPassed && ComparePointAndBlock("symmetric Gauss-Seidel",A,10); if (!SymmetricGallery) { //TestPassed = TestPassed && //ComparePointAndBlock("Gauss-Seidel",A,1); TestPassed = TestPassed && ComparePointAndBlock("Gauss-Seidel",A,10); } // ============================ // // verify effect of # of blocks // // ============================ // { int Iters4, Iters8, Iters16; Iters4 = CompareBlockSizes("Jacobi",A,4); Iters8 = CompareBlockSizes("Jacobi",A,8); Iters16 = CompareBlockSizes("Jacobi",A,16); if ((Iters16 > Iters8) && (Iters8 > Iters4)) { if (verbose) cout << "CompareBlockSizes Test passed" << endl; } else { if (verbose) cout << "CompareBlockSizes TEST FAILED!" << endl; TestPassed = TestPassed && false; } } // ================================== // // verify effect of overlap in Jacobi // // ================================== // { int Iters0, Iters2, Iters4; Iters0 = CompareBlockOverlap(A,0); Iters2 = CompareBlockOverlap(A,2); Iters4 = CompareBlockOverlap(A,4); if ((Iters4 < Iters2) && (Iters2 < Iters0)) { if (verbose) cout << "CompareBlockOverlap Test passed" << endl; } else { if (verbose) cout << "CompareBlockOverlap TEST FAILED!" << endl; TestPassed = TestPassed && false; } } // ================================== // // check if line smoothing works // // ================================== // { int Iters1= CompareLineSmoother(A,coord); printf(" comparelinesmoother iters %d \n",Iters1); } // ================================== // // check if All singleton version of CompareLineSmoother // // ================================== // { AllSingle(A,coord); } // ================================== // // test variable blocking // // ================================== // { TestPassed = TestPassed && TestVariableBlocking(A->Comm()); } // ================================== // // test variable blocking // // ================================== // { TestPassed = TestPassed && TestTriDiVariableBlocking(A->Comm()); } // ============ // // final output // // ============ // if (!TestPassed) { cout << "Test `TestRelaxation.exe' failed!" << endl; exit(EXIT_FAILURE); } #ifdef HAVE_MPI MPI_Finalize(); #endif cout << endl; cout << "Test `TestRelaxation.exe' passed!" << endl; cout << endl; return(EXIT_SUCCESS); }
static int SuperskyTest( const double T, const double max_mismatch, const char *lattice_name, const UINT8 patch_count, const double freq, const double freqband, const UINT8 total_ref, const double mism_hist_ref[MISM_HIST_BINS] ) { // Create lattice tiling LatticeTiling *tiling = XLALCreateLatticeTiling(3); XLAL_CHECK(tiling != NULL, XLAL_EFUNC); // Compute reduced supersky metric const double Tspan = T * 86400; LIGOTimeGPS ref_time; XLALGPSSetREAL8(&ref_time, 900100100); LALSegList segments; { XLAL_CHECK(XLALSegListInit(&segments) == XLAL_SUCCESS, XLAL_EFUNC); LALSeg segment; LIGOTimeGPS start_time = ref_time, end_time = ref_time; XLALGPSAdd(&start_time, -0.5 * Tspan); XLALGPSAdd(&end_time, 0.5 * Tspan); XLAL_CHECK(XLALSegSet(&segment, &start_time, &end_time, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK(XLALSegListAppend(&segments, &segment) == XLAL_SUCCESS, XLAL_EFUNC); } MultiLALDetector detectors = { .length = 1, .sites = { lalCachedDetectors[LAL_LLO_4K_DETECTOR] } }; EphemerisData *edat = XLALInitBarycenter(TEST_DATA_DIR "earth00-19-DE405.dat.gz", TEST_DATA_DIR "sun00-19-DE405.dat.gz"); XLAL_CHECK(edat != NULL, XLAL_EFUNC); SuperskyMetrics *metrics = XLALComputeSuperskyMetrics(0, &ref_time, &segments, freq, &detectors, NULL, DETMOTION_SPIN | DETMOTION_PTOLEORBIT, edat); XLAL_CHECK(metrics != NULL, XLAL_EFUNC); gsl_matrix *rssky_metric = metrics->semi_rssky_metric, *rssky_transf = metrics->semi_rssky_transf; metrics->semi_rssky_metric = metrics->semi_rssky_transf = NULL; XLALDestroySuperskyMetrics(metrics); XLALSegListClear(&segments); XLALDestroyEphemerisData(edat); // Add bounds printf("Bounds: supersky, sky patch 0/%" LAL_UINT8_FORMAT ", freq=%0.3g, freqband=%0.3g\n", patch_count, freq, freqband); XLAL_CHECK(XLALSetSuperskyLatticeTilingPhysicalSkyPatch(tiling, rssky_metric, rssky_transf, patch_count, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK(XLALSetSuperskyLatticeTilingPhysicalSpinBound(tiling, rssky_transf, 0, freq, freq + freqband) == XLAL_SUCCESS, XLAL_EFUNC); GFMAT(rssky_transf); // Set metric printf("Lattice type: %s\n", lattice_name); XLAL_CHECK(XLALSetTilingLatticeAndMetric(tiling, lattice_name, rssky_metric, max_mismatch) == XLAL_SUCCESS, XLAL_EFUNC); // Perform mismatch test XLAL_CHECK(MismatchTest(tiling, rssky_metric, max_mismatch, total_ref, mism_hist_ref) == XLAL_SUCCESS, XLAL_EFUNC); return XLAL_SUCCESS; } static int MultiSegSuperskyTest(void) { printf("Performing multiple-segment tests ...\n"); // Compute reduced supersky metrics const double Tspan = 86400; LIGOTimeGPS ref_time; XLALGPSSetREAL8(&ref_time, 900100100); LALSegList segments; { XLAL_CHECK(XLALSegListInit(&segments) == XLAL_SUCCESS, XLAL_EFUNC); LALSeg segment; { LIGOTimeGPS start_time = ref_time, end_time = ref_time; XLALGPSAdd(&start_time, -4 * Tspan); XLALGPSAdd(&end_time, -3 * Tspan); XLAL_CHECK(XLALSegSet(&segment, &start_time, &end_time, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK(XLALSegListAppend(&segments, &segment) == XLAL_SUCCESS, XLAL_EFUNC); } { LIGOTimeGPS start_time = ref_time, end_time = ref_time; XLALGPSAdd(&start_time, -0.5 * Tspan); XLALGPSAdd(&end_time, 0.5 * Tspan); XLAL_CHECK(XLALSegSet(&segment, &start_time, &end_time, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK(XLALSegListAppend(&segments, &segment) == XLAL_SUCCESS, XLAL_EFUNC); } { LIGOTimeGPS start_time = ref_time, end_time = ref_time; XLALGPSAdd(&start_time, 3.5 * Tspan); XLALGPSAdd(&end_time, 4.5 * Tspan); XLAL_CHECK(XLALSegSet(&segment, &start_time, &end_time, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK(XLALSegListAppend(&segments, &segment) == XLAL_SUCCESS, XLAL_EFUNC); } } MultiLALDetector detectors = { .length = 1, .sites = { lalCachedDetectors[LAL_LLO_4K_DETECTOR] } }; EphemerisData *edat = XLALInitBarycenter(TEST_DATA_DIR "earth00-19-DE405.dat.gz", TEST_DATA_DIR "sun00-19-DE405.dat.gz"); XLAL_CHECK(edat != NULL, XLAL_EFUNC); SuperskyMetrics *metrics = XLALComputeSuperskyMetrics(1, &ref_time, &segments, 50, &detectors, NULL, DETMOTION_SPIN | DETMOTION_PTOLEORBIT, edat); XLAL_CHECK(metrics != NULL, XLAL_EFUNC); // Project and rescale semicoherent metric to give equal frequency spacings const double coh_max_mismatch = 0.2, semi_max_mismatch = 0.4; XLAL_CHECK(XLALEqualizeReducedSuperskyMetricsFreqSpacing(metrics, coh_max_mismatch, semi_max_mismatch) == XLAL_SUCCESS, XLAL_EFUNC); // Create lattice tilings LatticeTiling *coh_tiling[metrics->num_segments]; for (size_t n = 0; n < metrics->num_segments; ++n) { coh_tiling[n] = XLALCreateLatticeTiling(4); XLAL_CHECK(coh_tiling[n] != NULL, XLAL_EFUNC); } LatticeTiling *semi_tiling = XLALCreateLatticeTiling(4); XLAL_CHECK(semi_tiling != NULL, XLAL_EFUNC); // Add bounds for (size_t n = 0; n < metrics->num_segments; ++n) { XLAL_CHECK(XLALSetSuperskyLatticeTilingPhysicalSkyPatch(coh_tiling[n], metrics->coh_rssky_metric[n], metrics->coh_rssky_transf[n], 1, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK(XLALSetSuperskyLatticeTilingPhysicalSpinBound(coh_tiling[n], metrics->coh_rssky_transf[n], 0, 50, 50 + 1e-4) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK(XLALSetSuperskyLatticeTilingPhysicalSpinBound(coh_tiling[n], metrics->coh_rssky_transf[n], 1, 0, -5e-10) == XLAL_SUCCESS, XLAL_EFUNC); } XLAL_CHECK(XLALSetSuperskyLatticeTilingPhysicalSkyPatch(semi_tiling, metrics->semi_rssky_metric, metrics->semi_rssky_transf, 1, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK(XLALSetSuperskyLatticeTilingPhysicalSpinBound(semi_tiling, metrics->semi_rssky_transf, 0, 50, 50 + 1e-4) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK(XLALSetSuperskyLatticeTilingPhysicalSpinBound(semi_tiling, metrics->semi_rssky_transf, 1, 0, -5e-10) == XLAL_SUCCESS, XLAL_EFUNC); // Set metric for (size_t n = 0; n < metrics->num_segments; ++n) { XLAL_CHECK(XLALSetTilingLatticeAndMetric(coh_tiling[n], "Ans", metrics->coh_rssky_metric[n], coh_max_mismatch) == XLAL_SUCCESS, XLAL_EFUNC); } XLAL_CHECK(XLALSetTilingLatticeAndMetric(semi_tiling, "Ans", metrics->semi_rssky_metric, semi_max_mismatch) == XLAL_SUCCESS, XLAL_EFUNC); // Check lattice step sizes in frequency const size_t ifreq = 3; const double semi_dfreq = XLALLatticeTilingStepSizes(semi_tiling, ifreq); for (size_t n = 0; n < metrics->num_segments; ++n) { const double coh_dfreq = XLALLatticeTilingStepSizes(coh_tiling[n], ifreq); const double tol = 1e-8; XLAL_CHECK(fabs(coh_dfreq - semi_dfreq) < tol * semi_dfreq, XLAL_EFAILED, " ERROR: semi_dfreq=%0.15e, coh_dfreq[%zu]=%0.15e, |coh_dfreq - semi_dfreq| >= %g * semi_dfreq", semi_dfreq, n, coh_dfreq, tol); } // Check computation of spindown range for coherent tilings for (size_t n = 0; n < metrics->num_segments; ++n) { PulsarSpinRange spin_range; XLAL_CHECK(XLALSuperskyLatticePulsarSpinRange(&spin_range, coh_tiling[n], metrics->coh_rssky_transf[n]) == XLAL_SUCCESS, XLAL_EFUNC); } // Cleanup for (size_t n = 0; n < metrics->num_segments; ++n) { XLALDestroyLatticeTiling(coh_tiling[n]); } XLALDestroyLatticeTiling(semi_tiling); XLALDestroySuperskyMetrics(metrics); XLALSegListClear(&segments); XLALDestroyEphemerisData(edat); LALCheckMemoryLeaks(); printf("\n"); fflush(stdout); return XLAL_SUCCESS; } int main(void) { // Perform basic tests XLAL_CHECK_MAIN(BasicTest(1, 0, 0, 0, 0, "Zn" , 1, 1, 1, 1) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(1, 1, 1, 1, 1, "Ans", 93, 0, 0, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(1, 1, 1, 1, 1, "Zn" , 93, 0, 0, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(2, 0, 0, 0, 0, "Ans", 1, 1, 1, 1) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(2, 1, 1, 1, 1, "Ans", 12, 144, 0, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(2, 1, 1, 1, 1, "Zn" , 13, 190, 0, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(3, 0, 0, 0, 0, "Zn" , 1, 1, 1, 1) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(3, 1, 1, 1, 1, "Ans", 8, 46, 332, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(3, 1, 1, 1, 1, "Zn" , 8, 60, 583, 0) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 0, 0, 0, 0, "Ans", 1, 1, 1, 1) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 0, 0, 0, 1, "Ans", 1, 1, 1, 4) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 0, 0, 1, 0, "Ans", 1, 1, 4, 4) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 0, 0, 1, 1, "Ans", 1, 1, 4, 20) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 0, 1, 0, 0, "Ans", 1, 4, 4, 4) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 0, 1, 0, 1, "Ans", 1, 5, 5, 25) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 0, 1, 1, 0, "Ans", 1, 5, 24, 24) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 0, 1, 1, 1, "Ans", 1, 5, 20, 115) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 1, 0, 0, 0, "Ans", 4, 4, 4, 4) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 1, 0, 0, 1, "Ans", 5, 5, 5, 23) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 1, 0, 1, 0, "Ans", 5, 5, 23, 23) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 1, 0, 1, 1, "Ans", 6, 6, 24, 139) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 1, 1, 0, 0, "Ans", 5, 25, 25, 25) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 1, 1, 0, 1, "Ans", 6, 30, 30, 162) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 1, 1, 1, 0, "Ans", 6, 27, 151, 151) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 1, 1, 1, 1, "Ans", 6, 30, 145, 897) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(BasicTest(4, 1, 1, 1, 1, "Zn" , 7, 46, 287, 2543) == XLAL_SUCCESS, XLAL_EFUNC); // Perform mismatch tests with a square parameter space XLAL_CHECK_MAIN(MismatchSquareTest("Zn", 0.03, 0, 0, 21460, Z1_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(MismatchSquareTest("Zn", 2e-4, -2e-9, 0, 23763, Z2_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(MismatchSquareTest("Zn", 1e-4, -1e-9, 1e-17, 19550, Z3_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(MismatchSquareTest("Ans", 0.03, 0, 0, 21460, A1s_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(MismatchSquareTest("Ans", 2e-4, -2e-9, 0, 18283, A2s_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(MismatchSquareTest("Ans", 1e-4, -2e-9, 2e-17, 20268, A3s_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); // Perform mismatch tests with an age--braking index parameter space XLAL_CHECK_MAIN(MismatchAgeBrakeTest("Ans", 100, 4.0e-5, 37872, A3s_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(MismatchAgeBrakeTest("Ans", 200, 1.5e-5, 37232, A3s_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(MismatchAgeBrakeTest("Ans", 300, 1.0e-5, 37022, A3s_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); // Perform mismatch tests with the reduced supersky parameter space and metric XLAL_CHECK_MAIN(SuperskyTest(1.1, 0.8, "Ans", 1, 50, 2.0e-5, 20548, A3s_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(SuperskyTest(1.5, 0.8, "Ans", 3, 50, 2.0e-5, 20202, A3s_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); XLAL_CHECK_MAIN(SuperskyTest(2.5, 0.8, "Ans", 17, 50, 2.0e-5, 29147, A3s_mism_hist) == XLAL_SUCCESS, XLAL_EFUNC); // Perform tests with the reduced supersky parameter space metric and multiple segments XLAL_CHECK_MAIN(MultiSegSuperskyTest() == XLAL_SUCCESS, XLAL_EFUNC); return EXIT_SUCCESS; }
int main(int argc, char* argv[]) { BasicTest(); AdvancedTest(); return 0; }