-
Notifications
You must be signed in to change notification settings - Fork 667
ostest: Add initial support for CONFIG_BUILD_KERNEL #1500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implement task_create and task_delete for use with ostest. The functions are unavailable in kernel build mode but overload them here and create a pthread worker instead. Some tests should be re-visited because the intent is to user another task (in this case another process) to e.g. receive signals. That will require quite a bit of extra work. Tests that had to be disabled: - waitpid: pthreads don't work with waitpid, but this can be fixed by starting a dummy process instead and using waitpid on that (NOT IMPLEMENTED) - restart: task_restart() does not work at all with kernel mode so it is disabled entirely - fpu: make sure the FPU test is not even attempted, because it will cause ASSERT() and stop the test - vfork: vfork() does not work for some reason in CONFIG_BUILD_KERNEL, there is something missing on the kernel side, so just disable the test for now Tests that should be re-visited: - The signal tests, now they signal the process itself while before the signal was sent to another task. This will require building the part that receives the signal as a separate process - waitpid: Like stated above, waitpid does not work for pthreads - user_main: It might be a better idea to just call user_main() because the "test creating a task works"-part has already been tested; if ostest starts, then task starting and creation also works
2a5157e
to
a5f8061
Compare
Why not skip the test which involve task_xxx function instead simulating task by pthread? |
Of course that is another way of doing it. I thought this would be better, many tests create "workers" via task_create and I thought it would be fine to use pthreads for that. We currently do not have any kind of ostest for CONFIG_BUILD_KERNEL, I made this to have at least something. It is not a full implementation but IMO better than nothing. |
If the case doesn't really depend on task_create, it's better to migrate to pthread or remove task_create calling directly.
If the test invokes the function which is impossible to implement in kernel mode:
|
I would have to go them through one by one, because I don't know how each test is supposed to work. Instead, I made a kludge solution that allows the test to compile and run (most) tests. |
The similar function is posix_spawn(), which requires:
Skipping these kind of tests is fine by me, but I don't know which tests could be converted to use pthread and which must be skipped. I already disabled some of the tests that I know won't work in kernel mode. |
Btw, I 100% agree with you that this incomplete implementation is not perfect and needs more work + clean up. I have been using this version for some time now and have found it useful (better than nothing) and I decided to make this PR to at least offer the solution to the community. However, if no extra value is seen in this partial implementation, I will just close the PR. Maybe at some point I will make a proper implementation for this, but as I said, I don't have time to do that now. |
The patch is valuable. My suggestion is very simple that:
Or provding a dummy function in the individual test source code
We can migrate task_create to posix_spawn or pthread_create as needed in the future. |
Summary
Implement task_create and task_delete for use with ostest. The functions are unavailable in kernel build mode but overload them here and create a pthread worker instead. Some tests should be re-visited because the intent is to user another task (in this case another process) to e.g. receive signals. That will require quite a bit of extra work.
Tests that had to be disabled:
Tests that should be re-visited:
Impact
Adds basic support for ostest with CONFIG_BUILD_KERNEL=y
Testing
icicle:knsh