I have a function called resize which changes the size of a shared object. I have another function called getsize which gets the size of that shared object. I want to introduce a race between resize and getsize where I need a delay in exactly a particular line of resize and that particular point I want resize to sleep and getsize to be called and getsize to run at that particular time. Is there any way I can achieve this using gtest MOCK facility?
Resize(int newsize) {
resizeint(newsize);
// Want to introduce delay here and call Getsize().
// This will simulate cache inconsistency.
// Getsize() will return old size even though shared object is resized.
writenewsizetocache();
}
int Getsize() {
int size = readsizefromlocalcahce();
return size;
}