Browse Source

Add a bind regression test (it fails)

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 3 years ago
parent
commit
806be58ba4
2 changed files with 40 additions and 0 deletions
  1. 39 0
      sys/src/regress/bindtest.c
  2. 1 0
      sys/src/regress/build.json

+ 39 - 0
sys/src/regress/bindtest.c

@@ -0,0 +1,39 @@
+/*
+ * This file is part of the UCB release of Plan 9. It is subject to the license
+ * terms in the LICENSE file found in the top-level directory of this
+ * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
+ * part of the UCB release of Plan 9, including this file, may be copied,
+ * modified, propagated, or distributed except according to the terms contained
+ * in the LICENSE file.
+ */
+
+#include <u.h>
+#include <libc.h>
+
+int
+cexecpipe(int *p0, int *p1)
+{
+	/* pipe the hard way to get close on exec */
+	if(bind("#|", "/mnt/temp", MREPL) < 0)
+		return -1;
+	//execl("/bin/ls", "ls", "-l", "/mnt/temp", 0);
+	//wait();
+	*p0 = open("/mnt/temp/data", ORDWR);
+	*p1 = open("/mnt/temp/data1", ORDWR|OCEXEC);
+	unmount(nil, "/mnt/temp");
+	if(*p0<0 || *p1<0)
+		return -1;
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	int f1, f2, ret;
+	ret = cexecpipe(&f1, &f2);
+	print("result %d f1 %d f2 %d\n", ret, f1, f2);
+	if (ret < 0)
+		printf("FAIL\n");
+	else
+		printf("OK\n");
+
+}

+ 1 - 0
sys/src/regress/build.json

@@ -7,6 +7,7 @@
 		"SourceFilesCmd": [
 			"alarm.c",
 			"args.c",
+		        "bindtest.c",
 			"chdir.c",
 			"conswrite.c",
 			"execl.c",