- (dtucker) [Makefile.in configure.ac, added openbsd-compat/regress/]
Add first attempt at regress tests for compat library. ok djm@
This commit is contained in:
parent
bf209f5901
commit
4881c371ce
|
@ -1,3 +1,7 @@
|
||||||
|
20060219
|
||||||
|
- (dtucker) [Makefile.in configure.ac, added openbsd-compat/regress/]
|
||||||
|
Add first attempt at regress tests for compat library. ok djm@
|
||||||
|
|
||||||
20060214
|
20060214
|
||||||
- (tim) [buildpkg.sh.in] Make the names consistent.
|
- (tim) [buildpkg.sh.in] Make the names consistent.
|
||||||
s/pkg_post_make_install_fixes.sh/pkg-post-make-install-fixes.sh/ OK dtucker@
|
s/pkg_post_make_install_fixes.sh/pkg-post-make-install-fixes.sh/ OK dtucker@
|
||||||
|
@ -3859,4 +3863,4 @@
|
||||||
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
|
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
|
||||||
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
|
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.4129 2006/02/13 20:46:44 tim Exp $
|
$Id: ChangeLog,v 1.4130 2006/02/19 11:50:20 dtucker Exp $
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: Makefile.in,v 1.274 2006/01/01 08:47:05 djm Exp $
|
# $Id: Makefile.in,v 1.275 2006/02/19 11:50:20 dtucker Exp $
|
||||||
|
|
||||||
# uncomment if you run a non bourne compatable shell. Ie. csh
|
# uncomment if you run a non bourne compatable shell. Ie. csh
|
||||||
#SHELL = @SH@
|
#SHELL = @SH@
|
||||||
|
@ -410,6 +410,9 @@ tests: $(TARGETS)
|
||||||
EXEEXT="$(EXEEXT)" \
|
EXEEXT="$(EXEEXT)" \
|
||||||
$@
|
$@
|
||||||
|
|
||||||
|
compat-tests: $(LIBCOMPAT)
|
||||||
|
(cd openbsd-compat/regress && $(MAKE))
|
||||||
|
|
||||||
regressclean:
|
regressclean:
|
||||||
if [ -f regress/Makefile ] && [ -r regress/Makefile ]; then \
|
if [ -f regress/Makefile ] && [ -r regress/Makefile ]; then \
|
||||||
(cd regress && $(MAKE) clean) \
|
(cd regress && $(MAKE) clean) \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: configure.ac,v 1.329 2006/02/12 02:37:48 tim Exp $
|
# $Id: configure.ac,v 1.330 2006/02/19 11:50:20 dtucker Exp $
|
||||||
#
|
#
|
||||||
# Copyright (c) 1999-2004 Damien Miller
|
# Copyright (c) 1999-2004 Damien Miller
|
||||||
#
|
#
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org)
|
AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org)
|
||||||
AC_REVISION($Revision: 1.329 $)
|
AC_REVISION($Revision: 1.330 $)
|
||||||
AC_CONFIG_SRCDIR([ssh.c])
|
AC_CONFIG_SRCDIR([ssh.c])
|
||||||
|
|
||||||
AC_CONFIG_HEADER(config.h)
|
AC_CONFIG_HEADER(config.h)
|
||||||
|
@ -3729,7 +3729,7 @@ CFLAGS="$CFLAGS $werror_flags"
|
||||||
|
|
||||||
AC_EXEEXT
|
AC_EXEEXT
|
||||||
AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openbsd-compat/Makefile \
|
AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openbsd-compat/Makefile \
|
||||||
scard/Makefile ssh_prng_cmds survey.sh])
|
openbsd-compat/regress/Makefile scard/Makefile ssh_prng_cmds survey.sh])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
||||||
# Print summary of options
|
# Print summary of options
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
# $Id: Makefile.in,v 1.1 2006/02/19 11:50:20 dtucker Exp $
|
||||||
|
|
||||||
|
sysconfdir=@sysconfdir@
|
||||||
|
piddir=@piddir@
|
||||||
|
srcdir=@srcdir@
|
||||||
|
top_srcdir=@top_srcdir@
|
||||||
|
|
||||||
|
VPATH=@srcdir@
|
||||||
|
CC=@CC@
|
||||||
|
LD=@LD@
|
||||||
|
CFLAGS=@CFLAGS@
|
||||||
|
CPPFLAGS=-I. -I.. -I$(srcdir) -I$(srcdir)/.. @CPPFLAGS@ @DEFS@
|
||||||
|
LIBS=@LIBS@
|
||||||
|
LDFLAGS=-L.. -lopenbsd-compat @LDFLAGS@
|
||||||
|
|
||||||
|
LIBCOMPAT=../libopenbsd-compat.a
|
||||||
|
TESTPROGS=strtonumtest strduptest snprintftest
|
||||||
|
|
||||||
|
all: t-exec ${OTHERTESTS}
|
||||||
|
|
||||||
|
t-exec: $(TESTPROGS)
|
||||||
|
@echo running compat regress tests
|
||||||
|
@for TEST in ""$?; do \
|
||||||
|
echo "run test $${TEST}" ... 1>&2; \
|
||||||
|
./$${TEST} || exit $$? ; \
|
||||||
|
done
|
||||||
|
@echo finished compat regress tests
|
||||||
|
|
||||||
|
strtonumtest: strtonumtest.c $(LIBCOMPAT)
|
||||||
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o strtonumtest $< $(LDFLAGS)
|
||||||
|
|
||||||
|
strduptest: strduptest.c $(LIBCOMPAT)
|
||||||
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o strduptest $< $(LDFLAGS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.a core $(TESTPROGS) valid.out
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
rm -f Makefile *~
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2005 Darren Tucker
|
||||||
|
* Copyright (c) 2005 Damien Miller
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define BUFSZ 2048
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
static int failed = 0;
|
||||||
|
|
||||||
|
static void
|
||||||
|
fail(const char *m)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s", m);
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int x_snprintf(char *str, size_t count, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
size_t ret;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
ret = vsnprintf(str, count, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
char b[5];
|
||||||
|
char *src;
|
||||||
|
|
||||||
|
snprintf(b,5,"123456789");
|
||||||
|
if (b[4] != '\0')
|
||||||
|
fail("snprintf does not correctly terminate long strings");
|
||||||
|
|
||||||
|
/* check for read overrun on unterminated string */
|
||||||
|
if ((src = malloc(BUFSZ)) == NULL) {
|
||||||
|
fail("malloc failed");
|
||||||
|
} else {
|
||||||
|
memset(src, 'a', BUFSZ);
|
||||||
|
snprintf(b, sizeof(b), "%.*s", 1, src);
|
||||||
|
if (strcmp(b, "a") != 0)
|
||||||
|
fail("failed with length limit '%%.s'");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check that snprintf and vsnprintf return sane values */
|
||||||
|
if (snprintf(b, 1, "%s %d", "hello", 12345) != 11)
|
||||||
|
fail("snprintf does not return required length");
|
||||||
|
if (x_snprintf(b, 1, "%s %d", "hello", 12345) != 11)
|
||||||
|
fail("vsnprintf does not return required length");
|
||||||
|
|
||||||
|
return failed;
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2005 Darren Tucker
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int fail = 0;
|
||||||
|
|
||||||
|
void
|
||||||
|
test(const char *a)
|
||||||
|
{
|
||||||
|
char *b;
|
||||||
|
|
||||||
|
b = strdup(a);
|
||||||
|
if (b == 0) {
|
||||||
|
fail = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (strcmp(a, b) != 0)
|
||||||
|
fail = 1;
|
||||||
|
free(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
test("");
|
||||||
|
test("a");
|
||||||
|
test("\0");
|
||||||
|
test("abcdefghijklmnopqrstuvwxyz");
|
||||||
|
return fail;
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
/* $OpenBSD: strtonumtest.c,v 1.1 2004/08/03 20:38:36 otto Exp $ */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004 Otto Moerbeek <otto@drijf.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* OPENBSD ORIGINAL: regress/lib/libc/strtonum/strtonumtest.c */
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int fail;
|
||||||
|
|
||||||
|
void
|
||||||
|
test(const char *p, long long lb, long long ub, int ok)
|
||||||
|
{
|
||||||
|
long long val;
|
||||||
|
const char *q;
|
||||||
|
|
||||||
|
val = strtonum(p, lb, ub, &q);
|
||||||
|
if (ok && q != NULL) {
|
||||||
|
fprintf(stderr, "%s [%lld-%lld] ", p, lb, ub);
|
||||||
|
fprintf(stderr, "NUMBER NOT ACCEPTED %s\n", q);
|
||||||
|
fail = 1;
|
||||||
|
} else if (!ok && q == NULL) {
|
||||||
|
fprintf(stderr, "%s [%lld-%lld] %lld ", p, lb, ub, val);
|
||||||
|
fprintf(stderr, "NUMBER ACCEPTED\n");
|
||||||
|
fail = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
test("1", 0, 10, 1);
|
||||||
|
test("0", -2, 5, 1);
|
||||||
|
test("0", 2, 5, 0);
|
||||||
|
test("0", 2, LLONG_MAX, 0);
|
||||||
|
test("-2", 0, LLONG_MAX, 0);
|
||||||
|
test("0", -5, LLONG_MAX, 1);
|
||||||
|
test("-3", -3, LLONG_MAX, 1);
|
||||||
|
test("-9223372036854775808", LLONG_MIN, LLONG_MAX, 1);
|
||||||
|
test("9223372036854775807", LLONG_MIN, LLONG_MAX, 1);
|
||||||
|
test("-9223372036854775809", LLONG_MIN, LLONG_MAX, 0);
|
||||||
|
test("9223372036854775808", LLONG_MIN, LLONG_MAX, 0);
|
||||||
|
test("1000000000000000000000000", LLONG_MIN, LLONG_MAX, 0);
|
||||||
|
test("-1000000000000000000000000", LLONG_MIN, LLONG_MAX, 0);
|
||||||
|
test("-2", 10, -1, 0);
|
||||||
|
test("-2", -10, -1, 1);
|
||||||
|
test("-20", -10, -1, 0);
|
||||||
|
test("20", -10, -1, 0);
|
||||||
|
|
||||||
|
return (fail);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue