提交 3e870336 编写于 作者: D Daniel P. Berrangé

tests: mock virRandomBits to make it endian stable

virRandomBits is implemented in terms of virRandomBytes. Although we
mock virRandomBytes to give a stable value, this is not sufficient to
make virRandomBits give a stable value. The result of virRandomBits will
vary depending on endianness. Thus we mock virRandomBits to return a
stable value directly.
Reviewed-by: NBoris Fiuczynski <fiuczy@linux.ibm.com>
Tested-by: NBoris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 8e09f9af
......@@ -44,6 +44,14 @@ virRandomBytes(unsigned char *buf,
return 0;
}
uint64_t virRandomBits(int nbits)
{
/* Chosen by a fair roll of a 2^64 sided dice */
uint64_t ret = 0x0706050403020100;
if (nbits < 64)
ret &= ((1ULL << nbits) - 1);
return ret;
}
int virRandomGenerateWWN(char **wwn,
const char *virt_type ATTRIBUTE_UNUSED)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册