]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-resolved: fix error code check in assertion
authorAlexey Bogdanenko <alexey@bogdanenko.com>
Thu, 6 Dec 2018 14:54:46 +0000 (17:54 +0300)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 6 Dec 2018 16:23:05 +0000 (17:23 +0100)
If file "/etc/hosts" does not exist, fopen fails and sets errno to ENOENT
("No such file or directory"). So errno should be compared with ENOENT.

This mistake causes test test-resolved-etc-hosts to fail when run on Debian
image built with mkosi.debian included in the repo. The image does not include
"/etc/hosts" file as it is not created by debootstrap, see debootstrap manpage
https://manpages.debian.org/stretch/debootstrap/debootstrap.8.en.html.

src/resolve/test-resolved-etc-hosts.c

index da10391d74eec6e35ad1d8e61fed7cf4aea9bae5..6130a036fd0342dd19be5f8211e8ae4acb27c549 100644 (file)
@@ -11,7 +11,7 @@ static void test_parse_etc_hosts_system(void) {
 
         f = fopen("/etc/hosts", "re");
         if (!f) {
-                assert_se(errno == -ENOENT);
+                assert_se(errno == ENOENT);
                 return;
         }