diff options
| author | XmiliaH <45106915+XmiliaH@users.noreply.github.com> | 2025-03-24 00:09:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-23 16:09:33 -0700 |
| commit | 3db126e018388facfab368ecb2c8f8bc566afe1a (patch) | |
| tree | 9cc6aba4270b4a1ed94b8513b98539e8a9fb0ecd /chapter21/src/test/java | |
| parent | 8d6de0e10358fc197490cdacb10cbcedc18bb4f6 (diff) | |
| download | Simple-3db126e018388facfab368ecb2c8f8bc566afe1a.tar.gz Simple-3db126e018388facfab368ecb2c8f8bc566afe1a.zip | |
First run as elf binary (#178)
Diffstat (limited to 'chapter21/src/test/java')
| -rw-r--r-- | chapter21/src/test/java/com/seaofnodes/simple/Compile.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Compile.java b/chapter21/src/test/java/com/seaofnodes/simple/Compile.java new file mode 100644 index 00000000..5286029a --- /dev/null +++ b/chapter21/src/test/java/com/seaofnodes/simple/Compile.java @@ -0,0 +1,27 @@ +package com.seaofnodes.simple; + +import com.seaofnodes.simple.codegen.CodeGen; +import org.junit.Ignore; +import org.junit.Test; + +import java.io.IOException; + +import static com.seaofnodes.simple.Main.PORTS; + +public class Compile { + + @Test + @Ignore + public void testCompile() throws IOException, InterruptedException { + boolean USE_WSL = System.getProperty("os.name").startsWith("Windows"); + CodeGen code = new CodeGen("return 13;"); + code.parse().opto().typeCheck().instSelect(PORTS,"x86_64_v2", "SystemV").GCM().localSched().regAlloc().encode(); + code.exportELF("test.o"); + Process p = Runtime.getRuntime().exec(USE_WSL ? new String[]{"wsl.exe", "gcc", "-o", "test", "test.o"}:new String[]{"gcc", "-o", "test", "test.o"}); + assert p.waitFor() == 0; + p = Runtime.getRuntime().exec(USE_WSL ? new String[]{"wsl.exe", "./test"}:new String[]{"./test"}); + System.out.println(p.waitFor()); + assert p.waitFor() == 13; + } + +} |
