This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFAv2 5/6] Test the | (pipe) command.
- From: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- To: gdb-patches at sourceware dot org
- Cc: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- Date: Fri, 26 Apr 2019 22:11:07 +0200
- Subject: [RFAv2 5/6] Test the | (pipe) command.
- References: <20190426201108.7489-1-philippe.waroquiers@skynet.be>
gdb/testsuite/ChangeLog
2019-04-26 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/shell.exp: Test pipe command.
---
gdb/testsuite/gdb.base/shell.exp | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/shell.exp b/gdb/testsuite/gdb.base/shell.exp
index 60d6e31e4f..30516286cf 100644
--- a/gdb/testsuite/gdb.base/shell.exp
+++ b/gdb/testsuite/gdb.base/shell.exp
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Test that the shell and ! commands work.
+# Test that the shell and ! and | and pipe commands work.
gdb_exit
gdb_start
@@ -22,3 +22,31 @@ gdb_test "shell echo foo" "foo"
gdb_test "! echo foo" "foo"
gdb_test "!echo foo" "foo"
+
+gdb_test "pipe help pipe | wc -l" "10" "check simple pipe"
+gdb_test "pipe help pipe | grep Usage: | wc -l" "4" "check double pipe"
+
+gdb_test "| help pipe | grep Usage: | wc -l" "4" "check double pipe, pipe char"
+gdb_test "|help pipe|grep Usage:|wc -l" "4" "no space around pipe char"
+
+gdb_test "echo coucou\\n" "coucou" "echo coucou"
+gdb_test "||wc -l" "1" "Check repeat previous command"
+
+gdb_test "| -d! echo this contains a | character\\n ! sed -e 's/|/PIPE/'" \
+ "this contains a PIPE character" "verify alternate separator"
+
+gdb_test "|-d! echo this contains a | character\\n!sed -e 's/|/PIPE/'" \
+ "this contains a PIPE character" "verify alternate separator, no space"
+
+# Some error handling verifications.
+gdb_test "|" "Missing \\\"\[COMMAND\] | SHELL_COMMAND\\\"" "all missing"
+gdb_test "| echo coucou" \
+ "Missing | SHELL_COMMAND in \\\"| COMMAND | SHELL_COMMAND\\\"" \
+ "pipe SHELL_COMMAND missing"
+gdb_test "|-d echo coucou" \
+ "Missing separator X after -d in \\\"| -dX COMMAND X SHELL_COMMAND\\\"" \
+ "separator missing"
+gdb_test "|-d! echo coucou" \
+ "Missing ! SHELL_COMMAND in \\\"| -d! COMMAND ! SHELL_COMMAND\\\"" \
+ "separator SHELL_COMMAND missing"
+
--
2.20.1