1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-18 19:13:51 +01:00

tests/sys/libc_newlib: drop test

This tests makes little sense to have for a number of reasons:

1. One should not use `iprintf()` for a number of reasons:
    1. It is non-standard and using it over `printf()` makes the code
       less portable (e.g. it cannot be used on AVR)
    2. The idea of adding a leaner variant of `printf()` in addition to
       the larger one is bogus, as apps will end up using both resulting
       in a *larger* firmware instead of a smaller
    3. RIOT's build system already has the `printf_float` module to
       control whether formatting of floating point numbers should be
       suppered. This mechanism will actually result in smaller builds,
       if floating point support is not needed, as it prevents two
       variants of printf to be linked in.
2. The test checks some implementation details (e.g. whether the
   address of two functions is identical), rather than correct behavior
   of the implementation. This is completely bogus.
This commit is contained in:
Marian Buschsieweke 2025-08-19 14:08:27 +02:00
parent 543714fb75
commit 7410255cfc
No known key found for this signature in database
GPG Key ID: 758BD52517F79C41
4 changed files with 0 additions and 173 deletions

View File

@ -1,46 +0,0 @@
include ../Makefile.sys_common
USEMODULE += embunit
include $(RIOTBASE)/Makefile.include
# Compile time tests
.PHONY: compile-test test-newlib-nano
# The tests should only be executed in build environment
ifneq ($(BUILD_IN_DOCKER),1)
all: compile-test
endif
ifneq (,$(filter newlib,$(USEMODULE)))
COMPILE_TESTS += test-newlib
ifneq (,$(filter newlib_nano,$(USEMODULE)))
CMP_OP = =
else
CMP_OP = !=
endif
endif
# Newlib-nano removed the integer only 'iprintf' functions which are now mapped
# to printf.
#
# `main.c` uses both functions to be sure they are included.
# It also duplicates the same test in C to verify it at runtime.
#
# Source:
#
# https://github.com/32bitmicro/newlib-nano-1.0/blob/f157c994b9a2c4bd8d0cfe9fe8fdd9cd54f8c63b/newlib/README.nano#L32
test-newlib: $(ELFFILE)
$(Q)test -f $^
$(Q)\
PRINTF_ADDR=$$($(NM) $^ | sed -n '/ printf$$/ s/ .*//p');\
IPRINTF_ADDR=$$($(NM) $^ | sed -n '/ iprintf$$/ s/ .*//p');\
echo "Test: comparing addresses of 'printf' and 'iprintf' symbols";\
if test "$${PRINTF_ADDR}" $(CMP_OP) "$${IPRINTF_ADDR}" ; then \
echo "[SUCCESS] '$${PRINTF_ADDR}' $(CMP_OP) '$${IPRINTF_ADDR}' is True"; \
else \
echo "[FAILED] '$${PRINTF_ADDR}' $(CMP_OP) '$${IPRINTF_ADDR}' is False"; \
exit 1; \
fi
compile-test: $(COMPILE_TESTS)

View File

@ -1,20 +0,0 @@
About
=====
Terifies if newlib/newlib-nano is correctly included by the build system
At compile time, it checks that:
* newlib-nano header is used when 'newlib-nano' module is included
* It defines `_NANO_FORMATTED_IO` macro
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/newlib.hin;h=eadafc8a6a51ef7674c004a14777f6a4619115ee;hb=d34336767e45ee801ebb107e40abe4b1acbd3d14#l83
* newlib or newlib-nano is properly linked
* `iprintf` is the same as `printf` or not as mentioned in:
https://github.com/32bitmicro/newlib-nano-1.0/blob/f157c994b9a2c4bd8d0cfe9fe8fdd9cd54f8c63b/newlib/README.nano#L32
At runtime, it checks that:
* the same `iprintf` and `printf` test as at compile time
Without newlib, the test does nothing.

View File

@ -1,93 +0,0 @@
/*
* Copyright (C) 2018 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Test application for newlib/newlib-nano inclusion
*
* @author Gaëtan Harter <gaetan.harter@fu-berlin.de>
*
* @}
*/
/*
* Make some different functions visible between newlib and newlib-nano
*/
#define _DEFAULT_SOURCE 1
#include <stdio.h>
#include "embUnit.h"
#ifdef MODULE_NEWLIB
#include <newlib.h>
/* Newlib-nano defines the _NANO_FORMATTED_IO macro
*
* Source:
*
* https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/newlib.hin;h=eadafc8a6a51ef7674c004a14777f6a4619115ee;hb=d34336767e45ee801ebb107e40abe4b1acbd3d14#l83
*/
#ifdef MODULE_NEWLIB_NANO
#ifndef _NANO_FORMATTED_IO
#error newlib-nano is enabled but the header is not visible by the build system
#endif /* _NANO_FORMATTED_IO */
#endif /* MODULE_NEWLIB_NANO */
#endif /* MODULE_NEWLIB */
/* Newlib-nano removed the integer only 'iprintf' functions which are now mapped
* to printf.
*
* Source:
*
* https://github.com/32bitmicro/newlib-nano-1.0/blob/f157c994b9a2c4bd8d0cfe9fe8fdd9cd54f8c63b/newlib/README.nano#L32
*
*/
static void test_newlib(void)
{
/*
* Be sure `iprintf` and `printf` are used when `newlib` is included as
* they should be visible in the final elf file for compile time tests
*
* With llvm and samr21-xpro, I could not directly do 'printf == iprintf'.
* But doing `(printf - iprintf) == 0` correctly checked if they are equal.
*/
#ifdef MODULE_NEWLIB
#ifdef MODULE_NEWLIB_NANO
/* Nano maps iprintf to printf */
TEST_ASSERT_MESSAGE((printf - iprintf) == 0, "iprintf == printf");
#else
/* Normal newlib does not */
TEST_ASSERT_MESSAGE((printf - iprintf) != 0, "iprintf != printf");
#endif
#endif
}
static Test *tests_newlib(void)
{
EMB_UNIT_TESTFIXTURES(fixtures) {
new_TestFixture(test_newlib),
};
EMB_UNIT_TESTCALLER(tests, NULL, NULL, fixtures);
return (Test *)&tests;
}
int main(void)
{
puts("Newlib/nano test");
TESTS_START();
TESTS_RUN(tests_newlib());
TESTS_END();
return 0;
}

View File

@ -1,14 +0,0 @@
#!/usr/bin/env python3
# Copyright (C) 2018 Freie Universität Berlin
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
import sys
from testrunner import run_check_unittests
if __name__ == "__main__":
sys.exit(run_check_unittests())