Signed-off-by: Xiaoguang Wang <[email protected]>
---
 testcases/kernel/syscalls/setpgid/setpgid01.c | 31 ++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/setpgid/setpgid01.c 
b/testcases/kernel/syscalls/setpgid/setpgid01.c
index d35f201..ed20f63 100644
--- a/testcases/kernel/syscalls/setpgid/setpgid01.c
+++ b/testcases/kernel/syscalls/setpgid/setpgid01.c
@@ -36,6 +36,7 @@
  * Description:
  * Verify that:
  *   1. Basic functionality test for setpgid(2).
+ *   2. Check proper functioning of setpgid(2) with pid = 0 and pgid = 0.
  */
 
 #include <errno.h>
@@ -52,7 +53,8 @@ static void cleanup(void);
 char *TCID = "setpgid01";
 
 static void setpgid_test1(void);
-static void (*testfunc[])(void) = { setpgid_test1};
+static void setpgid_test2(void);
+static void (*testfunc[])(void) = { setpgid_test1, setpgid_test2 };
 int TST_TOTAL = ARRAY_SIZE(testfunc);
 
 int main(int ac, char **av)
@@ -128,6 +130,33 @@ static void setpgid_test1(void)
                tst_resm(TFAIL, "test setpgid(%d, %d) fail", pid, pgid);
 }
 
+static void setpgid_test2(void)
+{
+       int ret;
+       pid_t pgid, pid;
+
+       pid = FORK_OR_VFORK();
+       if (pid == -1)
+               tst_brkm(TBROK | TERRNO, cleanup, "fork()");
+
+       if (pid != 0) {
+               ret = wait4child(pid);
+       } else {
+               pid = getpid();
+               TEST(setpgid(0, 0));
+               pgid = getpgrp();
+               if (TEST_RETURN == -1 || pid != pgid)
+                       exit(1);
+               else
+                       exit(0);
+       }
+
+       if (ret == 0)
+               tst_resm(TPASS, "test setpgid(0, 0) success");
+       else
+               tst_resm(TFAIL, "test setpgid(0, 0) fail");
+}
+
 static void setup(void)
 {
        tst_sig(FORK, DEF_HANDLER, cleanup);
-- 
1.8.2.1


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to