Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Aug 2010 09:42:50 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r211418 - head/tools/test/auxinfo
Message-ID:  <201008170942.o7H9gov7025783@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Aug 17 09:42:50 2010
New Revision: 211418
URL: http://svn.freebsd.org/changeset/base/211418

Log:
  Add simple test to check the functioning of retrieval of
  pagesize()/pagesizes() after change to use aux vector. Note that
  public function getosreldate() is different from libc-internal
  __getosreldate() and does not use aux to fetch osreldate value.
  
  MFC after:	1 month

Added:
  head/tools/test/auxinfo/
  head/tools/test/auxinfo/Makefile   (contents, props changed)
  head/tools/test/auxinfo/auxinfo.c   (contents, props changed)

Added: head/tools/test/auxinfo/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/test/auxinfo/Makefile	Tue Aug 17 09:42:50 2010	(r211418)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG=	auxinfo
+NO_MAN=
+WARNS?=	6
+
+.include <bsd.prog.mk>

Added: head/tools/test/auxinfo/auxinfo.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/test/auxinfo/auxinfo.c	Tue Aug 17 09:42:50 2010	(r211418)
@@ -0,0 +1,58 @@
+/*
+ * This file is in public domain.
+ * Written by Konstantin Belousov <kib@freebsd.org>
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/mman.h>
+#include <err.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static void
+test_pagesizes(void)
+{
+	size_t *ps;
+	int i, nelem;
+
+	nelem = getpagesizes(NULL, 0);
+	if (nelem == -1)
+		err(1, "getpagesizes(NULL, 0)");
+	ps = malloc(nelem * sizeof(size_t));
+	if (ps == NULL)
+		err(1, "malloc");
+	nelem = getpagesizes(ps, nelem);
+	if (nelem == -1)
+		err(1, "getpagesizes");
+	printf("Supported page sizes:");
+	for (i = 0; i < nelem; i++)
+		printf(" %jd", (intmax_t)ps[i]);
+	printf("\n");
+}
+
+static void
+test_pagesize(void)
+{
+
+	printf("Pagesize: %d\n", getpagesize());
+}
+
+static void
+test_osreldate(void)
+{
+
+	printf("OSRELDATE: %d\n", getosreldate());
+}
+
+int
+main(int argc __unused, char *argv[] __unused)
+{
+
+	test_pagesizes();
+	test_pagesize();
+	test_osreldate();
+	return (0);
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008170942.o7H9gov7025783>