[geany/geany-plugins] 65a4e6: debugger/gdb_mi: Add a few tests
Colomban Wendling
git-noreply at xxxxx
Sun Nov 15 17:28:25 UTC 2015
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Sun, 08 Mar 2015 21:15:39 UTC
Commit: 65a4e6583353ac38a80d156541de48f878a55894
https://github.com/geany/geany-plugins/commit/65a4e6583353ac38a80d156541de48f878a55894
Log Message:
-----------
debugger/gdb_mi: Add a few tests
Modified Paths:
--------------
debugger/src/Makefile.am
debugger/src/gdb_mi.c
debugger/src/tests/gdb_mi_test.expected
debugger/src/tests/gdb_mi_test.input
debugger/src/tests/gdb_mi_test.sh
Modified: debugger/src/Makefile.am
10 lines changed, 10 insertions(+), 0 deletions(-)
===================================================================
@@ -74,4 +74,14 @@ debugger_la_SOURCES = \
debugger_la_LIBADD = $(COMMONLIBS) $(VTE_LIBS) -lutil
debugger_la_CFLAGS = $(AM_CFLAGS) $(VTE_CFLAGS) -DDBGPLUG_DATA_DIR=\"$(plugindatadir)\" -DPLUGIN_NAME=\"$(plugin)\"
+check_PROGRAMS = gdb_mi_test
+dist_check_SCRIPTS = tests/gdb_mi_test.sh
+dist_check_DATA = tests/gdb_mi_test.input tests/gdb_mi_test.expected
+TESTS = $(dist_check_SCRIPTS)
+
+gdb_mi_test_SOURCES = gdb_mi.c gdb_mi.h
+gdb_mi_test_CFLAGS = $(AM_CFLAGS) -DTEST
+gdb_mi_test_LDFLAGS =
+gdb_mi_test_LDADD = $(COMMONLIBS)
+
include $(top_srcdir)/build/cppcheck.mk
Modified: debugger/src/gdb_mi.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -481,7 +481,7 @@ static void gdb_mi_record_dump(const struct gdb_mi_record *record)
int main(void)
{
- char buf[256] = {0};
+ char buf[1024] = {0};
while (fgets(buf, sizeof buf, stdin))
{
Modified: debugger/src/tests/gdb_mi_test.expected
338 lines changed, 338 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,338 @@
+# (gdb)
+record =>
+ type = '0' (0)
+ token = (null)
+ class = (null)
+ results =>
+# (gdb)
+record =>
+ type = '0' (0)
+ token = (null)
+ class = (null)
+ results =>
+# (gdb)
+record =>
+ type = '0' (0)
+ token = (null)
+ class = (null)
+ results =>
+# ^error,msg="failed"
+record =>
+ type = '^' (94)
+ token = (null)
+ class = error
+ results =>
+ var = msg
+ val =>
+ type = 0
+ string = failed
+# *stopped,reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt",frame={addr="0x00000000deadbeef",func="somefunc",args=[],file="somefile.c",fullname="/some/path/somefile.c",line="123"},thread-id="1",stopped-threads="all",core="1"
+record =>
+ type = '*' (42)
+ token = (null)
+ class = stopped
+ results =>
+ var = reason
+ val =>
+ type = 0
+ string = signal-received
+ var = signal-name
+ val =>
+ type = 0
+ string = SIGINT
+ var = signal-meaning
+ val =>
+ type = 0
+ string = Interrupt
+ var = frame
+ val =>
+ type = 1
+ list =>
+ var = addr
+ val =>
+ type = 0
+ string = 0x00000000deadbeef
+ var = func
+ val =>
+ type = 0
+ string = somefunc
+ var = args
+ val =>
+ type = 1
+ list =>
+ var = file
+ val =>
+ type = 0
+ string = somefile.c
+ var = fullname
+ val =>
+ type = 0
+ string = /some/path/somefile.c
+ var = line
+ val =>
+ type = 0
+ string = 123
+ var = thread-id
+ val =>
+ type = 0
+ string = 1
+ var = stopped-threads
+ val =>
+ type = 0
+ string = all
+ var = core
+ val =>
+ type = 0
+ string = 1
+# *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x0000000000400c55",func="gdb_mi_record_dump",args=[{name="record",value="0x603010"}],file="gdb_mi.c",fullname="/geany-plugins/debugger/src/gdb_mi.c",line="469"},thread-id="1",stopped-threads="all",core="1"
+record =>
+ type = '*' (42)
+ token = (null)
+ class = stopped
+ results =>
+ var = reason
+ val =>
+ type = 0
+ string = breakpoint-hit
+ var = disp
+ val =>
+ type = 0
+ string = keep
+ var = bkptno
+ val =>
+ type = 0
+ string = 1
+ var = frame
+ val =>
+ type = 1
+ list =>
+ var = addr
+ val =>
+ type = 0
+ string = 0x0000000000400c55
+ var = func
+ val =>
+ type = 0
+ string = gdb_mi_record_dump
+ var = args
+ val =>
+ type = 1
+ list =>
+ var = (null)
+ val =>
+ type = 1
+ list =>
+ var = name
+ val =>
+ type = 0
+ string = record
+ var = value
+ val =>
+ type = 0
+ string = 0x603010
+ var = file
+ val =>
+ type = 0
+ string = gdb_mi.c
+ var = fullname
+ val =>
+ type = 0
+ string = /geany-plugins/debugger/src/gdb_mi.c
+ var = line
+ val =>
+ type = 0
+ string = 469
+ var = thread-id
+ val =>
+ type = 0
+ string = 1
+ var = stopped-threads
+ val =>
+ type = 0
+ string = all
+ var = core
+ val =>
+ type = 0
+ string = 1
+# =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400bc0",func="main",file="gdb_mi.c",fullname="/geany-plugins/debugger/src/gdb_mi.c",line="469",thread-groups=["i1"],times="1",original-location="/geany-plugins/debugger/src/gdb_mi.c:469"}
+record =>
+ type = '=' (61)
+ token = (null)
+ class = breakpoint-modified
+ results =>
+ var = bkpt
+ val =>
+ type = 1
+ list =>
+ var = number
+ val =>
+ type = 0
+ string = 1
+ var = type
+ val =>
+ type = 0
+ string = breakpoint
+ var = disp
+ val =>
+ type = 0
+ string = keep
+ var = enabled
+ val =>
+ type = 0
+ string = y
+ var = addr
+ val =>
+ type = 0
+ string = 0x0000000000400bc0
+ var = func
+ val =>
+ type = 0
+ string = main
+ var = file
+ val =>
+ type = 0
+ string = gdb_mi.c
+ var = fullname
+ val =>
+ type = 0
+ string = /geany-plugins/debugger/src/gdb_mi.c
+ var = line
+ val =>
+ type = 0
+ string = 469
+ var = thread-groups
+ val =>
+ type = 1
+ list =>
+ var = (null)
+ val =>
+ type = 0
+ string = i1
+ var = times
+ val =>
+ type = 0
+ string = 1
+ var = original-location
+ val =>
+ type = 0
+ string = /geany-plugins/debugger/src/gdb_mi.c:469
+# =breakpoint-modified,bkpt={number="7",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400414",func="main",file="/tmp/\303\271\303\261\303\256\303\247\304\201\305\225\305\241.c",fullname="/tmp/\303\271\303\261\303\256\303\247\304\201\305\225\305\241.c",line="5",thread-groups=["i1"],times="1",original-location="/tmp/\303\271\303\261\303\256\303\247\304\201\305\225\305\241.c:5"}
+record =>
+ type = '=' (61)
+ token = (null)
+ class = breakpoint-modified
+ results =>
+ var = bkpt
+ val =>
+ type = 1
+ list =>
+ var = number
+ val =>
+ type = 0
+ string = 7
+ var = type
+ val =>
+ type = 0
+ string = breakpoint
+ var = disp
+ val =>
+ type = 0
+ string = keep
+ var = enabled
+ val =>
+ type = 0
+ string = y
+ var = addr
+ val =>
+ type = 0
+ string = 0x0000000000400414
+ var = func
+ val =>
+ type = 0
+ string = main
+ var = file
+ val =>
+ type = 0
+ string = /tmp/ùñîçāŕš.c
+ var = fullname
+ val =>
+ type = 0
+ string = /tmp/ùñîçāŕš.c
+ var = line
+ val =>
+ type = 0
+ string = 5
+ var = thread-groups
+ val =>
+ type = 1
+ list =>
+ var = (null)
+ val =>
+ type = 0
+ string = i1
+ var = times
+ val =>
+ type = 0
+ string = 1
+ var = original-location
+ val =>
+ type = 0
+ string = /tmp/ùñîçāŕš.c:5
+# *stopped,reason="breakpoint-hit",disp="keep",bkptno="7",frame={addr="0x0000000000400414",func="main",args=[],file="/tmp/ùñîçāŕš.c",fullname="/tmp/ùñîçāŕš.c",line="5"},thread-id="1",stopped-threads="all",core="1"
+record =>
+ type = '*' (42)
+ token = (null)
+ class = stopped
+ results =>
+ var = reason
+ val =>
+ type = 0
+ string = breakpoint-hit
+ var = disp
+ val =>
+ type = 0
+ string = keep
+ var = bkptno
+ val =>
+ type = 0
+ string = 7
+ var = frame
+ val =>
+ type = 1
+ list =>
+ var = addr
+ val =>
+ type = 0
+ string = 0x0000000000400414
+ var = func
+ val =>
+ type = 0
+ string = main
+ var = args
+ val =>
+ type = 1
+ list =>
+ var = file
+ val =>
+ type = 0
+ string = /tmp/ùñîçāŕš.c
+ var = fullname
+ val =>
+ type = 0
+ string = /tmp/ùñîçāŕš.c
+ var = line
+ val =>
+ type = 0
+ string = 5
+ var = thread-id
+ val =>
+ type = 0
+ string = 1
+ var = stopped-threads
+ val =>
+ type = 0
+ string = all
+ var = core
+ val =>
+ type = 0
+ string = 1
Modified: debugger/src/tests/gdb_mi_test.input
14 lines changed, 14 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,14 @@
+# empty prompts
+(gdb)
+(gdb)
+(gdb)
+# simple result
+^error,msg="failed"
+# a bit more subtle records
+*stopped,reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt",frame={addr="0x00000000deadbeef",func="somefunc",args=[],file="somefile.c",fullname="/some/path/somefile.c",line="123"},thread-id="1",stopped-threads="all",core="1"
+*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x0000000000400c55",func="gdb_mi_record_dump",args=[{name="record",value="0x603010"}],file="gdb_mi.c",fullname="/geany-plugins/debugger/src/gdb_mi.c",line="469"},thread-id="1",stopped-threads="all",core="1"
+=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400bc0",func="main",file="gdb_mi.c",fullname="/geany-plugins/debugger/src/gdb_mi.c",line="469",thread-groups=["i1"],times="1",original-location="/geany-plugins/debugger/src/gdb_mi.c:469"}
+# escapes for weird filenames
+=breakpoint-modified,bkpt={number="7",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400414",func="main",file="/tmp/\303\271\303\261\303\256\303\247\304\201\305\225\305\241.c",fullname="/tmp/\303\271\303\261\303\256\303\247\304\201\305\225\305\241.c",line="5",thread-groups=["i1"],times="1",original-location="/tmp/\303\271\303\261\303\256\303\247\304\201\305\225\305\241.c:5"}
+# for some reason in this output there are unescaped bytes (consistency, anyone?), but it works too
+*stopped,reason="breakpoint-hit",disp="keep",bkptno="7",frame={addr="0x0000000000400414",func="main",args=[],file="/tmp/ùñîçāŕš.c",fullname="/tmp/ùñîçāŕš.c",line="5"},thread-id="1",stopped-threads="all",core="1"
Modified: debugger/src/tests/gdb_mi_test.sh
19 lines changed, 19 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -e
+
+srcdir=${srcdir:-.}
+
+strip_comments()
+{
+ ${SED:-sed} -e '/^#/d'
+}
+
+TMPOUT=tests/gdb_mi_test.output.tmp
+TMPEXCPT=tests/gdb_mi_test.expected.tmp
+
+trap 'rm -f "$TMPOUT" "$TMPEXCPT"' EXIT QUIT TERM INT
+
+strip_comments < "$srcdir/tests/gdb_mi_test.input" | ./gdb_mi_test 2> "$TMPOUT"
+strip_comments < "$srcdir/tests/gdb_mi_test.expected" > "$TMPEXCPT"
+diff -u "$TMPEXCPT" "$TMPOUT"
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list