Skip to content

Commit 376c67d

Browse files
committed
More unique name for copied C libraries
1 parent 09c454d commit 376c67d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ public void testCreatingVenvForMulticontext() throws IOException {
187187
c0.initialize("python");
188188
c0.eval("python", String.format("__graalpython__.replicate_extensions_in_venv('%s', 2)", venv.toString().replace('\\', '/')));
189189

190-
assertTrue("created a copy of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".0")));
191-
assertTrue("created another copy of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".1")));
192-
assertFalse("created no more copies of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".2")));
190+
assertTrue("created a copy of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup0")));
191+
assertTrue("created another copy of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup1")));
192+
assertFalse("created no more copies of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2")));
193193

194194
builder.option("python.IsolateNativeModules", "true");
195195
var c1 = builder.build();
@@ -208,20 +208,20 @@ public void testCreatingVenvForMulticontext() throws IOException {
208208
// First one works
209209
var r1 = c1.eval(code);
210210
assertEquals("tiny_sha3", r1.asString());
211-
assertFalse("created no more copies of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".2")));
211+
assertFalse("created no more copies of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2")));
212212
// Second one works because of isolation
213213
var r2 = c2.eval(code);
214214
assertEquals("tiny_sha3", r2.asString());
215215
c2.eval("python", "import _sha3; _sha3.implementation = '12'");
216216
r2 = c2.eval(code);
217-
assertEquals("12", r2.asString());
217+
assertEquals(".dup2", r2.asString());
218218
// first context is unaffected
219219
r1 = c1.eval(code);
220220
assertEquals("tiny_sha3", r1.asString());
221-
assertFalse("created no more copies of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".2")));
221+
assertFalse("created no more copies of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2")));
222222
// Third one works and triggers a dynamic relocation
223223
c3.eval(code);
224-
assertTrue("created another copy of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".2")));
224+
assertTrue("created another copy of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2")));
225225
// Fourth one does not work because we changed the sys.prefix
226226
c4.eval("python", "import sys; sys.prefix = 12");
227227
try {
@@ -245,6 +245,7 @@ public void testCreatingVenvForMulticontext() throws IOException {
245245
} catch (PolyglotException e) {
246246
assertTrue("needs LLVM", e.getMessage().contains("LLVM"));
247247
}
248+
248249
}
249250

250251
private static boolean isVerbose() {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/copying/NativeLibraryLocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static void replicate(TruffleFile venvDirectory, PythonContext context, i
166166
}
167167

168168
private static String copyNameOf(String original, int capiSlot) {
169-
return original + "." + Integer.toHexString(capiSlot);
169+
return original + ".dup" + Integer.toHexString(capiSlot);
170170
}
171171

172172
private static String resolve(PythonContext context, TruffleFile original, int capiSlot, String capiOrignalName) throws ApiInitException {

0 commit comments

Comments
 (0)