Skip to content

Commit

Permalink
Better error message for database read problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
markasoftware committed Jan 20, 2024
1 parent 1c6cabd commit e65ee71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,10 @@ Pipeline SetPipeline(const PipelineOptions &values) {
fs.seekg(0, fs.end);
long length = fs.tellg();
fs.seekg(0, fs.beg);
if (fs.fail()) {
std::cerr << "Error reading database! " << strerror(errno) << std::endl;
exit(1);
}
std::cerr << "Reading " << length << " bytes of database" << std::endl;
result.database = std::unique_ptr<unsigned char[]>(new unsigned char[length]);
fs.read((char *)result.database.get(), length);
Expand Down
4 changes: 4 additions & 0 deletions test/scripts/random-crap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ echo 'Issue #36: Cog and Attitude without Star-ID'
echo 'Run the generator without centroids a whole bunch and make sure no assertions go off'
./lost pipeline --generate 200 --generate-perturb-centroids 5 --generate-centroids-only

echo 'Error message for database that does not exist'
no_database_out=$(./lost pipeline --generate 1 --database 'does not.exist' --star-id-algo py 2>&1) && exit 1
[[ $no_database_out == 'Error reading database!'* ]] || exit 1

echo 'Speed 95-th percentile should be different than max for 20 but not 19 trials'
nineteen_out=$(./lost pipeline --generate 19 --generate-centroids-only --attitude-algo quest --print-speed -)
nineteen_max_ns=$(echo "$nineteen_out" | grep total_max_ns | cut -d' ' -f2)
Expand Down

0 comments on commit e65ee71

Please sign in to comment.