aboutsummaryrefslogtreecommitdiff
path: root/generator.go
diff options
context:
space:
mode:
Diffstat (limited to 'generator.go')
-rw-r--r--generator.go55
1 files changed, 54 insertions, 1 deletions
diff --git a/generator.go b/generator.go
index f813ce4..dc5baa3 100644
--- a/generator.go
+++ b/generator.go
@@ -76,6 +76,8 @@ func ftrace(s string, args ...interface{}) {
fmt.Fprintf(os.Stderr, "# %%s:%%d: %%v\n", path.Base(fn), fl, fmt.Sprintf(s, args...))
os.Stderr.Sync()
}
+
+func Xsqlite3PendingByte() int32 { return _sqlite3PendingByte }
`
prologueTest = `// Code generated by ccgo. DO NOT EDIT.
@@ -113,6 +115,9 @@ func main() {
#define SQLITE_ENABLE_API_ARMOR 1
#define SQLITE_USE_URI 1
#define SQLITE_WITHOUT_MSIZE 1
+
+ int sqlite3PendingByte;
+
`
)
@@ -536,6 +541,54 @@ func threadTest(n int) {
unconvert(dst)
}
+func threadTest3() {
+ n := 3
+ repo := findRepo(sqliteRepo)
+ if repo == "" {
+ log.Fatalf("repository not found: %v", sqliteRepo)
+ return
+ }
+
+ sqlitePth := filepath.Join(repo, "sqlite-amalgamation-"+version)
+ pth := filepath.Join(repo, "sqlite-src-"+version, "test")
+ tag := fmt.Sprintf("threadtest%v", n)
+ test := filepath.Join(pth, tag+".c")
+ _, src := build(
+ defines,
+ [][]string{
+ {filepath.Join(sqlitePth, "sqlite3.c")},
+ {filepath.Join(repo, "sqlite-src-"+version, "src", "test_multiplex.c")},
+ {test},
+ },
+ []string{"bin"},
+ cc.EnableAnonymousStructFields(),
+ cc.IncludePaths([]string{".", sqlitePth, filepath.Join(repo, "sqlite-src-"+version, "src")}),
+ )
+
+ var b bytes.Buffer
+ fmt.Fprintf(&b, prologueTest, tidyComments(header(test)))
+ b.Write(src)
+ b2, err := format.Source(b.Bytes())
+ if err != nil {
+ b2 = b.Bytes()
+ }
+ if err := os.MkdirAll(filepath.Join("internal", tag), 0775); err != nil {
+ log.Fatal(err)
+ }
+
+ if err := os.MkdirAll(filepath.Join("testdata", tag), 0775); err != nil {
+ log.Fatal(err)
+ }
+
+ dst := fmt.Sprintf(filepath.Join("internal", tag, tag+"_%s_%s.go"), runtime.GOOS, runtime.GOARCH)
+ b2 = bytes.Replace(b2, []byte("Xsqlite3PendingByte"), []byte("bin.Xsqlite3PendingByte()"), -1)
+ if err := ioutil.WriteFile(dst, b2, 0664); err != nil {
+ log.Fatal(err)
+ }
+
+ unconvert(dst)
+}
+
func main() {
log.SetFlags(log.Lshortfile | log.Lmicroseconds)
var err error
@@ -549,6 +602,6 @@ func main() {
mpTest()
threadTest(1)
threadTest(2)
- // threadTest(3) depends on unexported function.
+ threadTest3()
threadTest(4)
}