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 // +build darwin dragonfly freebsd linux netbsd openbsd solaris
9 // Test a shared library created by -buildmode=c-shared that does not
18 // To test this we want to communicate between the main program and
19 // the shared library without using any exported symbols. The init
20 // function creates a pipe and Dups the read end to a known number
21 // that the C code can also use.
29 if e := syscall.Pipe(p[0:]); e != nil {
30 fmt.Fprintf(os.Stderr, "pipe: %v\n", e)
34 if e := dup2(p[0], fd); e != nil {
35 fmt.Fprintf(os.Stderr, "dup2: %v\n", e)
40 if n, e := syscall.Write(p[1], []byte(str)); e != nil || n != len(str) {
41 fmt.Fprintf(os.Stderr, "write: %d %v\n", n, e)
45 if e := syscall.Close(p[1]); e != nil {
46 fmt.Fprintf(os.Stderr, "close: %v\n", e)