From: Ken Raeburn Date: Mon, 28 Mar 2005 18:32:04 +0000 (+0000) Subject: Test new k5_getpwuid_r macro X-Git-Tag: ms-bug-test-20060525~297 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bc4421a1391d0e17b5b9b07e4fb6ac2d13998c46;p=krb5.git Test new k5_getpwuid_r macro * 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 --- diff --git a/src/tests/ChangeLog b/src/tests/ChangeLog index 3a10c382e..0a104749c 100644 --- a/src/tests/ChangeLog +++ b/src/tests/ChangeLog @@ -1,3 +1,8 @@ +2005-03-28 Ken Raeburn + + * configure.in: Create makefile in misc. + * Makefile.in (LOCAL_SUBDIRS): Add misc. + 2005-02-09 Ken Raeburn * gss-threads: New subdirectory. diff --git a/src/tests/Makefile.in b/src/tests/Makefile.in index 9e2f80bcd..c1261adc4 100644 --- a/src/tests/Makefile.in +++ b/src/tests/Makefile.in @@ -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@ diff --git a/src/tests/configure.in b/src/tests/configure.in index 88606f348..41bb3cf8b 100644 --- a/src/tests/configure.in +++ b/src/tests/configure.in @@ -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 index 000000000..864ee13cd --- /dev/null +++ b/src/tests/misc/ChangeLog @@ -0,0 +1,7 @@ +2005-03-28 Ken Raeburn + + * 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 index 000000000..5bb4f7472 --- /dev/null +++ b/src/tests/misc/Makefile.in @@ -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 index 000000000..cd5def6a9 --- /dev/null +++ b/src/tests/misc/test_getpw.c @@ -0,0 +1,25 @@ +#include "krb5/autoconf.h" +#include "k5-platform.h" +#include +#include +#include +#include +#include + +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); +}