summaryrefslogtreecommitdiff
path: root/Tests
AgeCommit message (Collapse)Author
2021-06-08AK: Make Vector capable of holding reference typesAli Mohammad Pur
This commit makes it possible to instantiate `Vector<T&>` and use it to store references to `T` in a vector. All non-pointer observers are made to return the reference, and the pointer observers simply yield the underlying pointer. Note that the 'find_*' methods act on the values and not the pointers that are stored in the vector. This commit also makes errors in various vector methods much more readable by directly using requires-clauses on them. And finally, it should be noted that Vector cannot hold temporaries :^)
2021-06-08LibSQL: Limit the number of nested subqueriesTimothy Flynn
SQLite hasn't documented a limit on https://www.sqlite.org/limits.html for the maximum number of nested subqueries. However, its parser is generated with Yacc and has an internal limit of 100 for general nested statements. Fixes https://crbug.com/oss-fuzz/35022.
2021-06-08LibSQL: Rename expression tree depth limit test caseTimothy Flynn
Meant to rename this before committing the test - 'stack_limit' isn't a great name when there's multiple test cases for various stack overflows.
2021-06-08LibCore/ArgsParser: Learn how to stop on first non-optionJelle Raaijmakers
We need this for utilities like `env`, that do not gain anything by parsing the options passed to the command they are supposed to execute.
2021-06-08LibCore/ArgsParser: Add test suiteJelle Raaijmakers
This adds a very basic test suite for ArgsParser that we can use to set a baseline of functionality that we want to make sure keeps working.
2021-06-07AK: Add IntrusiveList::size_slow() to match InlineLinkedListBrian Gianforcaro
The functionality is needed to replace InlineLinkedList with IntrusiveList in the Kernel Process class.
2021-06-06AK+Everywhere: Disallow constructing Functions from incompatible typesAli Mohammad Pur
Previously, AK::Function would accept _any_ callable type, and try to call it when called, first with the given set of arguments, then with zero arguments, and if all of those failed, it would simply not call the function and **return a value-constructed Out type**. This lead to many, many, many hard to debug situations when someone forgot a `const` in their lambda argument types, and many cases of people taking zero arguments in their lambdas to ignore them. This commit reworks the Function interface to not include any such surprising behaviour, if your function instance is not callable with the declared argument set of the Function, it can simply not be assigned to that Function instance, end of story.
2021-06-05LibSQL: Limit the allowed depth of an expression treeTimothy Flynn
According to the definition at https://sqlite.org/lang_expr.html, SQL expressions could be infinitely deep. For practicality, SQLite enforces a maxiumum expression tree depth of 1000. Apply the same limit in LibSQL to avoid stack overflow in the expression parser. Fixes https://crbug.com/oss-fuzz/34859.
2021-06-05LibWasm: Move Wasm::BytecodeInterpreter into its own headerSahan Fernando
2021-06-05AK: Do not trim away non-ASCII bytes when parsing URLMax Wipfli
Because non-ASCII code points have negative byte values, trimming away control characters requires checking for negative bytes values. This also adds a test case with a URL containing non-ASCII code points.
2021-06-04LibWasm: Load and instantiate tablesAli Mohammad Pur
This commit is a fairly large refactor, mainly because it unified the two different ways that existed to represent references. Now Reference values are also a kind of value. It also implements a printer for values/references instead of copying the implementation everywhere.
2021-06-04AK: Don’t drop lines between \r and \n in StringView::lines() (#7662)R Smith
StringView::lines() supports line-separators β€œ\n”, β€œ\r”, and β€œ\r\n”. The method will drop an entire line if it is surrounded by β€œ\r” and β€œ\n” separators on the left and right sides respectively.
2021-06-03AK: Do not VERIFY on invalid code point bytes in UTF8ViewDexesTTP
The previous behavior was to always VERIFY that the UTF-8 bytes were valid when iterating over the code points of an UTF8View. This change makes it so we instead output the 0xFFFD 'REPLACEMENT CHARACTER' code point when encountering invalid bytes, and keep iterating the view after skipping one byte. Leaving the decision to the consumer would break symmetry with the UTF32View API, which would in turn require heavy refactoring and/or code duplication in generic code such as the one found in Gfx::Painter and the Shell. To make it easier for the consumers to detect the original bytes, we provide a new method on the iterator that returns a Span over the data that has been decoded. This method is immediately used in the TextNode::compute_text_for_rendering method, which previously did this in a ad-hoc waay. This also add tests for the new behavior in TestUtf8.cpp, as well as reinforcements to the existing tests to check if the underlying bytes match up with their expected values.
2021-06-03Tests: Add tests for most functions in AK/CharacterType.hMax Wipfli
2021-06-03Tests: Add test coverage for AK::IntrusiveList reverse iterator supportBrian Gianforcaro
2021-06-03LibSQL: Report a syntax error for unsupported LIMIT clause syntaxTimothy Flynn
Rather than aborting when a LIMIT clause of the form 'LIMIT expr, expr' is encountered, fail the parser with a syntax error. This will be nicer for the user and fixes the following fuzzer bug: https://crbug.com/oss-fuzz/34837
2021-06-02LibWasm: Ensure that value signs are preserved when castingAli Mohammad Pur
Also makes normal arithmetic operations more spec-compliant by actually ignoring overflow on them.
2021-06-02LibWasm: Implement reference instructions (ref.{null,func,is_null})Ali Mohammad Pur
2021-06-01LibSQL: Return an error for empty common table expression listsTimothy Flynn
SQL::CommonTableExpressionList is required to be non-empty. Return an error if zero common table expressions were parsed. Fixes #7627
2021-06-01AK+Everywhere: Fix compiletime format parsing of replacement fieldsAli Mohammad Pur
2021-06-01AK: Strip leading/trailing C0-control-or-space in URLs correctlyAndreas Kling
We have to stop scanning once we hit a non-strippable character. Add some tests to cover this.
2021-06-01AK: Enable direct comparsion of Optional<T> and TMax Wipfli
This patch introduces a new operator== to compare an Optional to its contained type directly. If the Optional does not contain a value, the comparison will always return false. This also adds a test case for the new behavior as well as comparison between Optional objects themselves.
2021-06-01AK: Rename Utf8CodepointIterator => Utf8CodePointIteratorAndreas Kling
2021-06-01Tests: Add more tests for AK::URLMax Wipfli
This adds more tests for AK::URL. Furthermore, this also changes some tests to conform to what the reworked URL class does (and the URL specification mostly expects).
2021-06-01AK: Implement Utf8CodepointIterator::peek(size_t)Max Wipfli
This adds a peek method for Utf8CodepointIterator, which enables it to be used in some parsing cases where peeking is necessary. peek(0) is equivalent to operator*, expect that peek() does not contain any assertions and will just return an empty Optional<u32>. This also implements a test case for iterating UTF-8.
2021-05-31AK: Handle LEB128 encoded values that are too large for the result typeAndrew Kaster
Previously, we would go crazy and shift things way out of bounds. Add tests to verify that the decoding algorithm is safe around the limits of the result type.
2021-05-31AK: Add tests for LEB128 decoderAndrew Kaster
2021-05-30AK+Userland: Use akaster@serenityos.org for my copyright headersAndrew Kaster
2021-05-30AK: Make HashTable::operator=(HashTable&&) clear the moved-from tableAndreas Kling
This is consistent with how other AK containers behave when moved from.
2021-05-30LibTest+test-js: Add back the lost test262 parser test optionAli Mohammad Pur
Fixes #7566.
2021-05-29Kernel: Ensure that an unveil node with no permission is never acceptedAli Mohammad Pur
Otherwise nodes inheriting from root may still be accessed with `access(..., F_OK)`. Also adds a test case to TestKernelUnveil about this behaviour.
2021-05-27Tests: Add tests for LexicalPath dirname handlingTim Schumacher
2021-05-27Tests: Use ByteBuffer::create_zeroed in TestDeflate instead of memsetAndrew Kaster
The round trip compress test wants the first half of the byte buffer to be filled with random data, and the second half to be all zeroes. The strategy of using memset on ByteBuffer::offset_pointer confuses __builtin_memset_chk when building with -fsanitize=undefined. It thinks that the buffer is using inline capacity when we can prove to ourselves pretty easily that it's not. To avoid this, just create the buffer zeroed to start, and then fill the first half with the random data.
2021-05-26AK: Implement AK::StackJesse Buhagiar
2021-05-25LibC: Implement strerror_r()Gunnar Beutner
This implements the XSI-compliant version of strerror_r() - as opposed to the GNU-specific variant. The function explicitly saves errno so as to not accidentally change it with one of the calls to other functions.
2021-05-24AK+Everywhere: Consolidate String::index_of() and String::find()Andreas Kling
We had two functions for doing mostly the same thing. Combine both of them into String::find() and use that everywhere. Also add some tests to cover basic behavior.
2021-05-22AK: Fix Variant construction from lvalue referencesAli Mohammad Pur
Fixes #7371 and appends its test cases.
2021-05-21Tests: Remove default font tests from LibGfx/TestFontHandlingAndreas Kling
The system default font functions now rely on communication with WindowServer and so we can't really test them here.
2021-05-21Tests: Install non-LibTest based Kernel tests into Kernel/Legacy subdirAndrew Kaster
This makes it easier to run tests we know will work in CI, and ignore ones that need some help to be repeatable.
2021-05-21LibWasm: Make the instantiation process produce an OwnPtrAli Mohammad Pur
Managing the instantiated modules becomes a pain if they're on the stack, since an instantiated module will eventually reference itself. To make using this simpler, just avoid copying the instance.
2021-05-21LibWasm: Decouple ModuleInstance from the AbstractMachineAli Mohammad Pur
This fixes a FIXME and will allow linking only select modules together, instead of linking every instantiated module into a big mess of exported entities :P
2021-05-21LibWasm+Meta: Implement instantiation/execution primitives in test-wasmAli Mohammad Pur
This also optionally generates a test suite from the WebAssembly testsuite, which can be enabled via passing `INCLUDE_WASM_SPEC_TESTS` to cmake, which will generate test-wasm-compatible tests and the required fixtures. The generated directories are excluded from git since there's no point in committing them.
2021-05-21LibWasm+Meta: Add test-wasm and optionally test the conformance testsAli Mohammad Pur
This only tests "can it be parsed", but the goal of this commit is to provide a test framework that can be built upon :) The conformance tests are downloaded, compiled* and installed only if the INCLUDE_WASM_SPEC_TESTS cmake option is enabled. (*) Since we do not yet have a wast parser, the compilation is delegated to an external tool from binaryen, `wasm-as`, which is required for the test suite download/install to succeed. This *does* run the tests in CI, but it currently does not include the spec conformance tests.
2021-05-20AK: Added contains_in_range to Vectorr-paiva
Vector::contains_in_range() allows the search of an element in a given range on a vector object. Also added testcases for the new Vector method.
2021-05-20LibGfx: Remove Gfx::FontDatabase::default_bold_fixed_width_font()Andreas Kling
Ask for a bold_variant() of the default_fixed_width_font() instead.
2021-05-20LibGfx: Remove Gfx::FontDatabase::default_bold_font()Andreas Kling
Instead use default_font().bold_variant() in cases where we want a bold variant of the default font. :^)
2021-05-19LibCpp: Add regression tests for the parserItamar
For each .cpp file in the test suite data, there is a .ast file that represents the "known good" baseline of the parser result. Each .cpp file goes through the parser, and the result of invoking `ASTNode::dump()` on the root node is compared to the baseline to find regressions. We also check that there were no parser errors when parsing the .cpp files.
2021-05-19Tests: static vs non-static constexpr variablesLenny Maiorani
Problem: - `static` variables consume memory and sometimes are less optimizable. - `static const` variables can be `constexpr`, usually. - `static` function-local variables require an initialization check every time the function is run. Solution: - If a global `static` variable is only used in a single function then move it into the function and make it non-`static` and `constexpr`. - Make all global `static` variables `constexpr` instead of `const`. - Change function-local `static const[expr]` variables to be just `constexpr`.
2021-05-19AK: Add String::find_all() and String::count()Maciej Zygmanowski
2021-05-19Everywhere: Add missing includes for <AK/OwnPtr.h>Gunnar Beutner
Previously <AK/Function.h> also included <AK/OwnPtr.h>. That's about to change though. This patch fixes a few build problems that will occur when that change happens.