Files
garble/testdata/scripts/basic.txt
Daniel Martí ff0bea73b5 all: drop support for Go 1.15.x (#265)
This mainly cleans up the few bits of code where we explicitly kept
support for Go 1.15.x. With v0.1.0 released, we can drop support now,
since the next v0.2.0 release will only support Go 1.16.x.

Also updates all modules, including test ones, to 'go 1.16'.

Note that the TOOLEXEC_IMPORTPATH refactor is not done here, despite all
the TODOs about doing so when we drop 1.15 support. This is because that
refactor needs to be done carefully and might have side effects, so it's
best to keep it to a separate commit.

Finally, update the deps.
2021-03-05 16:52:00 +01:00

76 lines
2.2 KiB
Plaintext

# Check that the simplest use of garble works. Note the lack of a module or GOPRIVATE.
garble build main.go
exec ./main
cmp stderr main.stderr
# Ensure that -w and -s worked.
[!windows] [exec:readelf] exec readelf --section-headers main$exe
[!windows] [exec:readelf] ! stdout 'debug_info'
[!windows] [exec:readelf] ! stdout '\.symtab'
# The buildid needs to be missing from the binary. Otherwise, we leak
# information unnecessarily, which is made worse by how we use part of said
# buildid to obfuscate the main package.
[!windows] [exec:readelf] ! stdout 'buildid'
go tool buildid main$exe
! stdout .
# The build version needs to be missing too.
go version main$exe
stdout 'unknown'
! stdout 'go1'
! stdout 'devel'
! stdout $gofullversion
# The binary can't contain the version string either.
! binsubstr main$exe ${WORK@R} 'main.go' 'globalVar' 'globalFunc' 'garble' $gofullversion
[short] stop # checking that the build is reproducible is slow
# Check that we fail if the user used "go build -toolexec garble" instead of "garble build"
! exec go build -a -toolexec=garble main.go
stderr 'not running "garble \[command\]"'
# Also check that the binary is reproducible.
# No packages should be rebuilt either, thanks to the build cache.
cp main$exe main_old$exe
rm main$exe
garble build -v main.go
! stderr .
bincmp main$exe main_old$exe
# Check that the program works as expected without garble. No need to verify
# this when we run with -short.
exec go build main.go
exec ./main
cmp stderr main.stderr
# The default build includes DWARF and the symbol table.
[!windows] [exec:readelf] exec readelf --section-headers main$exe
[!windows] [exec:readelf] stdout 'debug_info'
[!windows] [exec:readelf] stdout '\.symtab'
# The default build includes full non-trimmed paths, as well as our names.
# Only check $WORK on non-windows, because it's difficult to do it there.
binsubstr main$exe 'main.go' 'globalVar' 'globalFunc' $gofullversion
[!windows] binsubstr main$exe ${WORK@R}
-- go.mod --
module test/mainfoo
go 1.16
-- main.go --
package main
var globalVar = "global value"
func globalFunc() { println("global func body") }
func main() {
println(globalVar)
globalFunc()
}
-- main.stderr --
global value
global func body