[LTP] [RFC PATCH 2/2] sched_football: Rewrite into new API

Petr Vorel pvorel@suse.cz
Fri Jul 12 15:22:05 CEST 2024


Hi Cyril,

First, thanks for having a look.

> Hi!
> > Combining LTP librealtime (librttest.c) and LTP library is somehow
> > experimental. -lltp was needed to be added to CFLAGS but yet on musl
> > it fails to find the function on runtime:
> > tst_test.c:985: TBROK: No test function specified

> That should not happen, you get this message something went horribly
> wrong and the test_all function pointer ended up NULL in the test
> library. Which gcc version was it, I would expect that this would be
> more compiler specific than libc specific.

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/13.2.1/lto-wrapper
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-13-20231014/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --enable-checking=release --disable-cet --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-default-ssp --enable-languages=c,c++,d,objc,go,fortran,ada --enable-link-serialization=2 --enable-linker-build-id --disable-libssp --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-bugurl=https://gitlab.alpinelinux.org/alpine/aports/-/issues --with-system-zlib --with-linker-hash-style=gnu --with-pkgversion='Alpine 13.2.1_git20231014'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.2.1 20231014 (Alpine 13.2.1_git20231014)

Hm, after doing make clean of the library everything magically worked. I'm sorry
for the noise.

$ make V=1
gcc -I/home/foo/ltp/testcases/realtime/include -I/home/foo/ltp/testcases/realtime/include -I../../../../include -I../../../../include -I../../../../include/old/ -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W -Wold-style-definition -std=gnu99 -D_GNU_SOURCE -L/home/foo/ltp/testcases/realtime/lib -L../../../../lib sched_football.c  -lrealtime -lpthread -lrt -lm -lltp -o sched_football

# ./sched_football
tst_test.c:1806: TINFO: LTP version: 20240524-81-g562d1b39b
tst_test.c:1650: TINFO: Timeout per run is 0h 00m 30s
sched_football.c:159: TINFO: players_per_team: 2 game_length: 5
sched_football.c:171: TINFO: Starting 2 offense threads at priority 15
sched_football.c:182: TINFO: Starting 2 defense threads at priority 30
sched_football.c:193: TINFO: Starting 2 fan threads at priority 50
sched_football.c:120: TINFO: Starting referee thread
sched_football.c:123: TINFO: Starting the game (5 sec)
sched_football.c:143: TINFO: Final ball position: 0
sched_football.c:145: TPASS: Expect: final_ball == 0

=> main problem solved, but there are 2 others.

1) realtime suite does not trigger libltp dependency (build system fix required):

/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lltp: No such file or directory

I wonder if we should get rid of LTP realtime library for this file. Fixing it
would be obviously better.

2) Running with -i is broken (everywhere, also on glibc)

./sched_football -i2
tst_test.c:1806: TINFO: LTP version: 20240524-93-g17c91c528
tst_test.c:1650: TINFO: Timeout per run is 0h 00m 30s
sched_football.c:159: TINFO: players_per_team: 2 game_length: 5
sched_football.c:171: TINFO: Starting 2 offense threads at priority 15
sched_football.c:182: TINFO: Starting 2 defense threads at priority 30
sched_football.c:193: TINFO: Starting 2 fan threads at priority 50
sched_football.c:120: TINFO: Starting referee thread
sched_football.c:123: TINFO: Starting the game (5 sec)
sched_football.c:143: TINFO: Final ball position: 0
sched_football.c:145: TPASS: Expect: final_ball == 0
sched_football.c:159: TINFO: players_per_team: 2 game_length: 5
sched_football.c:171: TINFO: Starting 2 offense threads at priority 15
Test timeouted, sending SIGKILL!

Something needs to be reset for each run and it's not?
ball is reset: tst_atomic_store(0, &ball);

Kind regards,
Petr

> Otherwise the conversion looks pretty straightforward, mostly about
> option parsing and printf vs tst_res().


More information about the ltp mailing list