| // This file was auto-generated by VTS compiler. |
| |
| #include <iostream> |
| |
| #include "FuncFuzzerUtils.h" |
| #include <android/hardware/renderscript/1.0/IDevice.h> |
| |
| using std::cerr; |
| using std::endl; |
| using std::string; |
| |
| using namespace ::android::hardware::renderscript::V1_0; |
| using namespace ::android::hardware; |
| |
| namespace android { |
| namespace vts { |
| |
| static string target_func; |
| |
| extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { |
| FuncFuzzerParams params{ExtractFuncFuzzerParams(*argc, *argv)}; |
| target_func = params.target_func_; |
| return 0; |
| } |
| |
| extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
| static ::android::sp<IDevice> renderscript = IDevice::getService(true); |
| if (renderscript == nullptr) { |
| cerr << "IDevice::getService() failed" << endl; |
| exit(1); |
| } |
| |
| if (target_func == "contextCreate") { |
| size_t type_size0 = sizeof(uint32_t); |
| if (size < type_size0) { return 0; } |
| size -= type_size0; |
| uint32_t arg0; |
| memcpy(&arg0, data, type_size0); |
| data += type_size0; |
| |
| size_t type_size1 = sizeof(::android::hardware::renderscript::V1_0::ContextType); |
| if (size < type_size1) { return 0; } |
| size -= type_size1; |
| ::android::hardware::renderscript::V1_0::ContextType arg1; |
| memcpy(&arg1, data, type_size1); |
| data += type_size1; |
| |
| size_t type_size2 = sizeof(int32_t); |
| if (size < type_size2) { return 0; } |
| size -= type_size2; |
| int32_t arg2; |
| memcpy(&arg2, data, type_size2); |
| data += type_size2; |
| |
| renderscript->contextCreate(arg0, arg1, arg2); |
| return 0; |
| } else { |
| cerr << "No such function: " << target_func << endl; |
| exit(1); |
| } |
| } |
| |
| } // namespace vts |
| } // namespace android |