Commit graph

178 commits

Author SHA1 Message Date
Christophe de Dinechin
0df86b131f simulator: Avoid crash rendering %t in recorder
If we print a really large value, we need to cut off what we print.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
838938336e menus: Place ListMenu as a keyboard-accesisble menu
Remove the `DataMenu`.

Replace `PrintMenu` with `ListMenu` as keyboard-accessible menu
(we can tuck the rarely used `PrintMenu` under `I/O`)

Add list product, sum, etc to `ListMenu`

Modify `ProgramMenu` to add special program entry characters.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
30fdb68279 tests: Additional key processing in Wait and Show commands
The new sync between tests and RPL theads was not working correctly in
the case of `Wait` and `Show` commands because they were popping keys
without correctly updating `last_key`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
3bdafe49b5 tests: Increase memory size to avoid failing tests
Some tests fail running out of memory:

```
../src/tests.cc:2669:  Test #21: highp: High-precision computations (60 digits)
../src/tests.cc:2669:  21:045.001: cbrt
../src/tests.cc:2669:    Expected output [0.68470 21277 57224 16184 09277 32646 81496 28057 14749 53139 45950 35873 52977 73009 35191 71304 84396 28932 73625 07589 02266 77954 73690 2353], got error [Out of memory] instead
```

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
a7f9fd4cab tests: Another refactoring of the test interface with RPL thread
Split the recorders between `tests` and `tests_rpl`.
Separate the handling of commands into `process_test_commands` and
`process_test_key`, with the key handling happening before we actually
run the code.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
189abcf40c tests: Timing information
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
88207e7eff simulator: Accelerate sys_sleep when running tests
This significantly improves the performance of tests by avoiding
delays waiting to process keys.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
1f6f148634 tests: Reorganize synchronization between RPL thread and tests
Use a separate channel for the communication of test commands with
the RPL thread, in order to make it simpler to deal with corner cases
such as an error being displayed.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
1e71991af2 tests: Add a delay before launching the test thread
This delay is necessary to avoid an occasional crash at startup when
running with `-Tall` and loading a large demo file.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:14 +01:00
Christophe de Dinechin
e24546b87a simulator: Add I/O wrapper
Put some common code for saving and restoring files in a wrapper.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
8f2fc58497 simulator: Add interface to report file errors
When writing to a file and there is an error, make sure we see it.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
b1c9856611 simulator: Add F8 key to save state in the simulator
This is a shortcut to save the current state.
Note that you can also get that with RSHIFT-EXIT.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
79760be3e4 dmcp: Avoid double return in the code
Two returns one after another are one too many.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
dbdca4f69b simulator: Accept numeric keys in DMCP menus
When hitting 1-9, trigger the corresponding DMCP menu.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Kjell Christenson
3a93d07788 Fixed problem in simulator missing quick mouse clicks
If two mouse clicks are issued quickly, the second one has the type
QEvent::MouseButtonDblClick.  This leads to the event being ignored.
This is now fixed.

Signed-off-by: Kjell Christenson <kjell.christenson@gmail.com>
Reviewed-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
eb4757bb69 tests: Run command-line tests silently
Do not simulate sound while running tests from the command-line.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:42 +01:00
Christophe de Dinechin
21151aaf60 dmcp: Do not treat the buzzer as error
Do not show `recorder` entries for calls to buzzer functions in DMCP.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-15 21:37:58 +01:00
Christophe de Dinechin
0255b867ad audio: Try to ensure audio always works
There is a problem with repeating error messages.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-15 21:37:58 +01:00
Christophe de Dinechin
dbd6886660 linux: Rewrite the audio-generation code to avoid crashes
The old audio-generation code was crashing on Linux deep in Qt.
Took the audiooutput example from Qt and tweaked it to match.
2024-03-14 18:37:52 +01:00
Christophe de Dinechin
cfe94ca0e0 linux: Add -s option for screen scaling
The `qApp->primaryScreen()->devicePixelRatio()` method no longer
returns the correct pixel ratio at least on X11 over the network.

Add the `-s` option as a workaround to be able to auto-scale the
window for testing purpose.
2024-03-14 01:08:53 +01:00
Christophe de Dinechin
b271555841 linux: Try to avoid a crash in audio
In reality, the problem is inside `audio->stop()`. `Beep` crashes.
2024-03-14 00:42:53 +01:00
Christophe de Dinechin
51c254b298 linux: Address warnings about missing initializers
It looks like gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4) thinks it's a good
idea to complain about every single zero-initialized C structure.

This is widely acknowledged as a (rather annoying)
[GCC bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119)

Add a constructor to silence the warning where possible.
For DMCP C structures where this is not possible, well, add ugly code.
2024-03-13 23:25:15 +01:00
Christophe de Dinechin
483a591986 linux: Remove warning about fall-through switch statement
With gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4), there is a message about
fall-through switch statements. Add comment to silence the warning when the
fall-through is intentional.

There was one case where the fall-through was not intentional.
Missing `break` added.

Fixes: #853
2024-03-13 23:25:15 +01:00
Christophe de Dinechin
f06d17afab linux: Remove warnings about unused arguments
On Fedora 38, GCC incorrectly warns about unused arguments despite the
`__attribute__((unused)))` that should silence the warning.

Observed with gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4).

Fixes: #853
2024-03-13 21:23:55 +01:00
Christophe de Dinechin
745b7227aa simulator: Do not try to create directory if it exists
This is just to avoid setting `errno` when we are just trying to
make sure that the directory exists.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-12 09:49:54 +01:00
Christophe de Dinechin
9e95425850 library: Add equations library and object library
These are two catalogs that behave much like the constants catalog,
and inherit most of the code.

The equations library is intended to store standard equations.

The library is for standard objects and various useful objects or
programs.

Both can be organized by topics.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 11:20:42 +01:00
Christophe de Dinechin
784f07b2c7 tests: Add extra delay in the wait for update
Instead of proactively wait, add a wait loop checking for the result.
This allows the tests to run significantly faster.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 01:49:10 +01:00
Christophe de Dinechin
c62b792b19 characterss: Add dynamic characters menu
Same principle as constants and units, but simpler.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 01:49:09 +01:00
Christophe de Dinechin
9be0f00eb6 simulator: Avoid piling up QT draw requests
Make sure that we capture consistent pixmaps, which we can do on the
RPL thread, and only defer the transfer of the pixmap to the main
thread, which is fast.

Additionally, optimize updates by doing a byte-by-byte xor comparison
in order to see which bytes actually changed. This minimizes the cost
on the RPL thread to update the pixmap.

This makes it possible to have a much better screen behaviour for the
`CBench` benchmark, where it updates it regularly on the screen while
not slowing things down too much.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 16:18:11 +01:00
Christophe de Dinechin
97cc7f90bd simulator: Add sound support
Add basic sound simulation in Qt

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
a5493f1e1c simulator: Lazy screen refresh
Perform screen refresh on demand instead of timer-based.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
75478a90e3 dmcp: Add UI refresh callback
Add a callback to explicitly refresh the screen instead of relying on
a volatile counter indicating that the screen is dirty.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
84764d71b1 simulator: Move QT-dependent code out of dmcp.cpp
Split the user-interface portion and the execution portion

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
4fc7e9c5b3 runtime: Various changes to isolate QT build from the rest
Being able to isolate parts that actually use QT is important
to build other platforms.
2024-03-05 12:36:42 +01:00
Christophe de Dinechin
3c48208759 dmcp: Day of week convention adjustment
By convention, 0 is Monday for DMCP, but Sunday for Unix.
I managed to not notice until now...

Fixes: #838

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 22:04:09 +01:00
Christophe de Dinechin
b0efb0ab44 simulator: Add screenshot keys
When hitting the F9 key, take a partial screen snapshot directly
(partial meaning no header).

When hitting the F8 key, take a screen snapshot using the `Screenshot`
command, which is now implemented on the simulator.

Also reduce the size of the window a little so that we can take video
snapshots that are 720 x 400 pixels and capture the keyboard.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
d5a621bbe7 tests: Interrupt tests when pressing the F11 or F12 key
While the test is running, make it possible to interrupt the test
thread at any time.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
418b5e2919 simulator: Adjust DMCP month off-by-one error
The DMCP convention is for the month field to start at 1.
Integrate that in our emulation.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
9b451d7887 time: Add ChronoTime command
The `ChronoTime` command returns time with centisecond precision.

Fixes: #827

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
bbec0939c8 date/time: Refactor the code and add Julian day number
Refactor the code to put all date and time related functions into the
`datetime.h` and `datetime.cc` files.

Also added Julian day number calculations, which enable the
computation of the day of the week in the date format rendering, and
will make it easier to implement future commands such as `DDAYS`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
13958d1ac1 time: Add commands to set the system date and time
Add the `→Date` command to set the system date,
and the `→Time` command to set the system time.

Fixes: #823

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
2782e32e42 expressions: Graphics rendering
Graphics rendering of expressions

Fixes: #47

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
beaaee23e4 constants: Evaluate constants from config/constants.csv
Dynamic constants menu, similar to units menu, which is populated
either from an internal table, or from `config/constants.csv`

Fixes: #497

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 00:55:00 +01:00
Christophe de Dinechin
c12d27ac8b hwfp: Add support for hardware-accelerated floating-point
The hardware-accelerated floating-point support in the ARM chip is
about 2000 faster than the variable-precision decimal floating point
implementation. It makes sense to use it.

See numbers recorded in `doc/6-Performance.md` for details.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
969c5325a3 tests: Add tests for on-line help
Add tests for the various on-line help features.

Fixes: #791

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-21 23:28:30 +01:00
Christophe de Dinechin
6cffed9615 tests: Add image checking for graphical tests
Add image checking from saved image references as a way to check that
the generated pixmaps are consistent from run to run.

Fixes: #732

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-20 20:43:45 +01:00
Christophe de Dinechin
ae1b04c2be tests: Make it possible to individually run tests.
Each test is controlled by a specific recorder tweak.

The `-T` option can now take a test name, e.g. `-Tkeyboard` to run
only that test in an automated way.

The `-O` option can select a single test for interactive testing with
the F12 key.

In both cases, the name follows the recorder syntax.

Fixes: #728

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-18 22:50:47 +01:00
Christophe de Dinechin
1507f36dc5 tests: Replace magic constant -1 with EXIT_PGM
We use `-1` to mark the termination of the RPL thread and request the
state to be saved on disk.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-18 22:48:16 +01:00
Christophe de Dinechin
71a4798534 dmcp: Make sure the tests don't block on wait_for_key
A call to `wait_for_key()` would prevent the key sync counters from
being updated, and as a result, the test suite would stop.

Fixes: #731

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-18 22:47:52 +01:00
Christophe de Dinechin
6f2158107e decimal: Remove all the BID128 stubs and related decimal types
Remove all the bid128 interfaces to make room for the decimal stuff.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-25 19:33:06 +01:00