Skip to content

Commit 394df75

Browse files
committed
[utest]: [signal]:Correct issues including grammatical errors, spelling mistakes, and ambiguities in function names.
Fixed the issue of grammatical errors in words; changed the variable 'recive_sig' to 'receive_sig'. Originally, rt_signal_unmask_test was testing the masking function of rt_signal_mask, while rt_signal_mask_test was verifying whether signals could be sent correctly during unmasking——the function names were exactly opposite to their functions. Now the two function names have been swapped, and the corresponding comments have also been updated accordingly.After modification, it has been verified that the signal-related utests can be executed correctly. Signed-off-by: Mengchen Teng <[email protected]>
1 parent 13a57ca commit 394df75

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

src/utest/signal_tc.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
* - functionality. The registration of the signal handler should be completed correctly.
2626
* - Include Case1 and Case2.
2727
*
28-
* - [rt_signal_mask_test]: Verify the correctness of the rt_signal_unmask functions's
28+
* - [rt_signal_unmask_test]: Verify the correctness of the rt_signal_unmask functions's
2929
* - functionality. The signal handler will only be triggered when the signal is unmasked.
3030
* - Include Case3.
3131
*
32-
* - [rt_signal_unmask_test]: Verify the correctness of the rt_signal_mask functions's
32+
* - [rt_signal_mask_test]: Verify the correctness of the rt_signal_mask functions's
3333
* - functionality. The signal handler will not be triggered when the signal is masked.
3434
* - Include Case4.
3535
*
@@ -48,19 +48,19 @@
4848
* - value is not equal to SIG_ERR). However, if signo is not within the above range, the
4949
* - rt_signal_install function returns SIG_ERR.
5050
*
51-
* - [rt_signal_mask_test]: When signo is valid, the signal handler will first be successfully
51+
* - [rt_signal_unmask_test]: When signo is valid, the signal handler will first be successfully
5252
* - registered via rt_signal_install, where receive_sig is assigned the value of the triggered
5353
* - signal signo. After successful registration, the specified signal mask is unmasked using
5454
* - rt_signal_unmask, and a signal is sent to rt_thread_self via rt_thread_kill. After a 1ms
55-
* - delay, the signal callback function is triggered successfully, and the value of recive_sig
55+
* - delay, the signal callback function is triggered successfully, and the value of receive_sig
5656
* - equals the value of signo.
5757
*
58-
* - [rt_signal_unmask_test]: When signo is valid, the signal handler will first be successfully
58+
* - [rt_signal_mask_test]: When signo is valid, the signal handler will first be successfully
5959
* - registered via rt_signal_install, where receive_sig is assigned the value of the triggered
6060
* - signal signo. After successful registration, the specified signal mask is unmasked using
6161
* - rt_signal_unmask, then masked again using rt_signal_mask. A signal is then sent to rt_thread_self
6262
* - via rt_thread_kill. After a 1ms delay, the signal callback function is not triggered, and the
63-
* - value of recive_sig does not equal the value of signo.
63+
* - value of receive_sig does not equal the value of signo.
6464
*
6565
* - [rt_signal_kill_test]: Case7(the for Loop) is the same as the loop in [rt_signal_mask_test].
6666
* - Case9 Verifies that when an invalid signal is sent using rt_signal_kill, the function returns
@@ -73,7 +73,7 @@
7373
* - "sig_t1" is waiting for the signal, and then sends the SIGUSR1 signal to "sig_t1" using
7474
* - rt_thread_kill. The main thread then waits on the _received_signal semaphore, which will be
7575
* - released by "sig_t1" upon receiving the signal. Finally, the test case verifies that the
76-
* - recive_sig variable is set to SIGUSR1, confirming that the signal was successfully
76+
* - receive_sig variable is set to SIGUSR1, confirming that the signal was successfully
7777
* - received by the waiting thread.
7878
*
7979
* - [rt_signal_wait_test2]: Similar to [rt_signal_wait_test], a new thread("sig_t1") is created
@@ -83,7 +83,7 @@
8383
* - to "sig_t1" using rt_thread_kill. Since "sig_t1" has already timed out waiting for the signal,
8484
* - it will not receive the signal. The main thread then attempts to take the _received_signal
8585
* - semaphore with a timeout of 1 tick, which should fail since "sig_t1" did not receive the signal
86-
* - and thus did not release the semaphore. Finally, the test case verifieds that the receive_sig
86+
* - and thus did not release the semaphore. Finally, the test case verifies that the receive_sig
8787
* - variable is not equal to SIGUSR1, confirming that the signal was not received by the waiting thread
8888
* - due to the timeout.
8989
*
@@ -93,19 +93,19 @@
9393
* - will not return SIG_ERR. Case 2 (i.e., the rt_signal_install outside the for loop)
9494
* - will return SIG_ERR.
9595
*
96-
* - [rt_signal_mask_test]: Every signo shall correctly trigger the signal handler, such
97-
* - that recive_sig equals signo.
96+
* - [rt_signal_unmask_test]: Every signo shall correctly trigger the signal handler, such
97+
* - that receive_sig equals signo.
9898
*
99-
* - [rt_signal_unmask_test]: Every signo shall not trigger the signal handler after masking,
100-
* - such that recive_sig does not equal signo.
99+
* - [rt_signal_mask_test]: Every signo shall not trigger the signal handler after masking,
100+
* - such that receive_sig does not equal signo.
101101
*
102102
* - [rt_signal_kill_test]: In Case7, every signo shall correctly trigger the signal handler,
103-
* - such that recive_sig equals signo. In Case9, rt_signal_kill shall return -RT_EINVAL.
103+
* - such that receive_sig equals signo. In Case9, rt_signal_kill shall return -RT_EINVAL.
104104
*
105-
* - [rt_signal_wait_test]: In Case5, recive_sig shall equal SIGUSR1, indicating that the waiting
105+
* - [rt_signal_wait_test]: In Case5, receive_sig shall equal SIGUSR1, indicating that the waiting
106106
* - thread successfully received the signal. And main thread can take the semaphore.
107107
*
108-
* - [rt_signal_wait_test2]: In Case6, recive_sig shall not equal SIGUSR1, indicating that the waiting
108+
* - [rt_signal_wait_test2]: In Case6, receive_sig shall not equal SIGUSR1, indicating that the waiting
109109
* - thread did not receive the signal due to timeout. And main thread fails to take the semaphore.
110110
*
111111
* Dependencies:
@@ -115,9 +115,9 @@
115115
* - [rt_signal_install_test]: Handlers installed successfully for all valid signals,
116116
* - installation fails for invalid signal.
117117
*
118-
* - [rt_signal_mask_test]: Signals are received when unmasked.
118+
* - [rt_signal_unmask_test]: Signals are received when unmasked.
119119
*
120-
* - [rt_signal_unmask_test]: Signals are not received when masked.
120+
* - [rt_signal_mask_test]: Signals are not received when masked.
121121
*
122122
* - [rt_signal_kill_test]: Signals are sent and received correctly for valid cases,
123123
* - errors returned for invalid cases.
@@ -131,12 +131,12 @@
131131
#include <rtthread.h>
132132
#include "utest.h"
133133

134-
static volatile int recive_sig = 0;
134+
static volatile int receive_sig = 0;
135135
static struct rt_semaphore _received_signal;
136136

137137
void sig_handle_default(int signo)
138138
{
139-
recive_sig = signo;
139+
receive_sig = signo;
140140
}
141141

142142
static void rt_signal_install_test(void)
@@ -157,42 +157,42 @@ static void rt_signal_install_test(void)
157157
return;
158158
}
159159

160-
static void rt_signal_mask_test(void)
160+
static void rt_signal_unmask_test(void)
161161
{
162162
int signo;
163163
rt_sighandler_t result;
164164

165165
/* case 3:rt_signal_mask/unmask, one thread self, install and unmask, then kill, should received. */
166166
for (signo = 0; signo < RT_SIG_MAX; signo++)
167167
{
168-
recive_sig = -1;
168+
receive_sig = -1;
169169
result = rt_signal_install(signo, sig_handle_default);
170170
uassert_true(result != SIG_ERR);
171171
rt_signal_unmask(signo);
172172
uassert_int_equal(rt_thread_kill(rt_thread_self(), signo), RT_EOK);
173173
rt_thread_mdelay(1);
174-
uassert_int_equal(recive_sig, signo);
174+
uassert_int_equal(receive_sig, signo);
175175
}
176176

177177
return;
178178
}
179179

180-
static void rt_signal_unmask_test(void)
180+
static void rt_signal_mask_test(void)
181181
{
182182
int signo;
183183
rt_sighandler_t result;
184184

185185
/* case 4:rt_signal_mask/unmask, one thread self, install and unmask and mask, then kill, should can't received. */
186186
for (signo = 0; signo < RT_SIG_MAX; signo++)
187187
{
188-
recive_sig = -1;
188+
receive_sig = -1;
189189
result = rt_signal_install(signo, sig_handle_default);
190190
uassert_true(result != SIG_ERR);
191191
rt_signal_unmask(signo);
192192
rt_signal_mask(signo);
193193
uassert_int_equal(rt_thread_kill(rt_thread_self(), signo), RT_EOK);
194194
rt_thread_mdelay(1);
195-
uassert_int_not_equal(recive_sig, signo);
195+
uassert_int_not_equal(receive_sig, signo);
196196
}
197197

198198
return;
@@ -206,13 +206,13 @@ static void rt_signal_kill_test(void)
206206
/* case 7:rt_signal_kill, kill legal thread, return 0; */
207207
for (signo = 0; signo < RT_SIG_MAX; signo++)
208208
{
209-
recive_sig = -1;
209+
receive_sig = -1;
210210
result = rt_signal_install(signo, sig_handle_default);
211211
uassert_true(result != SIG_ERR);
212212
rt_signal_unmask(signo);
213213
uassert_int_equal(rt_thread_kill(rt_thread_self(), signo), RT_EOK);
214214
rt_thread_mdelay(1);
215-
uassert_int_equal(recive_sig, signo);
215+
uassert_int_equal(receive_sig, signo);
216216
}
217217
/* case 8:rt_signal_kill, kill illegal thread, return failed; */
218218
// uassert_true(rt_thread_kill((rt_thread_t)-1, signo) == -RT_ERROR);
@@ -240,17 +240,17 @@ void rt_signal_wait_thread(void *parm)
240240
return;
241241
}
242242

243-
recive_sig = recive_si.si_signo;
243+
receive_sig = recive_si.si_signo;
244244

245-
LOG_I("received signal %d", recive_sig);
245+
LOG_I("received signal %d", receive_sig);
246246
rt_sem_release(&_received_signal);
247247
}
248248

249249
static void rt_signal_wait_test(void)
250250
{
251251
rt_thread_t t1;
252252

253-
recive_sig = -1;
253+
receive_sig = -1;
254254
t1 = rt_thread_create("sig_t1", rt_signal_wait_thread, 0, 4096, 14, 10);
255255
if (t1)
256256
{
@@ -261,7 +261,7 @@ static void rt_signal_wait_test(void)
261261
/* case 5:rt_signal_wait, two thread, thread1: install and unmask, then wait 1s; thread2: kill, should received. */
262262
uassert_int_equal(rt_thread_kill(t1, SIGUSR1), RT_EOK);
263263
rt_sem_take(&_received_signal, RT_WAITING_FOREVER);
264-
uassert_int_equal(recive_sig, SIGUSR1);
264+
uassert_int_equal(receive_sig, SIGUSR1);
265265

266266
return;
267267
}
@@ -270,7 +270,7 @@ static void rt_signal_wait_test2(void)
270270
{
271271
rt_thread_t t1;
272272

273-
recive_sig = -1;
273+
receive_sig = -1;
274274
t1 = rt_thread_create("sig_t1", rt_signal_wait_thread, 0, 4096, 14, 10);
275275
if (t1)
276276
{
@@ -283,7 +283,7 @@ static void rt_signal_wait_test2(void)
283283
uassert_int_not_equal(
284284
rt_sem_take(&_received_signal, 1),
285285
RT_EOK);
286-
uassert_int_not_equal(recive_sig, SIGUSR1);
286+
uassert_int_not_equal(receive_sig, SIGUSR1);
287287

288288
return;
289289
}

0 commit comments

Comments
 (0)