Added ability to dynamically load .so objects and the respective required testing.

Signed-off-by: Varun Mathur <varun.mathur@live.com>
This commit is contained in:
Varun Mathur
2018-07-10 14:39:02 -07:00
committed by Torin Sandall
parent 731904a4bf
commit 8885997264
5 changed files with 421 additions and 26 deletions
+6 -5
View File
@@ -13,7 +13,7 @@ import (
// WithTempFS creates a temporary directory structure and invokes f with the
// root directory path.
func WithTempFS(files map[string]string, f func(string)) {
rootDir, cleanup, err := MakeTempFS(files)
rootDir, cleanup, err := MakeTempFS("", "loader_test", files)
if err != nil {
panic(err)
}
@@ -21,12 +21,13 @@ func WithTempFS(files map[string]string, f func(string)) {
f(rootDir)
}
// MakeTempFS creates a temporary directory structure for test purposes. If the
// creation fails, cleanup is nil and the caller does not have to invoke it. If
// MakeTempFS creates a temporary directory structure for test purposes rooted at root.
// If root is empty, the dir is created in the default system temp location.
// If the creation fails, cleanup is nil and the caller does not have to invoke it. If
// creation succeeds, the caller should invoke cleanup when they are done.
func MakeTempFS(files map[string]string) (rootDir string, cleanup func(), err error) {
func MakeTempFS(root, prefix string, files map[string]string) (rootDir string, cleanup func(), err error) {
rootDir, err = ioutil.TempDir("", "loader_test")
rootDir, err = ioutil.TempDir(root, prefix)
if err != nil {
return "", nil, err