ltp icon indicating copy to clipboard operation
ltp copied to clipboard

sem_timedwait: 2-1.c : There is always an error output TEST FAILED

Open chenguanxi12138 opened this issue 1 year ago • 2 comments

When I run the code interfaces/sem_timedwait/2-1.c, I always get the following output: TEST FAILED TEST PASSED After my analysis, I found that this is due to the fact that the parent process and the child process are not operating on the same mysemp, the mysemp of child process is just a copy of the mysemp of parent process with the same name. So this will result in the parent process not being able to complete the unlocking of the child process via the sem_post operation, and the child process will print a FAILED message due to the timeout. Is this the desired result of this test case, or do we actually want the parent and child processes to operate the same semaphore?

chenguanxi12138 avatar Dec 22 '23 08:12 chenguanxi12138

And it looks like the failure is ignored since the code should be:

        if (WEXITSTATUS(i)
                return PTS_FAILE;

We can fix the test either by putting the semaphore into a piece of shared memory or by running the child in a thread instead. Can you send a patch?

metan-ucw avatar Jan 03 '24 16:01 metan-ucw

And it looks like the failure is ignored since the code should be:

        if (WEXITSTATUS(i)
                return PTS_FAILE;

We can fix the test either by putting the semaphore into a piece of shared memory or by running the child in a thread instead. Can you send a patch?

Of course, I'll send a patch later

chenguanxi12138 avatar Jan 04 '24 01:01 chenguanxi12138