Add a very, very simple test of XDR handling.

It just checks decoding of doubles, which NetBSD/arm32 seems to have got
wrong forever.
This commit is contained in:
bjh21 2001-02-18 21:57:16 +00:00
parent 19b7b64642
commit 13dbf7c5c5
5 changed files with 70 additions and 2 deletions

View File

@ -1,6 +1,7 @@
# $NetBSD: Makefile,v 1.17 2001/02/14 05:20:10 cgd Exp $
# $NetBSD: Makefile,v 1.18 2001/02/18 21:57:16 bjh21 Exp $
SUBDIR+= _setjmp db div gen hsearch md5sha popen regex setjmp sigsetjmp time
SUBDIR+= _setjmp db div gen hsearch md5sha popen regex rpc setjmp sigsetjmp \
time
.if (${MACHINE_ARCH} != "arm32" && ${MACHINE_ARCH} != "vax")
SUBDIR+= ieeefp
.endif

View File

@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2001/02/18 21:57:16 bjh21 Exp $
SUBDIR= xdr
.include <bsd.subdir.mk>

View File

@ -0,0 +1,4 @@
# $NetBSD: Makefile.inc,v 1.1 2001/02/18 21:57:16 bjh21 Exp $
#
# do not install regression test programs
proginstall::

View File

@ -0,0 +1,9 @@
# $NetBSD
PROG=xdrtest
MKMAN=no
regress: ${PROG}
./${PROG}
.include <bsd.prog.mk>

View File

@ -0,0 +1,49 @@
/* $NetBSD: xdrtest.c,v 1.1 2001/02/18 21:57:17 bjh21 Exp $ */
/*-
* Copyright (c) 2001 Ben Harris
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <err.h>
#include <stdio.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
char xdrdata[] = { 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
int
main(int argc, char **argv)
{
XDR x;
double d;
xdrmem_create(&x, xdrdata, sizeof(xdrdata), XDR_DECODE);
xdr_double(&x, &d);
if (d != 1.0)
errx(1, "double 1.0 decoded wrongly.");
exit(0);
}