Veerendra [EMAIL PROTECTED] wrote:
> Hi
>     Submitting the testcase, which would try to kill the parent namespace 
> pid from the container init.   Also this  tests a scenario of  killing  non 
> existent pid from the container.
>
>
> Regards
> Veerendra C
>
>

| [EMAIL PROTECTED] pidns]# ./pidns06
| pidns06     0  INFO  :  Parent: Passing the pid of the process 21939
| pidns06     1  PASS  :  Container: tried kill() on the parent pid 21939: 
errno set to 3 (No such process), as expected
| 
| pidns06     2  PASS  :  Container: While killing non existent pid errno set 
to 3 : No such process, as expected
| 
| 
| 
| Signed-off-by: Veerendra C <[EMAIL PROTECTED]>
| 
| 
| Index: 
root/root/new/ltp-full-20080930/testcases/kernel/containers/pidns/pidns06.c
| ===================================================================
| --- /dev/null
| +++ 
root/root/new/ltp-full-20080930/testcases/kernel/containers/pidns/pidns06.c
| @@ -0,0 +1,162 @@
| +/*
| +* Copyright (c) International Business Machines Corp., 2008
| +* This program is free software; you can redistribute it and/or modify
| +* it under the terms of the GNU General Public License as published by
| +* the Free Software Foundation; either version 2 of the License, or
| +* (at your option) any later version.
| +* This program is distributed in the hope that it will be useful
| +* but WITHOUT ANY WARRANTY; without even the implied warranty of
| +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
| +* the GNU General Public License for more details.
| +* You should have received a copy of the GNU General Public License
| +* along with this program; if not, write to the Free Software
| +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
| +
| +*************************************************************************
| +* Description:
| +*  Testcase tries killing of the parent namespace pid by the container-init.
| +*  It also tries killing of non-existent PID, by the container-init.
| +*  Returns Success if Unable to kill, and proper error number is set.
| +*  else Returns Failure
| +*
| +* Steps:
| +* 1. Parent process clone a process with flag CLONE_NEWPID
| +* 2. The pid of the parent namespace is passed to the container.
| +* 3. Container receieves the PID and passes SIGKILL to this PID.
| +* 4. If kill() is unsuccessful and the errno is set to 'No Such process'
| +*    then sets PASS
| +*    else,
| +*    sets FAIL
| +* 5. It also verifies by passing SIGKILL to FAKE_PID
| +* 6. If kill() is unsuccessful and the errno is set to 'No Such process'
| +*    then sets PASS
| +*    else,
| +*    sets FAIL
| +*
| +* History:
| +*
| +* FLAG DATE          NAME                            Description.
| +* 21/10/08   Veerendra C <[EMAIL PROTECTED]> Verifies killing of processes
| +*                                                    in container.
| 
+*******************************************************************************/
| +#define _GNU_SOURCE 1
| +#include <stdio.h>
| +#include <stdlib.h>
| +#include <sys/wait.h>
| +#include <assert.h>
| +#include <unistd.h>
| +#include <errno.h>
| +#include <usctest.h>
| +#include <test.h>
| +#include <libclone.h>
| +#include <signal.h>
| +
| +#define CINIT_PID       1
| +#define PARENT_PID      0
| +#define FAKE_PID     1230

How do we ensure that FAKE_PID pid is not in use ? There is a small
chance ( 1/pid_max :-) that a process exists. To ensure, maybe create
a process, wait for it to exit() and then kill it. Odds of a wrap-around
so quickly are much lower :-)

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to