mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-04 20:15:19 +00:00
tests: avoid seclabeltest crash
Commita56c347
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 commita22a36e8fe
) Conflicts: tests/seclabeltest.c
This commit is contained in:
parent
086c3fbab1
commit
758a066ab3
@ -6,6 +6,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "security/security_driver.h"
|
#include "security/security_driver.h"
|
||||||
|
#include "virrandom.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
||||||
@ -13,10 +14,14 @@ main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
|||||||
virSecurityManagerPtr mgr;
|
virSecurityManagerPtr mgr;
|
||||||
const char *doi, *model;
|
const char *doi, *model;
|
||||||
|
|
||||||
|
if (virThreadInitialize() < 0 ||
|
||||||
|
virRandomInitialize(time(NULL) ^ getpid()))
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
mgr = virSecurityManagerNew(NULL, false, true, false);
|
mgr = virSecurityManagerNew(NULL, false, true, false);
|
||||||
if (mgr == NULL) {
|
if (mgr == NULL) {
|
||||||
fprintf (stderr, "Failed to start security driver");
|
fprintf (stderr, "Failed to start security driver");
|
||||||
exit (-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
model = virSecurityManagerGetModel(mgr);
|
model = virSecurityManagerGetModel(mgr);
|
||||||
@ -24,7 +29,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "Failed to copy secModel model: %s",
|
fprintf (stderr, "Failed to copy secModel model: %s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
exit (-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
doi = virSecurityManagerGetDOI(mgr);
|
doi = virSecurityManagerGetDOI(mgr);
|
||||||
@ -32,7 +37,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "Failed to copy secModel DOI: %s",
|
fprintf (stderr, "Failed to copy secModel DOI: %s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
exit (-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
virSecurityManagerFree(mgr);
|
virSecurityManagerFree(mgr);
|
||||||
|
Loading…
Reference in New Issue
Block a user