Skip to content

Commit 1717075

Browse files
authored
Merge pull request #6867 from chu11/issue6860_fsck_error_message
flux-fsck: fix error message output
2 parents 127da10 + 07e9aa6 commit 1717075

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/cmd/builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static void fsck_valref (flux_t *h, const char *path, json_t *treeobj)
147147
if (fvd.errorcount) {
148148
/* each invalid blobref will be output in verbose mode */
149149
if (!verbose) {
150-
if (errno == ENOENT)
150+
if (fvd.errnum == ENOENT)
151151
read_error ("%s: missing blobref(s)", path);
152152
else
153153
read_error ("%s: error retrieving blobref(s): %s",

t/t2816-fsck-cmd.t

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ test_expect_success 'save some treeobjs for later' '
3939
test_expect_success 'unload kvs' '
4040
flux module remove kvs
4141
'
42-
test_expect_success 'flux-fsck works' '
42+
test_expect_success 'flux-fsck works (simple)' '
4343
flux fsck 2> simple.out &&
4444
grep "Checking integrity" simple.out &&
4545
grep "Total errors: 0" simple.out
4646
'
47-
test_expect_success 'flux-fsck verbose works' '
47+
test_expect_success 'flux-fsck verbose works (simple)' '
4848
flux fsck --verbose 2> verbose.out &&
4949
grep "dir\.a" verbose.out &&
5050
grep "dir\.b" verbose.out &&
@@ -66,7 +66,7 @@ test_expect_success LONGTEST 'call sync to ensure we have checkpointed' '
6666
test_expect_success LONGTEST 'unload kvs' '
6767
flux module remove kvs
6868
'
69-
test_expect_success LONGTEST 'flux-fsck works' '
69+
test_expect_success LONGTEST 'flux-fsck works (big)' '
7070
flux fsck --verbose 2> bigval.out &&
7171
grep "Checking integrity" bigval.out &&
7272
grep "bigval" bigval.out &&
@@ -77,7 +77,7 @@ test_expect_success 'load kvs' '
7777
'
7878
# unfortunately we don't have a `flux content remove` command, so we'll corrupt
7979
# a valref by overwriting a treeobj with a bad reference
80-
test_expect_success 'make a reference invalid' '
80+
test_expect_success 'make a reference invalid (dir.b)' '
8181
cat dirb.out | jq -c .data[1]=\"sha1-1234567890123456789012345678901234567890\" > dirbbad.out &&
8282
flux kvs put --treeobj dir.b="$(cat dirbbad.out)"
8383
'
@@ -88,27 +88,30 @@ test_expect_success 'unload kvs' '
8888
flux module remove kvs
8989
'
9090
# line count includes extra diagnostic messages
91-
test_expect_success 'flux-fsck detects errors' '
91+
test_expect_success 'flux-fsck detects errors (dir.b)' '
9292
test_must_fail flux fsck 2> fsckerrors1.out &&
93+
test_debug "cat fsckerrors1.out" &&
9394
count=$(cat fsckerrors1.out | wc -l) &&
9495
test $count -eq 3 &&
9596
grep "dir\.b" fsckerrors1.out | grep "missing blobref(s)" &&
9697
grep "Total errors: 1" fsckerrors1.out
9798
'
98-
test_expect_success 'flux-fsck --verbose outputs details' '
99+
test_expect_success 'flux-fsck --verbose outputs details (dir.b)' '
99100
test_must_fail flux fsck --verbose 2> fsckerrors1V.out &&
101+
test_debug "cat fsckerrors1V.out" &&
100102
grep "dir\.b" fsckerrors1V.out | grep "missing blobref" | grep "index=1" &&
101103
grep "Total errors: 1" fsckerrors1V.out
102104
'
103-
test_expect_success 'flux-fsck no output with --quiet' '
105+
test_expect_success 'flux-fsck no output with --quiet (dir.b)' '
104106
test_must_fail flux fsck --quiet 2> fsckerrors2.out &&
107+
test_debug "cat fsckerrors2.out" &&
105108
count=$(cat fsckerrors2.out | wc -l) &&
106109
test $count -eq 0
107110
'
108111
test_expect_success 'load kvs' '
109112
flux module load kvs
110113
'
111-
test_expect_success 'make a reference invalid' '
114+
test_expect_success 'make a reference invalid (dir.c)' '
112115
cat dirc.out | jq -c .data[1]=\"sha1-1234567890123456789012345678901234567890\" > dircbad1.out &&
113116
cat dircbad1.out | jq -c .data[2]=\"sha1-1234567890123456789012345678901234567890\" > dircbad2.out &&
114117
flux kvs put --treeobj dir.c="$(cat dircbad2.out)"
@@ -120,23 +123,26 @@ test_expect_success 'unload kvs' '
120123
flux module remove kvs
121124
'
122125
# line count includes extra diagnostic messages
123-
test_expect_success 'flux-fsck detects errors' '
126+
test_expect_success 'flux-fsck detects errors (dir.b & c)' '
124127
test_must_fail flux fsck 2> fsckerrors3.out &&
128+
test_debug "cat fsckerrors3.out" &&
125129
count=$(cat fsckerrors3.out | wc -l) &&
126130
test $count -eq 4 &&
127131
grep "dir\.b" fsckerrors3.out | grep "missing blobref(s)" &&
128132
grep "dir\.c" fsckerrors3.out | grep "missing blobref(s)" &&
129133
grep "Total errors: 2" fsckerrors3.out
130134
'
131-
test_expect_success 'flux-fsck --verbose outputs details' '
135+
test_expect_success 'flux-fsck --verbose outputs details (dir.b & c)' '
132136
test_must_fail flux fsck --verbose 2> fsckerrors3V.out &&
137+
test_debug "cat fsckerrors3V.out" &&
133138
grep "dir\.b" fsckerrors3V.out | grep "missing blobref" | grep "index=1" &&
134139
grep "dir\.c" fsckerrors3V.out | grep "missing blobref" | grep "index=1" &&
135140
grep "dir\.c" fsckerrors3V.out | grep "missing blobref" | grep "index=2" &&
136141
grep "Total errors: 2" fsckerrors3V.out
137142
'
138-
test_expect_success 'flux-fsck no output with --quiet' '
143+
test_expect_success 'flux-fsck no output with --quiet (dir.b & c)' '
139144
test_must_fail flux fsck --quiet 2> fsckerrors4.out &&
145+
test_debug "cat fsckerrors4.out" &&
140146
count=$(cat fsckerrors4.out | wc -l) &&
141147
test $count -eq 0
142148
'

0 commit comments

Comments
 (0)