summaryrefslogtreecommitdiff
path: root/Tests
AgeCommit message (Collapse)Author
2022-12-15LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtrLinus Groh
2022-12-14AK: Create relative path even if prefix is not an ancestor of the pathPoseydon42
2022-12-14LibSQL: Support 64-bit integer values and handle overflow errorsTimothy Flynn
Currently, integers are stored in LibSQL as 32-bit signed integers, even if the provided type is unsigned. This resulted in a series of unchecked unsigned-to-signed conversions, and prevented storing 64-bit values. Further, mathematical operations were performed without similar checks, and without checking for overflow. This changes SQL::Value to behave like SQLite for INTEGER types. In SQLite, the INTEGER type does not imply a size or signedness of the underlying type. Instead, SQLite determines on-the-fly what type is needed as values are created and updated. To do so, the SQL::Value variant can now hold an i64 or u64 integer. If a specific type is requested, invalid conversions are now explictly an error (e.g. converting a stored -1 to a u64 will fail). When binary mathematical operations are performed, we now try to coerce the RHS value to a type that works with the LHS value, failing the operation if that isn't possible. Any overflow or invalid operation (e.g. bitshifting a 64-bit value by more than 64 bytes) is an error.
2022-12-14LibSQL: Ungracefully handle database version incompatibilitiesTimothy Flynn
In the long run, this is obviously a bad way to handle version changes to the SQL database files. We will want to migrate old databases to new formats. Until we figure out a good way to do that, wipe old databases so that we don't crash trying to read incompatible data.
2022-12-14LibJS: Remove Object(Object& prototype) footgunAndreas Kling
This constructor was easily confused with a copy constructor, and it was possible to accidentally copy-construct Objects in at least one way that we dicovered (via generic ThrowCompletionOr construction). This patch adds a mandatory ConstructWithPrototypeTag parameter to the constructor to disambiguate it.
2022-12-14Everywhere: Stop shoving things into ::std and mentioning them as suchAli Mohammad Pur
Note that this still keeps the old behaviour of putting things in std by default on serenity so the tools can be happy, but if USING_AK_GLOBALLY is unset, AK behaves like a good citizen and doesn't try to put things in the ::std namespace. std::nothrow_t and its friends get to stay because I'm being told that compilers assume things about them and I can't yeet them into a different namespace...for now.
2022-12-14LibJS: Convert TypedArray::create() to NonnullGCPtrLinus Groh
2022-12-12LibCompress: Port `DeflateDecompressor` to `Core::Stream`Tim Schumacher
2022-12-12AK: Introduce cutoff to insertion sort for QuicksortMarc Luqué
Implement insertion sort in AK. The cutoff value 7 is a magic number here, values [5, 15] should work well. Main idea of the cutoff is to reduce recursion performed by quicksort to speed up sorting of small partitions.
2022-12-12LibCore: Propagate errors from `Stream::*_entire_buffer`Tim Schumacher
2022-12-12LibCore: Rename `Stream::*_or_error` to `*_entire_buffer`Tim Schumacher
All of our functions are `_or_error` (or are about to be), and maybe making it less reminiscient of AK::Stream will make people use it more.
2022-12-12LibCore: Rename `Stream::read_all` to `read_until_eof`Tim Schumacher
This generally seems like a better name, especially if we somehow also need a better name for "read the entire buffer, but not the entire file" somewhere down the line.
2022-12-12LibCore: Remove `Stream::is_{readable,writable}`Tim Schumacher
Next to functions like `is_eof` these were really confusing to use, and the `read`/`write` functions should fail anyways if a stream is not readable/writable.
2022-12-11Kernel+LibC+Tests: Implement `pwritev(2)`sin-ack
While this isn't really POSIX, it's needed by the Zig port and was simple enough to implement.
2022-12-11Tests: Update thread tests and make them passkleines Filmröllchen
The existing tests have only mildly changed, and there is another test for joining dead non-detached threads.
2022-12-11AK: Add LexicalPath::is_child_ofkleines Filmröllchen
This API checks whether this path is a child of (or the same as) another path.
2022-12-10test-test262: Use HashMap::try_ensure_capacityThomas Queiroz
2022-12-10LibCompress: Port GzipDecompressor to `Core::Stream`Tim Schumacher
2022-12-09AK: Unref old m_data in String's move assignmentMaciej
We were overridding the data pointer without unreffing it, causing a memory leak when assigning a String.
2022-12-08AK: Add formatters for Span<T> and Span<T const>Timothy Flynn
This generalizes the formatter currently used for Vector to be usable for any Span.
2022-12-08LibCore: Move `Core::Stream::File::exists()` to `Core::File`Tim Schumacher
`Core::Stream::File` shouldn't hold any utility methods that are unrelated to constructing a `Core::Stream`, so let's just replace the existing `Core::File::exists` with the nicer looking implementation.
2022-12-08Tests: Add tests for Checked<> decrement operatorPoseydon42
2022-12-07LibJS: Replace standalone js_bigint() with BigInt::create()Linus Groh
Three standalone Cell creation functions remain in the JS namespace: - js_bigint() - js_string() - js_symbol() All of them are leftovers from early iterations when LibJS still took inspiration from JSC, which itself has jsString(). Nowadays, we pretty much exclusively use static create() functions to construct types allocated on the JS heap, and there's no reason to not do the same for these. Also change the return type from BigInt* to NonnullGCPtr<BigInt> while we're here. This is patch 1/3, replacement of js_string() and js_symbol() follow.
2022-12-07LibSQL: Parse and execute sequential placeholder valuesTimothy Flynn
This partially implements SQLite's bind-parameter expression to support indicating placeholder values in a SQL statement. For example: INSERT INTO table VALUES (42, ?); In the above statement, the '?' identifier is a placeholder. This will allow clients to compile statements a single time while running those statements any number of times with different placeholder values. Further, this will help mitigate SQL injection attacks.
2022-12-07LibSQL: Partially implement the UPDATE commandTimothy Flynn
This implements enough to update rows filtered by a WHERE clause.
2022-12-06AK: Introduce the new String, replacement for DeprecatedStringAndreas Kling
DeprecatedString (formerly String) has been with us since the start, and it has served us well. However, it has a number of shortcomings that I'd like to address. Some of these issues are hard if not impossible to solve incrementally inside of DeprecatedString, so instead of doing that, let's build a new String class and then incrementally move over to it instead. Problems in DeprecatedString: - It assumes string allocation never fails. This makes it impossible to use in allocation-sensitive contexts, and is the reason we had to ban DeprecatedString from the kernel entirely. - The awkward null state. DeprecatedString can be null. It's different from the empty state, although null strings are considered empty. All code is immediately nicer when using Optional<DeprecatedString> but DeprecatedString came before Optional, which is how we ended up like this. - The encoding of the underlying data is ambiguous. For the most part, we use it as if it's always UTF-8, but there have been cases where we pass around strings in other encodings (e.g ISO8859-1) - operator[] and length() are used to iterate over DeprecatedString one byte at a time. This is done all over the codebase, and will *not* give the right results unless the string is all ASCII. How we solve these issues in the new String: - Functions that may allocate now return ErrorOr<String> so that ENOMEM errors can be passed to the caller. - String has no null state. Use Optional<String> when needed. - String is always UTF-8. This is validated when constructing a String. We may need to add a bypass for this in the future, for cases where you have a known-good string, but for now: validate all the things! - There is no operator[] or length(). You can get the underlying data with bytes(), but for iterating over code points, you should be using an UTF-8 iterator. Furthermore, it has two nifty new features: - String implements a small string optimization (SSO) for strings that can fit entirely within a pointer. This means up to 3 bytes on 32-bit platforms, and 7 bytes on 64-bit platforms. Such small strings will not be heap-allocated. - String can create substrings without making a deep copy of the substring. Instead, the superstring gets +1 refcount from the substring, and it acts like a view into the superstring. To make substrings like this, use the substring_with_shared_superstring() API. One caveat: - String does not guarantee that the underlying data is null-terminated like DeprecatedString does today. While this was nifty in a handful of places where we were calling C functions, it did stand in the way of shared-superstring substrings.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-12-05LibAudio: Switch LoaderPlugin to a more traditional constructor patternTim Schumacher
This now prepares all the needed (fallible) components before actually constructing a LoaderPlugin object, so we are no longer filling them in at an arbitrary later point in time.
2022-12-03Everywhere: Run clang-formatLinus Groh
2022-12-03test262-runner: Add option to enable bytecode optimizationsIdan Horowitz
2022-11-30LibSQL: Partially implement the DELETE commandTimothy Flynn
This implements enough to delete rows filtered by a WHERE clause.
2022-11-30LibSQL+SQLServer: Return a NonnullRefPtr from Database::get_tableTimothy Flynn
Database::get_table currently either returns a RefPtr to an existing table, a nullptr if the table doesn't exist, or an Error if some internal error occured. Change this to return a NonnullRefPtr to an exisiting table, or a SQL::Result with any error, including if the table was not found. Callers can then handle that specific error code if they want. Returning a NonnullRefPtr will enable some further cleanup. This had some fallout of needing to change some other methods' return types from AK::ErrorOr to SQL::Result so that TRY may continue to be used.
2022-11-30LibSQL+SQLServer: Return a NonnullRefPtr from Database::get_schemaTimothy Flynn
Database::get_schema currently either returns a RefPtr to an existing schema, a nullptr if the schema doesn't exist, or an Error if some internal error occured. Change this to return a NonnullRefPtr to an exisiting schema, or a SQL::Result with any error, including if the schema was not found. Callers can then handle that specific error code if they want. Returning a NonnullRefPtr will enable some further cleanup. This had some fallout of needing to change some other methods' return types from AK::ErrorOr to SQL::Result so that TRY may continue to be used.
2022-11-29Tests/Kernel: Add a very simple test for posix_fallocate()Andreas Kling
2022-11-26LibGL: Add some tests for the buffer APIcflip
2022-11-26LibSQL: Fix BTree corruption in `TreeNode::split`Jelle Raaijmakers
After splitting a node, the new node was written to the same pointer as the current node - probably a copy / paste error. This new code requires a `.pointer() -> u32` to exist on the object to be serialized, preventing this issue from happening again. Fixes #15844.
2022-11-26Tests: Replace {'if' => 'ifdef'} AK_OS_EMSCRIPTENAli Mohammad Pur
Our main build doesn't have -Werror-undef, so this went unnoticed.
2022-11-26Everywhere: Add support for compilation under emscriptenAli Mohammad Pur
Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2022-11-25LibVideo: Read Matroska lazily so that large files can start quicklyZaggy1024
The Demuxer class was changed to return errors for more functions so that all of the underlying reading can be done lazily. Other than that, the demuxer interface is unchanged, and only the underlying reader was modified. The MatroskaDocument class is no more, and MatroskaReader's getter functions replace it. Every MatroskaReader getter beyond the Segment element's position is parsed lazily from the file as needed. This means that all getter functions can return DecoderErrors which must be handled by callers.
2022-11-25LibVideo: Propagate decoder errors in the Matroska ReaderZaggy1024
Matroska::Reader functions now return DecoderErrorOr instead of values being declared Optional. Useful errors can be handled by the users of the parser, similarly to the VP9 decoder. A lot of the error checking in the reader is a lot cleaner thanks to this change, since all reads can be range checked in Streamer::read_octet() now. Most functions for the Streamer class are now also out-of-line in Reader.cpp now instead of residing in the header.
2022-11-25LibVideo: Reorganize demuxer file hierarchy and rename Matroska filesZaggy1024
As new demuxers are added, this will get quite full of files, so it'll be good to have a separate folder for these. To avoid too many chained namespaces, the Containers subdirectory is not also a namespace, but the Matroska folder is for the sake of separating the multiple classes for parsed information entering the Video namespace.
2022-11-23Userland+Tests: Remove a few more LibJS/{AST.h,Parser.h} includesAndreas Kling
2022-11-23LibJS+LibWeb: Make CyclicModule.h not include AST.hAndreas Kling
This led to some fallout as many things in LibJS and LibWeb were pulling in other things via CyclicModule.h
2022-11-19LibC+Tests: Simplify getpwuid_r() and getpwnam_r() and add testsAndreas Kling
These functions are now implemented in terms of getpwent_r() which allows us to remove two FIXMEs about global variable shenanigans. I'm also adding tests for both APIs. :^)
2022-11-18AK: Add JSON object/array for-each methods for fallible callbacksTimothy Flynn
This allows the provided callback to return an ErrorOr-like type to propagate errors back to the caller.
2022-11-15Tests/AK: Re-enable `HashTable<double>` testDaniel Bertalan
The incorrect UBSan alignment check that made this test fail has been fixed in Clang 15. Closes #13614
2022-11-11AK: Add optional explicit cast to underlying type to DistinctNumericSam Atkins
2022-11-11AK+Everywhere: Replace DistinctNumeric bool parameters with named onesSam Atkins
This means that rather than this: ``` AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u64, true, true, false, false, false, true, FunctionAddress); ``` We now have this: ``` AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u64, FunctionAddress, Arithmetic, Comparison, Increment); ``` Which is a lot more readable. :^) Co-authored-by: Ali Mohammad Pur <mpfard@serenityos.org>
2022-11-11AK: Don't crash in HashTable::clear_with_capacity on an empty tableZaggy1024
When calling clear_with_capacity on an empty HashTable/HashMap, a null deref would occur when trying to memset() m_buckets. Checking that it has capacity before clearing fixes the issue.