summaryrefslogtreecommitdiff
path: root/test/rpc
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2016-10-24 20:22:12 +0200
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-10-24 20:22:12 +0200
commit7988979a722b4cdf287b2093956a76a3f19b9897 (patch)
treed35e251d0472ceca55a2eef61cff261c8ee68fab /test/rpc
add uClibc-ng test directory
Diffstat (limited to 'test/rpc')
-rw-r--r--test/rpc/Makefile8
-rw-r--r--test/rpc/Makefile.in11
-rw-r--r--test/rpc/getrpcent.c18
-rw-r--r--test/rpc/getrpcent_r.c25
4 files changed, 62 insertions, 0 deletions
diff --git a/test/rpc/Makefile b/test/rpc/Makefile
new file mode 100644
index 0000000..e098072
--- /dev/null
+++ b/test/rpc/Makefile
@@ -0,0 +1,8 @@
+# uClibc rpc tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
+include ../Test.mak
diff --git a/test/rpc/Makefile.in b/test/rpc/Makefile.in
new file mode 100644
index 0000000..5612ff2
--- /dev/null
+++ b/test/rpc/Makefile.in
@@ -0,0 +1,11 @@
+# uClibc rpc tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+TESTS := getrpcent
+
+ifeq ($(UCLIBC_HAS_REENTRANT_RPC),y)
+TESTS += getrpcent_r
+endif
+
+DODIFF_getrpcent := 1
+
diff --git a/test/rpc/getrpcent.c b/test/rpc/getrpcent.c
new file mode 100644
index 0000000..e12e768
--- /dev/null
+++ b/test/rpc/getrpcent.c
@@ -0,0 +1,18 @@
+#include <netdb.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ struct rpcent *ent;
+
+ while ((ent = getrpcent()) != NULL) {
+ printf("%s: %i", ent->r_name, ent->r_number);
+ while (ent->r_aliases[0])
+ printf(" %s", *ent->r_aliases++);
+ printf("\n");
+ }
+
+ endrpcent();
+
+ return 0;
+}
diff --git a/test/rpc/getrpcent_r.c b/test/rpc/getrpcent_r.c
new file mode 100644
index 0000000..65ca61c
--- /dev/null
+++ b/test/rpc/getrpcent_r.c
@@ -0,0 +1,25 @@
+#include <netdb.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+int main(int argc, char *argv[])
+{
+ int ret;
+ char rpcdata[1024];
+ struct rpcent rpcbuf, *ent;
+
+ while ((ret = getrpcent_r(&rpcbuf, rpcdata, sizeof(rpcdata), &ent)) == 0) {
+ printf("%s: %i", ent->r_name, ent->r_number);
+ while (ent->r_aliases[0])
+ printf(" %s", *ent->r_aliases++);
+ printf("\n");
+ }
+
+ if (ret != ENOENT)
+ printf("Test failed: %s\n", strerror(ret));
+
+ endrpcent();
+
+ return 0;
+}