[systemd-devel] [PATCH v4] Skip tests that depend on /etc/machine-id if it is not present

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Sun Dec 2 02:34:27 PST 2012


On Sat, Dec 01, 2012 at 08:28:43PM -0800, David Strauss wrote:
> Would it be possible, for testing purposes, to generate a machine ID
> on the fly if one is not present on disk?
For systemd to boot properly when the root fs is readonly, either
/etc/machine-id with some value, or an empty /etc/machine-id must
be present. So it would make sense to check for an empty /etc/machine-id
and then generate a value, but the case where there's no /etc/machine-id
should fail, IMHO.

Zbyszek

> On Sat, Dec 1, 2012 at 7:48 AM, Zbigniew Jędrzejewski-Szmek
> <zbyszek at in.waw.pl> wrote:
> > On Sat, Dec 01, 2012 at 10:01:35AM +0530, Ramkumar Ramachandra wrote:
> >> The following tests fail if /etc/machine-id is not present:
> >>
> >>   $ ./test-id128
> >>   random: a08ea8ed34594d4bbd953dd182ec86f9
> >>   Assertion 'sd_id128_get_machine(&id) == 0' failed at
> >>   src/test/test-id128.c:41, function main(). Aborting.
> >>   [1]    8017 abort (core dumped)  ./test-id128
> >>
> >>   $ ./test-journal
> >>   Assertion 'journal_file_open("test.journal", O_RDWR|O_CREAT, 0666,
> >>   true, true, NULL, NULL, NULL, &f) == 0' failed at
> >>   src/journal/test-journal.c:46, function main(). Aborting.
> >>   [1]    8059 abort (core dumped)  ./test-journal
> >>
> >>   $ ./test-journal-stream
> >>   Assertion 'journal_file_open("one.journal", O_RDWR|O_CREAT, 0666,
> >>   true, false, NULL, NULL, NULL, &one) == 0' failed at
> >>   src/journal/test-journal-stream.c:88, function main(). Aborting.
> >>   [1]    8107 abort (core dumped)  ./test-journal-stream
> >>
> >>   $ ./test-journal-verify
> >>   Generating...
> >>   Assertion 'journal_file_open("test.journal", O_RDWR|O_CREAT, 0666,
> >>   true, !!verification_key, NULL, NULL, NULL, &f) == 0' failed at
> >>   src/journal/test-journal-verify.c:87, function main(). Aborting.
> >>   [1]    8154 abort (core dumped)  ./test-journal-verify
> >>
> >> This is because they call sd_id128_get_machine() which barfs if
> >> /etc/machine-id can't be open()'ed.  Treat ENOENT as a special case
> >> and skip the dependent tests instead of failing them.
> > Hi,
> >
> > I started munging your patch to apply it, but on second thought it is
> > totally the wrong direction to take. The purpose of tests is to check
> > if systemd will function after installation. And as mentioned
> > elsewhere in the thread, journald will break badly, and thus systemd
> > will not function as expected. So it is much better to have the tests
> > fail as they do now, then to paper over a missing file. So I think that
> > the patch should
> > (a) skip _some_ of the tests to reduce noise,
> > (b) fail at least one test to tell the user that /etc/machine-id is missing.
> >
> > I would be nice to
> > (c) using automake skip (below) to do that,
> >
> > Automake test skipping:
> > + #define EXIT_AUTOMAKE_SKIP 77
> >
> > +        sd_id128_t id;
> > +
> > +        if (sd_id128_get_machine(&id) == -ENOENT) {
> > +                printf("skipping test: /etc/machine-id not present\n");
> > +                return EXIT_AUTOMAKE_SKIP;
> > +        }
> >
> > SKIP: test-journal-verify
> > PASS: test-mmap-cache
> > ======================
> > All 17 tests passed
> > (4 tests were not run)
> > ======================
> >
> > Zbyszek
> > _______________________________________________
> > systemd-devel mailing list
> > systemd-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 
> 
> 
> -- 
> David Strauss
>    | david at davidstrauss.net
>    | +1 512 577 5827 [mobile]
> 


More information about the systemd-devel mailing list