package com.oracle.truffle.llvm.tests.debug;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.oracle.truffle.llvm.tests.options.TestOptions;
import com.oracle.truffle.llvm.tests.Platform;
import org.graalvm.polyglot.Context;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public final class LLVMDebugTest extends LLVMDebugTestBase {
private static final Path BC_DIR_PATH = Paths.get(TestOptions.TEST_SUITE_PATH, "debug");
private static final Path SRC_DIR_PATH = Paths.get(TestOptions.PROJECT_ROOT, "..", "tests", "com.oracle.truffle.llvm.tests.debug.native", "debug");
private static final Path TRACE_DIR_PATH = Paths.get(TestOptions.PROJECT_ROOT, "..", "tests", "com.oracle.truffle.llvm.tests.debug.native", "trace");
private static final String BC_O0 = "O0.bc";
private static final String BC_O1 = "O1.bc";
private static final String BC_MEM2REG = "O0_MEM2REG.bc";
public LLVMDebugTest(String testName, String configuration) {
super(testName, configuration);
}
@Parameters(name = "{0}" + TEST_FOLDER_EXT + "/{1}")
public static Collection<Object[]> getConfigurations() {
final Map<String, String[]> configs = new HashMap<>();
configs.put("testUnions.c", new String[]{BC_O0, BC_MEM2REG, BC_O1});
configs.put("testDecorators.c", new String[]{BC_O0, BC_MEM2REG, BC_O1});
configs.put("testControlFlow.c", new String[]{BC_O0, BC_MEM2REG});
if (!Platform.isAArch64()) {
configs.put("testPrimitives.c", new String[]{BC_O0, BC_MEM2REG});
String clangCC = System.getenv("CLANG_CC");
if (clangCC == null || !clangCC.contains("-4.0")) {
configs.put("testStructures.c", new String[]{BC_O1});
configs.put("testClasses.cpp", new String[]{BC_O0, BC_MEM2REG, BC_O1});
}
configs.put("testReenterArgsAndVals.c", new String[]{BC_O0, BC_MEM2REG});
configs.put("testFunctionPointer.c", new String[]{BC_O0, BC_MEM2REG, BC_O1});
configs.put("testLongDouble.cpp", new String[]{BC_O0, BC_MEM2REG});
configs.put("testBitFields.cpp", new String[]{BC_O0, BC_MEM2REG});
configs.put("testScopes.cpp", new String[]{BC_O0, BC_MEM2REG, BC_O1});
configs.put("testObjectPointer.cpp", new String[]{BC_O0, BC_MEM2REG});
configs.put("testBooleans.cpp", new String[]{BC_O0, BC_MEM2REG, BC_O1});
}
configs.put("testLoop.c", new String[]{BC_O0, BC_MEM2REG});
return configs.entrySet().stream().flatMap(e -> Stream.of(e.getValue()).map(v -> new Object[]{e.getKey(), v})).collect(Collectors.toSet());
}
@Override
void setContextOptions(Context.Builder contextBuilder) {
}
@Override
Path getBitcodePath() {
return BC_DIR_PATH;
}
@Override
Path getSourcePath() {
return SRC_DIR_PATH;
}
@Override
Path getTracePath() {
return TRACE_DIR_PATH;
}
}