1 // This file was auto-generated by VTS compiler. 2 3 #include <iostream> 4 5 #include "FuncFuzzerUtils.h" 6 #include <android/hardware/renderscript/1.0/IDevice.h> 7 8 using std::cerr; 9 using std::endl; 10 using std::string; 11 12 using namespace ::android::hardware::renderscript::V1_0; 13 using namespace ::android::hardware; 14 15 namespace android { 16 namespace vts { 17 18 static string target_func; 19 20 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { 21 FuncFuzzerParams params{ExtractFuncFuzzerParams(*argc, *argv)}; 22 target_func = params.target_func_; 23 return 0; 24 } 25 26 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 27 static ::android::sp<IDevice> renderscript = IDevice::getService(true); 28 if (renderscript == nullptr) { 29 cerr << "IDevice::getService() failed" << endl; 30 exit(1); 31 } 32 33 if (target_func == "contextCreate") { 34 size_t type_size0 = sizeof(uint32_t); 35 if (size < type_size0) { return 0; } 36 size -= type_size0; 37 uint32_t arg0; 38 memcpy(&arg0, data, type_size0); 39 data += type_size0; 40 41 size_t type_size1 = sizeof(::android::hardware::renderscript::V1_0::ContextType); 42 if (size < type_size1) { return 0; } 43 size -= type_size1; 44 ::android::hardware::renderscript::V1_0::ContextType arg1; 45 memcpy(&arg1, data, type_size1); 46 data += type_size1; 47 48 size_t type_size2 = sizeof(int32_t); 49 if (size < type_size2) { return 0; } 50 size -= type_size2; 51 int32_t arg2; 52 memcpy(&arg2, data, type_size2); 53 data += type_size2; 54 55 renderscript->contextCreate(arg0, arg1, arg2); 56 return 0; 57 } else { 58 cerr << "No such function: " << target_func << endl; 59 exit(1); 60 } 61 } 62 63 } // namespace vts 64 } // namespace android 65