Browse Source

add a basic errno test based on one from ltp

Mike Frysinger 20 years ago
parent
commit
8e31aa28dc
2 changed files with 28 additions and 1 deletions
  1. 1 1
      test/unistd/Makefile
  2. 27 0
      test/unistd/errno.c

+ 1 - 1
test/unistd/Makefile

@@ -1,7 +1,7 @@
 # uClibc unistd tests
 # Licensed under the GNU Library General Public License, see COPYING.LIB
 
-TESTS = clone fork getcwd getopt getopt_long preadwrite vfork
+TESTS = clone errno fork getcwd getopt getopt_long preadwrite vfork
 
 include ../Test.mak
 

+ 27 - 0
test/unistd/errno.c

@@ -0,0 +1,27 @@
+/* based originally on one the clone tests in the LTP */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sched.h>
+
+int child_fn(void *arg)
+{
+	fprintf(stderr, "in child_fn\n");
+	exit(1);
+}
+
+int main(void)
+{
+	int r_clone, ret_errno;
+
+	r_clone = clone(child_fn, NULL, (int) NULL, NULL);
+	ret_errno = errno;
+	if (ret_errno != EINVAL) {
+		fprintf(stderr, "clone: res=%d (%d) errno=%d %m\n",
+			r_clone, (int) NULL, errno);
+		return 1;
+	}
+
+	return 0;
+}