File tree 2 files changed +23
-0
lines changed
tests/src/test/scala/org/scalanative/bindgen
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ RUN set -x \
13
13
g++ openjdk-8-jdk-headless sbt cmake make curl git \
14
14
zlib1g-dev \
15
15
libgc-dev libunwind8-dev libre2-dev \
16
+ valgrind \
16
17
&& rm -rf /var/lib/apt/lists/*
17
18
18
19
ARG LLVM_VERSION=6.0
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package org.scalanative.bindgen
3
3
import java .io .File
4
4
import org .scalatest .FunSpec
5
5
import scala .io .Source
6
+ import scala .sys .process .{Process , ProcessLogger }
6
7
7
8
class BindgenSpec extends FunSpec {
8
9
describe(" Bindgen" ) {
@@ -32,6 +33,23 @@ class BindgenSpec extends FunSpec {
32
33
def contentOf (file : File ) =
33
34
Source .fromFile(file).getLines.mkString(" \n " ).trim()
34
35
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
+
35
53
for (input <- inputDirectory.listFiles() if input.getName.endsWith(" .h" )) {
36
54
it(s " should generate bindings for ${input.getName}" ) {
37
55
val testName = input.getName.replace(" .h" , " " )
@@ -43,6 +61,10 @@ class BindgenSpec extends FunSpec {
43
61
assert(output.exists())
44
62
assert(contentOf(output) == contentOf(expected))
45
63
}
64
+
65
+ it(s " should generate bindings for ${input.getName} without memory errors " ) {
66
+ assert(0 == checkMemoryErrors(input))
67
+ }
46
68
}
47
69
}
48
70
}
You can’t perform that action at this time.
0 commit comments