< prev index next >

test/jdk/com/sun/tools/jextract/TestUpcall.java

Print this page




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




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


< prev index next >