File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
tests/src/test/scala/org/scalanative/bindgen Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ RUN set -x \
1313 g++ openjdk-8-jdk-headless sbt cmake make curl git \
1414 zlib1g-dev \
1515 libgc-dev libunwind8-dev libre2-dev \
16+ valgrind \
1617 && rm -rf /var/lib/apt/lists/*
1718
1819ARG LLVM_VERSION=6.0
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package org.scalanative.bindgen
33import java .io .File
44import org .scalatest .FunSpec
55import scala .io .Source
6+ import scala .sys .process .{Process , ProcessLogger }
67
78class BindgenSpec extends FunSpec {
89 describe(" Bindgen" ) {
@@ -32,6 +33,23 @@ class BindgenSpec extends FunSpec {
3233 def contentOf (file : File ) =
3334 Source .fromFile(file).getLines.mkString(" \n " ).trim()
3435
36+ /**
37+ * @return valgrind exit code
38+ */
39+ def checkMemoryErrors (inputFile : File ): Int = {
40+ val cmd = Seq (
41+ " valgrind" ,
42+ " --leak-check=full" ,
43+ " --error-exitcode=1" ,
44+ bindgenPath,
45+ inputFile.getAbsolutePath,
46+ " --name" ,
47+ " lib" ,
48+ " --"
49+ )
50+ Process (cmd).run(ProcessLogger (_ => ())).exitValue()
51+ }
52+
3553 for (input <- inputDirectory.listFiles() if input.getName.endsWith(" .h" )) {
3654 it(s " should generate bindings for ${input.getName}" ) {
3755 val testName = input.getName.replace(" .h" , " " )
@@ -43,6 +61,10 @@ class BindgenSpec extends FunSpec {
4361 assert(output.exists())
4462 assert(contentOf(output) == contentOf(expected))
4563 }
64+
65+ it(s " should generate bindings for ${input.getName} without memory errors " ) {
66+ assert(0 == checkMemoryErrors(input))
67+ }
4668 }
4769 }
4870}
You can’t perform that action at this time.
0 commit comments