Browse Source

start of some rpc tests

Mike Frysinger 19 years ago
parent
commit
d4057a47ca
3 changed files with 81 additions and 0 deletions
  1. 38 0
      test/rpc/Makefile
  2. 18 0
      test/rpc/getrpcent.c
  3. 25 0
      test/rpc/getrpcent_r.c

+ 38 - 0
test/rpc/Makefile

@@ -0,0 +1,38 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2005 Erik Andersen <andersen@uclibc.org>
+
+include ../Rules.mak
+
+# getrpcent_r_diff
+TARGETS = getrpcent getrpcent_glibc getrpcent_diff
+
+all: $(TARGETS)
+
+getrpcent: getrpcent.c Makefile $(TESTDIR)/Rules.mak
+	-@ echo "-------"
+	-@ echo " "
+	-@ echo "Compiling $@ vs uClibc: "
+	-@ echo " "
+	$(CC) $(CFLAGS) -c $< -o $@.o
+	$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+	$(STRIPTOOL) -x -R .note -R .comment $@
+	./$@ > getrpcent.out
+	-@ echo " "
+
+getrpcent_glibc: getrpcent.c Makefile $(TESTDIR)/Rules.mak
+	-@ echo "-------"
+	-@ echo " "
+	-@ echo "Compiling $@ vs glibc: "
+	-@ echo " "
+	$(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+	$(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+	$(STRIPTOOL) -x -R .note -R .comment $@
+	./$@ > getrpcent_glibc.out
+	-@ echo " "
+
+getrpcent_diff: getrpcent getrpcent_glibc
+	diff -u getrpcent_glibc.out getrpcent.out
+
+clean:
+	$(RM) *.[oa] *~ core $(TARGETS) *.out

+ 18 - 0
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;
+}

+ 25 - 0
test/rpc/getrpcent_r.c

@@ -0,0 +1,25 @@
+#include <netdb.h>
+#include <stdio.h>
+#include <errno.h>
+
+int main(int argc, char *argv[])
+{
+	int ret;
+	char rpcdata[10024];
+	struct rpcent rpcbuf, *ent;
+memset(rpcdata, 0x00, sizeof(rpcdata));
+
+	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;
+}