* [LTP] [PATCH] semctl01.c: Pass the correct parameter
@ 2013-05-21 8:51 DAN LI
2013-05-21 10:22 ` Jan Stancek
0 siblings, 1 reply; 3+ messages in thread
From: DAN LI @ 2013-05-21 8:51 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 | 28 +++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl01.c b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
index 687d909..aee6ccf 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl01.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
@@ -52,6 +52,8 @@ char *TCID = "semctl01";
int TST_TOTAL = 13;
static int sem_id_1 = -1;
+static int sem_id;
+static int sem_index;
static int sync_pipes[2];
@@ -67,12 +69,12 @@ static void pid_setup(void), func_pid(int);
static void func_gval(int);
static void sall_setup(void), func_sall(void);
static void func_sval(void);
-static void func_rmid(void);
+static void rmid_setup(void), func_rmid(void);
static void child_cnt(void);
static void child_pid(void);
static void func_iinfo(int);
static void func_sinfo(void);
-static void func_sstat(int);
+static void sstat_setup(void), func_sstat(int);
static struct semid_ds buf;
static struct seminfo ipc_buf;
@@ -117,8 +119,8 @@ static struct test_case_t {
{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},
+ {0, SEM_STAT, func_sstat, SEMUN_CAST & buf, sstat_setup},
+ {0, IPC_RMID, func_rmid, SEMUN_CAST & buf, rmid_setup},
};
int main(int argc, char *argv[])
@@ -538,6 +540,11 @@ static void func_sval(void)
tst_resm(TPASS, "semaphore value is correct");
}
+static void rmid_setup(void)
+{
+ sem_id_1 = sem_id;
+}
+
/*
* func_rmid() - check the functionality of the IPC_RMID command with semctl()
*/
@@ -560,10 +567,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)
@@ -574,6 +584,12 @@ static void func_sinfo(void)
tst_resm(TPASS, "number of semaphore sets is correct");
}
+static void sstat_setup(void)
+{
+ sem_id = sem_id_1;
+ sem_id_1 = sem_index;
+}
+
static void func_sstat(int semidx)
{
if (semidx >= 0)
--
1.7.11.rc0
------------------------------------------------------------------------------
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] semctl01.c: Pass the correct parameter
2013-05-21 8:51 [LTP] [PATCH] semctl01.c: Pass the correct parameter DAN LI
@ 2013-05-21 10:22 ` Jan Stancek
2013-05-22 1:47 ` DAN LI
0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2013-05-21 10:22 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>
> Sent: Tuesday, 21 May, 2013 10:51:53 AM
> Subject: [LTP] [PATCH] 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>
> ---
Hi,
that backup/restore of global variable in setup/cleanup funcs
between testcases looks a bit odd to me.
How about adding new field to test_case_t?
+static int sem_index = 0;
static struct test_case_t {
+ int *semid;
...
- TEST(semctl(sem_id_1, TC[i].semnum, TC[i].cmd,
+ TEST(semctl(*(TC[i].semid), TC[i].semnum, TC[i].cmd,
These you could initialise in TC[] definition to either &sem_id_1 or &sem_index
and avoid all that backup/restore of sem_id_1.
What do you think?
Regards,
Jan
------------------------------------------------------------------------------
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] semctl01.c: Pass the correct parameter
2013-05-21 10:22 ` Jan Stancek
@ 2013-05-22 1:47 ` DAN LI
0 siblings, 0 replies; 3+ messages in thread
From: DAN LI @ 2013-05-22 1:47 UTC (permalink / raw)
To: Jan Stancek; +Cc: LTP list
On 05/21/2013 06:22 PM, Jan Stancek wrote:
>
>
>
>
> ----- Original Message -----
>> From: "DAN LI" <li.dan@cn.fujitsu.com>
>> To: "LTP list" <ltp-list@lists.sourceforge.net>
>> Sent: Tuesday, 21 May, 2013 10:51:53 AM
>> Subject: [LTP] [PATCH] 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>
>> ---
>
> Hi,
>
> that backup/restore of global variable in setup/cleanup funcs
> between testcases looks a bit odd to me.
>
> How about adding new field to test_case_t?
>
> +static int sem_index = 0;
> static struct test_case_t {
> + int *semid;
> ...
> - TEST(semctl(sem_id_1, TC[i].semnum, TC[i].cmd,
> + TEST(semctl(*(TC[i].semid), TC[i].semnum, TC[i].cmd,
>
> These you could initialise in TC[] definition to either &sem_id_1 or &sem_index
> and avoid all that backup/restore of sem_id_1.
>
> What do you think?
Sounds better.;)
Thank you for reviewing.
Regards,
DAN LI
>
> Regards,
> Jan
>
------------------------------------------------------------------------------
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 1:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-21 8:51 [LTP] [PATCH] semctl01.c: Pass the correct parameter DAN LI
2013-05-21 10:22 ` Jan Stancek
2013-05-22 1:47 ` DAN LI
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox