summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2018-06-29 22:19:01 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2018-06-29 22:19:01 +0000
commit42c3adc8841167026bb8409cb5e4390a32bff49a (patch)
tree1a14cc8bedf9e1bf76a177228227b012c275be1f /tests/src
parent633445be1a9be37ae727c044417f5607706cf4ae (diff)
downloadnsss-42c3adc8841167026bb8409cb5e4390a32bff49a.tar.xz
Fix Makefile and typo in a function name, add basic tests
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/test-all.c46
-rw-r--r--tests/src/test-unix.c46
2 files changed, 92 insertions, 0 deletions
diff --git a/tests/src/test-all.c b/tests/src/test-all.c
new file mode 100644
index 0000000..147868a
--- /dev/null
+++ b/tests/src/test-all.c
@@ -0,0 +1,46 @@
+/* ISC license. */
+
+#include <errno.h>
+#include <skalibs/buffer.h>
+#include <skalibs/lolstdio.h>
+#include <nsss/pwd.h>
+#include <nsss/nsss-all.h>
+
+int main (void)
+{
+ for (;;)
+ {
+ struct passwd *pw ;
+ errno = 0 ;
+ pw = nsss_all_getpwent() ;
+ if (!pw) break ;
+ lolprintf("%s:%s:%d:%d:%s:%s:%s\n", pw->pw_name, pw->pw_passwd, (int)pw->pw_uid, (int)pw->pw_gid, pw->pw_gecos, pw->pw_dir, pw->pw_shell) ;
+ }
+ if (errno)
+ strerr_diefu1sys(111, "nsss_all_getpwent") ;
+ nsss_all_endpwent() ;
+ buffer_flush(buffer_1) ;
+ lolprintf("\n") ;
+
+ for (;;)
+ {
+ struct group *gr ;
+ char **p ;
+ errno = 0 ;
+ gr = nsss_all_getgrent() ;
+ if (!gr) break ;
+ p = gr->gr_mem ;
+ lolprintf("%s:%s:%d:", gr->gr_name, gr->gr_passwd, (int)gr->gr_gid) ;
+ if (*p)
+ {
+ while (*p) lolprintf("%s,", *p++) ;
+ buffer_unput(buffer_1, 1) ;
+ }
+ buffer_put(buffer_1, "\n", 1) ;
+ }
+ if (errno)
+ strerr_diefu1sys(111, "nsss_all_getgrent") ;
+ nsss_all_endgrent() ;
+ buffer_flush(buffer_1) ;
+ return 0 ;
+}
diff --git a/tests/src/test-unix.c b/tests/src/test-unix.c
new file mode 100644
index 0000000..e62fa01
--- /dev/null
+++ b/tests/src/test-unix.c
@@ -0,0 +1,46 @@
+/* ISC license. */
+
+#include <errno.h>
+#include <skalibs/buffer.h>
+#include <skalibs/lolstdio.h>
+#include <nsss/pwd.h>
+#include <nsss/nsss-unix.h>
+
+int main (void)
+{
+ for (;;)
+ {
+ struct passwd *pw ;
+ errno = 0 ;
+ pw = nsss_unix_getpwent() ;
+ if (!pw) break ;
+ lolprintf("%s:%s:%d:%d:%s:%s:%s\n", pw->pw_name, pw->pw_passwd, (int)pw->pw_uid, (int)pw->pw_gid, pw->pw_gecos, pw->pw_dir, pw->pw_shell) ;
+ }
+ if (errno)
+ strerr_diefu1sys(111, "nsss_unix_getpwent") ;
+ nsss_unix_endpwent() ;
+ buffer_flush(buffer_1) ;
+ lolprintf("\n") ;
+
+ for (;;)
+ {
+ struct group *gr ;
+ char **p ;
+ errno = 0 ;
+ gr = nsss_unix_getgrent() ;
+ if (!gr) break ;
+ p = gr->gr_mem ;
+ lolprintf("%s:%s:%d:", gr->gr_name, gr->gr_passwd, (int)gr->gr_gid) ;
+ if (*p)
+ {
+ while (*p) lolprintf("%s,", *p++) ;
+ buffer_unput(buffer_1, 1) ;
+ }
+ buffer_put(buffer_1, "\n", 1) ;
+ }
+ if (errno)
+ strerr_diefu1sys(111, "nsss_unix_getgrent") ;
+ nsss_unix_endgrent() ;
+ buffer_flush(buffer_1) ;
+ return 0 ;
+}