Commit Graph

383 Commits

Author SHA1 Message Date
Idan Horowitz
390a04a985 LibJS: Convert the GetValue AO to ThrowCompletionOr 2021-11-02 19:48:35 +01:00
Idan Horowitz
d73b258874 LibJS: Convert reference deletion to ThrowCompletionOr 2021-11-02 19:48:35 +01:00
Ben Wiederhake
f20a42e871 Kernel: Write test that crashes ProcFS 2021-10-31 18:44:12 +01:00
Idan Horowitz
10b93506ad Tests: Convert test-wasm functions to ThrowCompletionOr 2021-10-31 18:20:37 +02:00
Daniel Bertalan
fed9cb5d2d AK+Tests: Fix formatting of infinity and NaN values
When I added this code in 1472f6d, I forgot to add tests for it. That's
why I didn't realize that the values were appended to the wrong
FormatBuilder object, so an empty string was returned instead of the
expected "nan"/"inf". This made debugging some FPU issues with the
ScummVM port significantly more difficult.
2021-10-31 12:15:34 +01:00
Ali Mohammad Pur
ac856cb965 LibRegex: Don't ignore empty alternatives in append_alternation()
Doing so would cause patterns like `(a|)` to not match the empty string.
2021-10-29 15:57:59 +02:00
Liav A
8554952690 Kernel + WindowServer: Re-define the interface to framebuffer devices
We create a base class called GenericFramebufferDevice, which defines
all the virtual functions that must be implemented by a
FramebufferDevice. Then, we make the VirtIO FramebufferDevice and other
FramebufferDevice implementations inherit from it.
The most important consequence of rearranging the classes is that we now
have one IOCTL method, so all drivers should be committed to not
override the IOCTL method or make their own IOCTLs of FramebufferDevice.
All graphical IOCTLs are known to all FramebufferDevices, and it's up to
the specific implementation whether to support them or discard them (so
we require extensive usage of KResult and KResultOr, together with
virtual characteristic functions).
As a result, the interface is much cleaner and understandable to read.
2021-10-27 07:57:44 +03:00
Jan de Visser
7496f17620 LibSQL Tests: Add tests for SELECT ... WHERE ... 2021-10-25 12:59:42 +02:00
Jelle Raaijmakers
a44978b9b0 LibC: Fix %n conversion specifier in scanf() format
Also add a test to prevent this from happening again. There were two
bugs:

* The number of bytes just after processing the last value was written,
  instead of the number of bytes after skipping remaining whitespace.
  Confirmed by testing against GNU's `scanf()` since the man page
  leaves something to be desired.

* The number of bytes was written to the wrong variable argument; i.e.
  the first argument was overwritten.
2021-10-24 22:43:27 -07:00
Jelle Raaijmakers
00f36fc5ae Tests: Print full 32-byte range of values in TestScanf
We are trying to show 8 u32 values, each of which needs at most 8
hexadecimal characters to be shown entirely.
2021-10-24 22:43:27 -07:00
Jelle Raaijmakers
e71e9de61f Tests: Reword 'output' to 'return value' in TestScanf 2021-10-24 22:43:27 -07:00
Jelle Raaijmakers
e3f17401cb Tests: Use correct argument count for value conformance in TestScanf 2021-10-24 22:43:27 -07:00
Tim Schumacher
65bcee3c62 Tests: Only test truthiness for iswctype 2021-10-24 22:40:11 -07:00
Tim Schumacher
9e3e4a692d Tests: Use proper comparison macros for wctype 2021-10-24 22:40:11 -07:00
Ben Wiederhake
cb868cfa41 AK+Everywhere: Make Base64 decoding fallible 2021-10-23 19:16:40 +01:00
Ben Wiederhake
3bf1f7ae87 AK: Don't crash on invalid Base64 input
In the long-term, we should probably have a way to signal decoding
failure. For now, it should suffice to at least not crash. This is
particularly relevant because apparently this can be triggered while
parsing a PEM certificate, which happens during every TLS connection.

Found by OSS Fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38979
2021-10-23 19:16:40 +01:00
Tim Schumacher
79bcfa967b LibC: Fix up mblen 2021-10-22 13:28:56 -07:00
Tim Schumacher
8df6955838 LibC: Fix up mbtowc
One more proper implementation and one less FIXME.
2021-10-22 13:28:56 -07:00
Liav A
cf0dbc9069 Tests: Add a unit test to ensure the /dev/mem device works correctly
To ensure everything works as expected, a unit test was added with
multiple scenarios.
This binary has to have the SetUID flag, and we also bind-mount the
/usr/Tests directory to allow running of SetUID binaries.
2021-10-22 13:13:00 +02:00
Tim Schumacher
89afd4d063 LibC: Implement mbsnrtowcs 2021-10-21 23:57:32 -07:00
Tim Schumacher
552ae77f0d LibC: Implement wcsnrtombs 2021-10-21 23:57:32 -07:00
Tim Schumacher
e618602433 LibC: Implement mbrlen 2021-10-21 23:47:20 -07:00
Idan Horowitz
44555eb50a LibJS: Convert test-js/test-web/test-wasm to ThrowCompletionOr 2021-10-20 12:27:19 +01:00
Idan Horowitz
40eb3a39d4 LibJS: Rename define_native_function => define_old_native_function
This method will eventually be removed once all native functions are
converted to ThrowCompletionOr
2021-10-20 12:27:19 +01:00
Idan Horowitz
20163c0584 LibJS: Add ThrowCompletionOr versions of the JS native function macros
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and
JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all
native functions were converted to the new format.
2021-10-20 12:27:19 +01:00
Daniel Bertalan
48687c3fbb Tests: Remove Clang workaround from TestSourceLocation
Clang 13 now correctly handles `__builtin_FILE()` and
`-ffile-prefix-map` being specified together, so this test should fully
pass.
2021-10-17 17:09:58 +01:00
Daniel Bertalan
13e6d9d71a LibC: Implement wcslcpy 2021-10-17 17:09:58 +01:00
Idan Horowitz
1639ed7e0a LibJS: Convert to_double() to ThrowCompletionOr 2021-10-17 12:12:35 +01:00
Idan Horowitz
df181809fd LibJS: Convert to_bigint_int64() to ThrowCompletionOr 2021-10-17 12:12:35 +01:00
Tim Schumacher
420bdccf0b LibC: Implement mbsrtowcs 2021-10-15 21:50:19 -07:00
Tim Schumacher
b0babd062e LibC: Implement wcsrtombs 2021-10-15 21:50:19 -07:00
Daniel Bertalan
c8367df746 LibC: Implement wcrtomb
This function converts a single wide character into its multibyte
representation (UTF-8 in our case). It is called from libc++'s
`std::basic_ostream<wchar_t>::flush`, which gets called at program exit
from a global destructor in order to flush `std::wcout`.
2021-10-15 21:50:19 -07:00
Tim Schumacher
4b423a5ec7 LibC: Implement twalk 2021-10-15 21:50:19 -07:00
Tim Schumacher
7448626bae LibC: Implement tfind and tsearch 2021-10-15 21:50:19 -07:00
Linus Groh
52976bfac6 LibJS: Convert to_object() to ThrowCompletionOr 2021-10-13 09:55:10 +01:00
Linus Groh
4d8912a92b LibJS: Convert to_string() to ThrowCompletionOr
Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
2021-10-13 09:55:10 +01:00
Ben Wiederhake
50ad294527 AK: Implement a way to resolve relative paths lexically 2021-10-10 15:18:55 -07:00
Nico Weber
96666f3209 Tests: Fix -Wunreachable-code warnings from clang 2021-10-08 23:33:46 +02:00
Andreas Kling
fc36f830ae Tests: Disable LibThreading detach tests for now
These tests don't pass (at least not without KVM) at the moment,
so let's not run them on CI.
2021-10-06 19:21:35 +02:00
Junior Rantila
1552873275 Tests: Add LibThreading to CMakeLists.txt 2021-10-06 19:05:39 +02:00
Rodrigo Tobar
4b091a7cc2 LibELF: Fix dynamic linking of dlopen()-ed libs
Consider the situation where two shared libraries libA and libB, both
depending (as in having a NEEDED dtag) on libC. libA is first
dlopen()-ed, which produces libC to be mapped and linked. When libB is
dlopen()-ed the DynamicLinker would re-map and re-link libC though,
causing any previous references to its old location to be invalid. And
if libA's PLT has been patched to point to libC's symbols, then any
further invocations to libA will cause the code to jump to a virtual
address that isn't mapped anymore, therefore causing a crash. This
situation was reported in #10014, although the setup was more convolved
in the ticket.

This commit fixes the issue by distinguishing between a main program
loading being performed by Loader.so, and a dlopen() call. The main
difference between these two cases is that in the former the
s_globals_objects maps is always empty, while in the latter it might
already contain dependencies for the library being dlopen()-ed. Hence,
when collecting dependencies to map and link, dlopen() should skip those
that are present in the global map to avoid the issue described above.

With this patch the original issue seen in #10014 is gone, with all
python3 modules (so far) loading correctly.

A unit test reproducing a simplified issue is also included in this
commit. The unit test includes the building of two dynamic libraries A
and B with both depending on libline.so (and B also depending on A); the
test then dlopen()s libA, invokes one its function, then does the same
with libB.
2021-10-06 12:33:21 +02:00
Mahmoud Mandour
0e5b2c923d LibSQL: Add an INSERT without column names test
This adds a passing test of an insert statement that contains no column
names and assumes full tuple input
2021-10-04 15:51:48 +02:00
Mahmoud Mandour
235573f7ba LibSQL: Test INSERT statement with wrong number of values 2021-10-04 15:51:48 +02:00
Mahmoud Mandour
4df85840c3 LibSQL: Test INSERT statement with wrong data types 2021-10-04 15:51:48 +02:00
Mahmoud Mandour
6065383e05 LibSQL: Check NoError individually in execution tests
This enables tests to check that a statement is erroneous, we could not
do so by only calling `execute()` since it asserted that no errors
occurred.
2021-10-04 15:51:48 +02:00
Tim Schumacher
7af7fc8c16 Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
Ali Mohammad Pur
8f722302d9 LibRegex: Use a match table for character classes
Generate a sorted, compressed series of ranges in a match table for
character classes, and use a binary search to find the matches.
This is about a 3-4x speedup for character class match performance. :^)
2021-10-03 19:16:36 +02:00
davidot
ac2c3a73b1 LibJS: Add a specific test for invalid unicode characters in the lexer
Also fixes that it tried to make substrings past the end of the source
if we overran the source length.
2021-10-03 17:42:05 +02:00
Tim Schumacher
4302e7ac26 Tests: Add tests for mbrtowc 2021-10-03 11:13:50 +00:00
Tim Schumacher
67a579aab0 AK: Add a basic formatter for wchar_t 2021-10-03 11:13:50 +00:00