Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ab788a2

Browse files
committedNov 28, 2017
Replace most call to grep in run-make by a script that cat the input.
Introduced a new src/etc/cat-and-grep.sh script (called in run-make as $(CGREP)), which prints the input and do a grep simultaneously. This is mainly used to debug spurious failures in run-make, such as the sanitizer error in #45810, as well as real errors such as #46126.
1 parent 3bde5e7 commit ab788a2

File tree

47 files changed

+241
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+241
-119
lines changed
 

‎src/etc/cat-and-grep.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
5+
# file at the top-level directory of this distribution and at
6+
# http://rust-lang.org/COPYRIGHT.
7+
#
8+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
9+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
10+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
11+
# option. This file may not be copied, modified, or distributed
12+
# except according to those terms.
13+
14+
# Performs `cat` and `grep` simultaneously for `run-make` tests in the Rust CI.
15+
#
16+
# This program will read lines from stdin and print them to stdout immediately.
17+
# At the same time, it will check if the input line contains the substring or
18+
# regex specified in the command line. If any match is found, the program will
19+
# set the exit code to 0, otherwise 1.
20+
#
21+
# This is written to simplify debugging runmake tests. Since `grep` swallows all
22+
# output, when a test involving `grep` failed, it is impossible to know the
23+
# reason just by reading the failure log. While it is possible to `tee` the
24+
# output into another stream, it becomes pretty annoying to do this for all test
25+
# cases.
26+
27+
USAGE='
28+
cat-and-grep.sh [-v] [-e] [-i] s1 s2 s3 ... < input.txt
29+
30+
Prints the stdin, and exits successfully only if all of `sN` can be found in
31+
some lines of the input.
32+
33+
Options:
34+
-v Invert match, exits successfully only if all of `sN` cannot be found
35+
-e Regex search, search using extended Regex instead of fixed string
36+
-i Case insensitive search.
37+
'
38+
39+
GREPPER=fgrep
40+
INVERT=0
41+
GREPFLAGS='q'
42+
while getopts ':vieh' OPTION; do
43+
case "$OPTION" in
44+
v)
45+
INVERT=1
46+
ERROR_MSG='should not be found'
47+
;;
48+
i)
49+
GREPFLAGS="i$GREPFLAGS"
50+
;;
51+
e)
52+
GREPPER=egrep
53+
;;
54+
h)
55+
echo "$USAGE"
56+
exit 2
57+
;;
58+
*)
59+
break
60+
;;
61+
esac
62+
done
63+
64+
shift $((OPTIND - 1))
65+
66+
LOG=$(mktemp -t cgrep.XXXXXX)
67+
trap "rm -f $LOG" EXIT
68+
69+
printf "[[[ begin stdout ]]]\n\033[90m"
70+
tee "$LOG"
71+
echo >> "$LOG" # ensure at least 1 line of output, otherwise `grep -v` may unconditionally fail.
72+
printf "\033[0m\n[[[ end stdout ]]]\n"
73+
74+
HAS_ERROR=0
75+
for MATCH in "$@"; do
76+
if "$GREPPER" "-$GREPFLAGS" -- "$MATCH" "$LOG"; then
77+
if [ "$INVERT" = 1 ]; then
78+
printf "\033[1;31mError: should not match: %s\033[0m\n" "$MATCH"
79+
HAS_ERROR=1
80+
fi
81+
else
82+
if [ "$INVERT" = 0 ]; then
83+
printf "\033[1;31mError: cannot match: %s\033[0m\n" "$MATCH"
84+
HAS_ERROR=1
85+
fi
86+
fi
87+
done
88+
89+
exit "$HAS_ERROR"

‎src/test/run-make/atomic-lock-free/Makefile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,36 @@ all:
77
ifeq ($(UNAME),Linux)
88
ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86)
99
$(RUSTC) --target=i686-unknown-linux-gnu atomic_lock_free.rs
10-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
10+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
1111
$(RUSTC) --target=x86_64-unknown-linux-gnu atomic_lock_free.rs
12-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
12+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
1313
endif
1414
ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm)
1515
$(RUSTC) --target=arm-unknown-linux-gnueabi atomic_lock_free.rs
16-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
16+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
1717
$(RUSTC) --target=arm-unknown-linux-gnueabihf atomic_lock_free.rs
18-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
18+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
1919
$(RUSTC) --target=armv7-unknown-linux-gnueabihf atomic_lock_free.rs
20-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
20+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
2121
endif
2222
ifeq ($(filter aarch64,$(LLVM_COMPONENTS)),aarch64)
2323
$(RUSTC) --target=aarch64-unknown-linux-gnu atomic_lock_free.rs
24-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
24+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
2525
endif
2626
ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips)
2727
$(RUSTC) --target=mips-unknown-linux-gnu atomic_lock_free.rs
28-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
28+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
2929
$(RUSTC) --target=mipsel-unknown-linux-gnu atomic_lock_free.rs
30-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
30+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
3131
endif
3232
ifeq ($(filter powerpc,$(LLVM_COMPONENTS)),powerpc)
3333
$(RUSTC) --target=powerpc-unknown-linux-gnu atomic_lock_free.rs
34-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
34+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
3535
$(RUSTC) --target=powerpc64-unknown-linux-gnu atomic_lock_free.rs
36-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
36+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
3737
$(RUSTC) --target=powerpc64le-unknown-linux-gnu atomic_lock_free.rs
38-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
38+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
3939
$(RUSTC) --target=s390x-unknown-linux-gnu atomic_lock_free.rs
40-
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
40+
nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
4141
endif
4242
endif

0 commit comments

Comments
 (0)
Please sign in to comment.