* [LTP] [PATCH V2] semctl01.c: Pass the correct parameter
@ 2013-05-22 1:52 DAN LI
2013-05-22 7:11 ` Jan Stancek
2013-05-22 8:56 ` Wanlong Gao
0 siblings, 2 replies; 3+ messages in thread
From: DAN LI @ 2013-05-22 1:52 UTC (permalink / raw)
To: LTP list
For SEM_STAT, the semid argument is not a semaphore identifier, but instead an
index into the kernel’s internal array that maintains information about all
semaphore sets on the system.
Pass a correct index of the kernel' internal array intead of a semaphores id when
testing feature SEM_STAT.
Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
---
testcases/kernel/syscalls/ipc/semctl/semctl01.c | 37 ++++++++++++++-----------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl01.c b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
index 687d909..0399842 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl01.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
@@ -52,6 +52,7 @@ char *TCID = "semctl01";
int TST_TOTAL = 13;
static int sem_id_1 = -1;
+static int sem_index;
static int sync_pipes[2];
@@ -100,25 +101,26 @@ static int sem_op;
#endif
static struct test_case_t {
+ int *semid;
int semnum;
int cmd;
void (*func_test) ();
union semun arg;
void (*func_setup) ();
} TC[] = {
- {0, IPC_STAT, func_stat, SEMUN_CAST & buf, NULL},
- {0, IPC_SET, func_set, SEMUN_CAST & buf, set_setup},
- {0, GETALL, func_gall, SEMUN_CAST array, NULL},
- {SEM4, GETNCNT, func_cnt, SEMUN_CAST & buf, cnt_setup},
- {SEM2, GETPID, func_pid, SEMUN_CAST & buf, pid_setup},
- {SEM2, GETVAL, func_gval, SEMUN_CAST & buf, NULL},
- {SEM4, GETZCNT, func_cnt, SEMUN_CAST & buf, cnt_setup},
- {0, SETALL, func_sall, SEMUN_CAST array, sall_setup},
- {SEM4, SETVAL, func_sval, SEMUN_CAST INCVAL, NULL},
- {0, IPC_INFO, func_iinfo, SEMUN_CAST & ipc_buf, NULL},
- {0, SEM_INFO, func_sinfo, SEMUN_CAST & ipc_buf, NULL},
- {0, SEM_STAT, func_sstat, SEMUN_CAST & buf, NULL},
- {0, IPC_RMID, func_rmid, SEMUN_CAST & buf, NULL},
+ {&sem_id_1, 0, IPC_STAT, func_stat, SEMUN_CAST & buf, NULL},
+ {&sem_id_1, 0, IPC_SET, func_set, SEMUN_CAST & buf, set_setup},
+ {&sem_id_1, 0, GETALL, func_gall, SEMUN_CAST array, NULL},
+ {&sem_id_1, SEM4, GETNCNT, func_cnt, SEMUN_CAST & buf, cnt_setup},
+ {&sem_id_1, SEM2, GETPID, func_pid, SEMUN_CAST & buf, pid_setup},
+ {&sem_id_1, SEM2, GETVAL, func_gval, SEMUN_CAST & buf, NULL},
+ {&sem_id_1, SEM4, GETZCNT, func_cnt, SEMUN_CAST & buf, cnt_setup},
+ {&sem_id_1, 0, SETALL, func_sall, SEMUN_CAST array, sall_setup},
+ {&sem_id_1, SEM4, SETVAL, func_sval, SEMUN_CAST INCVAL, NULL},
+ {&sem_id_1, 0, IPC_INFO, func_iinfo, SEMUN_CAST & ipc_buf, NULL},
+ {&sem_id_1, 0, SEM_INFO, func_sinfo, SEMUN_CAST & ipc_buf, NULL},
+ {&sem_index, 0, SEM_STAT, func_sstat, SEMUN_CAST & buf, NULL},
+ {&sem_id_1, 0, IPC_RMID, func_rmid, SEMUN_CAST & buf, NULL},
};
int main(int argc, char *argv[])
@@ -162,7 +164,7 @@ int main(int argc, char *argv[])
}
}
- TEST(semctl(sem_id_1, TC[i].semnum, TC[i].cmd,
+ TEST(semctl(*(TC[i].semid), TC[i].semnum, TC[i].cmd,
TC[i].arg));
if (TEST_RETURN == -1) {
@@ -560,10 +562,13 @@ static void func_rmid(void)
static void func_iinfo(int hidx)
{
- if (hidx >= 0)
+ if (hidx >= 0) {
+ sem_index = hidx;
tst_resm(TPASS, "the highest index is correct");
- else
+ } else {
+ sem_index = 0;
tst_resm(TFAIL, "the highest index is incorrect");
+ }
}
static void func_sinfo(void)
--
1.8.1
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [LTP] [PATCH V2] semctl01.c: Pass the correct parameter
2013-05-22 1:52 [LTP] [PATCH V2] semctl01.c: Pass the correct parameter DAN LI
@ 2013-05-22 7:11 ` Jan Stancek
2013-05-22 8:56 ` Wanlong Gao
1 sibling, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2013-05-22 7:11 UTC (permalink / raw)
To: DAN LI; +Cc: LTP list
----- Original Message -----
> From: "DAN LI" <li.dan@cn.fujitsu.com>
> To: "LTP list" <ltp-list@lists.sourceforge.net>
> Cc: "Jan Stancek" <jstancek@redhat.com>
> Sent: Wednesday, 22 May, 2013 3:52:09 AM
> Subject: [LTP] [PATCH V2] semctl01.c: Pass the correct parameter
>
>
> For SEM_STAT, the semid argument is not a semaphore identifier, but instead
> an
> index into the kernel’s internal array that maintains information about all
> semaphore sets on the system.
>
> Pass a correct index of the kernel' internal array intead of a semaphores id
> when
> testing feature SEM_STAT.
>
> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
Looks good to me. sem_index == 0 would work too, I'm assuming you
went with hidx as a corner case, which is also valid value.
Reviewed-by: Jan Stancek <jstancek@redhat.com>
Regards,
Jan
> ---
> testcases/kernel/syscalls/ipc/semctl/semctl01.c | 37
> ++++++++++++++-----------
> 1 file changed, 21 insertions(+), 16 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl01.c
> b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
> index 687d909..0399842 100644
> --- a/testcases/kernel/syscalls/ipc/semctl/semctl01.c
> +++ b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
> @@ -52,6 +52,7 @@ char *TCID = "semctl01";
> int TST_TOTAL = 13;
>
> static int sem_id_1 = -1;
> +static int sem_index;
>
> static int sync_pipes[2];
>
> @@ -100,25 +101,26 @@ static int sem_op;
> #endif
>
> static struct test_case_t {
> + int *semid;
> int semnum;
> int cmd;
> void (*func_test) ();
> union semun arg;
> void (*func_setup) ();
> } TC[] = {
> - {0, IPC_STAT, func_stat, SEMUN_CAST & buf, NULL},
> - {0, IPC_SET, func_set, SEMUN_CAST & buf, set_setup},
> - {0, GETALL, func_gall, SEMUN_CAST array, NULL},
> - {SEM4, GETNCNT, func_cnt, SEMUN_CAST & buf, cnt_setup},
> - {SEM2, GETPID, func_pid, SEMUN_CAST & buf, pid_setup},
> - {SEM2, GETVAL, func_gval, SEMUN_CAST & buf, NULL},
> - {SEM4, GETZCNT, func_cnt, SEMUN_CAST & buf, cnt_setup},
> - {0, SETALL, func_sall, SEMUN_CAST array, sall_setup},
> - {SEM4, SETVAL, func_sval, SEMUN_CAST INCVAL, NULL},
> - {0, IPC_INFO, func_iinfo, SEMUN_CAST & ipc_buf, NULL},
> - {0, SEM_INFO, func_sinfo, SEMUN_CAST & ipc_buf, NULL},
> - {0, SEM_STAT, func_sstat, SEMUN_CAST & buf, NULL},
> - {0, IPC_RMID, func_rmid, SEMUN_CAST & buf, NULL},
> + {&sem_id_1, 0, IPC_STAT, func_stat, SEMUN_CAST & buf, NULL},
> + {&sem_id_1, 0, IPC_SET, func_set, SEMUN_CAST & buf, set_setup},
> + {&sem_id_1, 0, GETALL, func_gall, SEMUN_CAST array, NULL},
> + {&sem_id_1, SEM4, GETNCNT, func_cnt, SEMUN_CAST & buf, cnt_setup},
> + {&sem_id_1, SEM2, GETPID, func_pid, SEMUN_CAST & buf, pid_setup},
> + {&sem_id_1, SEM2, GETVAL, func_gval, SEMUN_CAST & buf, NULL},
> + {&sem_id_1, SEM4, GETZCNT, func_cnt, SEMUN_CAST & buf, cnt_setup},
> + {&sem_id_1, 0, SETALL, func_sall, SEMUN_CAST array, sall_setup},
> + {&sem_id_1, SEM4, SETVAL, func_sval, SEMUN_CAST INCVAL, NULL},
> + {&sem_id_1, 0, IPC_INFO, func_iinfo, SEMUN_CAST & ipc_buf, NULL},
> + {&sem_id_1, 0, SEM_INFO, func_sinfo, SEMUN_CAST & ipc_buf, NULL},
> + {&sem_index, 0, SEM_STAT, func_sstat, SEMUN_CAST & buf, NULL},
> + {&sem_id_1, 0, IPC_RMID, func_rmid, SEMUN_CAST & buf, NULL},
> };
>
> int main(int argc, char *argv[])
> @@ -162,7 +164,7 @@ int main(int argc, char *argv[])
> }
> }
>
> - TEST(semctl(sem_id_1, TC[i].semnum, TC[i].cmd,
> + TEST(semctl(*(TC[i].semid), TC[i].semnum, TC[i].cmd,
> TC[i].arg));
>
> if (TEST_RETURN == -1) {
> @@ -560,10 +562,13 @@ static void func_rmid(void)
>
> static void func_iinfo(int hidx)
> {
> - if (hidx >= 0)
> + if (hidx >= 0) {
> + sem_index = hidx;
> tst_resm(TPASS, "the highest index is correct");
> - else
> + } else {
> + sem_index = 0;
> tst_resm(TFAIL, "the highest index is incorrect");
> + }
> }
>
> static void func_sinfo(void)
> --
> 1.8.1
>
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [LTP] [PATCH V2] semctl01.c: Pass the correct parameter
2013-05-22 1:52 [LTP] [PATCH V2] semctl01.c: Pass the correct parameter DAN LI
2013-05-22 7:11 ` Jan Stancek
@ 2013-05-22 8:56 ` Wanlong Gao
1 sibling, 0 replies; 3+ messages in thread
From: Wanlong Gao @ 2013-05-22 8:56 UTC (permalink / raw)
To: DAN LI; +Cc: LTP list
On 05/22/2013 09:52 AM, DAN LI wrote:
> For SEM_STAT, the semid argument is not a semaphore identifier, but instead an
> index into the kernel’s internal array that maintains information about all
> semaphore sets on the system.
>
> Pass a correct index of the kernel' internal array intead of a semaphores id when
> testing feature SEM_STAT.
>
> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
Applied, thank you.
Wanlong Gao
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-22 8:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-22 1:52 [LTP] [PATCH V2] semctl01.c: Pass the correct parameter DAN LI
2013-05-22 7:11 ` Jan Stancek
2013-05-22 8:56 ` Wanlong Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox