COVESA/dlt-daemon

test failure on big endian platforms

LocutusOfBorg opened this issue ยท 11 comments

Hello, looks like we are failing testsuite on s390x... Is anything needed to debug the issue?
https://buildd.debian.org/status/fetch.php?pkg=dlt-daemon&arch=s390x&ver=2.18.10-1&stamp=1692269034&raw=0

Hello @LocutusOfBorg
Could you kindly share with me the dev environment information? I mean the debian version you are performing the test.
And do I need to setup anything else for system or just build dlt and trigger dlt unit tests?
I will try to reproduce the issue on docker.
Thank you

Hello @minminlittleshrimp , this is my rules file (with cmake configuration)
https://sources.debian.org/src/dlt-daemon/2.18.10-3/debian/rules/
dh_auto_configure --
-DWITH_SYSTEMD=ON -DWITH_SYSTEMD_JOURNAL=ON -DWITH_MAN=ON -DWITH_DLT_ADAPTOR=ON
-DWITH_DLT_DBUS=ON -DWITH_DLT_SYSTEM=ON -DWITH_DLT_KPI=ON -DWITH_DLT_FILETRANSFER=ON -DWITH_UDP_CONNECTION=ON
-DWITH_DLT_UNIT_TESTS=ON -DWITH_EXTENDED_FILTERING=ON -DWITH_DLT_LOGSTORAGE_GZIP=ON -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

Hello @LocutusOfBorg
Thanks for the info.
I could not access to the link, it keeps loading, so could you kindly share a raw txt file?
Regards

#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
export DH_VERBOSE = 1

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
	dh $@


override_dh_auto_configure:
	# keep disabled for now? -DDLT_IPC=UNIX_SOCKET -DWITH_SYSTEMD_SOCKET_ACTIVATION=ON
	dh_auto_configure -- \
		-DWITH_SYSTEMD=ON -DWITH_SYSTEMD_JOURNAL=ON -DWITH_MAN=ON -DWITH_DLT_ADAPTOR=ON \
		-DWITH_DLT_DBUS=ON -DWITH_DLT_SYSTEM=ON -DWITH_DLT_KPI=ON -DWITH_DLT_FILETRANSFER=ON -DWITH_UDP_CONNECTION=ON \
		-DWITH_DLT_UNIT_TESTS=ON -DWITH_EXTENDED_FILTERING=ON -DWITH_DLT_LOGSTORAGE_GZIP=ON -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)


override_dh_auto_install:
	dh_auto_install
	# we use the Debian version for the services files
	rm debian/tmp/usr/lib/systemd/system/dlt-dbus.service debian/tmp/usr/lib/systemd/system/dlt-system.service debian/tmp/usr/lib/systemd/system/dlt.service
	# they are used only for testing, and they mention /usr/local/ in source code, so they can't work anyway
	rm debian/tmp/usr/share/dlt-filetransfer/dlt-test-filetransfer-file debian/tmp/usr/share/dlt-filetransfer/dlt-test-filetransfer-image.png

override_dh_installinit:
	dh_installinit -pdlt-tools --name=dlt-tools-system -n
	dh_installinit -pdlt-tools --name=dlt-tools-dbus -n
	dh_installinit -n

override_dh_clean:
	dh_clean
	rm -rf include/dlt/dlt_version.h

Hello DLT team,

The error logs:

[ RUN      ] t_dlt_gateway_parse_get_log_info.normal
[498219.735922]~DLT~1768677~ERROR    ~Parsing GET_LOG_INFO failed
./tests/gtest_dlt_daemon_gateway.cpp:556: Failure
Expected equality of these values:
  DLT_RETURN_OK
    Which is: 0
  dlt_gateway_parse_get_log_info(&daemon, ecuid, &msg, CONTROL_MESSAGE_NOT_REQUESTED, 0)
    Which is: -1
[  FAILED  ] t_dlt_gateway_parse_get_log_info.normal (0 ms)

Regards

Same issue is happening on the ppc64 build.
Maybe someone wants to run the debian ppc64 in qemu and try to debug it.
I do not have any 64-bit big endian machine at my hand ;)

@michael-methner To me looks really like a Big Endian issue, I did setup a qemu big endian chroot
(pbuilder-dist sid s390x create && pbuilder-dist sid s390x login)
and found with some debug that
dlt_message_payload is swapping endianess for a byte (id) that is already swap.

I added this around

    if (DLT_MSG_IS_NONVERBOSE(msg)) {
        DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t);
        id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
        fprintf(stderr,"ID BEFORE %d AND AFTER %d\n", id_tmp, id);

and this is printed:
ID BEFORE 3 AND AFTER 50331648

while for other tests looks everything correct:
ID BEFORE 285212672 AND AFTER 17

My guess is that the test needs some adjustments for big endian platform, however I fail to see why and specially why this regressed only in the 2.18.10 release.
I'm opening a PR that fixes the test, in the meanwhile I finish my debug.

This is the bad commit highlighted by git bisect

commit 81ac18fa847da21634ced0e07b4d103891ac3849 (HEAD)
Author: Minh Quang Luu <50074497+minminlittleshrimp@users.noreply.github.com>
Date:   Wed Jun 14 16:15:32 2023 +0700

    dlt_unit_test: Fix and improve quality of unit tests (#494)
    
    + Fix issues offline log unit test fail when not trigger gzip feature
    + Add timeout to prevent timeout silently ignored
    + Limit dlt_user final test suite to 5 seconds
    + Fix wrongly triggered gtests with environment (gateway+offline)
    
    Signed-off-by: Luu Quang Minh <Minh.LuuQuang@vn.bosch.com>


and indeed, this makes sense, because before that commit, the test was not actually run

5/8 Testing: gtest_dlt_daemon_gateway
5/8 Test: gtest_dlt_daemon_gateway   
Command: "/bin/sh" "gtest_dlt_daemon_gateway.sh" "gtest_dlt_daemon_gateway" 
Directory: /home/locutusofborg/dlt-daemon/foo/tests
"gtest_dlt_daemon_gateway" start time: Aug 22 12:07 UTC
Output:
----------------------------------------------------------
WARNNG: env variable DLT_UT_DAEMON_PATH is not set
Cleaning up dlt-daemon instances     
basename: missing operand
Try 'basename --help' for more information.
Initializing test
dlt-daemon is not available
Usage: 
sh ./gtest_dlt_daemon_gateway.sh     
<end of output>
Test time =   0.01 sec
----------------------------------------------------------

2.18.9 has the same issue on Big Endian machines, just run the test manually

5/8 Testing: gtest_dlt_daemon_gateway
5/8 Test: gtest_dlt_daemon_gateway   
Command: "/bin/sh" "gtest_dlt_daemon_gateway.sh" "gtest_dlt_daemon_gateway" 
Directory: /home/locutusofborg/dlt-daemon/foo/tests
"gtest_dlt_daemon_gateway" start time: Aug 22 12:07 UTC
Output:
----------------------------------------------------------
WARNNG: env variable DLT_UT_DAEMON_PATH is not set
Cleaning up dlt-daemon instances     
basename: missing operand
Try 'basename --help' for more information.
Initializing test
dlt-daemon is not available
Usage: 
sh ./gtest_dlt_daemon_gateway.sh     
<end of output>
Test time =   0.01 sec
----------------------------------------------------------