mirror of
https://gitee.com/openharmony/communication_ipc
synced 2024-11-23 07:50:24 +00:00
!1493 fix:code coverage of fuzz test
Merge pull request !1493 from yue/master
This commit is contained in:
commit
cc298ac979
@ -120,4 +120,19 @@ static inline bool GenerateString(std::string &value)
|
||||
return DataGenerator::GetInstance().ReadString(value);
|
||||
}
|
||||
|
||||
static inline bool GenerateStringByLength(std::string &value, size_t length = 0)
|
||||
{
|
||||
size_t readAbleSize = DataGenerator::GetInstance().GetReadableBytes();
|
||||
if (length == 0 || length > readAbleSize) {
|
||||
length = readAbleSize;
|
||||
}
|
||||
|
||||
const char *bufData = reinterpret_cast<const char *>(DataGenerator::GetInstance().ReadBuffer(length));
|
||||
if (bufData == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
value = std::string(bufData, length);
|
||||
return true;
|
||||
}
|
||||
#endif // FUZZ_DATA_GENERATOR_H
|
@ -33,7 +33,7 @@ namespace OHOS {
|
||||
int32_t listenFd;
|
||||
std::string deviceId;
|
||||
if (!GenerateUint32(pid) || !GenerateUint32(uid) || !GenerateUint32(tokenId) || !GenerateInt32(listenFd) ||
|
||||
!GenerateUint64(stubIndex) || !GenerateString(deviceId)) {
|
||||
!GenerateUint64(stubIndex) || !GenerateStringByLength(deviceId)) {
|
||||
return false;
|
||||
}
|
||||
IPCProcessSkeleton *current = IPCProcessSkeleton::GetCurrent();
|
||||
@ -56,7 +56,7 @@ namespace OHOS {
|
||||
int32_t listenFd;
|
||||
std::string deviceId;
|
||||
if (!GenerateUint32(pid) || !GenerateUint32(uid) || !GenerateUint32(tokenId) || !GenerateInt32(listenFd) ||
|
||||
!GenerateString(deviceId)) {
|
||||
!GenerateStringByLength(deviceId)) {
|
||||
return false;
|
||||
}
|
||||
IPCProcessSkeleton *current = IPCProcessSkeleton::GetCurrent();
|
||||
@ -828,7 +828,7 @@ namespace OHOS {
|
||||
sptr<IRemoteObject> remoteObj = new IPCObjectProxy(0, u"proxyTest", 0);
|
||||
IRemoteObject *stub = remoteObj.GetRefPtr();
|
||||
if (!GenerateInt32(pid) || !GenerateInt32(uid) || !GenerateUint32(tokenId) ||
|
||||
!GenerateString(deviceId) || !GenerateInt32(socketId)) {
|
||||
!GenerateInt32(socketId) || !GenerateStringByLength(deviceId)) {
|
||||
return false;
|
||||
}
|
||||
current->QueryCommAuthInfo(pid, uid, tokenId, deviceId);
|
||||
@ -853,7 +853,7 @@ namespace OHOS {
|
||||
sptr<IRemoteObject> remoteObj = new IPCObjectProxy(0, u"proxyTest", 0);
|
||||
IRemoteObject *stub = remoteObj.GetRefPtr();
|
||||
if (!GenerateInt32(pid) || !GenerateInt32(uid) || !GenerateUint32(tokenId) ||
|
||||
!GenerateString(deviceId) || !GenerateInt32(socketId)) {
|
||||
!GenerateInt32(socketId) || !GenerateStringByLength(deviceId)) {
|
||||
return false;
|
||||
}
|
||||
current->AttachCommAuthInfo(stub, pid, uid, tokenId, deviceId);
|
||||
@ -875,7 +875,7 @@ namespace OHOS {
|
||||
sptr<IRemoteObject> remoteObj = new IPCObjectProxy(0, u"proxyTest", 0);
|
||||
IRemoteObject *stub = remoteObj.GetRefPtr();
|
||||
if (!GenerateInt32(pid) || !GenerateInt32(uid) || !GenerateUint32(tokenId) ||
|
||||
!GenerateString(deviceId) || !GenerateInt32(socketId)) {
|
||||
!GenerateInt32(socketId) || !GenerateStringByLength(deviceId)) {
|
||||
return false;
|
||||
}
|
||||
current->AttachCommAuthInfo(stub, pid, uid, tokenId, deviceId);
|
||||
|
Loading…
Reference in New Issue
Block a user