Skip to content

Commit 1c90d78

Browse files
committed
Remove hard-coded paths in daemons.go.
1 parent a26fa2a commit 1c90d78

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

contrib/pg_dtm/tests/daemons.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"sync"
99
"os"
1010
"strconv"
11+
"strings"
1112
)
1213

1314
func read_to_channel(r io.Reader, c chan string, wg *sync.WaitGroup) {
@@ -94,6 +95,7 @@ func postgres(bin string, datadir string, port int, nodeid int, wg *sync.WaitGro
9495
"-c", "autovacuum=off",
9596
"-c", "fsync=off",
9697
"-c", "synchronous_commit=off",
98+
"-c", "shared_preload_libraries=pg_dtm",
9799
}
98100
name := "postgres " + datadir
99101
c := make(chan string)
@@ -118,11 +120,30 @@ func check_bin(bin *map[string]string) {
118120
}
119121
}
120122

123+
func get_prefix(srcroot string) string {
124+
makefile, err := os.Open(srcroot + "/src/Makefile.global")
125+
if err != nil {
126+
return "."
127+
}
128+
129+
scanner := bufio.NewScanner(makefile)
130+
for scanner.Scan() {
131+
s := scanner.Text()
132+
if strings.HasPrefix(s, "prefix := ") {
133+
return strings.TrimPrefix(s, "prefix := ")
134+
}
135+
}
136+
return "."
137+
}
138+
121139
func main() {
140+
srcroot := "../../.."
141+
prefix := get_prefix(srcroot)
142+
122143
bin := map[string]string{
123-
"dtmd": "/home/kvap/postgrespro/contrib/pg_xtm/dtmd/bin/dtmd",
124-
"initdb": "/home/kvap/postgrespro-build/bin/initdb",
125-
"postgres": "/home/kvap/postgrespro-build/bin/postgres",
144+
"dtmd": srcroot + "/contrib/pg_dtm/dtmd/bin/dtmd",
145+
"initdb": prefix + "/bin/initdb",
146+
"postgres": prefix + "/bin/postgres",
126147
}
127148

128149
datadirs := []string{"/tmp/data1", "/tmp/data2"}

0 commit comments

Comments
 (0)