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