[cache_check] Errors weren't being propagated up to the exit code
This commit is contained in:
parent
ce8e19fa75
commit
fd7c539a58
@ -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);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user