fuzz: use FQName to identify our fuzz target
am: 87cb3790b0
Change-Id: I8fdd9db05d1eb642bb8aa682a193b8ad5b143562
diff --git a/iface_fuzzer/Android.bp b/iface_fuzzer/Android.bp
index 75d6138..c52182d 100644
--- a/iface_fuzzer/Android.bp
+++ b/iface_fuzzer/Android.bp
@@ -28,12 +28,16 @@
"test/vts-testcase/fuzz/iface_fuzzer/include",
],
shared_libs: [
+ "libbase",
"libprotobuf-cpp-full",
"libvintf",
"libvts_common",
"libvts_multidevice_proto",
"libvts_proto_fuzzer_proto",
],
+ static_libs: [
+ "libhidl-gen-utils",
+ ],
cflags: [
"-Wall",
"-Werror",
diff --git a/iface_fuzzer/ProtoFuzzerMain.cpp b/iface_fuzzer/ProtoFuzzerMain.cpp
index 7a58ceb..58a7d9a 100644
--- a/iface_fuzzer/ProtoFuzzerMain.cpp
+++ b/iface_fuzzer/ProtoFuzzerMain.cpp
@@ -104,10 +104,10 @@
mutator = make_unique<ProtoFuzzerMutator>(
*random.get(), ExtractPredefinedTypes(params.comp_specs_),
mutator_config);
- runner =
- make_unique<ProtoFuzzerRunner>(params.comp_specs_, params.version_iface_);
+ runner = make_unique<ProtoFuzzerRunner>(params.comp_specs_,
+ params.target_fq_name_.version());
- runner->Init(params.target_iface_, params.binder_mode_);
+ runner->Init(params.target_fq_name_.name(), params.binder_mode_);
// Register atexit handler after all static objects' initialization.
std::atexit(AtExit);
// Register signal handler for SIGABRT.
diff --git a/iface_fuzzer/ProtoFuzzerUtils.cpp b/iface_fuzzer/ProtoFuzzerUtils.cpp
index 8f77079..75d227c 100644
--- a/iface_fuzzer/ProtoFuzzerUtils.cpp
+++ b/iface_fuzzer/ProtoFuzzerUtils.cpp
@@ -46,9 +46,9 @@
"LLVMFuzzerTestOneInput.\n"
"\tvts_spec_dir: \":\"-separated list of directories on the target "
"containing .vts spec files.\n"
- "\tvts_target_iface: name of interface targeted for fuzz with the "
- "version, e.g. "
- "\"INfc@1.1\".\n"
+ "\tvts_target_fq_name: fully-qualified name of interface targeted for "
+ "fuzz version, e.g. "
+ "\"android.hardware.nfc@1.1::INfc\".\n"
"\tvts_seed: optional integral argument used to initalize the random "
"number generator.\n"
"\n"
@@ -63,7 +63,7 @@
{"vts_spec_dir", required_argument, 0, 'd'},
{"vts_exec_size", required_argument, 0, 'e'},
{"vts_seed", required_argument, 0, 's'},
- {"vts_target_iface", required_argument, 0, 't'}};
+ {"vts_target_fq_name", required_argument, 0, 't'}};
// Removes information from CompSpec not needed by fuzzer.
static void TrimCompSpec(CompSpec *comp_spec) {
@@ -105,26 +105,6 @@
return result;
}
-template <class Container>
-static void Split(const std::string &str, Container &cont, char delim) {
- std::stringstream ss(str);
- std::string token;
- while (std::getline(ss, token, delim)) {
- cont.push_back(token);
- }
-}
-
-static vector<string> ExtractIfaceNameAndVersion(const string &arg) {
- vector<string> nameWithVersion;
- Split(optarg, nameWithVersion, '@');
- if (nameWithVersion.size() != 2) {
- cerr << __func__ << ": Should specify vts_target_iface with version."
- << endl;
- std::abort();
- }
- return nameWithVersion;
-}
-
static void ExtractPredefinedTypesFromVar(
const TypeSpec &var_spec,
unordered_map<string, TypeSpec> &predefined_types) {
@@ -161,9 +141,10 @@
params.seed_ = std::stoull(optarg);
break;
case 't': {
- vector<string> nameWithVersion = ExtractIfaceNameAndVersion(optarg);
- params.target_iface_ = nameWithVersion[0];
- params.version_iface_ = nameWithVersion[1];
+ if (!FQName::parse(optarg, ¶ms.target_fq_name_)) {
+ usage();
+ std::abort();
+ }
break;
}
default:
@@ -177,7 +158,7 @@
string ProtoFuzzerParams::DebugString() const {
std::stringstream ss;
ss << "Execution size: " << exec_size_ << endl;
- ss << "Target interface: " << target_iface_ << endl;
+ ss << "Target FQ name: " << target_fq_name_.string() << endl;
ss << "Binder mode: " << binder_mode_ << endl;
ss << "Seed: " << seed_ << endl;
ss << "Loaded specs: " << endl;
diff --git a/iface_fuzzer/include/ProtoFuzzerUtils.h b/iface_fuzzer/include/ProtoFuzzerUtils.h
index a4466ae..626fe8b 100644
--- a/iface_fuzzer/include/ProtoFuzzerUtils.h
+++ b/iface_fuzzer/include/ProtoFuzzerUtils.h
@@ -24,6 +24,8 @@
#include <unordered_map>
#include <vector>
+#include <hidl-util/FQName.h>
+
#include "driver_base/DriverBase.h"
#include "test/vts/proto/ExecutionSpecificationMessage.pb.h"
@@ -71,10 +73,9 @@
size_t exec_size_;
// VTS specs supplied to the fuzzer.
std::vector<CompSpec> comp_specs_;
- // Name of target interface, e.g. "INfc".
- std::string target_iface_;
- // Version of target interface, e.g. "1.1".
- std::string version_iface_;
+ // Fully-qualified name of the target, e.g.
+ // "android.hardware.light@2.0::ILight"
+ android::FQName target_fq_name_;
// Controls whether HAL is opened in passthrough or binder mode.
// Binder mode is default. Used for testing.
bool binder_mode_ = true;