Skip to content

Commit dae3e49

Browse files
committed
✅ Add test
1 parent 7575421 commit dae3e49

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
"""
2+
Verify that a program which depends on library which in turns depend on another library
3+
can be built correctly using CheckLibWithHeader
4+
"""
5+
6+
from pathlib import Path
7+
8+
from TestSCons import TestSCons
9+
10+
test = TestSCons(match=TestSCons.match_re_dotall)
11+
12+
13+
libA_dir = Path(test.workdir) / "libA"
14+
libA_dir.mkdir()
15+
test.write(
16+
str(libA_dir / "libA.h"),
17+
"""\
18+
void libA();
19+
""",
20+
)
21+
test.write(
22+
str(libA_dir / "libA.c"),
23+
"""\
24+
#include <stdio.h>
25+
#include "libA.h"
26+
27+
void libA() {
28+
printf("libA\\n");
29+
}
30+
""",
31+
)
32+
test.write(
33+
str(libA_dir / "SConstruct"),
34+
"""\
35+
SharedLibrary('libA', source=['libA.c'])
36+
""",
37+
)
38+
test.run(chdir=libA_dir)
39+
40+
41+
libB_dir = Path(test.workdir) / "libB"
42+
libB_dir.mkdir()
43+
test.write(
44+
str(libB_dir / "libB.h"),
45+
"""\
46+
void libB();
47+
""",
48+
)
49+
test.write(
50+
str(libB_dir / "libB.c"),
51+
"""\
52+
#include <stdio.h>
53+
#include "libA.h"
54+
#include "libB.h"
55+
56+
void libB () {
57+
libA();
58+
}
59+
""",
60+
)
61+
test.write(
62+
str(libB_dir / "SConstruct"),
63+
"""\
64+
SharedLibrary(
65+
'libB',
66+
source=['libB.c'],
67+
LIBS=['A'],
68+
LIBPATH='../libA',
69+
CPPPATH='../libA',
70+
)
71+
""",
72+
)
73+
test.run(chdir=libB_dir)
74+
75+
test.write(
76+
"SConstruct",
77+
"""\
78+
import os
79+
env = Environment(ENV=os.environ, CPPPATH=['libB', 'libA'], LIBPATH=['libB', 'libA'])
80+
conf = Configure(env)
81+
82+
ret = conf.CheckLibWithHeader(
83+
['B'],
84+
header="libB.h",
85+
language='C',
86+
extra_libs=['A'],
87+
call='libB();',
88+
autoadd=False,
89+
)
90+
assert ret
91+
""",
92+
)
93+
test.run()
94+
test.pass_test()

0 commit comments

Comments
 (0)