scripts/check-local-headers.sh: Verify there is input (don't hang).
Commit Message
If you have a failed build, and run `make check` it could hang forever
in check-local-headers.sh because the awk script waits reading stdin
if the input shell glob expands to nothing (missing input).
We have three options, close stdin, more awk to detect missing input
or more shell. I chose the latter, but we could probably fix this with
`exec 0>&-` in the shell if anyone objects to using find/grep or more
awk.
Tested on x86_64 with a broken build directory.
OK to checkin?
2014-12-10 Carlos O'Donell <carlos@redhat.com>
* scripts/check-local-headers.sh: Verify there is input.
Comments
"Carlos O'Donell" <carlos@redhat.com> writes:
> We have three options, close stdin, more awk to detect missing input
> or more shell. I chose the latter, but we could probably fix this with
> `exec 0>&-` in the shell if anyone objects to using find/grep or more
> awk.
Just redirect from /dev/null.
Andreas.
On Wed, 10 Dec 2014, Carlos O'Donell wrote:
> If you have a failed build, and run `make check` it could hang forever
> in check-local-headers.sh because the awk script waits reading stdin
> if the input shell glob expands to nothing (missing input).
>
> We have three options, close stdin, more awk to detect missing input
> or more shell. I chose the latter, but we could probably fix this with
> `exec 0>&-` in the shell if anyone objects to using find/grep or more
> awk.
We have consensus to redirect test input from /dev/null (unless a test
needs input from some other file, of course). See bug 14753.
@@ -25,6 +25,13 @@ cd "$objpfx"
# OK if *.os is missing.
shopt -s nullglob
+# Don't hang in awk reading stdin if there is no input to the test.
+# The most likely cause of this failure is a build failure.
+if ! find . -regex '.*\.o[sS]*\.d' | grep -q '.*\.o[sS]*\.d'; then
+ echo "FAIL: No input files to read."
+ exit 1
+fi
+
# Search all dependency files for file names in the include directory.
# There are a few system headers we are known to use.
# These include Linux kernel headers (asm*, arch, and linux),