* [PATCH 0/2] lib: print_freq() should output kHz not KHz @ 2020-10-08 20:23 Heinrich Schuchardt 2020-10-08 20:23 ` [PATCH 1/2] " Heinrich Schuchardt 2020-10-08 20:23 ` [PATCH 2/2] test: unit tests for print_freq(), print_size() Heinrich Schuchardt 0 siblings, 2 replies; 9+ messages in thread From: Heinrich Schuchardt @ 2020-10-08 20:23 UTC (permalink / raw) To: u-boot Correct print_freq() for output of kHz. Provide unit tests for print_freq() and print_size(). Heinrich Schuchardt (2): lib: print_freq() should output kHz not KHz test: unit tests for print_freq(), print_size() include/display_options.h | 2 +- lib/display_options.c | 2 +- test/lib/Makefile | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) -- 2.28.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] lib: print_freq() should output kHz not KHz 2020-10-08 20:23 [PATCH 0/2] lib: print_freq() should output kHz not KHz Heinrich Schuchardt @ 2020-10-08 20:23 ` Heinrich Schuchardt 2020-10-09 4:12 ` Stefan Roese 2020-10-23 0:29 ` Tom Rini 2020-10-08 20:23 ` [PATCH 2/2] test: unit tests for print_freq(), print_size() Heinrich Schuchardt 1 sibling, 2 replies; 9+ messages in thread From: Heinrich Schuchardt @ 2020-10-08 20:23 UTC (permalink / raw) To: u-boot In the International System of Units (SI) the prefix kilo is abbreviated as 'k' not 'K'. 'K' is the symbol for Kelvin. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> --- include/display_options.h | 2 +- lib/display_options.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/display_options.h b/include/display_options.h index a0dabca2b8..049688e39e 100644 --- a/include/display_options.h +++ b/include/display_options.h @@ -24,7 +24,7 @@ void print_size(uint64_t size, const char *suffix); /** * print_freq() - Print a frequency with a suffix * - * Print frequencies as "x.xx GHz", "xxx KHz", etc as needed; allow for + * Print frequencies as "x.xx GHz", "xxx kHz", etc as needed; allow for * optional trailing string (like "\n") * * @freq: Frequency to print in Hz diff --git a/lib/display_options.c b/lib/display_options.c index ea9977cc18..b2025eeb5c 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -54,7 +54,7 @@ void print_freq(uint64_t freq, const char *s) { unsigned long m = 0; uint32_t f; - static const char names[] = {'G', 'M', 'K'}; + static const char names[] = {'G', 'M', 'k'}; unsigned long d = 1e9; char c = 0; unsigned int i; -- 2.28.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 1/2] lib: print_freq() should output kHz not KHz 2020-10-08 20:23 ` [PATCH 1/2] " Heinrich Schuchardt @ 2020-10-09 4:12 ` Stefan Roese 2020-10-23 0:29 ` Tom Rini 1 sibling, 0 replies; 9+ messages in thread From: Stefan Roese @ 2020-10-09 4:12 UTC (permalink / raw) To: u-boot On 08.10.20 22:23, Heinrich Schuchardt wrote: > In the International System of Units (SI) the prefix kilo is abbreviated as > 'k' not 'K'. 'K' is the symbol for Kelvin. > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Stefan Roese <sr@denx.de> Thanks, Stefan > --- > include/display_options.h | 2 +- > lib/display_options.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/display_options.h b/include/display_options.h > index a0dabca2b8..049688e39e 100644 > --- a/include/display_options.h > +++ b/include/display_options.h > @@ -24,7 +24,7 @@ void print_size(uint64_t size, const char *suffix); > /** > * print_freq() - Print a frequency with a suffix > * > - * Print frequencies as "x.xx GHz", "xxx KHz", etc as needed; allow for > + * Print frequencies as "x.xx GHz", "xxx kHz", etc as needed; allow for > * optional trailing string (like "\n") > * > * @freq: Frequency to print in Hz > diff --git a/lib/display_options.c b/lib/display_options.c > index ea9977cc18..b2025eeb5c 100644 > --- a/lib/display_options.c > +++ b/lib/display_options.c > @@ -54,7 +54,7 @@ void print_freq(uint64_t freq, const char *s) > { > unsigned long m = 0; > uint32_t f; > - static const char names[] = {'G', 'M', 'K'}; > + static const char names[] = {'G', 'M', 'k'}; > unsigned long d = 1e9; > char c = 0; > unsigned int i; > -- > 2.28.0 > Viele Gr??e, Stefan -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] lib: print_freq() should output kHz not KHz 2020-10-08 20:23 ` [PATCH 1/2] " Heinrich Schuchardt 2020-10-09 4:12 ` Stefan Roese @ 2020-10-23 0:29 ` Tom Rini 1 sibling, 0 replies; 9+ messages in thread From: Tom Rini @ 2020-10-23 0:29 UTC (permalink / raw) To: u-boot On Thu, Oct 08, 2020 at 10:23:23PM +0200, Heinrich Schuchardt wrote: > In the International System of Units (SI) the prefix kilo is abbreviated as > 'k' not 'K'. 'K' is the symbol for Kelvin. > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > Reviewed-by: Stefan Roese <sr@denx.de> Applied to u-boot/master, thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/7c67791a/attachment.sig> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] test: unit tests for print_freq(), print_size() 2020-10-08 20:23 [PATCH 0/2] lib: print_freq() should output kHz not KHz Heinrich Schuchardt 2020-10-08 20:23 ` [PATCH 1/2] " Heinrich Schuchardt @ 2020-10-08 20:23 ` Heinrich Schuchardt 2020-10-09 1:23 ` Sean Anderson 2020-10-22 13:56 ` Tom Rini 1 sibling, 2 replies; 9+ messages in thread From: Heinrich Schuchardt @ 2020-10-08 20:23 UTC (permalink / raw) To: u-boot Provide unit tests for functions print_freq() and print_size(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> --- test/lib/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/test/lib/Makefile b/test/lib/Makefile index 22236f8587..15cd512506 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_device_path.o obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o obj-y += hexdump.o obj-y += lmb.o +obj-y += test_print.o obj-$(CONFIG_SSCANF) += sscanf.o obj-y += string.o obj-$(CONFIG_ERRNO_STR) += test_errno_str.o -- 2.28.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] test: unit tests for print_freq(), print_size() 2020-10-08 20:23 ` [PATCH 2/2] test: unit tests for print_freq(), print_size() Heinrich Schuchardt @ 2020-10-09 1:23 ` Sean Anderson 2020-10-22 13:56 ` Tom Rini 1 sibling, 0 replies; 9+ messages in thread From: Sean Anderson @ 2020-10-09 1:23 UTC (permalink / raw) To: u-boot On 10/8/20 4:23 PM, Heinrich Schuchardt wrote: > Provide unit tests for functions print_freq() and print_size(). > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > --- > test/lib/Makefile | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/test/lib/Makefile b/test/lib/Makefile > index 22236f8587..15cd512506 100644 > --- a/test/lib/Makefile > +++ b/test/lib/Makefile > @@ -7,6 +7,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_device_path.o > obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o > obj-y += hexdump.o > obj-y += lmb.o > +obj-y += test_print.o Should test/lib/test_print.c be included in this patch? --Sean > obj-$(CONFIG_SSCANF) += sscanf.o > obj-y += string.o > obj-$(CONFIG_ERRNO_STR) += test_errno_str.o > -- > 2.28.0 > ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] test: unit tests for print_freq(), print_size() 2020-10-08 20:23 ` [PATCH 2/2] test: unit tests for print_freq(), print_size() Heinrich Schuchardt 2020-10-09 1:23 ` Sean Anderson @ 2020-10-22 13:56 ` Tom Rini 1 sibling, 0 replies; 9+ messages in thread From: Tom Rini @ 2020-10-22 13:56 UTC (permalink / raw) To: u-boot On Thu, Oct 08, 2020 at 10:23:24PM +0200, Heinrich Schuchardt wrote: > Provide unit tests for functions print_freq() and print_size(). > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > --- > test/lib/Makefile | 1 + > 1 file changed, 1 insertion(+) > > -- > 2.28.0 > > diff --git a/test/lib/Makefile b/test/lib/Makefile > index 22236f8587..15cd512506 100644 > --- a/test/lib/Makefile > +++ b/test/lib/Makefile > @@ -7,6 +7,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_device_path.o > obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o > obj-y += hexdump.o > obj-y += lmb.o > +obj-y += test_print.o > obj-$(CONFIG_SSCANF) += sscanf.o > obj-y += string.o > obj-$(CONFIG_ERRNO_STR) += test_errno_str.o New test file missing. -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/e8c99ff2/attachment.sig> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 0/2] lib: print_freq() should output kHz not KHz @ 2020-10-22 19:45 Heinrich Schuchardt 2020-10-22 19:45 ` [PATCH 2/2] test: unit tests for print_freq(), print_size() Heinrich Schuchardt 0 siblings, 1 reply; 9+ messages in thread From: Heinrich Schuchardt @ 2020-10-22 19:45 UTC (permalink / raw) To: u-boot Correct print_freq() for output of kHz. Provide unit tests for print_freq() and print_size(). v2: add missing test/lib/test_print.c Heinrich Schuchardt (2): lib: print_freq() should output kHz not KHz test: unit tests for print_freq(), print_size() include/display_options.h | 2 +- lib/display_options.c | 2 +- test/lib/Makefile | 1 + test/lib/test_print.c | 71 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 test/lib/test_print.c -- 2.28.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] test: unit tests for print_freq(), print_size() 2020-10-22 19:45 [PATCH 0/2] lib: print_freq() should output kHz not KHz Heinrich Schuchardt @ 2020-10-22 19:45 ` Heinrich Schuchardt 2020-10-24 14:52 ` Tom Rini 0 siblings, 1 reply; 9+ messages in thread From: Heinrich Schuchardt @ 2020-10-22 19:45 UTC (permalink / raw) To: u-boot Provide unit tests for functions print_freq() and print_size(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> --- v2: add missing add missing test/lib/test_print.c --- test/lib/Makefile | 1 + test/lib/test_print.c | 71 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 test/lib/test_print.c diff --git a/test/lib/Makefile b/test/lib/Makefile index 22236f8587..15cd512506 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_device_path.o obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o obj-y += hexdump.o obj-y += lmb.o +obj-y += test_print.o obj-$(CONFIG_SSCANF) += sscanf.o obj-y += string.o obj-$(CONFIG_ERRNO_STR) += test_errno_str.o diff --git a/test/lib/test_print.c b/test/lib/test_print.c new file mode 100644 index 0000000000..1d497d0041 --- /dev/null +++ b/test/lib/test_print.c @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Tests for print functions + * + * Copyright 2020, Heinrich Schuchadt <xypron.glpk@gmx.de> + */ + +#include <common.h> +#include <command.h> +#include <display_options.h> +#include <test/lib.h> +#include <test/test.h> +#include <test/ut.h> + +DECLARE_GLOBAL_DATA_PTR; + +static int test_print_freq(struct unit_test_state *uts, + uint64_t freq, char *expected) +{ + console_record_reset_enable(); + print_freq(freq, ";\n"); + gd->flags &= ~GD_FLG_RECORD; + console_record_readline(uts->actual_str, sizeof(uts->actual_str)); + ut_asserteq_str(expected, uts->actual_str); + ut_assertok(ut_check_console_end(uts)); + return 0; +} + +static int lib_test_print_freq(struct unit_test_state *uts) +{ + ut_assertok(test_print_freq(uts, 321, "321 Hz;")); + ut_assertok(test_print_freq(uts, 4321, "4.32 kHz;")); + ut_assertok(test_print_freq(uts, 54321, "54.32 kHz;")); + ut_assertok(test_print_freq(uts, 654321, "654.32 kHz;")); + ut_assertok(test_print_freq(uts, 7654321, "7.66 MHz;")); + ut_assertok(test_print_freq(uts, 87654321, "87.66 MHz;")); + ut_assertok(test_print_freq(uts, 987654321, "987.66 MHz;")); + ut_assertok(test_print_freq(uts, 1987654321, "1.99 GHz;")); + ut_assertok(test_print_freq(uts, 54321987654321, "54321.99 GHz;")); + return 0; +} + +LIB_TEST(lib_test_print_freq, 0); + +static int test_print_size(struct unit_test_state *uts, + uint64_t freq, char *expected) +{ + console_record_reset_enable(); + print_size(freq, ";\n"); + gd->flags &= ~GD_FLG_RECORD; + console_record_readline(uts->actual_str, sizeof(uts->actual_str)); + ut_asserteq_str(expected, uts->actual_str); + ut_assertok(ut_check_console_end(uts)); + return 0; +} + +static int lib_test_print_size(struct unit_test_state *uts) +{ + ut_assertok(test_print_size(uts, 321, "321 Bytes;")); + ut_assertok(test_print_size(uts, 4321, "4.2 KiB;")); + ut_assertok(test_print_size(uts, 54321, "53 KiB;")); + ut_assertok(test_print_size(uts, 654321, "639 KiB;")); + ut_assertok(test_print_size(uts, 7654321, "7.3 MiB;")); + ut_assertok(test_print_size(uts, 87654321, "83.6 MiB;")); + ut_assertok(test_print_size(uts, 987654321, "941.9 MiB;")); + ut_assertok(test_print_size(uts, 1987654321, "1.9 GiB;")); + ut_assertok(test_print_size(uts, 54321987654321, "49.4 TiB;")); + return 0; +} + +LIB_TEST(lib_test_print_size, 0); -- 2.28.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] test: unit tests for print_freq(), print_size() 2020-10-22 19:45 ` [PATCH 2/2] test: unit tests for print_freq(), print_size() Heinrich Schuchardt @ 2020-10-24 14:52 ` Tom Rini 0 siblings, 0 replies; 9+ messages in thread From: Tom Rini @ 2020-10-24 14:52 UTC (permalink / raw) To: u-boot On Thu, Oct 22, 2020 at 09:45:28PM +0200, Heinrich Schuchardt wrote: > Provide unit tests for functions print_freq() and print_size(). > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Applied to u-boot/master, thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201024/ad73a117/attachment.sig> ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-10-24 14:52 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-10-08 20:23 [PATCH 0/2] lib: print_freq() should output kHz not KHz Heinrich Schuchardt 2020-10-08 20:23 ` [PATCH 1/2] " Heinrich Schuchardt 2020-10-09 4:12 ` Stefan Roese 2020-10-23 0:29 ` Tom Rini 2020-10-08 20:23 ` [PATCH 2/2] test: unit tests for print_freq(), print_size() Heinrich Schuchardt 2020-10-09 1:23 ` Sean Anderson 2020-10-22 13:56 ` Tom Rini 2020-10-22 19:45 [PATCH 0/2] lib: print_freq() should output kHz not KHz Heinrich Schuchardt 2020-10-22 19:45 ` [PATCH 2/2] test: unit tests for print_freq(), print_size() Heinrich Schuchardt 2020-10-24 14:52 ` Tom Rini
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.