semctl01.c: Pass the correct parameter
PATCH 1/1 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.
--- testcases/kernel/syscalls/ipc/semctl/semctl01.c | 28 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/ipc/semctl/semctl01.c +22 -6
@@ -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 )
Signature · 12 lines
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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
----- Original Message -----
Quoted 11 lines
From: "DAN LI" <[email protected]>
To: "LTP list" <[email protected]>
Sent: Tuesday, 21 May, 2013 10:51:53 AM
Subject: [LTP] [PATCH]semctl01.c: Pass the correct parameterFor
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.
Quoted 6 lines
Pass a correct index of the kernel' internal array intead of a semaphores id when
testing featureSEM_STAT.Signed-off-by DAN LI <[email protected]>---
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 37 lines · Jan Stancek
----- Original Message -----
Quoted 11 lines
From: "DAN LI" <[email protected]>
To: "LTP list" <[email protected]>
Sent: Tuesday, 21 May, 2013 10:51:53 AM
Subject: [LTP] [PATCH]semctl01.c: Pass the correct parameterFor
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.Quoted 6 lines
Pass a correct index of the kernel' internal array intead of a semaphores id when
testing featureSEM_STAT.Signed-off-by DAN LI <[email protected]>---
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?(quoted diff) +3
-1+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,
Quoted 4 lines
These you could initialise in TC[] definition to either
&sem_id_1or&sem_indexand avoid all that backup/restore ofsem_id_1.What do you think?
Sounds better.;)
Thank you for reviewing.
Regards,
DAN LI
Quoted 4 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list