PERFORCE change 156340 for review

Robert Watson rwatson at FreeBSD.org
Sun Jan 18 09:50:50 PST 2009


http://perforce.freebsd.org/chv.cgi?CH=156340

Change 156340 by rwatson at rwatson_freebsd_capabilities on 2009/01/18 17:50:41

	Consistently check pid returned by pdgetpid() in regression
	test.

Affected files ...

.. //depot/projects/trustedbsd/capabilities/src/tools/regression/procdesc/procdesc_test.c#3 edit

Differences ...

==== //depot/projects/trustedbsd/capabilities/src/tools/regression/procdesc/procdesc_test.c#3 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/capabilities/src/tools/regression/procdesc/procdesc_test.c#2 $
+ * $P4: //depot/projects/trustedbsd/capabilities/src/tools/regression/procdesc/procdesc_test.c#3 $
  */
 
 #include <sys/types.h>
@@ -81,6 +81,9 @@
 		sleep(10);
 		if (pdgetpid(fd, &pid) < 0)
 			err(-1, "pdgetpid");
+		if (pid != realpid)
+			errx(-1, "pdfork pid %d pdgetpid pid %d", realpid,
+			    pid);
 		if (fstat(fd, &sb) < 0)
 			err(-1, "fstat");
 		if (sb.st_mode != S_IFREG)
@@ -91,15 +94,18 @@
 
 	printf("2. pdfork() and close() before child exits itself.\n");
 
-	pid = pdfork(&fd);
-	if (pid < 0)
+	realpid = pdfork(&fd);
+	if (realpid < 0)
 		err(-1, "pdfork");
-	if (pid == 0) {
+	if (realpid == 0) {
 		if (execve(sleep_argv[0], sleep_argv, environ) < 0)
 			err(-1, "%s", sleep_argv[0]);
 	} else {
 		if (pdgetpid(fd, &pid) < 0)
 			err(-1, "pdgetpid");
+		if (pid != realpid)
+			errx(-1, "pdfork pid %d pdgetpid pid %d", realpid,
+			    pid);
 		if (fstat(fd, &sb) < 0)
 			err(-1, "fstat");
 		if (sb.st_mode != (S_IFREG | S_IRWXU))
@@ -108,6 +114,9 @@
 		sleep(2);
 		if (pdgetpid(fd, &pid) < 0)
 			err(-1, "pdgetpid");
+		if (pid != realpid)
+			errx(-1, "pdfork pid %d pdgetpid pid %d", realpid,
+			    pid);
 		if (fstat(fd, &sb) < 0)
 			err(-1, "fstat");
 		if (sb.st_mode != (S_IFREG | S_IRWXU))
@@ -118,15 +127,18 @@
 
 	printf("3. pdfork() and pdkill() before child exits itself.\n");
 
-	pid = pdfork(&fd);
-	if (pid < 0)
+	realpid = pdfork(&fd);
+	if (realpid < 0)
 		err(-1, "pdfork");
-	if (pid == 0) {
+	if (realpid == 0) {
 		if (execve(sleep_argv[0], sleep_argv, environ) < 0)
 			err(-1, "%s", sleep_argv[0]);
 	} else {
 		if (pdgetpid(fd, &pid) < 0)
 			err(-1, "pdgetpid");
+		if (pid != realpid)
+			errx(-1, "pdfork pid %d pdgetpid pid %d", realpid,
+			    pid);
 		if (fstat(fd, &sb) < 0)
 			err(-1, "fstat");
 		if (sb.st_mode != (S_IFREG | S_IRWXU))
@@ -135,6 +147,9 @@
 		sleep(2);
 		if (pdgetpid(fd, &pid) < 0)
 			err(-1, "pdgetpid");
+		if (pid != realpid)
+			errx(-1, "pdfork pid %d pdgetpid pid %d", realpid,
+			    pid);
 		if (fstat(fd, &sb) < 0)
 			err(-1, "fstat");
 		if (sb.st_mode != (S_IFREG | S_IRWXU))
@@ -145,6 +160,9 @@
 		sleep(1);
 		if (pdgetpid(fd, &pid) < 0)
 			err(-1, "pdgetpid");
+		if (pid != realpid)
+			errx(-1, "pdfork pid %d pdgetpid pid %d", realpid,
+			    pid);
 		if (fstat(fd, &sb) < 0)
 			err(-1, "fstat");
 		if (sb.st_mode != S_IFREG)


More information about the p4-projects mailing list