diff --git a/src/io.cpp b/src/io.cpp index e385190b..0c73be3f 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -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(new unsigned char[length]); fs.read((char *)result.database.get(), length); diff --git a/test/scripts/random-crap.sh b/test/scripts/random-crap.sh index 71596c1b..848c0e00 100755 --- a/test/scripts/random-crap.sh +++ b/test/scripts/random-crap.sh @@ -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)