qemu-e2k/tests/unit
Eric Blake 42cc08d13a cutils: Improve qemu_strtosz handling of fractions
We have several limitations and bugs worth fixing; they are
inter-related enough that it is not worth splitting this patch into
smaller pieces:

* ".5k" should work to specify 512, just as "0.5k" does
* "1.9999k" and "1." + "9"*50 + "k" should both produce the same
  result of 2048 after rounding
* "1." + "0"*350 + "1B" should not be treated the same as "1.0B";
  underflow in the fraction should not be lost
* "7.99e99" and "7.99e999" look similar, but our code was doing a
  read-out-of-bounds on the latter because it was not expecting ERANGE
  due to overflow. While we document that scientific notation is not
  supported, and the previous patch actually fixed
  qemu_strtod_finite() to no longer return ERANGE overflows, it is
  easier to pre-filter than to try and determine after the fact if
  strtod() consumed more than we wanted.  Note that this is a
  low-level semantic change (when endptr is not NULL, we can now
  successfully parse with a scale of 'E' and then report trailing
  junk, instead of failing outright with EINVAL); but an earlier
  commit already argued that this is not a high-level semantic change
  since the only caller passing in a non-NULL endptr also checks that
  the tail is whitespace-only.

Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1629
Fixes: cf923b78 ("utils: Improve qemu_strtosz() to have 64 bits of precision", 6.0.0)
Fixes: 7625a1ed ("utils: Use fixed-point arithmetic in qemu_strtosz", 6.0.0)
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Message-Id: <20230522190441.64278-20-eblake@redhat.com>
[eblake: tweak function comment for accuracy]
2023-06-02 12:29:27 -05:00
..
check-block-qdict.c tests: unit: add NULL-pointer check 2022-09-18 09:17:41 +02:00
check-qdict.c
check-qjson.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
check-qlist.c
check-qlit.c
check-qnull.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
check-qnum.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
check-qobject.c tests: remove block/qdict checks from check-qobject.c 2022-04-21 17:03:51 +04:00
check-qom-interface.c
check-qom-proplist.c include: add qemu/keyval.h 2022-04-21 17:03:51 +04:00
check-qstring.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
crypto-tls-psk-helpers.c tests: avoid DOS line endings in PSK file 2022-10-27 11:55:41 +01:00
crypto-tls-psk-helpers.h tests: add migration tests of TLS with PSK credentials 2022-05-16 11:46:04 +01:00
crypto-tls-x509-helpers.c tests: fix encoding of IP addresses in x509 certs 2022-05-16 11:46:04 +01:00
crypto-tls-x509-helpers.h tests: add more helper macros for creating TLS x509 certs 2022-05-16 11:46:04 +01:00
io-channel-helpers.c tests/channel-helper: set blocking in main thread 2022-10-12 19:22:01 +04:00
io-channel-helpers.h
iothread.c
iothread.h
meson.build aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
pkix_asn1_tab.c
ptimer-test-stubs.c async: Add an optional reentrancy guard to the BH API 2023-04-28 11:31:07 +02:00
ptimer-test.c tests/unit: Replace g_memdup() by g_memdup2() 2022-07-18 20:24:36 +02:00
ptimer-test.h
rcutorture.c Updated the FSF address to <https://www.gnu.org/licenses/> 2023-02-27 09:15:39 +01:00
socket-helpers.c win32: replace closesocket() with close() wrapper 2023-03-13 15:39:31 +04:00
socket-helpers.h tests/unit: Update test-io-channel-socket.c for Windows 2022-09-02 15:54:47 +04:00
test-aio-multithread.c test-aio-multithread: simplify test_multi_co_schedule 2023-05-08 11:10:48 +02:00
test-aio.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
test-authz-list.c
test-authz-listfile.c
test-authz-pam.c
test-authz-simple.c
test-base64.c
test-bdrv-drain.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
test-bdrv-graph-mod.c test-bdrv-graph-mod: fix filters to be filters 2022-10-27 20:14:11 +02:00
test-bitcnt.c
test-bitmap.c
test-bitops.c
test-block-backend.c
test-block-iothread.c raw-format: Fix open with 'file' in iothread 2023-05-30 17:21:23 +02:00
test-blockjob-txn.c jobs: use job locks also in the unit tests 2022-10-07 12:11:41 +02:00
test-blockjob.c tests/unit/test-blockjob: Disable complete_in_standby test 2023-03-20 12:43:50 +01:00
test-bufferiszero.c
test-char.c qapi chardev: Elide redundant has_FOO in generated C 2022-12-14 20:04:47 +01:00
test-clone-visitor.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
test-coroutine.c coroutine: Clean up superfluous inclusion of qemu/lockable.h 2023-01-19 10:18:28 +01:00
test-crypto-afsplit.c
test-crypto-akcipher.c tests/crypto: Add test suite for RSA keys 2022-05-26 11:41:56 +01:00
test-crypto-block.c qapi crypto: Elide redundant has_FOO in generated C 2022-12-14 20:04:47 +01:00
test-crypto-cipher.c
test-crypto-der.c crypto: Support DER encodings 2022-11-02 06:56:32 -04:00
test-crypto-hash.c
test-crypto-hmac.c
test-crypto-ivgen.c
test-crypto-pbkdf.c
test-crypto-secret.c test: Fix test-crypto-secret when compiling without keyring support 2023-04-20 06:50:11 +02:00
test-crypto-tlscredsx509.c tests: Use g_mkdir_with_parents() 2022-08-25 15:24:09 +02:00
test-crypto-tlssession.c Call qemu_socketpair() instead of socketpair() when possible 2023-01-16 17:42:17 +01:00
test-crypto-xts.c
test-cutils.c cutils: Improve qemu_strtosz handling of fractions 2023-06-02 12:29:27 -05:00
test-div128.c
test-error-report.c error: add global &error_warn destination 2023-03-13 15:23:37 +04:00
test-forward-visitor.c include: add qemu/keyval.h 2022-04-21 17:03:51 +04:00
test-hbitmap.c Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
test-image-locking.c tests/unit/test-image-locking: Fix handling of temporary files 2022-10-12 12:48:53 +02:00
test-int128.c qemu/int128: add int128_urshift 2022-04-20 18:00:30 -03:00
test-interval-tree.c util: Add interval-tree.c 2022-12-20 17:09:41 -08:00
test-io-channel-buffer.c
test-io-channel-command.c tests: fix path separator, use g_build_filename() 2023-03-13 15:39:31 +04:00
test-io-channel-file.c tests: replace pipe() with g_unix_open_pipe(CLOEXEC) 2022-05-03 15:46:08 +04:00
test-io-channel-null.c io: add a QIOChannelNull equivalent to /dev/null 2022-06-22 18:11:21 +01:00
test-io-channel-socket.c io: Add support for MSG_PEEK for socket channel 2023-02-06 19:22:56 +01:00
test-io-channel-tls.c Call qemu_socketpair() instead of socketpair() when possible 2023-01-16 17:42:17 +01:00
test-io-task.c
test-iov.c tests/unit: Replace g_memdup() by g_memdup2() 2022-07-18 20:24:36 +02:00
test-keyval.c include: add qemu/keyval.h 2022-04-21 17:03:51 +04:00
test-logging.c util/log: Remove qemu_log_close 2022-04-20 10:51:11 -07:00
test-mul64.c
test-nested-aio-poll.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
test-opts-visitor.c
test-qapi-util.c
test-qdev-global-props.c
test-qdist.c
test-qemu-opts.c
test-qga.c qga: test: Add tests for merged flag 2023-05-04 09:12:48 +00:00
test-qgraph.c
test-qht.c
test-qmp-cmds.c tests: add G_GNUC_PRINTF for various functions 2023-01-11 10:44:34 +01:00
test-qmp-event.c qapi tests: Elide redundant has_FOO in generated C 2022-12-13 18:31:37 +01:00
test-qobject-input-visitor.c qapi: allow unions to contain further unions 2023-04-26 07:52:45 +02:00
test-qobject-output-visitor.c qapi: allow unions to contain further unions 2023-04-26 07:52:45 +02:00
test-qtree.c util: import GTree as QTree 2023-03-28 15:23:10 -07:00
test-rcu-list.c replace TABs with spaces 2023-03-20 12:43:50 +01:00
test-rcu-simpleq.c
test-rcu-slist.c
test-rcu-tailq.c
test-replication.c
test-seccomp.c Don't include headers already included by qemu/osdep.h 2023-02-08 07:28:05 +01:00
test-shift128.c
test-smp-parse.c tests/unit/test-smp-parse: Keep default MIN/MAX CPUs in machine_base_class_init 2021-12-31 13:42:48 +01:00
test-string-input-visitor.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
test-string-output-visitor.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
test-thread-pool.c tests: mark more coroutine_fns 2023-04-25 13:17:28 +02:00
test-throttle.c
test-timed-average.c
test-util-filemonitor.c
test-util-sockets.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
test-uuid.c
test-visitor-serialization.c qapi tests: Elide redundant has_FOO in generated C 2022-12-13 18:31:37 +01:00
test-vmstate.c test-vmstate: fix bad GTree usage, use-after-free 2023-03-02 17:06:27 +01:00
test-write-threshold.c
test-x86-cpuid.c
test-xbzrle.c migration/xbzrle: Use i386 host/cpuinfo.h 2023-05-23 16:51:18 -07:00
test-xs-node.c hw/xen: Add foreignmem operations to allow redirection to internal emulation 2023-03-07 17:04:30 +00:00
test-yank.c