1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
6 // +build darwin dragonfly freebsd linux netbsd openbsd solaris
10 // Test a shared library created by -buildmode=c-shared that does not
19 // To test this we want to communicate between the main program and
20 // the shared library without using any exported symbols. The init
21 // function creates a pipe and Dups the read end to a known number
22 // that the C code can also use.
30 if e := syscall.Pipe(p[0:]); e != nil {
31 fmt.Fprintf(os.Stderr, "pipe: %v\n", e)
35 if e := dup2(p[0], fd); e != nil {
36 fmt.Fprintf(os.Stderr, "dup2: %v\n", e)
41 if n, e := syscall.Write(p[1], []byte(str)); e != nil || n != len(str) {
42 fmt.Fprintf(os.Stderr, "write: %d %v\n", n, e)
46 if e := syscall.Close(p[1]); e != nil {
47 fmt.Fprintf(os.Stderr, "close: %v\n", e)