I'm using google test framework for testing hardware Ethernet switch. Some operations (e.x. enabling RSTP) take time to proceed. So I need to implement some sort of a Sleep()
function inside the test case:
TEST_F(RSTP, enableRSTP) {
snmp.set(OID, Integer32(3));
// after changing value switch is unavailable
// so I need to wait before request
auto result = snmp.get(OID);
auto res = std::get<Integer32>(result);
ASSERT_EQ(res, Integer32(3));
}
How do I accomplish this?
As mentioned in one of the comments, you could just use (c++14):
#include <chrono>
#include <thread>
TEST_F(RSTP, enableRSTP) {
...
using namespace std::chrono_literals;
std::this_thread::sleep_for(2s);
...
}
... or for c++11, replace 2s
with:
std::chrono::seconds(2)
If you don't use >= c++11, then this becomes an OS specific question (not standard c++)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With