Make portability easier to achieve, add functional kernel tests#2
Merged
Make portability easier to achieve, add functional kernel tests#2
Conversation
Stuff, which is platform dependent goes into separate CMake files
Relevant warnings cleaned up in the sources. Sources now build cleanly.
Vast majority of code in kernel now is platform dependent. Move it out of kernel directory and start bringing only platform independent code back into kernel tree. This will siplify further porting efforts. Some of original files were split into arch-depentend and arch-independent portions in a fairly dirty way just to split the code.
Simple testsuite subsystem which allows to develop tests quickly. No need to repeat boilerplace code again and again. One just has to write the stuff which matters and use TEST_SUCCESS and TEST_FAIL functions to signalize success or failure of the test. Fix some bugs in CMake files which prevented tests to be build elsewhere than in root of the tree
Staged tests allow to check if test passes certain checkpoints in given order. You can use TEST_STEP function to assert if steps are passed in given order. Function will yield test failure if the order is not correct and no action if order is correct. The last step shall be marked with TEST_SUCCESS().
RPC call macroworks now supports RPC ABI checking (making sure that service structure has correct layout, so that kernel will see the same we do see during the compile time) and a bit enhanced type checking to make sure argument types match the ones expected by the RPC method.
Add tests which test rpc_call and usleep syscalls
Linker scripit generator contained construct that prevented successfull collection of allocations within one file. Code always created container from scratch dropping the previous container which already contained some allocations. This caused section to become zero-sized whenever there were any trailing fillers.
CTest default test timeout is something like 1500 seconds. Shorten this for out hardware tests to 15 seconds which shall be long enough to load and execute the test.
Add type check for service_instance argument. Call will fail if service_instance is not passed as pointer. Improve the rest of the code so that if service_instance is not passed as pointer then the developer won't be overwhelmed by a bunch of irrelevant errors.
Add test which will check for successful execution of RPC call.
This test checks wherher it is possible to access local process data.
__make_pointer_to() and __strip_pointer_from() don't play well with cases where rpc_call is called like rpc_call(&some_service, ....);
This test tests if control is passed to the calling program once RPC method returns.
These two tests test if creation of new thread and manual calling of sched_yield() will give control to the right thread. Thread with the highest priority ready to run shall be executed().
Genlink was printing some debug messages and littering the build output. Stop that.
Do not support mutexes in ARMv6M. Hardware doesn't support conditional load/store unit, nor instructions so userspace futexes are not possible.
If test contained more than one application, only one of them was linked to all the needed libraries.
This change is not very constructive but will help to support MCUs where peripherals often need to handle two regions of memory which are far apart. Often such case happens when HAL is using some kind of bit-level access engine combined with another peripheral and these two are connected to different bus having entirely different base address. Second MMIO region will allow to specify two relatively small regions to which the driver has access rather than creating god-like or kernel-level drivers that are powerful enough to mess with whatever they want.
Decrease littering of configure step
This test launches one statically defined thread which then creates thread of priority slightly lower than the original thread. First it is tested that the scheduler won't schedule lower priority thread. Then it is tested that after the original thread decreases its priority, the other thread is scheduled automatically.
Move some code back from ARM layer into kernel as it is platform independent. Fix CMakelists to include arch layer as dependency of the kernel. Make code build with less warnings if -Wall -Wextra is passed to the compiler.
Tests using sequences were failing even if the code was performing well. The reason was missing "continue" at the end of handler for test step.
This test tests if SHARED attribute of variable is honored and makes the memory block in question available to the RPC method being called.
The code of tests themselves will be moved out of the source tree. This way any "test"-named directory can hold test harness. There's need of one emerging.
Move top-level CMakelists.txt one directory up. This way projects don't need to include cmrx/src, rather they include just cmrx directory. This also allows testsuite to live outside of the src directory.
Previously GDB path has been hardcoded in CMakeLists.txt, now expect it to be passed as CMake argument.
Both caller and callee had wrong application names used which prevented these apps from being recognized by the kernel loader.
Init application had wrong application name used which prevented kernel loader from finding this application.
Until now, the config.h had to be configured by the caller. Now it gets configured by CMRX CMakeLists.txt.
Testsuite drops the use of its own openocd.cfg. Instead of it it expects that the project will provide its own OpenOCD configuration that can be used by the debugger. This way the tests shall be fully portable to whatever configuration that can provide testing-platform library and openocd.cfg file.
Tests link again test_platform and test_platform main libraries. They have to be defined as CMake targets before test suite is included (preferably by the project that includes CMRX). If they don't exist then fail.
One nasty bug to debug is if you make a typo or simply misname application in the OS_APPLICATION(...) call. Application instance will be defined but later it will be dropped. Step that checks for correct application instance name added. It simply checks if correct symbol in correct section exists.
Most of HIL tests run less than 2 seconds. Shorten test timeout to 5 seconds rather than 15 seconds. This speeds up hung tests.
This test tests if the thread created with higher priority than the calling thread stops, if it sends SIGSTOP itself. The expected result is that the thread is stopped and control is given to the calling thread. If thread continues running after it sent SIGSTOP itself, test is considered as failed.
This tests installs a signal handler and then another thread sends this particular signal to the thread, which installed the handler. Test tests that the signal handler is actually being called.
This test checks if the return value passed to thread_exit is available by calling the thread_join().
Userspace definition of the thread_join() was different than the kernel implementation of the syscall. The latter returned the exit status code in function return value, while the userspace implementation expected it to be written into memory pointed to by the 2nd argument. The way the kernel does it was selected to be a preferred way as the pointer approach requires us to actually go and verify that the piece of memory userspace points at is owned by the process calling the syscall.
It might be useful to see the backtrace of failed test run. It makes diagnostics a tad bit easier.
Merged three CMRX-related libraries for userspace (ipc pthread stdlib) into one (stdlib). There is no point in having three of them. Certain headers files moved from kernel include into special subdirectory where things that need to be implemented by a port reside. Certain headers removed and/or merged into others as their split is not warranted by anything. Mutex portion of userspace library moved into architecture-specific subdirectory as mutexes shall be supported by HW and accessible from userspace to be as fast as possible. Code cleaned up to suppress all warnings.
Some code moved from port into generic portion of the kernel code, some code moved the other way. Improved port declaration layer and separation of architecture-independent layer and port layer.
Move irrelevant stuff out of the way of kernel.
Add readme that shall shed some light on how to port CMRX to another platform/HAL.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve the way how kernel is separated into port and architecture-independent parts. Minimize the port size and separate both portions as much as possible. Create clear interface between two portions. Clean the code and the build system. Add some functional tests to test the kernel.