73 checks.forEach(c -> c.accept(res)); 74 } 75 } 76 System.err.println("...done"); 77 } 78 79 @DataProvider 80 public Object[][] getArgs() { 81 return Stream.of(headerCls.getDeclaredMethods()) 82 .map(m -> new Object[]{ m.getName(), m }) 83 .toArray(Object[][]::new); 84 } 85 86 } 87 88 @Factory 89 public Object[] getTests() throws ReflectiveOperationException { 90 List<DowncallTest> res = new ArrayList<>(); 91 for (int i = 0 ; i < MAX_CODE ; i++) { 92 Path clzPath = getOutputFilePath("libTestDowncall.jar"); 93 checkSuccess(null,"-o", clzPath.toString(), 94 "--exclude-symbols", filterFor(i), 95 getInputFilePath("libTestDowncall.h").toString()); 96 Class<?> headerCls = loadClass("libTestDowncall", clzPath); 97 Object lib = Libraries.bind(headerCls, Libraries.loadLibrary(MethodHandles.lookup(), "TestDowncall")); 98 res.add(new DowncallTest(headerCls, lib)); 99 } 100 if(res.isEmpty()) 101 throw new RuntimeException("Could not generate any tests"); 102 return res.toArray(); 103 } 104 105 static Object[] makeArgs(Scope sc, Method m, List<Consumer<Object>> checks) throws ReflectiveOperationException { 106 Class<?>[] params = m.getParameterTypes(); 107 Object[] args = new Object[params.length]; 108 for (int i = 0 ; i < params.length ; i++) { 109 args[i] = makeArg(sc, params[i], checks, i == 0); 110 } 111 return args; 112 } 113 114 @SuppressWarnings("unchecked") 115 static Object makeArg(Scope sc, Class<?> carrier, List<Consumer<Object>> checks, boolean check) throws ReflectiveOperationException { | 73 checks.forEach(c -> c.accept(res)); 74 } 75 } 76 System.err.println("...done"); 77 } 78 79 @DataProvider 80 public Object[][] getArgs() { 81 return Stream.of(headerCls.getDeclaredMethods()) 82 .map(m -> new Object[]{ m.getName(), m }) 83 .toArray(Object[][]::new); 84 } 85 86 } 87 88 @Factory 89 public Object[] getTests() throws ReflectiveOperationException { 90 List<DowncallTest> res = new ArrayList<>(); 91 for (int i = 0 ; i < MAX_CODE ; i++) { 92 Path clzPath = getOutputFilePath("libTestDowncall.jar"); 93 run("-o", clzPath.toString(), 94 "--exclude-symbols", filterFor(i), 95 getInputFilePath("libTestDowncall.h").toString()).checkSuccess(); 96 Class<?> headerCls = loadClass("libTestDowncall", clzPath); 97 Object lib = Libraries.bind(headerCls, Libraries.loadLibrary(MethodHandles.lookup(), "TestDowncall")); 98 res.add(new DowncallTest(headerCls, lib)); 99 } 100 if(res.isEmpty()) 101 throw new RuntimeException("Could not generate any tests"); 102 return res.toArray(); 103 } 104 105 static Object[] makeArgs(Scope sc, Method m, List<Consumer<Object>> checks) throws ReflectiveOperationException { 106 Class<?>[] params = m.getParameterTypes(); 107 Object[] args = new Object[params.length]; 108 for (int i = 0 ; i < params.length ; i++) { 109 args[i] = makeArg(sc, params[i], checks, i == 0); 110 } 111 return args; 112 } 113 114 @SuppressWarnings("unchecked") 115 static Object makeArg(Scope sc, Class<?> carrier, List<Consumer<Object>> checks, boolean check) throws ReflectiveOperationException { |