Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy over go testsuite files from upstream gdb #140

Merged
merged 4 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ jobs:
stat info.js.json || echo "info.js.json"; \
elif test -r info.min.js && test -x "$(which du)"; then \
stat info.min.js && du info.min.js; \
elif test -x "$(which yamllint)"; then \
pwd && (yamllint . || yamllint --version); \
fi; \
sync && echo "Done with texinfo javascript."; \
popd || exit; \
Expand All @@ -277,6 +279,8 @@ jobs:
find . -name '*.go' -print0 | xargs -0 gofmt; \
elif test -x "$(which actionlint)"; then \
sync && which actionlint && actionlint -verbose && sleep 1; \
elif test -x "$(which yamllint)"; then \
sync && which yamllint && yamllint . && sleep 1; \
else \
sync && echo "no linters found for go ($(which go))." && sleep 1; \
fi; \
Expand All @@ -303,7 +307,7 @@ jobs:
fi; \
elif test ${{ matrix.language }} == 'csharp' && test -x "$(which yamllint)"; then \
sync && which -a yamllint && sleep 1; \
yamllint .github/codeql/extensions/apple-gdb-1824-csharp/codeql-pack.yml; \
yamllint .github/codeql/extensions/apple-gdb*csharp/codeql-pack.yml; \
stat "$(which csc)" || stat "$(which mcs)" || which -a dotnet; \
sync && echo "TODO: find a proper linter for csharp…" && sleep 1; \
else \
Expand Down Expand Up @@ -472,6 +476,13 @@ jobs:
elif test -r /usr/x86_64-linux-gnu/include/proc_service.h; then \
cat /usr/x86_64-linux-gnu/include/proc_service.h; \
fi
if test ${{ matrix.language }} == 'go'; then \
if test -x "$(which go)"; then \
stat "$(which go)" && go version && go env; \
else \
sync && echo "no usable 'go' binary found"; \
fi; \
fi

- name: Extra coverage build (C)
if: matrix.language == 'c-cpp' && success()
Expand Down
5 changes: 5 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
# https://yamllint.readthedocs.io/en/stable/configuration.html
extends: default

ignore:
- src/gdb/*/*/*/build/*.build/Debug/*.build/all-product-headers.yaml
- src/tk/macosx/build/*.build/Development/*.build/all-product-headers.yaml

rules:
float-values: enable
indentation:
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module src/gdb/testsuite/gdb.go

go 1.18
1 change: 1 addition & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go 1.18
10 changes: 3 additions & 7 deletions src/gdb/testsuite/gdb.go/basic-types.exp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This testcase is part of GDB, the GNU debugger.

# Copyright 2012-2013 Free Software Foundation, Inc.
# Copyright 2012-2024 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -20,7 +20,7 @@

load_lib "go.exp"

if { [skip_go_tests] } { continue }
require allow_go_tests

proc test_integer_literal_types_accepted {} {
# Test various decimal values.
Expand Down Expand Up @@ -100,11 +100,7 @@ proc test_complex_literal_types_accepted {} {
gdb_test "pt complex128(i1.0)" "type = complex128"
}

# Start with a fresh gdb.

gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
clean_restart

if [set_lang_go] {
test_integer_literal_types_accepted
Expand Down
11 changes: 5 additions & 6 deletions src/gdb/testsuite/gdb.go/chan.exp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This testcase is part of GDB, the GNU debugger.

# Copyright 2012-2013 Free Software Foundation, Inc.
# Copyright 2012-2024 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -20,32 +20,31 @@

load_lib "go.exp"

if { [skip_go_tests] } { continue }
require allow_go_tests support_go_compile

standard_testfile .go

if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } {
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } {
return -1
}

set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]

if { [go_runto_main] < 0 } {
untested $testfile
return -1
}

if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
pass "setting breakpoint 1"
}

gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "going to first breakpoint"

gdb_test_no_output "disable"

if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
pass "setting breakpoint 2"
}

gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "going to second breakpoint"
15 changes: 3 additions & 12 deletions src/gdb/testsuite/gdb.go/handcall.exp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This testcase is part of GDB, the GNU debugger.

# Copyright 2012-2013 Free Software Foundation, Inc.
# Copyright 2012-2024 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -19,26 +19,17 @@

load_lib "go.exp"

if { [skip_go_tests] } { continue }
require allow_go_tests support_go_compile

standard_testfile .go

if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } {
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } {
return -1
}

set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]

if { [go_runto_main] < 0 } {
untested $testfile
return -1
}

if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
pass "setting breakpoint 1"
}

gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"

gdb_test "print add (1, 2)" " = 3"
gdb_test "print main.add (1, 2)" " = 3"
2 changes: 1 addition & 1 deletion src/gdb/testsuite/gdb.go/handcall.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ func sub (a,b int) (int) {
var v_int int

func main () {
v_int = 42 // set breakpoint 1 here
v_int = 42
}
25 changes: 5 additions & 20 deletions src/gdb/testsuite/gdb.go/hello.exp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This testcase is part of GDB, the GNU debugger.

# Copyright 2012-2013 Free Software Foundation, Inc.
# Copyright 2012-2024 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -19,41 +19,26 @@

load_lib "go.exp"

if { [skip_go_tests] } { continue }
require allow_go_tests support_go_compile

standard_testfile .go

if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } {
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } {
return -1
}

set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]

if { [go_runto_main] < 0 } {
untested $testfile
return -1
}

if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
pass "setting breakpoint 1"
}

gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"

# This used to print "", i.e., the local "st" initialized as "".
setup_xfail "*-*-*"

gdb_test "print st" \
".* = $hex \"\"" \
"Starting string check"

if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
pass "setting breakpoint 2"
}

gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "going to first breakpoint"

gdb_test "print st" \
".* = $hex \"Hello, world!\"" \
"String after assignment check"
"string after assignment check"
9 changes: 3 additions & 6 deletions src/gdb/testsuite/gdb.go/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ package main

import "fmt"

var myst = "Shall we?"

func main () {
fmt.Println ("Before assignment") // set breakpoint 1 here
st := "Hello, world!" // this intentionally shadows the global "st"
fmt.Println (st) // set breakpoint 2 here
fmt.Println (myst) // set breakpoint 2 here
fmt.Println ("Before assignment")
st := "Hello, world!"
fmt.Println (st) // set breakpoint 1 here
}
27 changes: 13 additions & 14 deletions src/gdb/testsuite/gdb.go/integers.exp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This testcase is part of GDB, the GNU debugger.

# Copyright 2012-2013 Free Software Foundation, Inc.
# Copyright 2012-2024 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -19,40 +19,39 @@

load_lib "go.exp"

if { [skip_go_tests] } { continue }
require allow_go_tests support_go_compile

standard_testfile .go

if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } {
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } {
return -1
}

set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]

if { [go_runto_main] < 0 } {
untested $testfile
return -1
}

if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
pass "setting breakpoint 1"
}

gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "going to first breakpoint"

gdb_test "print i" ".* = 0" "Print i before assigned to 1"
gdb_test "print i" ".* = 0" "print i before assigned to 1"

gdb_test "next" "i = 1" "Next to 'i = 1' line"
gdb_test "next" "j = 2" "Next to 'j = 2' line"
gdb_test "next" "i = 1" "next to 'i = 1' line"
gdb_test "next" "j = 2" "next to 'j = 2' line"
# At that point,
# i should be equal to 1
gdb_test "print i" " = 1"
# but j should still be equal to zero
gdb_test "print j" " = 0" "Test j value before assignment"
gdb_test "print j" " = 0" "test j value before assignment"

gdb_test "next" "k = 3" "Next to 'k = 3' line"
gdb_test "next" "l = k" "Next to 'l = k' line"
gdb_test "next" "k = 3" "next to 'k = 3' line"
gdb_test "next" "l = k" "next to 'l = k' line"

#j should be equal to 2
gdb_test "print j" " = 2"
Expand All @@ -67,7 +66,7 @@ gdb_test "print i + k" " = 4"
gdb_test "print j + k" " = 5"
gdb_test "print i + j + k" " = 6"

# Test substraction
# Test subtraction
gdb_test "print j - i" " = 1"
gdb_test "print i - j" "= -1"
gdb_test "print k -i -j" " = 0"
Expand Down Expand Up @@ -101,7 +100,7 @@ gdb_test "print i+10*j+100*k" " = 321"
gdb_test " print (i + 5) * (j + 7)" " = 54"

gdb_test "set var i = 2" " = 2"
gdb_test "print i" " = 2" "Testing new i value"
gdb_test "print i" " = 2" "testing new i value"

if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
pass "setting breakpoint 2"
Expand All @@ -112,4 +111,4 @@ gdb_test "cont" \
"Going to second breakpoint"
gdb_test "print i" \
".* = 5.*" \
"Value of i after assignment"
"value of i after assignment"
Loading
Loading