Fixed bug: return EXIT_FAILURE on error

This commit is contained in:
Laurent Saboret 2008-06-06 10:51:13 +00:00
parent 5f314df538
commit f12bd2fb13
4 changed files with 84 additions and 18 deletions

View File

@ -63,16 +63,24 @@ int main(int argc, char * argv[])
std::cerr << "Analysis tests" << std::endl;
std::cerr << "No output" << std::endl;
// decode parameters
if(argc < 2)
{
std::cerr << "Usage: " << argv[0] << " file1.xyz file2.xyz ..." << std::endl;
return EXIT_FAILURE;
}
// for each input file
const unsigned int k = 8; // # neighbors
// Accumulated errors
int accumulated_fatal_err = EXIT_SUCCESS;
// Process each input file
for(int i=1; i<argc; i++)
{
std::cerr << std::endl;
// Load point set
std::list<Point> points;
std::cerr << " Open " << argv[i] << " for reading...";
if(CGAL::surface_reconstruction_read_xyz(argv[i],
@ -84,8 +92,16 @@ int main(int argc, char * argv[])
test_average_spacing(points,k);
}
else
std::cerr << " Unable to open file " << argv[i] << std::endl;
}
return EXIT_SUCCESS;
{
std::cerr << " FATAL ERROR: cannot read file " << argv[i] << std::endl;
accumulated_fatal_err = EXIT_FAILURE;
}
} // for each input file
std::cerr << std::endl;
// Return accumulated fatal error
std::cerr << "Tool returned " << accumulated_fatal_err << std::endl;
return accumulated_fatal_err;
}

View File

@ -102,16 +102,24 @@ int main(int argc, char * argv[])
std::cerr << "Normal estimation test" << std::endl;
std::cerr << "No output" << std::endl;
// decode parameters
if(argc < 2)
{
std::cerr << "Usage: " << argv[0] << " file1.xyz file2.xyz ..." << std::endl;
return EXIT_FAILURE;
}
// for each input file
const unsigned int k = 10; // # neighbors
// Accumulated errors
int accumulated_fatal_err = EXIT_SUCCESS;
// Process each input file
for(int i=1; i<argc; i++)
{
std::cerr << std::endl;
// Load point set
std::vector<Point> points;
std::cerr << " Open " << argv[i] << " for reading...";
if(CGAL::surface_reconstruction_read_xyz(argv[i],
@ -126,9 +134,17 @@ int main(int argc, char * argv[])
test_orient_normals_MST(points, normals_jet_fitting, k);
}
else
std::cerr << " Unable to open file " << argv[i] << std::endl;
}
return EXIT_SUCCESS;
{
std::cerr << " FATAL ERROR: cannot read file " << argv[i] << std::endl;
accumulated_fatal_err = EXIT_FAILURE;
}
} // for each input file
std::cerr << std::endl;
// Return accumulated fatal error
std::cerr << "Tool returned " << accumulated_fatal_err << std::endl;
return accumulated_fatal_err;
}
@ -148,5 +164,6 @@ int main()
return EXIT_SUCCESS;
}
#endif // CGAL_USE_LAPACK

View File

@ -71,17 +71,25 @@ int main(int argc, char * argv[])
std::cerr << "Normal estimation test" << std::endl;
std::cerr << "No output" << std::endl;
// decode parameters
if(argc < 2)
{
std::cerr << "Usage: " << argv[0] << " file1.xyz file2.xyz ..." << std::endl;
return EXIT_FAILURE;
}
// for each input file
const unsigned int k = 10; // # neighbors
const unsigned int outliers_percentage = 5; // percentage of points to remove
// Accumulated errors
int accumulated_fatal_err = EXIT_SUCCESS;
// Process each input file
for(int i=1; i<argc; i++)
{
std::cerr << std::endl;
// Load point set
std::vector<Point> points;
std::cerr << " Open " << argv[i] << " for reading...";
if(CGAL::surface_reconstruction_read_xyz(argv[i],
@ -93,8 +101,16 @@ int main(int argc, char * argv[])
test_avg_knn_sq_distance(points, k, outliers_percentage);
}
else
std::cerr << " Unable to open file " << argv[i] << std::endl;
}
return EXIT_SUCCESS;
{
std::cerr << " FATAL ERROR: cannot read file " << argv[i] << std::endl;
accumulated_fatal_err = EXIT_FAILURE;
}
} // for each input file
std::cerr << std::endl;
// Return accumulated fatal error
std::cerr << "Tool returned " << accumulated_fatal_err << std::endl;
return accumulated_fatal_err;
}

View File

@ -71,16 +71,24 @@ int main(int argc, char * argv[])
std::cerr << "Smoothing test" << std::endl;
std::cerr << "No output" << std::endl;
// decode parameters
if(argc < 2)
{
std::cerr << "Usage: " << argv[0] << " file1.xyz file2.xyz ..." << std::endl;
return EXIT_FAILURE;
}
// for each input file
const unsigned int k = 20; // # neighbors
// Accumulated errors
int accumulated_fatal_err = EXIT_SUCCESS;
// Process each input file
for(int i=1; i<argc; i++)
{
std::cerr << std::endl;
// Load point set
std::list<Point> points;
std::cerr << " Open " << argv[i] << " for reading...";
if(CGAL::surface_reconstruction_read_xyz(argv[i],
@ -92,11 +100,19 @@ int main(int argc, char * argv[])
test_jet_fitting(points,k);
}
else
std::cerr << " Unable to open file " << argv[i] << std::endl;
}
return EXIT_SUCCESS;
{
std::cerr << " FATAL ERROR: cannot read file " << argv[i] << std::endl;
accumulated_fatal_err = EXIT_FAILURE;
}
} // for each input file
std::cerr << std::endl;
// Return accumulated fatal error
std::cerr << "Tool returned " << accumulated_fatal_err << std::endl;
return accumulated_fatal_err;
}
#else // CGAL_USE_LAPACK
@ -110,9 +126,10 @@ int main(int argc, char * argv[])
int main()
{
std::cerr << "Skip smoothing test as LAPACK is not installed" << std::endl;
std::cerr << "Skip test as LAPACK is not installed" << std::endl;
return EXIT_SUCCESS;
}
#endif // CGAL_USE_LAPACK