summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2016-04-11 22:31:57 +0300
committerMartin Pitt <martin.pitt@ubuntu.com>2016-04-11 21:31:57 +0200
commitdbab702a2a2ba942d75f9682e2ab11f9b55df683 (patch)
tree257ac1f189c06c6f5844747f4fe20e8bd1b07307 /src/test
parent70a399c43a293cc4864c4e9421e265a64305cdc5 (diff)
tests: port udev-test to log_*_errno (#3015)
SYSTEMD_LOG_LEVEL=debug test/udev-test.pl is working now Also, fixes CID 1354602
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-udev.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/test/test-udev.c b/src/test/test-udev.c
index e5f0d00b94..e965b4494a 100644
--- a/src/test/test-udev.c
+++ b/src/test/test-udev.c
@@ -27,6 +27,7 @@
#include <unistd.h>
#include "fs-util.h"
+#include "log.h"
#include "missing.h"
#include "selinux-util.h"
#include "signal-util.h"
@@ -48,33 +49,22 @@ static int fake_filesystems(void) {
{ "test/run", UDEVLIBEXECDIR "/rules.d", "failed to mount empty " UDEVLIBEXECDIR "/rules.d", true },
};
unsigned int i;
- int err;
- err = unshare(CLONE_NEWNS);
- if (err < 0) {
- err = -errno;
- fprintf(stderr, "failed to call unshare(): %m\n");
- goto out;
- }
+ if (unshare(CLONE_NEWNS) < 0)
+ return log_error_errno(errno, "failed to call unshare(): %m");
- if (mount(NULL, "/", NULL, MS_PRIVATE|MS_REC, NULL) < 0) {
- err = -errno;
- fprintf(stderr, "failed to mount / as private: %m\n");
- goto out;
- }
+ if (mount(NULL, "/", NULL, MS_PRIVATE|MS_REC, NULL) < 0)
+ return log_error_errno(errno, "failed to mount / as private: %m");
for (i = 0; i < ELEMENTSOF(fakefss); i++) {
- err = mount(fakefss[i].src, fakefss[i].target, NULL, MS_BIND, NULL);
- if (err < 0) {
- err = -errno;
- fprintf(stderr, "%s %m%s\n", fakefss[i].error, fakefss[i].ignore_mount_error ? ", ignoring" : "");
+ if (mount(fakefss[i].src, fakefss[i].target, NULL, MS_BIND, NULL) < 0) {
+ log_full_errno(fakefss[i].ignore_mount_error ? LOG_DEBUG : LOG_ERR, errno, "%s: %m", fakefss[i].error);
if (!fakefss[i].ignore_mount_error)
- return err;
- err = 0;
+ return -errno;
}
}
-out:
- return err;
+
+ return 0;
}
int main(int argc, char *argv[]) {
@@ -87,6 +77,9 @@ int main(int argc, char *argv[]) {
const char *action;
int err;
+ log_parse_environment();
+ log_open();
+
err = fake_filesystems();
if (err < 0)
return EXIT_FAILURE;