Hi Bruno,

On 5/17/24 5:59 AM, Bruno Haible wrote:
> The test fails on Alpine Linux.
> 
> 
> FAIL: test-getusershell
> =======================
> 
> ../../gltests/test-getusershell.c:53: assertion 'ptr[0] != '#'' failed
> Aborted (core dumped)
> FAIL test-getusershell (exit status: 134)

Hahaha, I added that check expecting that it would never cause issues.

I remember you saying a few days ago saying that "every function is
worth testing", so here is more evidence. :)

> If you want to look into it: It's easy to install Alpine Linux in a VM.
> Cf. maint-tools/platforms/test-environments.txt. Here's my writeup:

I'll set one up this weekend so I have a musl environment for running
tests.

However, I think this failure has an easy explanation now that I look
at the musl sources.

The glibc implementation is derived from BSD. In the FreeBSD man page
for shells(5) the following is said [1]:

    A hash mark (``#'') indicates the beginning of a comment;
    subsequent characters up to the end of the line are not
    interpreted by the routines which search the file. Blank lines are
    also ignored.

In other words getusershell () should ignore comments which glibc also does.

It appears that musl doesn't check for comments which explains that
failure [2].

It also looks like musl will return empty lines (getline () with
length 1), which I believe is incorrect from the FreeBSD man page
description.

If you still have your alpine machine up you can remove the comments
from '/etc/shells' and check if it passes.

[1] 
https://man.freebsd.org/cgi/man.cgi?query=shells&sektion=5&apropos=0&manpath=FreeBSD+14.0-RELEASE+and+Ports
[2] https://git.musl-libc.org/cgit/musl/tree/src/legacy/getusershell.c

Collin

Reply via email to