Skip to content

Commit 7f78fc5

Browse files
authored
Merge pull request #68 from golang-fips/wip/leak
run runtime.GC() a few times before checking for leaks
2 parents cc4484a + c81b6c5 commit 7f78fc5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

openssl/openssl_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99
"runtime"
1010
"testing"
11+
"time"
1112

1213
"github.com/golang-fips/openssl-fips/openssl"
1314
)
@@ -42,7 +43,12 @@ func TestMain(m *testing.M) {
4243
fmt.Println("OpenSSL version:", openssl.VersionText())
4344
fmt.Println("FIPS enabled:", openssl.FIPS())
4445
status := m.Run()
45-
runtime.GC()
46+
for i := 0; i < 5; i++ {
47+
// Run GC a few times to avoid false positives in leak detection.
48+
runtime.GC()
49+
// Sleep a bit to let the finalizers run.
50+
time.Sleep(10 * time.Millisecond)
51+
}
4652
openssl.CheckLeaks()
4753
os.Exit(status)
4854
}

scripts/openssl.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ rm -rf "openssl-$version"
4848
mv "openssl-$tag" "openssl-$version"
4949

5050
cd "openssl-$version"
51-
./config $config
51+
# -d makes a debug build which helps with debugging memory issues and
52+
# other problems. It's not necessary for normal use.
53+
./config -d $config
5254
make -j$(nproc) $make
5355

5456
cp -H ./libcrypto.so "/usr/lib/libcrypto.so.${version}"

0 commit comments

Comments
 (0)