Test new k5_getpwuid_r macro
authorKen Raeburn <raeburn@mit.edu>
Mon, 28 Mar 2005 18:32:04 +0000 (18:32 +0000)
committerKen Raeburn <raeburn@mit.edu>
Mon, 28 Mar 2005 18:32:04 +0000 (18:32 +0000)
* configure.in: Create makefile in misc.
* Makefile.in (LOCAL_SUBDIRS): Add misc.

* misc/test_getpw.c: New file.
* misc/Makefile.in: New file, based on ../resolve/Makefile.in.
(test_getpw): New target.
(check): Build and run it.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17161 dc483132-0cff-0310-8789-dd5450dbe970

src/tests/ChangeLog
src/tests/Makefile.in
src/tests/configure.in
src/tests/misc/ChangeLog [new file with mode: 0644]
src/tests/misc/Makefile.in [new file with mode: 0644]
src/tests/misc/test_getpw.c [new file with mode: 0644]

index 3a10c382ee263e2c90b097bd2f7cb88faed5bef7..0a104749c1e785072404531c693a447ea23c6813 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-28  Ken Raeburn  <raeburn@mit.edu>
+
+       * configure.in: Create makefile in misc.
+       * Makefile.in (LOCAL_SUBDIRS): Add misc.
+
 2005-02-09  Ken Raeburn  <raeburn@mit.edu>
 
        * gss-threads: New subdirectory.
index 9e2f80bcd5ff46bd5962c48906a41d21fa266d87..c1261adc4461890fc824a2f31e387d7f5f15743d 100644 (file)
@@ -2,7 +2,7 @@ thisconfigdir=.
 mydir=.
 BUILDTOP=$(REL)..
 LOCAL_SUBDIRS = resolve asn.1 create hammer verify gssapi dejagnu shlib \
-       gss-threads
+       gss-threads misc
 
 RUN_SETUP = @KRB5_RUN_ENV@ KRB5_KDC_PROFILE=kdc.conf KRB5_CONFIG=$(SRCTOP)/config-files/krb5.conf
 KRB5_RUN_ENV= @KRB5_RUN_ENV@
index 88606f34873baf9fd81948a31257d928cd8ea885..41bb3cf8b067f24df05d26f2e86c419fc8e81a26 100644 (file)
@@ -27,4 +27,4 @@ else
 fi
 AC_SUBST(KRB4_DEJAGNU_TEST)
 KRB5_AC_PRIOCNTL_HACK
-V5_AC_OUTPUT_MAKEFILE(. resolve asn.1 create hammer verify gssapi dejagnu threads shlib gss-threads)
+V5_AC_OUTPUT_MAKEFILE(. resolve asn.1 create hammer verify gssapi dejagnu threads shlib gss-threads misc)
diff --git a/src/tests/misc/ChangeLog b/src/tests/misc/ChangeLog
new file mode 100644 (file)
index 0000000..864ee13
--- /dev/null
@@ -0,0 +1,7 @@
+2005-03-28  Ken Raeburn  <raeburn@mit.edu>
+
+       * test_getpw.c: New file.
+       * Makefile.in: New file, based on ../resolve/Makefile.in.
+       (test_getpw): New target.
+       (check): Build and run it.
+
diff --git a/src/tests/misc/Makefile.in b/src/tests/misc/Makefile.in
new file mode 100644 (file)
index 0000000..5bb4f74
--- /dev/null
@@ -0,0 +1,31 @@
+thisconfigdir=./..
+myfulldir=tests/misc
+mydir=misc
+BUILDTOP=$(REL)..$(S)..
+RUN_SETUP = @KRB5_RUN_ENV@
+PROG_LIBPATH=-L$(TOPLIBD)
+PROG_RPATH=$(KRB5_LIBDIR)
+
+OBJS=test_getpw.o
+SRCS=$(srcdir)/test_getpw.c
+
+all:: test_getpw
+
+check:: test_getpw
+       $(RUN_SETUP) ./test_getpw
+
+test_getpw: $(srcdir)/../misc/test_getpw.c ../../include/krb5/autoconf.h
+       $(CC_LINK) $(ALL_CFLAGS) -o test_getpw $(srcdir)/../misc/test_getpw.c
+
+install::
+
+clean::
+       $(RM) test_getpw
+
+# +++ Dependency line eater +++
+# 
+# Makefile dependencies follow.  This must be the last section in
+# the Makefile.in file
+#
+$(OUTPRE)test_getpw.$(OBJEXT): test_getpw.c $(BUILDTOP)/include/krb5/autoconf.h \
+  $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-thread.h
diff --git a/src/tests/misc/test_getpw.c b/src/tests/misc/test_getpw.c
new file mode 100644 (file)
index 0000000..cd5def6
--- /dev/null
@@ -0,0 +1,25 @@
+#include "krb5/autoconf.h"
+#include "k5-platform.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <pwd.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+int main()
+{
+    uid_t my_uid;
+    struct passwd *pwd, pwx;
+    char pwbuf[BUFSIZ];
+    int x;
+
+    my_uid = getuid();
+    printf("my uid: %ld\n", (long) my_uid);
+
+    x = k5_getpwuid_r(my_uid, &pwx, pwbuf, sizeof(pwbuf), &pwd);
+    printf("k5_getpwuid_r returns %d\n", x);
+    if (x != 0)
+       exit(1);
+    printf("    username is '%s'\n", pwd->pw_name);
+    exit(0);
+}