提交 2f809dba 编写于 作者: E Eric Blake 提交者: Cole Robinson

tests: avoid seclabeltest crash

Commit a56c3470 introduced a use of random numbers into seclabel
handling, but failed to initialize the random number generator
in the testsuite.  Also, fail with usual status, not 255.

* tests/seclabeltest.c (main): Initialize randomness.
(cherry picked from commit a22a36e8)

Conflicts:
	tests/seclabeltest.c
上级 b50badc5
......@@ -6,6 +6,7 @@
#include <string.h>
#include <errno.h>
#include "security/security_driver.h"
#include "util.h"
int
main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
......@@ -13,10 +14,14 @@ main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
virSecurityManagerPtr mgr;
const char *doi, *model;
if (virThreadInitialize() < 0 ||
virRandomInitialize(time(NULL) ^ getpid()))
exit(EXIT_FAILURE);
mgr = virSecurityManagerNew(NULL, false);
if (mgr == NULL) {
fprintf (stderr, "Failed to start security driver");
exit (-1);
exit(EXIT_FAILURE);
}
model = virSecurityManagerGetModel(mgr);
......@@ -24,7 +29,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
fprintf (stderr, "Failed to copy secModel model: %s",
strerror (errno));
exit (-1);
exit(EXIT_FAILURE);
}
doi = virSecurityManagerGetDOI(mgr);
......@@ -32,7 +37,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
fprintf (stderr, "Failed to copy secModel DOI: %s",
strerror (errno));
exit (-1);
exit(EXIT_FAILURE);
}
virSecurityManagerFree(mgr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册