Add TestThread3 (does not yet pass). Updates #15.

modified:   Makefile
	modified:   all_test.go
	modified:   generator.go
	modified:   internal/bin/bin_linux_386.go
	modified:   internal/bin/bin_linux_amd64.go
	new file:   internal/threadtest3/threadtest3_linux_386.go
	new file:   internal/threadtest3/threadtest3_linux_amd64.go
This commit is contained in:
Jan Mercl
2017-07-03 23:36:03 +02:00
parent 481e652f27
commit 2aa5e95243
7 changed files with 13526 additions and 24 deletions

View File

@@ -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)
}