aboutsummaryrefslogtreecommitdiff
path: root/internal/testfixture/main.go
diff options
context:
space:
mode:
authorJan Mercl <0xjnml@gmail.com>2020-07-26 22:36:18 +0200
committerJan Mercl <0xjnml@gmail.com>2020-07-26 22:36:18 +0200
commitb406626c64313ae348996c243a0a05d3f6ed2c3c (patch)
tree0eaae4fa6348b150568725e6f2ec0b4c4203b5f8 /internal/testfixture/main.go
parentd8d9f40ce80062793349c0ea47520b6878312f4a (diff)
release v1.4.0-beta1v1.4.0-beta1
Diffstat (limited to 'internal/testfixture/main.go')
-rw-r--r--internal/testfixture/main.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/testfixture/main.go b/internal/testfixture/main.go
new file mode 100644
index 0000000..02acb67
--- /dev/null
+++ b/internal/testfixture/main.go
@@ -0,0 +1,34 @@
+// Copyright 2020 The Sqlite Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package testfixture
+
+import (
+ "fmt"
+ "os"
+ "unsafe"
+
+ "modernc.org/crt/v3"
+)
+
+func Main() {
+ crt.Watch(fmt.Sprint(os.Args))
+ tls := crt.NewTLS()
+ argv := crt.Xcalloc(tls, crt.Size_t(len(os.Args)+1), crt.Size_t(unsafe.Sizeof(uintptr(0))))
+ a := []uintptr{argv}
+ p := argv
+ for _, v := range os.Args {
+ s := crt.Xcalloc(tls, crt.Size_t(len(v)+1), 1)
+ a = append(a, s)
+ copy((*(*[1 << 20]byte)(unsafe.Pointer(s)))[:], v)
+ *(*uintptr)(unsafe.Pointer(p)) = s
+ p += unsafe.Sizeof(uintptr(0))
+ }
+ crt.SetEnviron(os.Environ())
+ rc := main(tls, int32(len(os.Args)), argv)
+ for _, p := range a {
+ crt.Xfree(tls, p)
+ }
+ crt.Xexit(tls, rc)
+}