Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine Linux and "ps: unrecognized option: p" #17542

Closed
noloader opened this issue Feb 7, 2020 · 5 comments · Fixed by #21329
Closed

Alpine Linux and "ps: unrecognized option: p" #17542

noloader opened this issue Feb 7, 2020 · 5 comments · Fixed by #21329

Comments

@noloader
Copy link

noloader commented Feb 7, 2020

Description
I'm testing on Alpine Linux 3.10 x86_64. I'm building Perl 5.30.1 from the release tarball.

Alpine has BusyBox and Musl. BusyBox is anemic at times. For example, unzip lacks the -a option to autoconvert text files. And Musl has its own personality. It is a good test platform.

make check is complaining:

...
t/op/lvref ..................................................... ok
t/op/magic-27839 ............................................... ok
t/op/magic ..................................................... ps: unrecognized option: p
BusyBox v1.30.1 (2019-10-26 11:23:07 UTC) multi-call binary.

Usage: ps [-o COL1,COL2=HEADER]

Show list of processes

	-o COL1,COL2=HEADER	Select columns for display
FAILED--unexpected output at test 102

Steps to Reproduce
Perform a configure, make, make check on Alpine Linux.

Expected behavior
Clean testing.

Perl configuration

$ PERL5LIB=./lib ./perl -V
Summary of my perl5 (revision 5 version 30 subversion 1) configuration:
   
  Platform:
    osname=linux
    osvers=4.19.98-0-vanilla
    archname=x86_64-linux
    uname='linux alpine3-x64 4.19.98-0-vanilla #1-alpine smp thu jan 23 10:26:30 utc 2020 x86_64 linux '
    config_args='-des -Dprefix=/usr/local -Dlibdir=/usr/local/lib -Dpkgconfig=/usr/local/lib/pkgconfig -Dcc=gcc -Acppflags=-I/usr/local/include -DNDEBUG -Accflags=-g2 -O2 -march=native -fPIC -pthread -Acxxflags=-g2 -O2 -march=native -fPIC -pthread -Aldflags=-L/usr/local/lib -Wl,-R,'XXORIGIN/../lib' -Wl,-R,/usr/local/lib -Wl,--enable-new-dtags -Dextras=Text::Template Test::More'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags ='-g2 -O2 -march=native -fPIC -pthread -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    optimize='-O2'
    cppflags='-I/usr/local/include -DNDEBUG -g2 -O2 -march=native -fPIC -pthread -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='8.3.0'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='gcc'
    ldflags =' -L/usr/local/lib -Wl,-R,XXORIGIN/../lib -Wl,-R,/usr/local/lib -Wl,--enable-new-dtags -fstack-protector-strong'
    libpth=/usr/local/lib /usr/lib /lib/../lib /usr/lib/../lib /lib
    libs=-lpthread -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=/usr/lib/libc.a
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O2 -L/usr/local/lib -Wl,-R,XXORIGIN/../lib -Wl,-R,/usr/local/lib -fstack-protector-strong'

Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under linux
  Compiled at Feb  7 2020 00:37:24
  %ENV:
    PERL5LIB="./lib"
  @INC:
    ./lib
    /usr/local/lib/perl5/site_perl/5.30.1/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.30.1
    /usr/local/lib/perl5/5.30.1/x86_64-linux
    /usr/local/lib/perl5/5.30.1
@noloader
Copy link
Author

noloader commented Feb 7, 2020

And one more failed test on Alpine:

cpan/Time-Piece/t/02core_dst ................................... #   Failed test at t/02core_dst.t line 133.
#          got: '-14400'
#     expected: '-18000'
#   Failed test at t/02core_dst.t line 134.
#          got: '2013-01-09 08:07:11 EDT'
#     expected: '2013-01-09 07:07:11 EST'
#   Failed test at t/02core_dst.t line 135.
#                   '-0400'
#     doesn't match '(?^:-0500|EST)'
# Looks like you failed 3 tests of 56.
FAILED at test 53

@jkeenan
Copy link
Contributor

jkeenan commented Feb 7, 2020

And two more failed tests on Alpine:

cpan/Time-Piece/t/02core_dst ................................... #   Failed test at t/02core_dst.t line 133.
#          got: '-14400'
#     expected: '-18000'
#   Failed test at t/02core_dst.t line 134.
#          got: '2013-01-09 08:07:11 EDT'
#     expected: '2013-01-09 07:07:11 EST'
#   Failed test at t/02core_dst.t line 135.
#                   '-0400'
#     doesn't match '(?^:-0500|EST)'
# Looks like you failed 3 tests of 56.
FAILED at test 53

[snip]

Time::Piece is maintained upstream on CPAN. This problem appears to have already been reported there at https://rt.cpan.org/Public/Bug/Display.html?id=128240. You may wish to add a comment to that ticket.

Thank you very much.
Jim Keenan

@jkeenan
Copy link
Contributor

jkeenan commented Feb 7, 2020

Description
I'm testing on Alpine Linux 3.10 x86_64. I'm building Perl 5.30.1 from the release tarball.

Alpine has BusyBox and Musl. BusyBox is anemic at times. For example, unzip lacks the -a option to autoconvert text files. And Musl has its own personality. It is a good test platform.

Is there any general way to determine that one is on a platform that is using the BusyBox versions of Linux utilities as opposed to the regular GNU versions?

Similarly, is there any general way to determine that one is using musl libc?

Thank you very much.
Jim Keenan

@bingos
Copy link
Contributor

bingos commented Feb 7, 2020

That particular test is already quite robust (t/op/magic.t). All it requires is a 2>&1 on the ps line (817) to redirect STDERR to STDOUT where it is eaten by the backticks.

Tested on Alpine 3.11.3

@richardleach
Copy link
Contributor

A general way to check for the use of BusyBox is:

my $is_busybox = (`basename \$(readlink /proc/$$/exe)` =~ /^busybox$/);

The skip() test added to magic.t in fca083c could then be amended to:

skip("\$0 check with 'ps' only on Linux (but not Android or BusyBox) and FreeBSD", 1) if $^O eq 'android' || $is_busybox;

But what @bingos suggested looks simpler and would more likely handle other stripped-back multicall binaries besides BusyBox.

mbeijen added a commit to mbeijen/perl5 that referenced this issue Jan 11, 2022
I found that this test is failing on Alpine Linux, a rather popular
linux for creating Docker containers out of.

Alpine Linux uses busybox and the `ps` command it provides does not
handle the `-p` option used by this test, or any option, really.

But also yocto (used for building embedded linuxes) uses busybox

Alpine currently has a patch for this test in their perl package:
https://git.alpinelinux.org/aports/tree/main/perl/skip-test-due-to-busybox-ps.patch

The fix in this commit is as proposed by @bingos in
Perl#17542 (comment)

I tested it on alpine, debian and macOS

Closes Perl#17542
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants