Modifying sched_thread_local.c test to add corner cases.#3412
Modifying sched_thread_local.c test to add corner cases.#3412Biancaa-R wants to merge 1 commit intoapache:masterfrom
Conversation
a) Adding test to verify if all the created threads share addr. b) Checking if initial value is not corrupted. c) assert(false)->incase status is not okay. So faulty invalid object doesnt move forward. Signed-off-by: Biancaa Ramesh <biancaa2210329@ssn.edu.in>
|
|
||
| /* In a broken system, all threads might point to the same static address */ | ||
|
|
||
| static void *g_first_thread_addr = NULL; |
There was a problem hiding this comment.
@Biancaa-R all common code (that needs to work on old microcontrollers) should follow the C89. Please read the https://nuttx.apache.org/docs/latest/contributing/coding_style.html for more info about the NuttX coding style
There was a problem hiding this comment.
Other detail: g_ is used when you are defining a global variable, that is not the case here since you are defining it inside a function
There was a problem hiding this comment.
@Biancaa-R all common code (that needs to work on old microcontrollers) should follow the C89. Please read the https://nuttx.apache.org/docs/latest/contributing/coding_style.html for more info about the NuttX coding style
Sure sir Ill read it and modify accordingly.
| /* In a broken system, all threads might point to the same static address */ | ||
|
|
||
| static void *g_first_thread_addr = NULL; | ||
| if (id == 0) |
There was a problem hiding this comment.
Did you try to print the "id" ? I think it never will be 0, if I'm not wrong (and I could be wrong) it starts from 1.
There was a problem hiding this comment.
I think it does start from 0 based on the attached log (it is printed a few times)
There was a problem hiding this comment.
I think it does start from 0 based on the attached log (it is printed a few times)
Yes.
linguini1
left a comment
There was a problem hiding this comment.
Hi @Biancaa-R , please read the contributing guide and modify your commit message to follow it
| printf("ERROR: Thread %d shares address with Thread 0\n", id); | ||
| ASSERT(false); | ||
|
|
||
| /* Checking 0 and other addresses */ |
| "status=%d\n", status); | ||
| ASSERT(false); | ||
|
|
||
| /* the threads will call pthread_barrier_wait on an invalid object */ |
| static void *g_first_thread_addr = NULL; | ||
| if (id == 0) | ||
| { | ||
| g_first_thread_addr = (void *)&g_tls_int; |
There was a problem hiding this comment.
What happens when the threads are released from the synchronized barrier? There is no guarantee that the first thread will set g_first_thread_addr before it is read by other threads. In fact, in your attached log, thread 2 starts first.
This check doesn't work.
a) Adding test to verify if all the created threads share the same static address (an issue.)
b) Checking if initial value is not corrupted.
c) assert(false)->incase status is not okay.
So faulty invalid object doesnt move forward.
Note: Please adhere to Contributing Guidelines.
Summary
Impact
Makes the testing cover more corner cases , more robust.
Testing
For testing of these features I had used :
Modified test section:

CI test:
