Documentation
¶
Overview ¶
Helpers and values which can be used in any package
Index ¶
- Constants
- Variables
- func Build(tags []string) string
- func Copy(sourcePath string, target string) error
- func HashFile(path string) ([]byte, error)
- func IsDir(path string) bool
- func PermissionDenied(t *testing.T, filename string) *os.File
- func RemoveBuildDir(bin string)
- func ReplaceBetween(original io.Reader, marker1 string, marker2 string, replacement []byte) []byte
- func SameFile(src string, dest string) bool
- func SameInode(path1 string, path2 string) (bool, error)
- func SetDocComment(path string, comment string) error
- func StripLines(multiline string) []string
- func TestdataPath(path string) string
- func WorkspaceTempDir(t testing.TB) string
Constants ¶
const P_ld_linux = "/lib64/ld-linux-x86-64.so.2"
Path to interpreter
Variables ¶
var ( P_libc = findLib("libc.so.6") P_libm = findLib("libm.so.6") P_libpcre2_8 = findLib("libpcre2-8.so.0") P_libpthread = findLib("libpthread.so.0") P_libselinux = findLib("libselinux.so.1") )
Paths to common libraries
var ( P_ctypes_so = TestdataPath("_ctypes_test.cpython-314-x86_64-linux-gnu.so") P_empty = TestdataPath("empty") P_hello_dynamic = TestdataPath("hello_dynamic") P_hello_pie = TestdataPath("hello_pie") P_hello_static = TestdataPath("hello_static") P_id = TestdataPath("id") P_ldd = TestdataPath("ldd") P_which = TestdataPath("which") P_build_sh = TestdataPath("hello/build.sh") P_hello_pie_cgo = TestdataPath("hello/hello") P_hello_go = TestdataPath("hello/hello.go") P_symlinked_id = TestdataPath("symlink/id2") P_symlinked_build_sh = TestdataPath("symlink/hello/build.sh") P_symlinked_hello_dynamic = TestdataPath("symlink/hello/hello") P_symlinked_hello_go = TestdataPath("symlink/hello/hello.go") )
Paths to our test binaries
var Ld_linux_64_RE = regexp.MustCompile(`^\/lib64(?:\/.+|)\/ld-linux.*\.so(?:\..+|)$`)
Regex to check if this is a 64-bit version of `ld-linux*.so`, matches /lib64(/more/directories)/ld-linux*.so(.*)
var P_ld_linux_resolved, _ = filepath.EvalSymlinks(P_ld_linux)
Functions ¶
func Build ¶ added in v0.3.0
Build current dir with optional tags, to tmp directory, returns path to resulting binary.
Remember to `defer RemoveBuildDir()`
func Copy ¶ added in v0.3.0
Copy a file, maintaining mode & attempting to maintain ownership.
Errors returned will be of type *fs.PathError (unless they came from io.Copy, which sadly doesn't document error details ...)
func PermissionDenied ¶
Test helper: Provides a temporary file which exists but has no read permission
func RemoveBuildDir ¶ added in v0.3.0
func RemoveBuildDir(bin string)
Cleans up the tmp directory created by Build()
func ReplaceBetween ¶ added in v0.3.0
func SetDocComment ¶ added in v0.3.0
func StripLines ¶ added in v0.2.0
StripLines converts a multiline string into a []string without line termination or indentation.
func TestdataPath ¶
Constructs the correct absolute value of path, where path is relative to ./internal/testdata
func WorkspaceTempDir ¶
Constructs a TempDir under `./.tmp`
This is (almost) guaranteed to be on the same filesystem as `./internal/testdata` and therefore allow for valid hardlinks.
Types ¶
This section is empty.