|
40 | 40 | */
|
41 | 41 | package org.graalvm.wasm.predefined.testutil;
|
42 | 42 |
|
43 |
| -import static org.graalvm.wasm.WasmType.I32_TYPE; |
44 |
| - |
45 |
| -import java.io.IOException; |
46 |
| -import java.nio.file.Files; |
47 |
| -import java.nio.file.Path; |
48 |
| -import java.nio.file.Paths; |
49 |
| - |
50 | 43 | import org.graalvm.wasm.WasmContext;
|
51 | 44 | import org.graalvm.wasm.WasmLanguage;
|
52 | 45 | import org.graalvm.wasm.WasmModule;
|
53 | 46 | import org.graalvm.wasm.predefined.BuiltinModule;
|
54 | 47 |
|
55 | 48 | public class TestutilModule extends BuiltinModule {
|
56 | 49 |
|
57 |
| - public static class Options { |
58 |
| - static final String KEEP_TEMP_FILES = System.getProperty("wasmtest.keepTempFiles", "false"); |
59 |
| - } |
60 |
| - |
61 | 50 | public static class Names {
|
62 | 51 | public static final String RUN_CUSTOM_INITIALIZATION = "__testutil_run_custom_initialization";
|
63 |
| - public static final String SAVE_BINARY_FILE = "__testutil_save_binary_file"; |
64 |
| - } |
65 |
| - |
66 |
| - private static Path createTemporaryDirectory() { |
67 |
| - try { |
68 |
| - if (Options.KEEP_TEMP_FILES.equals("true")) { |
69 |
| - final Path directory = Paths.get("./test-output/"); |
70 |
| - directory.toFile().mkdirs(); |
71 |
| - return directory; |
72 |
| - } else { |
73 |
| - final Path tempDirectory = Files.createTempDirectory("temp-dir-"); |
74 |
| - tempDirectory.toFile().deleteOnExit(); |
75 |
| - return tempDirectory; |
76 |
| - } |
77 |
| - } catch (IOException e) { |
78 |
| - throw new RuntimeException(e); |
79 |
| - } |
80 | 52 | }
|
81 | 53 |
|
82 | 54 | @Override
|
83 | 55 | protected WasmModule createModule(WasmLanguage language, WasmContext context, String name) {
|
84 |
| - final Path temporaryDirectory = createTemporaryDirectory(); |
85 | 56 | WasmModule module = WasmModule.createBuiltin(name);
|
86 | 57 |
|
87 | 58 | // Note: in the following methods, the types are not important here, since these methods
|
88 | 59 | // are not accessed by Wasm code.
|
89 | 60 | defineFunction(context, module, Names.RUN_CUSTOM_INITIALIZATION, types(), types(), new RunCustomInitializationNode(language, module));
|
90 | 61 |
|
91 |
| - // The following methods are exposed to the Wasm test programs. |
92 |
| - defineFunction(context, module, Names.SAVE_BINARY_FILE, types(I32_TYPE, I32_TYPE, I32_TYPE), types(), new SaveBinaryFileNode(language, module, temporaryDirectory)); |
93 | 62 | return module;
|
94 | 63 | }
|
95 | 64 | }
|
0 commit comments