diff --git a/caching/cache_check.cc b/caching/cache_check.cc index 5cb2c7d..f1667c3 100644 --- a/caching/cache_check.cc +++ b/caching/cache_check.cc @@ -175,6 +175,7 @@ namespace { } int check(string const &path, flags const &fs) { + error_state err; struct stat info = guarded_stat(path); if (!S_ISREG(info.st_mode) && !S_ISBLK(info.st_mode)) { @@ -185,9 +186,7 @@ namespace { try { block_manager<>::ptr bm = open_bm(path, block_io<>::READ_ONLY); - //metadata::ptr md(new metadata(bm, metadata::OPEN)); - - error_state err = metadata_check(bm, fs); + err = metadata_check(bm, fs); #if 0 if (maybe_errors) { if (!fs.quiet_) @@ -202,7 +201,7 @@ namespace { return 1; } - return 0; + return err == NO_ERROR ? 0 : 1; } void usage(ostream &out, string const &cmd) { @@ -256,15 +255,7 @@ int main(int argc, char **argv) return 1; } - try { - check(argv[optind], fs); - - } catch (std::exception const &e) { - cerr << e.what() << endl; - return 1; - } - - return 0; + return check(argv[optind], fs); } //---------------------------------------------------------------- diff --git a/features/cache_check.feature b/features/cache_check.feature index 773aaa3..28687af 100644 --- a/features/cache_check.feature +++ b/features/cache_check.feature @@ -56,25 +56,18 @@ Feature: cache_check Scenario: Metadata file exists, but can't be opened Given input without read permissions - When I run `cache_check input` - Then it should fail And the stderr should contain: """ - input: Permission denied + Permission denied """ Scenario: Metadata file full of zeroes Given input file And block 1 is zeroed - When I run `cache_check input` - - And the stderr should contain: - """ - input: No superblock found - """ + Then it should fail Scenario: A valid metadata area passes Given metadata containing: @@ -82,5 +75,5 @@ Feature: cache_check """ When I run cache_check + Then it should pass - Then it should pass \ No newline at end of file