diff options
Diffstat (limited to 'tools')
54 files changed, 0 insertions, 3777 deletions
diff --git a/tools/regression/acct/Makefile b/tools/regression/acct/Makefile deleted file mode 100644 index 581cc5f..0000000 --- a/tools/regression/acct/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# -# $FreeBSD$ -# -# "make" will compile the acct test programs -# - -PROG= pack -SRCS= pack.c -MAN= -CFLAGS+= -I${.OBJDIR} - -pack.o: convert.c - -CLEANFILES+= convert.c -convert.c: ../../../sys/kern/kern_acct.c - sed -n -e 's/log(/syslog(/g' \ - -e '/FLOAT_CONVERSION_START/,/FLOAT_CONVERSION_END/p' $? >$@ - -regress: pack regress.t - ${.CURDIR}/regress.t - -.include <bsd.prog.mk> diff --git a/tools/regression/acct/pack.c b/tools/regression/acct/pack.c deleted file mode 100644 index d1d3085..0000000 --- a/tools/regression/acct/pack.c +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * Copyright (c) 2007 Diomidis Spinellis. 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. - * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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 <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> - -#include <assert.h> -#include <float.h> -#include <limits.h> -#include <math.h> -#include <stdio.h> -#include <stdint.h> -#include <stdlib.h> -#include <strings.h> -#include <syslog.h> -#include <time.h> - -#define KASSERT(val, msg) assert(val) - -typedef u_int32_t comp_t; - -#define AHZ 1000000 - -#include "convert.c" - -static int nerr; - -union cf { - comp_t c; - float f; -}; - -static void -check_result(const char *name, float expected, union cf v) -{ - double eps; - - eps = fabs(expected - v.f) / expected; - if (eps > FLT_EPSILON) { - printf("Error in %s\n", name); - printf("Got 0x%08x %12g\n", v.c, v.f); - v.f = expected; - printf("Expected 0x%08x %12g (%.15lg)\n", v.c, v.f, expected); - printf("Epsilon=%lg, rather than %g\n", eps, FLT_EPSILON); - nerr++; - } -} - -int -main(int argc, char *argv[]) -{ - union cf v; - long l; - int i, end; - struct timeval tv; - - if (argc == 2) { - /* Loop test */ - end = atoi(argv[1]); - for (i = 0; i < end; i++) { - tv.tv_sec = random(); - tv.tv_usec = (random() % 1000000); - v.c = encode_timeval(tv); - check_result("encode_timeval", - (float)tv.tv_sec * AHZ + tv.tv_usec, v); - l = random(); - v.c = encode_long(l); - check_result("encode_long", l, v); - } - } else if (argc == 3) { - /* Single-value timeval/long test */ - tv.tv_sec = atol(argv[1]); - tv.tv_usec = atol(argv[2]); - v.c = encode_timeval(tv); - check_result("encode_timeval", - (float)tv.tv_sec * AHZ + tv.tv_usec, v); - v.c = encode_long(tv.tv_sec); - check_result("encode_long", tv.tv_sec, v); - } else { - fprintf(stderr, "usage:\n%s repetitions\n%s sec usec\n", - argv[0], argv[0]); - return (1); - } - return (nerr); -} diff --git a/tools/regression/acct/regress.t b/tools/regression/acct/regress.t deleted file mode 100755 index 3f63c3a..0000000 --- a/tools/regression/acct/regress.t +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# $FreeBSD$ -# - -if test -z "${DIR}" ; then - DIR=$( make -V .OBJDIR ) -fi -if test -z "${DIR}" ; then - DIR=$( dirname $0 ) -fi - -check() -{ - NUM=$1 - shift - if $DIR/pack $* - then - echo "ok $NUM" - else - echo "not ok $NUM" - fi -} - -(cd $DIR ; make pack) >/dev/null 2>&1 - -echo 1..7 - -check 1 0 0 -check 2 0 1 -check 3 1 0 -check 4 1 999999 -check 5 1 1000000 -check 6 2147483647 999999 -check 7 10000000 - -(cd $DIR ; make clean) >/dev/null 2>&1 - -exit 0 diff --git a/tools/regression/lib/libc/locale/Makefile b/tools/regression/lib/libc/locale/Makefile deleted file mode 100644 index ebbd537..0000000 --- a/tools/regression/lib/libc/locale/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# $FreeBSD$ - -TESTS= test-mbrtowc \ - test-wcrtomb \ - test-mbsnrtowcs \ - test-mbsrtowcs \ - test-wcsnrtombs \ - test-wcsrtombs \ - test-btowc \ - test-mbrlen \ - test-mbtowc \ - test-wctomb \ - test-mbstowcs \ - test-wcstombs \ - test-mblen \ - test-iswctype \ - test-towctrans \ - test-c16rtomb \ - test-mbrtoc16 - -.PHONY: tests -tests: ${TESTS} - for p in ${TESTS}; do ${.OBJDIR}/$$p; done - -.PHONY: clean -clean: - -rm -f ${TESTS} diff --git a/tools/regression/lib/libc/locale/test-btowc.c b/tools/regression/lib/libc/locale/test-btowc.c deleted file mode 100644 index b01c043..0000000 --- a/tools/regression/lib/libc/locale/test-btowc.c +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * Copyright (c) 2002 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for btowc() and wctob() as specified by IEEE Std. 1003.1-2001 - * and ISO/IEC 9899:1999. - * - * The function is tested in the "C" and "ja_JP.eucJP" locales. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <wchar.h> - -int -main(int argc, char *argv[]) -{ - int i; - - printf("1..2\n"); - - /* - * C/POSIX locale. - */ - assert(btowc(EOF) == WEOF); - assert(wctob(WEOF) == EOF); - for (i = 0; i < UCHAR_MAX; i++) - assert(btowc(i) == (wchar_t)i && i == (int)wctob(i)); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX > 1); - assert(btowc('A') == L'A' && wctob(L'A') == 'A'); - assert(btowc(0xa3) == WEOF && wctob(0xa3c1) == EOF); - - printf("ok 1 - btowc()\n"); - printf("ok 2 - wctob()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-btowc.t b/tools/regression/lib/libc/locale/test-btowc.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-btowc.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-c16rtomb.c b/tools/regression/lib/libc/locale/test-c16rtomb.c deleted file mode 100644 index 2c188fa..0000000 --- a/tools/regression/lib/libc/locale/test-c16rtomb.c +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * Copyright (c) 2002 Tim J. Robbins - * All rights reserved. - * - * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ -/* - * Test program for c16rtomb() as specified by ISO/IEC 9899:2011. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <string.h> -#include <uchar.h> - -int -main(int argc, char *argv[]) -{ - mbstate_t s; - char buf[MB_LEN_MAX + 1]; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - /* - * If the buffer argument is NULL, c16 is implicitly 0, - * c16rtomb() resets its internal state. - */ - assert(c16rtomb(NULL, L'\0', NULL) == 1); - assert(c16rtomb(NULL, 0xdc00, NULL) == 1); - - /* Null wide character. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - assert(c16rtomb(buf, 0, &s) == 1); - assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc); - - /* Latin letter A, internal state. */ - assert(c16rtomb(NULL, L'\0', NULL) == 1); - assert(c16rtomb(NULL, L'A', NULL) == 1); - - /* Latin letter A. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - assert(c16rtomb(buf, L'A', &s) == 1); - assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc); - - /* Unicode character 'Pile of poo'. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - assert(c16rtomb(buf, 0xd83d, &s) == 0); - assert(c16rtomb(buf, 0xdca9, &s) == (size_t)-1); - assert(errno == EILSEQ); - assert((unsigned char)buf[0] == 0xcc); - - /* - * ISO8859-1. - */ - - assert(strcmp(setlocale(LC_CTYPE, "en_US.ISO8859-1"), - "en_US.ISO8859-1") == 0); - - /* Unicode character 'Euro sign'. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - assert(c16rtomb(buf, 0x20ac, &s) == (size_t)-1); - assert(errno == EILSEQ); - assert((unsigned char)buf[0] == 0xcc); - - /* - * ISO8859-15. - */ - - assert(strcmp(setlocale(LC_CTYPE, "en_US.ISO8859-15"), - "en_US.ISO8859-15") == 0); - - /* Unicode character 'Euro sign'. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - assert(c16rtomb(buf, 0x20ac, &s) == 1); - assert((unsigned char)buf[0] == 0xa4 && (unsigned char)buf[1] == 0xcc); - - /* - * UTF-8. - */ - - assert(strcmp(setlocale(LC_CTYPE, "en_US.UTF-8"), "en_US.UTF-8") == 0); - - /* Unicode character 'Pile of poo'. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - assert(c16rtomb(buf, 0xd83d, &s) == 0); - assert(c16rtomb(buf, 0xdca9, &s) == 4); - assert((unsigned char)buf[0] == 0xf0 && (unsigned char)buf[1] == 0x9f && - (unsigned char)buf[2] == 0x92 && (unsigned char)buf[3] == 0xa9 && - (unsigned char)buf[4] == 0xcc); - - /* Invalid code; 'Pile of poo' without the trail surrogate. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - assert(c16rtomb(buf, 0xd83d, &s) == 0); - assert(c16rtomb(buf, L'A', &s) == (size_t)-1); - assert(errno == EILSEQ); - assert((unsigned char)buf[0] == 0xcc); - - /* Invalid code; 'Pile of poo' without the lead surrogate. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - assert(c16rtomb(buf, 0xdca9, &s) == (size_t)-1); - assert(errno == EILSEQ); - assert((unsigned char)buf[0] == 0xcc); - - printf("ok 1 - c16rtomb()\n"); -} diff --git a/tools/regression/lib/libc/locale/test-iswctype.c b/tools/regression/lib/libc/locale/test-iswctype.c deleted file mode 100644 index 1c56b88..0000000 --- a/tools/regression/lib/libc/locale/test-iswctype.c +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * Copyright (c) 2003 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for wctype() and iswctype() as specified by - * IEEE Std. 1003.1-2001 and ISO/IEC 9899:1999. - * - * The functions are tested in the "C" and "ja_JP.eucJP" locales. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <locale.h> -#include <stdio.h> -#include <string.h> -#include <wchar.h> -#include <wctype.h> - -int -main(int argc, char *argv[]) -{ - wctype_t t; - int i, j; - struct { - const char *name; - int (*func)(wint_t); - } cls[] = { - { "alnum", iswalnum }, - { "alpha", iswalpha }, - { "blank", iswblank }, - { "cntrl", iswcntrl }, - { "digit", iswdigit }, - { "graph", iswgraph }, - { "lower", iswlower }, - { "print", iswprint }, - { "punct", iswpunct }, - { "space", iswspace }, - { "upper", iswupper }, - { "xdigit", iswxdigit } - }; - - printf("1..2\n"); - - /* - * C/POSIX locale. - */ - for (i = 0; i < sizeof(cls) / sizeof(*cls); i++) { - t = wctype(cls[i].name); - assert(t != 0); - for (j = 0; j < 256; j++) - assert(cls[i].func(j) == iswctype(j, t)); - } - t = wctype("elephant"); - assert(t == 0); - for (i = 0; i < 256; i++) - assert(iswctype(i, t) == 0); - - /* - * Japanese (EUC) locale. - */ - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - for (i = 0; i < sizeof(cls) / sizeof(*cls); i++) { - t = wctype(cls[i].name); - assert(t != 0); - for (j = 0; j < 65536; j++) - assert(cls[i].func(j) == iswctype(j, t)); - } - t = wctype("elephant"); - assert(t == 0); - for (i = 0; i < 65536; i++) - assert(iswctype(i, t) == 0); - - printf("ok 1 - iswctype()\n"); - printf("ok 2 - wctype()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-iswctype.t b/tools/regression/lib/libc/locale/test-iswctype.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-iswctype.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-mblen.c b/tools/regression/lib/libc/locale/test-mblen.c deleted file mode 100644 index dd07359..0000000 --- a/tools/regression/lib/libc/locale/test-mblen.c +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * Copyright (c) 2002-2004 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for mblen(), as specified by IEEE Std. 1003.1-2001 and - * ISO/IEC 9899:1990. - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -int -main(int argc, char *argv[]) -{ - size_t len; - char buf[MB_LEN_MAX + 1]; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - assert(MB_CUR_MAX == 1); - - /* No shift states in C locale. */ - assert(mblen(NULL, 0) == 0); - - /* Null wide character. */ - memset(buf, 0xcc, sizeof(buf)); - buf[0] = '\0'; - assert(mblen(buf, 1) == 0); - - /* Latin letter A. */ - buf[0] = 'A'; - assert(mblen(buf, 1) == 1); - - /* Incomplete character sequence. */ - buf[0] = '\0'; - assert(mblen(buf, 0) == -1); - assert(mblen(NULL, 0) == 0); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX > 1); - - /* No shift states in EUC. */ - assert(mblen(NULL, 0) == 0); - - /* Null wide character. */ - memset(buf, 0xcc, sizeof(buf)); - buf[0] = '\0'; - assert(mblen(buf, 1) == 0); - - /* Latin letter A. */ - buf[0] = 'A'; - assert(mblen(buf, 1) == 1); - - /* Incomplete character sequence. */ - buf[0] = '\0'; - assert(mblen(buf, 0) == -1); - assert(mblen(NULL, 0) == 0); - - /* Incomplete character sequence (truncated double-byte). */ - memset(buf, 0xcc, sizeof(buf)); - buf[0] = 0xa3; - buf[1] = 0x00; - assert(mblen(buf, 1) == -1); - assert(mblen(NULL, 0) == 0); - - /* Same as above, but complete. */ - buf[1] = 0xc1; - assert(mblen(buf, 2) == 2); - - printf("ok 1 - mblen()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-mblen.t b/tools/regression/lib/libc/locale/test-mblen.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-mblen.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-mbrlen.c b/tools/regression/lib/libc/locale/test-mbrlen.c deleted file mode 100644 index 3198a77..0000000 --- a/tools/regression/lib/libc/locale/test-mbrlen.c +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * Copyright (c) 2002 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for mbrlen(), as specified by IEEE Std. 1003.1-2001 and - * ISO/IEC 9899:1999. - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <wchar.h> - -int -main(int argc, char *argv[]) -{ - mbstate_t s; - size_t len; - char buf[MB_LEN_MAX + 1]; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - assert(MB_CUR_MAX == 1); - - /* Null wide character, internal state. */ - memset(buf, 0xcc, sizeof(buf)); - buf[0] = 0; - assert(mbrlen(buf, 1, NULL) == 0); - - /* Null wide character. */ - memset(&s, 0, sizeof(s)); - assert(mbrlen(buf, 1, &s) == 0); - - /* Latin letter A, internal state. */ - assert(mbrlen(NULL, 0, NULL) == 0); - buf[0] = 'A'; - assert(mbrlen(buf, 1, NULL) == 1); - - /* Latin letter A. */ - memset(&s, 0, sizeof(s)); - assert(mbrlen(buf, 1, &s) == 1); - - /* Incomplete character sequence. */ - memset(&s, 0, sizeof(s)); - assert(mbrlen(buf, 0, &s) == (size_t)-2); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX > 1); - - /* Null wide character, internal state. */ - assert(mbrlen(NULL, 0, NULL) == 0); - memset(buf, 0xcc, sizeof(buf)); - buf[0] = 0; - assert(mbrlen(buf, 1, NULL) == 0); - - /* Null wide character. */ - memset(&s, 0, sizeof(s)); - assert(mbrlen(buf, 1, &s) == 0); - - /* Latin letter A, internal state. */ - assert(mbrlen(NULL, 0, NULL) == 0); - buf[0] = 'A'; - assert(mbrlen(buf, 1, NULL) == 1); - - /* Latin letter A. */ - memset(&s, 0, sizeof(s)); - assert(mbrlen(buf, 1, &s) == 1); - - /* Incomplete character sequence (zero length). */ - memset(&s, 0, sizeof(s)); - assert(mbrlen(buf, 0, &s) == (size_t)-2); - - /* Incomplete character sequence (truncated double-byte). */ - memset(buf, 0xcc, sizeof(buf)); - buf[0] = 0xa3; - buf[1] = 0x00; - memset(&s, 0, sizeof(s)); - assert(mbrlen(buf, 1, &s) == (size_t)-2); - - /* Same as above, but complete. */ - buf[1] = 0xc1; - memset(&s, 0, sizeof(s)); - assert(mbrlen(buf, 2, &s) == 2); - - printf("ok 1 - mbrlen()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-mbrlen.t b/tools/regression/lib/libc/locale/test-mbrlen.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-mbrlen.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-mbrtoc16.c b/tools/regression/lib/libc/locale/test-mbrtoc16.c deleted file mode 100644 index f709a9c..0000000 --- a/tools/regression/lib/libc/locale/test-mbrtoc16.c +++ /dev/null @@ -1,195 +0,0 @@ -/*- - * Copyright (c) 2002 Tim J. Robbins - * All rights reserved. - * - * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ -/* - * Test program for mbrtoc16() as specified by ISO/IEC 9899:2011. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <string.h> -#include <uchar.h> - -int -main(int argc, char *argv[]) -{ - mbstate_t s; - size_t len; - char16_t c16; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - /* Null wide character, internal state. */ - assert(mbrtoc16(&c16, "", 1, NULL) == 0); - assert(c16 == 0); - - /* Null wide character. */ - memset(&s, 0, sizeof(s)); - assert(mbrtoc16(&c16, "", 1, &s) == 0); - assert(c16 == 0); - - /* Latin letter A, internal state. */ - assert(mbrtoc16(NULL, 0, 0, NULL) == 0); - assert(mbrtoc16(&c16, "A", 1, NULL) == 1); - assert(c16 == L'A'); - - /* Latin letter A. */ - memset(&s, 0, sizeof(s)); - assert(mbrtoc16(&c16, "A", 1, &s) == 1); - assert(c16 == L'A'); - - /* Incomplete character sequence. */ - c16 = L'z'; - memset(&s, 0, sizeof(s)); - assert(mbrtoc16(&c16, "", 0, &s) == (size_t)-2); - assert(c16 == L'z'); - - /* Check that mbrtoc16() doesn't access the buffer when n == 0. */ - c16 = L'z'; - memset(&s, 0, sizeof(s)); - assert(mbrtoc16(&c16, "", 0, &s) == (size_t)-2); - assert(c16 == L'z'); - - /* Check that mbrtoc16() doesn't read ahead too aggressively. */ - memset(&s, 0, sizeof(s)); - assert(mbrtoc16(&c16, "AB", 2, &s) == 1); - assert(c16 == L'A'); - assert(mbrtoc16(&c16, "C", 1, &s) == 1); - assert(c16 == L'C'); - - /* - * ISO-8859-1. - */ - - assert(strcmp(setlocale(LC_CTYPE, "en_US.ISO8859-1"), - "en_US.ISO8859-1") == 0); - - /* Currency sign. */ - memset(&s, 0, sizeof(s)); - assert(mbrtoc16(&c16, "\xa4", 1, &s) == 1); - assert(c16 == 0xa4); - - /* - * ISO-8859-15. - */ - - assert(strcmp(setlocale(LC_CTYPE, "en_US.ISO8859-15"), - "en_US.ISO8859-15") == 0); - - /* Euro sign. */ - memset(&s, 0, sizeof(s)); - assert(mbrtoc16(&c16, "\xa4", 1, &s) == 1); - assert(c16 == 0x20ac); - - /* - * UTF-8. - */ - - assert(strcmp(setlocale(LC_CTYPE, "en_US.UTF-8"), "en_US.UTF-8") == 0); - - /* Null wide character, internal state. */ - assert(mbrtoc16(NULL, 0, 0, NULL) == 0); - assert(mbrtoc16(&c16, "", 1, NULL) == 0); - assert(c16 == 0); - - /* Null wide character. */ - memset(&s, 0, sizeof(s)); - assert(mbrtoc16(&c16, "", 1, &s) == 0); - assert(c16 == 0); - - /* Latin letter A, internal state. */ - assert(mbrtoc16(NULL, 0, 0, NULL) == 0); - assert(mbrtoc16(&c16, "A", 1, NULL) == 1); - assert(c16 == L'A'); - - /* Latin letter A. */ - memset(&s, 0, sizeof(s)); - assert(mbrtoc16(&c16, "A", 1, &s) == 1); - assert(c16 == L'A'); - - /* Incomplete character sequence (zero length). */ - c16 = L'z'; - memset(&s, 0, sizeof(s)); - assert(mbrtoc16(&c16, "", 0, &s) == (size_t)-2); - assert(c16 == L'z'); - - /* Incomplete character sequence (truncated double-byte). */ - memset(&s, 0, sizeof(s)); - c16 = 0; - assert(mbrtoc16(&c16, "\xc3", 1, &s) == (size_t)-2); - - /* Same as above, but complete. */ - memset(&s, 0, sizeof(s)); - c16 = 0; - assert(mbrtoc16(&c16, "\xc3\x84", 2, &s) == 2); - assert(c16 == 0xc4); - - /* Test restarting behaviour. */ - memset(&s, 0, sizeof(s)); - c16 = 0; - assert(mbrtoc16(&c16, "\xc3", 1, &s) == (size_t)-2); - assert(c16 == 0); - assert(mbrtoc16(&c16, "\xb7", 1, &s) == 1); - assert(c16 == 0xf7); - - /* Surrogate pair. */ - memset(&s, 0, sizeof(s)); - c16 = 0; - assert(mbrtoc16(&c16, "\xf0\x9f\x92\xa9", 4, &s) == 4); - assert(c16 == 0xd83d); - assert(mbrtoc16(&c16, "", 0, &s) == (size_t)-3); - assert(c16 == 0xdca9); - - /* Letter e with acute, precomposed. */ - memset(&s, 0, sizeof(s)); - c16 = 0; - assert(mbrtoc16(&c16, "\xc3\xa9", 2, &s) == 2); - assert(c16 == 0xe9); - - /* Letter e with acute, combined. */ - memset(&s, 0, sizeof(s)); - c16 = 0; - assert(mbrtoc16(&c16, "\x65\xcc\x81", 3, &s) == 1); - assert(c16 == 0x65); - assert(mbrtoc16(&c16, "\xcc\x81", 2, &s) == 2); - assert(c16 == 0x301); - - printf("ok 1 - mbrtoc16()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-mbrtowc.c b/tools/regression/lib/libc/locale/test-mbrtowc.c deleted file mode 100644 index e9a2ea0..0000000 --- a/tools/regression/lib/libc/locale/test-mbrtowc.c +++ /dev/null @@ -1,163 +0,0 @@ -/*- - * Copyright (c) 2002 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for mbrtowc(), as specified by IEEE Std. 1003.1-2001 and - * ISO/IEC 9899:1999. - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <wchar.h> - -int -main(int argc, char *argv[]) -{ - mbstate_t s; - size_t len; - wchar_t wc; - char buf[MB_LEN_MAX + 1]; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - assert(MB_CUR_MAX == 1); - - /* Null wide character, internal state. */ - memset(buf, 0xcc, sizeof(buf)); - buf[0] = 0; - assert(mbrtowc(&wc, buf, 1, NULL) == 0); - assert(wc == 0); - - /* Null wide character. */ - memset(&s, 0, sizeof(s)); - assert(mbrtowc(&wc, buf, 1, &s) == 0); - assert(wc == 0); - - /* Latin letter A, internal state. */ - assert(mbrtowc(NULL, 0, 0, NULL) == 0); - buf[0] = 'A'; - assert(mbrtowc(&wc, buf, 1, NULL) == 1); - assert(wc == L'A'); - - /* Latin letter A. */ - memset(&s, 0, sizeof(s)); - assert(mbrtowc(&wc, buf, 1, &s) == 1); - assert(wc == L'A'); - - /* Incomplete character sequence. */ - wc = L'z'; - memset(&s, 0, sizeof(s)); - assert(mbrtowc(&wc, buf, 0, &s) == (size_t)-2); - assert(wc == L'z'); - - /* Check that mbrtowc() doesn't access the buffer when n == 0. */ - wc = L'z'; - memset(&s, 0, sizeof(s)); - buf[0] = '\0'; - assert(mbrtowc(&wc, buf, 0, &s) == (size_t)-2); - assert(wc == L'z'); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX > 1); - - /* Null wide character, internal state. */ - assert(mbrtowc(NULL, 0, 0, NULL) == 0); - memset(buf, 0xcc, sizeof(buf)); - buf[0] = 0; - assert(mbrtowc(&wc, buf, 1, NULL) == 0); - assert(wc == 0); - - /* Null wide character. */ - memset(&s, 0, sizeof(s)); - assert(mbrtowc(&wc, buf, 1, &s) == 0); - assert(wc == 0); - - /* Latin letter A, internal state. */ - assert(mbrtowc(NULL, 0, 0, NULL) == 0); - buf[0] = 'A'; - assert(mbrtowc(&wc, buf, 1, NULL) == 1); - assert(wc == L'A'); - - /* Latin letter A. */ - memset(&s, 0, sizeof(s)); - assert(mbrtowc(&wc, buf, 1, &s) == 1); - assert(wc == L'A'); - - /* Incomplete character sequence (zero length). */ - wc = L'z'; - memset(&s, 0, sizeof(s)); - assert(mbrtowc(&wc, buf, 0, &s) == (size_t)-2); - assert(wc == L'z'); - - /* Incomplete character sequence (truncated double-byte). */ - memset(buf, 0xcc, sizeof(buf)); - buf[0] = 0xa3; - buf[1] = 0x00; - memset(&s, 0, sizeof(s)); - wc = 0; - assert(mbrtowc(&wc, buf, 1, &s) == (size_t)-2); - - /* Same as above, but complete. */ - buf[1] = 0xc1; - memset(&s, 0, sizeof(s)); - wc = 0; - assert(mbrtowc(&wc, buf, 2, &s) == 2); - assert(wc == 0xa3c1); - - /* Test restarting behaviour. */ - memset(buf, 0xcc, sizeof(buf)); - buf[0] = 0xa3; - memset(&s, 0, sizeof(s)); - wc = 0; - assert(mbrtowc(&wc, buf, 1, &s) == (size_t)-2); - assert(wc == 0); - buf[0] = 0xc1; - assert(mbrtowc(&wc, buf, 1, &s) == 1); - assert(wc == 0xa3c1); - - printf("ok 1 - mbrtowc()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-mbrtowc.t b/tools/regression/lib/libc/locale/test-mbrtowc.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-mbrtowc.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-mbsnrtowcs.c b/tools/regression/lib/libc/locale/test-mbsnrtowcs.c deleted file mode 100644 index 585dd4e..0000000 --- a/tools/regression/lib/libc/locale/test-mbsnrtowcs.c +++ /dev/null @@ -1,194 +0,0 @@ -/*- - * Copyright (c) 2002-2004 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for mbsnrtowcs(). - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <wchar.h> - -int -main(int argc, char *argv[]) -{ - char srcbuf[128]; - wchar_t dstbuf[128]; - char *src; - mbstate_t s; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - /* Simple null terminated string. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(mbsnrtowcs(dstbuf, (const char **)&src, 6, sizeof(dstbuf) / - sizeof(*dstbuf), &s) == 5); - assert(wcscmp(dstbuf, L"hello") == 0); - assert(dstbuf[6] == 0xcccc); - assert(src == NULL); - - /* Simple null terminated string, stopping early. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(mbsnrtowcs(dstbuf, (const char **)&src, 4, sizeof(dstbuf) / - sizeof(*dstbuf), &s) == 4); - assert(wmemcmp(dstbuf, L"hell", 4) == 0); - assert(dstbuf[5] == 0xcccc); - assert(src == srcbuf + 4); - - /* Not enough space in destination buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(mbsnrtowcs(dstbuf, (const char **)&src, 6, 4, &s) == 4); - assert(wmemcmp(dstbuf, L"hell", 4) == 0); - assert(dstbuf[5] == 0xcccc); - assert(src == srcbuf + 4); - - /* Null terminated string, internal dest. buffer */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(mbsnrtowcs(NULL, (const char **)&src, 6, 0, &s) == 5); - - /* Null terminated string, internal dest. buffer, stopping early */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(mbsnrtowcs(NULL, (const char **)&src, 4, 0, &s) == 4); - - /* Null terminated string, internal state. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - src = srcbuf; - assert(mbsnrtowcs(dstbuf, (const char **)&src, 6, sizeof(dstbuf) / - sizeof(*dstbuf), NULL) == 5); - assert(wcscmp(dstbuf, L"hello") == 0); - assert(dstbuf[6] == 0xcccc); - assert(src == NULL); - - /* Null terminated string, internal state, internal dest. buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - src = srcbuf; - assert(mbsnrtowcs(NULL, (const char **)&src, 6, 0, NULL) == 5); - - /* Empty source buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - srcbuf[0] = '\0'; - src = srcbuf; - memset(&s, 0, sizeof(s)); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbsnrtowcs(dstbuf, (const char **)&src, 1, 1, &s) == 0); - assert(dstbuf[0] == 0); - assert(dstbuf[1] == 0xcccc); - assert(src == NULL); - - /* Zero length destination buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - src = srcbuf; - memset(&s, 0, sizeof(s)); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbsnrtowcs(dstbuf, (const char **)&src, 1, 0, &s) == 0); - assert(dstbuf[0] == 0xcccc); - assert(src == srcbuf); - - /* Zero length source buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbsnrtowcs(dstbuf, (const char **)&src, 0, 1, &s) == 0); - assert(dstbuf[0] == 0xcccc); - assert(src == srcbuf); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX > 1); - - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "\xA3\xC1 B \xA3\xC3"); - src = srcbuf; - memset(&s, 0, sizeof(s)); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbsnrtowcs(dstbuf, (const char **)&src, 8, sizeof(dstbuf) / - sizeof(*dstbuf), &s) == 5); - assert(dstbuf[0] == 0xA3C1 && dstbuf[1] == 0x20 && dstbuf[2] == 0x42 && - dstbuf[3] == 0x20 && dstbuf[4] == 0xA3C3 && dstbuf[5] == 0); - assert(src == NULL); - - /* Partial character. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "\xA3\xC1 B \xA3\xC3"); - src = srcbuf; - memset(&s, 0, sizeof(s)); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbsnrtowcs(dstbuf, (const char **)&src, 6, sizeof(dstbuf) / - sizeof(*dstbuf), &s) == 4); - assert(src == srcbuf + 6); - assert(!mbsinit(&s)); - assert(mbsnrtowcs(dstbuf, (const char **)&src, 1, sizeof(dstbuf) / - sizeof(*dstbuf), &s) == 1); - assert(src == srcbuf + 7); - assert(mbsnrtowcs(dstbuf, (const char **)&src, 1, sizeof(dstbuf) / - sizeof(*dstbuf), &s) == 0); - assert(src == NULL); - - printf("ok 1 - mbsnrtowcs()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-mbsnrtowcs.t b/tools/regression/lib/libc/locale/test-mbsnrtowcs.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-mbsnrtowcs.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-mbsrtowcs.c b/tools/regression/lib/libc/locale/test-mbsrtowcs.c deleted file mode 100644 index dd6a7e1..0000000 --- a/tools/regression/lib/libc/locale/test-mbsrtowcs.c +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * Copyright (c) 2002 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for mbsrtowcs(), as specified by IEEE Std. 1003.1-2001 and - * ISO/IEC 9899:1999. - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <wchar.h> - -int -main(int argc, char *argv[]) -{ - char srcbuf[128]; - wchar_t dstbuf[128]; - char *src; - mbstate_t s; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - /* Simple null terminated string. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(mbsrtowcs(dstbuf, (const char **)&src, sizeof(dstbuf) / - sizeof(*dstbuf), &s) == 5); - assert(wcscmp(dstbuf, L"hello") == 0); - assert(dstbuf[6] == 0xcccc); - assert(src == NULL); - - /* Not enough space in destination buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(mbsrtowcs(dstbuf, (const char **)&src, 4, &s) == 4); - assert(wmemcmp(dstbuf, L"hell", 4) == 0); - assert(dstbuf[5] == 0xcccc); - assert(src == srcbuf + 4); - - /* Null terminated string, internal dest. buffer */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(mbsrtowcs(NULL, (const char **)&src, 0, &s) == 5); - - /* Null terminated string, internal state. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - src = srcbuf; - assert(mbsrtowcs(dstbuf, (const char **)&src, sizeof(dstbuf) / - sizeof(*dstbuf), NULL) == 5); - assert(wcscmp(dstbuf, L"hello") == 0); - assert(dstbuf[6] == 0xcccc); - assert(src == NULL); - - /* Null terminated string, internal state, internal dest. buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - src = srcbuf; - assert(mbsrtowcs(NULL, (const char **)&src, 0, NULL) == 5); - - /* Empty source buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - srcbuf[0] = '\0'; - src = srcbuf; - memset(&s, 0, sizeof(s)); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbsrtowcs(dstbuf, (const char **)&src, 1, &s) == 0); - assert(dstbuf[0] == 0); - assert(dstbuf[1] == 0xcccc); - assert(src == NULL); - - /* Zero length destination buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - src = srcbuf; - memset(&s, 0, sizeof(s)); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbsrtowcs(dstbuf, (const char **)&src, 0, &s) == 0); - assert(dstbuf[0] == 0xcccc); - assert(src == srcbuf); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX > 1); - - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "\xA3\xC1 B \xA3\xC3"); - src = srcbuf; - memset(&s, 0, sizeof(s)); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbsrtowcs(dstbuf, (const char **)&src, sizeof(dstbuf) / - sizeof(*dstbuf), &s) == 5); - assert(dstbuf[0] == 0xA3C1 && dstbuf[1] == 0x20 && dstbuf[2] == 0x42 && - dstbuf[3] == 0x20 && dstbuf[4] == 0xA3C3 && dstbuf[5] == 0); - assert(src == NULL); - - printf("ok 1 - mbsrtowcs()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-mbsrtowcs.t b/tools/regression/lib/libc/locale/test-mbsrtowcs.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-mbsrtowcs.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-mbstowcs.c b/tools/regression/lib/libc/locale/test-mbstowcs.c deleted file mode 100644 index 18039dd..0000000 --- a/tools/regression/lib/libc/locale/test-mbstowcs.c +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * Copyright (c) 2002 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for mbstowcs(), as specified by IEEE Std. 1003.1-2001 and - * ISO/IEC 9899:1999. - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <wchar.h> - -int -main(int argc, char *argv[]) -{ - char srcbuf[128]; - wchar_t dstbuf[128]; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - /* Simple null terminated string. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbstowcs(dstbuf, srcbuf, sizeof(dstbuf) / sizeof(*dstbuf)) == 5); - assert(wcscmp(dstbuf, L"hello") == 0); - assert(dstbuf[6] == 0xcccc); - - /* Not enough space in destination buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbstowcs(dstbuf, srcbuf, 4) == 4); - assert(wmemcmp(dstbuf, L"hell", 4) == 0); - assert(dstbuf[5] == 0xcccc); - - /* Null terminated string, internal dest. buffer (XSI extension) */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - assert(mbstowcs(NULL, srcbuf, 0) == 5); - - /* Empty source buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - srcbuf[0] = '\0'; - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbstowcs(dstbuf, srcbuf, 1) == 0); - assert(dstbuf[0] == 0); - assert(dstbuf[1] == 0xcccc); - - /* Zero length destination buffer. */ - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "hello"); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbstowcs(dstbuf, srcbuf, 0) == 0); - assert(dstbuf[0] == 0xcccc); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX > 1); - - memset(srcbuf, 0xcc, sizeof(srcbuf)); - strcpy(srcbuf, "\xA3\xC1 B \xA3\xC3"); - wmemset(dstbuf, 0xcccc, sizeof(dstbuf) / sizeof(*dstbuf)); - assert(mbstowcs(dstbuf, srcbuf, sizeof(dstbuf) / sizeof(*dstbuf)) == 5); - assert(dstbuf[0] == 0xA3C1 && dstbuf[1] == 0x20 && dstbuf[2] == 0x42 && - dstbuf[3] == 0x20 && dstbuf[4] == 0xA3C3 && dstbuf[5] == 0); - - printf("ok 1 - mbstowcs()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-mbstowcs.t b/tools/regression/lib/libc/locale/test-mbstowcs.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-mbstowcs.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-mbtowc.c b/tools/regression/lib/libc/locale/test-mbtowc.c deleted file mode 100644 index 5ee070c..0000000 --- a/tools/regression/lib/libc/locale/test-mbtowc.c +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * Copyright (c) 2002-2004 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for mbtowc(), as specified by IEEE Std. 1003.1-2001 and - * ISO/IEC 9899:1990. - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -int -main(int argc, char *argv[]) -{ - size_t len; - wchar_t wc; - char buf[MB_LEN_MAX + 1]; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - assert(MB_CUR_MAX == 1); - - /* No shift states in C locale. */ - assert(mbtowc(NULL, NULL, 0) == 0); - - /* Null wide character. */ - wc = 0xcccc; - memset(buf, 0, sizeof(buf)); - assert(mbtowc(&wc, buf, 1) == 0); - assert(wc == 0); - - /* Latin letter A. */ - buf[0] = 'A'; - assert(mbtowc(&wc, buf, 1) == 1); - assert(wc == L'A'); - - /* Incomplete character sequence. */ - wc = L'z'; - buf[0] = '\0'; - assert(mbtowc(&wc, buf, 0) == -1); - assert(wc == L'z'); - assert(mbtowc(NULL, NULL, 0) == 0); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX > 1); - - /* Null wide character */ - memset(buf, 0xcc, sizeof(buf)); - buf[0] = 0; - wc = 0xcccc; - assert(mbtowc(&wc, buf, 1) == 0); - assert(wc == 0); - - /* Latin letter A. */ - buf[0] = 'A'; - assert(mbtowc(&wc, buf, 1) == 1); - assert(wc == L'A'); - - /* Incomplete character sequence (zero length). */ - wc = L'z'; - buf[0] = '\0'; - assert(mbtowc(&wc, buf, 0) == -1); - assert(wc == L'z'); - assert(mbtowc(NULL, NULL, 0) == 0); - - /* Incomplete character sequence (truncated double-byte). */ - memset(buf, 0xcc, sizeof(buf)); - buf[0] = 0xa3; - buf[1] = 0x00; - wc = L'z'; - assert(mbtowc(&wc, buf, 1) == -1); - assert(wc == L'z'); - assert(mbtowc(NULL, NULL, 0) == 0); - - /* Same as above, but complete. */ - buf[1] = 0xc1; - assert(mbtowc(&wc, buf, 2) == 2); - assert(wc == 0xa3c1); - - printf("ok 1 - mbtowc()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-mbtowc.t b/tools/regression/lib/libc/locale/test-mbtowc.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-mbtowc.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-towctrans.c b/tools/regression/lib/libc/locale/test-towctrans.c deleted file mode 100644 index fabb343..0000000 --- a/tools/regression/lib/libc/locale/test-towctrans.c +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * Copyright (c) 2003 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for wctrans() and towctrans() as specified by - * IEEE Std. 1003.1-2001 and ISO/IEC 9899:1999. - * - * The functions are tested in the "C" and "ja_JP.eucJP" locales. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <locale.h> -#include <stdio.h> -#include <string.h> -#include <wchar.h> -#include <wctype.h> - -int -main(int argc, char *argv[]) -{ - wctype_t t; - int i, j; - struct { - const char *name; - wint_t (*func)(wint_t); - } tran[] = { - { "tolower", towlower }, - { "toupper", towupper }, - }; - - printf("1..2\n"); - - /* - * C/POSIX locale. - */ - for (i = 0; i < sizeof(tran) / sizeof(*tran); i++) { - t = wctrans(tran[i].name); - assert(t != 0); - for (j = 0; j < 256; j++) - assert(tran[i].func(j) == towctrans(j, t)); - } - t = wctrans("elephant"); - assert(t == 0); - for (i = 0; i < 256; i++) - assert(towctrans(i, t) == i); - - /* - * Japanese (EUC) locale. - */ - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - for (i = 0; i < sizeof(tran) / sizeof(*tran); i++) { - t = wctrans(tran[i].name); - assert(t != 0); - for (j = 0; j < 65536; j++) - assert(tran[i].func(j) == towctrans(j, t)); - } - t = wctrans("elephant"); - assert(t == 0); - for (i = 0; i < 65536; i++) - assert(towctrans(i, t) == i); - - printf("ok 1 - towctrans()\n"); - printf("ok 2 - wctrans()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-towctrans.t b/tools/regression/lib/libc/locale/test-towctrans.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-towctrans.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-wcrtomb.c b/tools/regression/lib/libc/locale/test-wcrtomb.c deleted file mode 100644 index d7ec029..0000000 --- a/tools/regression/lib/libc/locale/test-wcrtomb.c +++ /dev/null @@ -1,134 +0,0 @@ -/*- - * Copyright (c) 2002 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for wcrtomb(), as specified by IEEE Std. 1003.1-2001 and - * ISO/IEC 9899:1999. - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <wchar.h> - -int -main(int argc, char *argv[]) -{ - mbstate_t s; - size_t len; - char buf[MB_LEN_MAX + 1]; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - assert(MB_CUR_MAX == 1); - - /* - * If the buffer argument is NULL, wc is implicitly L'\0', - * wcrtomb() resets its internal state. - */ - assert(wcrtomb(NULL, L'\0', NULL) == 1); - assert(wcrtomb(NULL, UCHAR_MAX + 1, NULL) == 1); - - /* Null wide character. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - len = wcrtomb(buf, L'\0', &s); - assert(len == 1); - assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc); - - /* Latin letter A, internal state. */ - assert(wcrtomb(NULL, L'\0', NULL) == 1); - assert(wcrtomb(NULL, L'A', NULL) == 1); - - /* Latin letter A. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - len = wcrtomb(buf, L'A', &s); - assert(len == 1); - assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc); - - /* Invalid code. */ - assert(wcrtomb(buf, UCHAR_MAX + 1, NULL) == (size_t)-1); - assert(errno == EILSEQ); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX == 3); - - /* - * If the buffer argument is NULL, wc is implicitly L'\0', - * wcrtomb() resets its internal state. - */ - assert(wcrtomb(NULL, L'\0', NULL) == 1); - - /* Null wide character. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - len = wcrtomb(buf, L'\0', &s); - assert(len == 1); - assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc); - - /* Latin letter A, internal state. */ - assert(wcrtomb(NULL, L'\0', NULL) == 1); - assert(wcrtomb(NULL, L'A', NULL) == 1); - - /* Latin letter A. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - len = wcrtomb(buf, L'A', &s); - assert(len == 1); - assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc); - - /* Full width letter A. */ - memset(&s, 0, sizeof(s)); - memset(buf, 0xcc, sizeof(buf)); - len = wcrtomb(buf, 0xa3c1, &s); - assert(len == 2); - assert((unsigned char)buf[0] == 0xa3 && - (unsigned char)buf[1] == 0xc1 && - (unsigned char)buf[2] == 0xcc); - - printf("ok 1 - wcrtomb()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-wcrtomb.t b/tools/regression/lib/libc/locale/test-wcrtomb.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-wcrtomb.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-wcsnrtombs.c b/tools/regression/lib/libc/locale/test-wcsnrtombs.c deleted file mode 100644 index 2290cac..0000000 --- a/tools/regression/lib/libc/locale/test-wcsnrtombs.c +++ /dev/null @@ -1,194 +0,0 @@ -/*- - * Copyright (c) 2002-2004 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for wcsnrtombs(). - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <wchar.h> - -int -main(int argc, char *argv[]) -{ - wchar_t srcbuf[128]; - char dstbuf[128]; - wchar_t *src; - mbstate_t s; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - /* Simple null terminated string. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsnrtombs(dstbuf, (const wchar_t **)&src, 6, sizeof(dstbuf), - &s) == 5); - assert(strcmp(dstbuf, "hello") == 0); - assert((unsigned char)dstbuf[6] == 0xcc); - assert(src == NULL); - - /* Simple null terminated string, stopping early. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsnrtombs(dstbuf, (const wchar_t **)&src, 4, sizeof(dstbuf), - &s) == 4); - assert(memcmp(dstbuf, "hell", 4) == 0); - assert((unsigned char)dstbuf[5] == 0xcc); - assert(src == srcbuf + 4); - - /* Not enough space in destination buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsnrtombs(dstbuf, (const wchar_t **)&src, 6, 4, - &s) == 4); - assert(memcmp(dstbuf, "hell", 4) == 0); - assert((unsigned char)dstbuf[5] == 0xcc); - assert(src == srcbuf + 4); - - /* Null terminated string, internal dest. buffer */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsnrtombs(NULL, (const wchar_t **)&src, 6, sizeof(dstbuf), - &s) == 5); - - /* Null terminated string, internal dest. buffer, stopping early. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsnrtombs(NULL, (const wchar_t **)&src, 4, sizeof(dstbuf), - &s) == 4); - - /* Null terminated string, internal state. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - assert(wcsnrtombs(dstbuf, (const wchar_t **)&src, 6, sizeof(dstbuf), - NULL) == 5); - assert(strcmp(dstbuf, "hello") == 0); - assert((unsigned char)dstbuf[6] == 0xcc); - assert(src == NULL); - - /* Null terminated string, internal state, internal dest. buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - src = srcbuf; - assert(wcsnrtombs(NULL, (const wchar_t **)&src, 6, 0, NULL) == 5); - - /* Empty source buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - srcbuf[0] = L'\0'; - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsnrtombs(dstbuf, (const wchar_t **)&src, 1, sizeof(dstbuf), - &s) == 0); - assert(dstbuf[0] == L'\0'); - - /* Zero length destination buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsnrtombs(dstbuf, (const wchar_t **)&src, 6, 0, &s) == 0); - assert((unsigned char)dstbuf[0] == 0xcc); - - /* Zero length source buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsnrtombs(dstbuf, (const wchar_t **)&src, 0, sizeof(dstbuf), - &s) == 0); - assert((unsigned char)dstbuf[0] == 0xcc); - assert(src == srcbuf); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX > 1); - - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - srcbuf[0] = 0xA3C1; - srcbuf[1] = 0x0020; - srcbuf[2] = 0x0042; - srcbuf[3] = 0x0020; - srcbuf[4] = 0xA3C3; - srcbuf[5] = 0x0000; - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsnrtombs(dstbuf, (const wchar_t **)&src, 6, sizeof(dstbuf), - &s) == 7); - assert(strcmp(dstbuf, "\xA3\xC1 B \xA3\xC3") == 0); - assert((unsigned char)dstbuf[8] == 0xcc); - assert(src == NULL); - - /* Stopping early. */ - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsnrtombs(dstbuf, (const wchar_t **)&src, 6, 6, - &s) == 5); - assert(memcmp(dstbuf, "\xA3\xC1 B ", 5) == 0); - assert((unsigned char)dstbuf[5] == 0xcc); - assert(src == srcbuf + 4); - - printf("ok 1 - wcsnrtombs()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-wcsnrtombs.t b/tools/regression/lib/libc/locale/test-wcsnrtombs.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-wcsnrtombs.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-wcsrtombs.c b/tools/regression/lib/libc/locale/test-wcsrtombs.c deleted file mode 100644 index 48fe366..0000000 --- a/tools/regression/lib/libc/locale/test-wcsrtombs.c +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * Copyright (c) 2002 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for wcsrtombs(), as specified by IEEE Std. 1003.1-2001 and - * ISO/IEC 9899:1999. - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <wchar.h> - -int -main(int argc, char *argv[]) -{ - wchar_t srcbuf[128]; - char dstbuf[128]; - wchar_t *src; - mbstate_t s; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - /* Simple null terminated string. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsrtombs(dstbuf, (const wchar_t **)&src, sizeof(dstbuf), - &s) == 5); - assert(strcmp(dstbuf, "hello") == 0); - assert((unsigned char)dstbuf[6] == 0xcc); - assert(src == NULL); - - /* Not enough space in destination buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsrtombs(dstbuf, (const wchar_t **)&src, 4, - &s) == 4); - assert(memcmp(dstbuf, "hell", 4) == 0); - assert((unsigned char)dstbuf[5] == 0xcc); - assert(src == srcbuf + 4); - - /* Null terminated string, internal dest. buffer */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsrtombs(NULL, (const wchar_t **)&src, sizeof(dstbuf), - &s) == 5); - - /* Null terminated string, internal state. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - assert(wcsrtombs(dstbuf, (const wchar_t **)&src, sizeof(dstbuf), - NULL) == 5); - assert(strcmp(dstbuf, "hello") == 0); - assert((unsigned char)dstbuf[6] == 0xcc); - assert(src == NULL); - - /* Null terminated string, internal state, internal dest. buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - src = srcbuf; - assert(wcsrtombs(NULL, (const wchar_t **)&src, 0, NULL) == 5); - - /* Empty source buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - srcbuf[0] = L'\0'; - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsrtombs(dstbuf, (const wchar_t **)&src, sizeof(dstbuf), - &s) == 0); - assert(dstbuf[0] == L'\0'); - - /* Zero length destination buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsrtombs(dstbuf, (const wchar_t **)&src, 0, &s) == 0); - assert((unsigned char)dstbuf[0] == 0xcc); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX > 1); - - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - srcbuf[0] = 0xA3C1; - srcbuf[1] = 0x0020; - srcbuf[2] = 0x0042; - srcbuf[3] = 0x0020; - srcbuf[4] = 0xA3C3; - srcbuf[5] = 0x0000; - memset(dstbuf, 0xcc, sizeof(dstbuf)); - src = srcbuf; - memset(&s, 0, sizeof(s)); - assert(wcsrtombs(dstbuf, (const wchar_t **)&src, sizeof(dstbuf), - &s) == 7); - assert(strcmp(dstbuf, "\xA3\xC1 B \xA3\xC3") == 0); - assert((unsigned char)dstbuf[8] == 0xcc); - assert(src == NULL); - - printf("ok 1 - wcsrtombs()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-wcsrtombs.t b/tools/regression/lib/libc/locale/test-wcsrtombs.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-wcsrtombs.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-wcstombs.c b/tools/regression/lib/libc/locale/test-wcstombs.c deleted file mode 100644 index f4a5770..0000000 --- a/tools/regression/lib/libc/locale/test-wcstombs.c +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * Copyright (c) 2002 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for wcstombs(), as specified by IEEE Std. 1003.1-2001 and - * ISO/IEC 9899:1999. - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <wchar.h> - -int -main(int argc, char *argv[]) -{ - wchar_t srcbuf[128]; - char dstbuf[128]; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - /* Simple null terminated string. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - assert(wcstombs(dstbuf, srcbuf, sizeof(dstbuf)) == 5); - assert(strcmp(dstbuf, "hello") == 0); - assert((unsigned char)dstbuf[6] == 0xcc); - - /* Not enough space in destination buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - assert(wcstombs(dstbuf, srcbuf, 4) == 4); - assert(memcmp(dstbuf, "hell", 4) == 0); - assert((unsigned char)dstbuf[5] == 0xcc); - - /* Null terminated string, internal dest. buffer */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - assert(wcstombs(NULL, srcbuf, sizeof(dstbuf)) == 5); - - /* Null terminated string, internal state. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - assert(wcstombs(dstbuf, srcbuf, sizeof(dstbuf)) == 5); - assert(strcmp(dstbuf, "hello") == 0); - assert((unsigned char)dstbuf[6] == 0xcc); - - /* Null terminated string, internal state, internal dest. buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - assert(wcstombs(NULL, srcbuf, 0) == 5); - - /* Empty source buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - srcbuf[0] = L'\0'; - memset(dstbuf, 0xcc, sizeof(dstbuf)); - assert(wcstombs(dstbuf, srcbuf, sizeof(dstbuf)) == 0); - assert(dstbuf[0] == L'\0'); - - /* Zero length destination buffer. */ - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - wcscpy(srcbuf, L"hello"); - memset(dstbuf, 0xcc, sizeof(dstbuf)); - assert(wcstombs(dstbuf, srcbuf, 0) == 0); - assert((unsigned char)dstbuf[0] == 0xcc); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX > 1); - - wmemset(srcbuf, 0xcc, sizeof(srcbuf) / sizeof(*srcbuf)); - srcbuf[0] = 0xA3C1; - srcbuf[1] = 0x0020; - srcbuf[2] = 0x0042; - srcbuf[3] = 0x0020; - srcbuf[4] = 0xA3C3; - srcbuf[5] = 0x0000; - memset(dstbuf, 0xcc, sizeof(dstbuf)); - assert(wcstombs(dstbuf, srcbuf, sizeof(dstbuf)) == 7); - assert(strcmp(dstbuf, "\xA3\xC1 B \xA3\xC3") == 0); - assert((unsigned char)dstbuf[8] == 0xcc); - - printf("ok 1 - wcstombs()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-wcstombs.t b/tools/regression/lib/libc/locale/test-wcstombs.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-wcstombs.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/locale/test-wctomb.c b/tools/regression/lib/libc/locale/test-wctomb.c deleted file mode 100644 index d55b3db..0000000 --- a/tools/regression/lib/libc/locale/test-wctomb.c +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * Copyright (c) 2002-2004 Tim J. Robbins - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * Test program for wctomb(), as specified by IEEE Std. 1003.1-2001 and - * ISO/IEC 9899:1999. - * - * The function is tested with both the "C" ("POSIX") LC_CTYPE setting and - * "ja_JP.eucJP". Other encodings are not tested. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -int -main(int argc, char *argv[]) -{ - size_t len; - char buf[MB_LEN_MAX + 1]; - - /* - * C/POSIX locale. - */ - - printf("1..1\n"); - - assert(MB_CUR_MAX == 1); - - /* No shift states in C locale. */ - assert(wctomb(NULL, L'\0') == 0); - - /* Null wide character. */ - memset(buf, 0xcc, sizeof(buf)); - len = wctomb(buf, L'\0'); - assert(len == 1); - assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc); - - /* Latin letter A. */ - memset(buf, 0xcc, sizeof(buf)); - len = wctomb(buf, L'A'); - assert(len == 1); - assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc); - - /* Invalid code. */ - assert(wctomb(buf, UCHAR_MAX + 1) == -1); - assert(wctomb(NULL, 0) == 0); - - /* - * Japanese (EUC) locale. - */ - - assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0); - assert(MB_CUR_MAX == 3); - - /* No shift states in EUC encoding. */ - assert(wctomb(NULL, L'\0') == 0); - - /* Null wide character. */ - memset(buf, 0xcc, sizeof(buf)); - len = wctomb(buf, L'\0'); - assert(len == 1); - assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc); - - /* Latin letter A. */ - memset(buf, 0xcc, sizeof(buf)); - len = wctomb(buf, L'A'); - assert(len == 1); - assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc); - - /* Full width letter A. */ - memset(buf, 0xcc, sizeof(buf)); - len = wctomb(buf, 0xa3c1); - assert(len == 2); - assert((unsigned char)buf[0] == 0xa3 && - (unsigned char)buf[1] == 0xc1 && - (unsigned char)buf[2] == 0xcc); - - printf("ok 1 - wctomb()\n"); - - return (0); -} diff --git a/tools/regression/lib/libc/locale/test-wctomb.t b/tools/regression/lib/libc/locale/test-wctomb.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/locale/test-wctomb.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/net/Makefile b/tools/regression/lib/libc/net/Makefile deleted file mode 100644 index 4f19edf..0000000 --- a/tools/regression/lib/libc/net/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ - -TESTS= test-ether test-eui64_aton test-eui64_ntoa -CFLAGS+= -g -Wall - -.PHONY: tests -tests: ${TESTS} - for p in ${TESTS}; do ${.OBJDIR}/$$p; done - -.PHONY: clean -clean: - -rm -f ${TESTS} diff --git a/tools/regression/lib/libc/net/test-ether.c b/tools/regression/lib/libc/net/test-ether.c deleted file mode 100644 index 7408101..0000000 --- a/tools/regression/lib/libc/net/test-ether.c +++ /dev/null @@ -1,235 +0,0 @@ -/*- - * Copyright (c) 2007 Robert N. M. Watson - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - * - * $FreeBSD$ - */ - -#include <sys/types.h> - -#include <net/ethernet.h> - -#include <stdio.h> -#include <string.h> - -static int testnum; - -#define OK() do { \ - printf("ok %d %s\n", testnum, __func__); \ - return; \ -} while (0) - -#define NOTOK(why) do { \ - printf("not ok %d %s # %s\n", testnum, __func__, why); \ - return; \ -} while (0) - -#define TODO() NOTOK("TODO") - -static const char *ether_line_string = - "01:23:45:67:89:ab ether_line_hostname"; -static const char *ether_line_hostname = "ether_line_hostname"; -static const struct ether_addr ether_line_addr = { - { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab } -}; - -static void -test_ether_line(void) -{ - struct ether_addr e; - char hostname[256]; - - testnum++; - if (ether_line(ether_line_string, &e, hostname) != 0) - NOTOK("returned error"); - if (bcmp(&e, ðer_line_addr, ETHER_ADDR_LEN) != 0) - NOTOK("bad address"); - if (strcmp(hostname, ether_line_hostname) != 0) { - printf("hostname: %s\n", hostname); - NOTOK("bad hostname"); - } - OK(); -} - -static const char *ether_line_bad_1_string = "x"; - -static void -test_ether_line_bad_1(void) -{ - struct ether_addr e; - char hostname[256]; - - testnum++; - if (ether_line(ether_line_bad_1_string, &e, hostname) == 0) - NOTOK("returned success"); - OK(); -} - -static const char *ether_line_bad_2_string = "x x"; - -static void -test_ether_line_bad_2(void) -{ - struct ether_addr e; - char hostname[256]; - - testnum++; - if (ether_line(ether_line_bad_2_string, &e, hostname) == 0) - NOTOK("returned success"); - OK(); -} - -static const char *ether_aton_string = "01:23:45:67:89:ab"; -static const struct ether_addr ether_aton_addr = { - { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab } -}; - -static void -test_ether_aton_r(void) -{ - struct ether_addr e, *ep; - - testnum++; - ep = ether_aton_r(ether_aton_string, &e); - if (ep == NULL) - NOTOK("returned NULL"); - if (ep != &e) - NOTOK("returned different pointer"); - if (bcmp(&e, ðer_aton_addr, ETHER_ADDR_LEN) != 0) - NOTOK("bad address"); - OK(); -} - -static const char *ether_aton_bad_string = "x"; - -static void -test_ether_aton_r_bad(void) -{ - struct ether_addr e, *ep; - - testnum++; - ep = ether_aton_r(ether_aton_bad_string, &e); - if (ep == &e) - NOTOK("returned success"); - if (ep != NULL) - NOTOK("returned different pointer"); - OK(); -} - -static void -test_ether_aton(void) -{ - struct ether_addr *ep; - - testnum++; - ep = ether_aton(ether_aton_string); - if (ep == NULL) - NOTOK("returned NULL"); - if (bcmp(ep, ðer_aton_addr, ETHER_ADDR_LEN) != 0) - NOTOK("bad address"); - OK(); -} - -static void -test_ether_aton_bad(void) -{ - struct ether_addr *ep; - - testnum++; - ep = ether_aton(ether_aton_bad_string); - if (ep != NULL) - NOTOK("returned success"); - OK(); -} - -static const char *ether_ntoa_string = "01:23:45:67:89:ab"; -static const struct ether_addr ether_ntoa_addr = { - { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab } -}; - -static void -test_ether_ntoa_r(void) -{ - char buf[256], *cp; - - testnum++; - cp = ether_ntoa_r(ðer_ntoa_addr, buf); - if (cp == NULL) - NOTOK("returned NULL"); - if (cp != buf) - NOTOK("returned different pointer"); - if (strcmp(cp, ether_ntoa_string) != 0) - NOTOK("bad string"); - OK(); -} - -static void -test_ether_ntoa(void) -{ - char *cp; - - testnum++; - cp = ether_ntoa(ðer_ntoa_addr); - if (cp == NULL) - NOTOK("returned NULL"); - if (strcmp(cp, ether_ntoa_string) != 0) - NOTOK("bad string"); - OK(); -} - -static void -test_ether_ntohost(void) -{ - - testnum++; - TODO(); -} - -static void -test_ether_hostton(void) -{ - - testnum++; - TODO(); -} - -int -main(int argc, char *argv[]) -{ - - printf("1..11\n"); - - test_ether_line(); - test_ether_line_bad_1(); - test_ether_line_bad_2(); - test_ether_aton_r(); - test_ether_aton_r_bad(); - test_ether_aton(); - test_ether_aton_bad(); - test_ether_ntoa_r(); - test_ether_ntoa(); - test_ether_ntohost(); - test_ether_hostton(); - return (0); -} diff --git a/tools/regression/lib/libc/net/test-ether.t b/tools/regression/lib/libc/net/test-ether.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/net/test-ether.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/net/test-eui64.h b/tools/regression/lib/libc/net/test-eui64.h deleted file mode 100644 index ea82a10..0000000 --- a/tools/regression/lib/libc/net/test-eui64.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2004 The Aerospace Corporation. 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 Aerospace Corporation may not be used to endorse or - * promote products derived from this software. - * - * THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "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 AEROSPACE CORPORATION 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. - * - * $FreeBSD$ - */ -#ifndef _TEST_EUI64_H -#define _TEST_EUI64_H - -struct eui64 test_eui64_id = {{0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77}}; -struct eui64 test_eui64_eui48 = {{0x00,0x11,0x22,0xFF,0xFE,0x33,0x44,0x55}}; -struct eui64 test_eui64_mac48 = {{0x00,0x11,0x22,0xFF,0xFF,0x33,0x44,0x55}}; - -#define test_eui64_id_ascii "00-11-22-33-44-55-66-77" -#define test_eui64_id_colon_ascii "00:11:22:33:44:55:66:77" -#define test_eui64_hex_ascii "0x0011223344556677" -#define test_eui64_eui48_ascii "00-11-22-ff-fe-33-44-55" -#define test_eui64_mac48_ascii "00-11-22-ff-fe-33-44-55" -#define test_eui64_mac_ascii "00-11-22-33-44-55" -#define test_eui64_mac_colon_ascii "00:11:22:33:44:55" -#define test_eui64_id_host "id" -#define test_eui64_eui48_host "eui-48" -#define test_eui64_mac48_host "mac-48" - -#define test_eui64_line_id "00-11-22-33-44-55-66-77 id" -#define test_eui64_line_id_colon "00:11:22:33:44:55:66:77 id" -#define test_eui64_line_eui48 "00-11-22-FF-fe-33-44-55 eui-48" -#define test_eui64_line_mac48 "00-11-22-FF-ff-33-44-55 mac-48" -#define test_eui64_line_eui48_6byte "00-11-22-33-44-55 eui-48" -#define test_eui64_line_eui48_6byte_c "00:11:22:33:44:55 eui-48" - -#endif /* !_TEST_EUI64_H */ diff --git a/tools/regression/lib/libc/net/test-eui64_aton.c b/tools/regression/lib/libc/net/test-eui64_aton.c deleted file mode 100644 index e10f985..0000000 --- a/tools/regression/lib/libc/net/test-eui64_aton.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2004 The Aerospace Corporation. 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 Aerospace Corporation may not be used to endorse or - * promote products derived from this software. - * - * THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "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 AEROSPACE CORPORATION 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. - * - * $FreeBSD$ - */ - -#include <sys/types.h> -#include <sys/eui64.h> -#include <stdio.h> -#include <string.h> - -#include "test-eui64.h" - -static int -test_str( const char *str, const struct eui64 *eui) -{ - struct eui64 e; - char buf[EUI64_SIZ]; - static int test = 0; - - test++; - - if (eui64_aton(str, &e) != 0 && - memcmp(&e, &eui, sizeof(struct eui64)) != 0) { - printf("not ok %d - : eui64_aton(%s)\n", test, str); - eui64_ntoa(&e, buf, sizeof(buf)); - printf("# got: %s\n", buf); - return (0); - } else { - printf("ok %d - eui64_aton(%s)\n", test, str); - return (1); - } - -} - -int -main(int argc, char **argv) -{ - - printf("1..5\n"); - - test_str(test_eui64_id_ascii, &test_eui64_id); - test_str(test_eui64_id_colon_ascii, &test_eui64_id); - test_str(test_eui64_mac_ascii, &test_eui64_eui48); - test_str(test_eui64_mac_colon_ascii, &test_eui64_eui48); - test_str(test_eui64_hex_ascii, &test_eui64_id); - - return (0); -} diff --git a/tools/regression/lib/libc/net/test-eui64_aton.t b/tools/regression/lib/libc/net/test-eui64_aton.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/net/test-eui64_aton.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/lib/libc/net/test-eui64_ntoa.c b/tools/regression/lib/libc/net/test-eui64_ntoa.c deleted file mode 100644 index f7582f0..0000000 --- a/tools/regression/lib/libc/net/test-eui64_ntoa.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2004 The Aerospace Corporation. 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 Aerospace Corporation may not be used to endorse or - * promote products derived from this software. - * - * THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "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 AEROSPACE CORPORATION 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. - * - * $FreeBSD$ - */ - -#include <sys/types.h> -#include <sys/eui64.h> -#include <stdio.h> -#include <string.h> - -#include "test-eui64.h" - -int -main(int argc, char **argv) -{ - char a[EUI64_SIZ]; - - printf("1..1\n"); - - if (eui64_ntoa(&test_eui64_id, a, sizeof(a)) == 0 && - strcmp(a, test_eui64_id_ascii) == 0) { - printf("ok 1 - eui64_ntoa\n"); - return (0); - } - printf("# a = '%s'\n", a); - - printf("not ok 1 - eui64_ntoa\n"); - return (0); -} diff --git a/tools/regression/lib/libc/net/test-eui64_ntoa.t b/tools/regression/lib/libc/net/test-eui64_ntoa.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/lib/libc/net/test-eui64_ntoa.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/pipe/Makefile b/tools/regression/pipe/Makefile deleted file mode 100644 index 8a5f83a..0000000 --- a/tools/regression/pipe/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# -# $FreeBSD$ -# -# "make" then "make regress". -# -PROG= bigpipetest -MAN= - -regress: - @if ./bigpipetest; then \ - echo "PASS"; \ - else \ - echo "FAIL"; \ - fi - -.include <bsd.prog.mk> diff --git a/tools/regression/pipe/bigpipetest.c b/tools/regression/pipe/bigpipetest.c deleted file mode 100644 index c5983fa..0000000 --- a/tools/regression/pipe/bigpipetest.c +++ /dev/null @@ -1,82 +0,0 @@ -#include <stdio.h> -#include <fcntl.h> -#include <unistd.h> -#include <stdlib.h> -#include <sys/select.h> -#include <string.h> -#include <errno.h> - -#define BIG_PIPE_SIZE 64*1024 /* From sys/pipe.h */ - -/* - * Test for the non-blocking big pipe bug (write(2) returning - * EAGAIN while select(2) returns the descriptor as ready for write). - * - * $FreeBSD$ - */ - -void write_frame(int fd, char *buf, unsigned long buflen) -{ - fd_set wfd; - int i; - - while (buflen) { - FD_ZERO(&wfd); - FD_SET(fd, &wfd); - i = select(fd+1, NULL, &wfd, NULL, NULL); - if (i < 0) { - perror("select"); - exit(1); - } - if (i != 1) { - fprintf(stderr, "select returned unexpected value %d\n", i); - exit(1); - } - i = write(fd, buf, buflen); - if (i < 0) { - if (errno != EAGAIN) - perror("write"); - exit(1); - } - buf += i; - buflen -= i; - } -} - -int main() -{ - char buf[BIG_PIPE_SIZE]; /* any value over PIPE_SIZE should do */ - int i, flags, fd[2]; - - printf("1..1\n"); - - if (pipe(fd) < 0) { perror("pipe"); exit(1); } - - flags = fcntl(fd[1], F_GETFL); - if (flags == -1 || fcntl(fd[1], F_SETFL, flags|O_NONBLOCK) == -1) { - perror("fcntl"); - exit(1); - } - - switch (fork()) { - case -1: - perror("fork"); - exit(1); - case 0: - close(fd[1]); - for (;;) { - i = read(fd[0], buf, 256); /* any small size should do */ - if (i == 0) break; - if (i < 0) { perror("read"); exit(1); } - } - exit(0); - default: - break; - } - - close(fd[0]); - memset(buf, 0, sizeof buf); - for (i = 0; i < 1000; i++) write_frame(fd[1], buf, sizeof buf); - printf("ok 1\n"); - exit(0); -} diff --git a/tools/regression/pipe/bigpipetest.t b/tools/regression/pipe/bigpipetest.t deleted file mode 100644 index 8bdfd03..0000000 --- a/tools/regression/pipe/bigpipetest.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -cd `dirname $0` - -executable=`basename $0 .t` - -make $executable 2>&1 > /dev/null - -exec ./$executable diff --git a/tools/regression/pipe/pipe-fstatbug.c b/tools/regression/pipe/pipe-fstatbug.c deleted file mode 100644 index 724c2d8..0000000 --- a/tools/regression/pipe/pipe-fstatbug.c +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright (C) 2004 Michael J. Silbersack. 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. - -THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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 <stdio.h> -#include <unistd.h> -#include <sys/stat.h> - -/* - * $FreeBSD$ - * The goal of this program is to see if fstat reports the correct - * data count for a pipe. Prior to revision 1.172 of sys_pipe.c, - * 0 would be returned once the pipe entered direct write mode. - * - * Linux (2.6) always returns zero, so it's not a valuable platform - * for comparison. - */ - -int main (void) -{ -char buffer[32768], buffer2[32768]; -int desc[2]; -int error, successes = 0; -struct stat status; -pid_t new_pid; - -error = pipe(desc); - -if (error) - err(0, "Couldn't allocate fds\n"); - -new_pid = fork(); - -if (new_pid == 0) { - write(desc[1], &buffer, 145); - usleep(1000000); - write(desc[1], &buffer, 2048); - usleep(1000000); - write(desc[1], &buffer, 4096); - usleep(1000000); - write(desc[1], &buffer, 8191); - usleep(1000000); - write(desc[1], &buffer, 8192); - usleep(1000000); -} else { - while (successes < 5) { - usleep(3000); - fstat(desc[0], &status); - error = read(desc[0], &buffer2, 32768); - if (status.st_size != error) - err(0, "FAILURE: stat size %d read size %d\n", (int)status.st_size, error); - if (error > 0) { - printf("SUCCESS at stat size %d read size %d\n", (int)status.st_size, error); - successes++; - /* Sleep to avoid the natural race in reading st_size. */ - usleep(1000000); - } - } -} - -} diff --git a/tools/regression/pipe/pipe-ino.c b/tools/regression/pipe/pipe-ino.c deleted file mode 100644 index f739cc9..0000000 --- a/tools/regression/pipe/pipe-ino.c +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 2011 Giovanni Trematerra <giovanni.trematerra@gmail.com> - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - */ - -/* - * $FreeBSD$ - * Test conformance to stat(2) SUSv4 description: - * "For all other file types defined in this volume of POSIX.1-2008, the - * structure members st_mode, st_ino, st_dev, st_uid, st_gid, st_atim, - * st_ctim, and st_mtim shall have meaningful values ...". - * Check that st_dev and st_ino are meaningful. - */ - -#include <sys/types.h> -#include <sys/stat.h> -#include <err.h> -#include <stdio.h> -#include <unistd.h> - -int -main(int argc, char **argv) -{ - int pipefd[2]; - struct stat st1, st2; - - if (pipe(pipefd) == -1) - err(1, "FAIL: pipe"); - - if (fstat(pipefd[0], &st1) == -1) - err(1, "FAIL: fstat st1"); - if (fstat(pipefd[1], &st2) == -1) - err(1, "FAIL: fstat st2"); - if (st1.st_dev != st2.st_dev || st1.st_dev == 0 || st2.st_dev == 0) { - errx(1, "FAIL: wrong dev number %d %d", - st1.st_dev, st2.st_dev); - } - if (st1.st_ino == st2.st_ino) - errx(1, "FAIL: inode numbers are equal: %d", st1.st_ino); - close(pipefd[0]); - close(pipefd[1]); - printf("PASS\n"); - - return (0); -} diff --git a/tools/regression/pipe/pipe-overcommit1.c b/tools/regression/pipe/pipe-overcommit1.c deleted file mode 100644 index c468658..0000000 --- a/tools/regression/pipe/pipe-overcommit1.c +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (C) 2005 Michael J. Silbersack <silby@freebsd.org> - * 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(s), this list of conditions and the following disclaimer as - * the first lines of this file unmodified other than the possible - * addition of one or more copyright notices. - * 2. Redistributions in binary form must reproduce the above copyright - * notice(s), this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 <stdio.h> -#include <stdlib.h> - -/* - * $FreeBSD$ - * This program just allocates as many pipes as it can to ensure - * that using up all pipe memory doesn't cause a panic. - */ - -int main (void) - -{ - int i, returnval; - int pipes[10000]; - for (i = 0; i < 10000; i++) { - returnval = pipe(&pipes[i]); - } - printf("PASS\n"); -} diff --git a/tools/regression/pipe/pipe-overcommit2.c b/tools/regression/pipe/pipe-overcommit2.c deleted file mode 100644 index 5979585..0000000 --- a/tools/regression/pipe/pipe-overcommit2.c +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * Copyright (C) 2005 Michael J. Silbersack <silby@freebsd.org> - * 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(s), this list of conditions and the following disclaimer as - * the first lines of this file unmodified other than the possible - * addition of one or more copyright notices. - * 2. Redistributions in binary form must reproduce the above copyright - * notice(s), this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 <stdio.h> -#include <stdlib.h> -#include <fcntl.h> - -/* - * $FreeBSD$ - * This program tests how sys_pipe.c handles the case where there - * is ample memory to allocate a pipe, but the file descriptor - * limit for that user has been exceeded. - */ - -int main (int argc, void *argv[]) - -{ - int i, returnval, lastfd; - int pipes[10000]; - - for (i = 0; i < 100000; i++) { - returnval = open(argv[0], O_RDONLY); - if (returnval < 1) - break; /* All descriptors exhausted. */ - else - lastfd = returnval; - } - - /* First falloc failure case in sys_pipe.c:pipe() */ - for (i = 0; i < 1000; i++) { - returnval = pipe(&pipes[i]); - } - - /* - * Free just one FD so that the second falloc failure - * case will occur. - */ - close(lastfd); - - for (i = 0; i < 1000; i++) { - returnval = pipe(&pipes[i]); - } - printf("PASS\n"); -} diff --git a/tools/regression/pipe/pipe-reverse.c b/tools/regression/pipe/pipe-reverse.c deleted file mode 100644 index 702c516..0000000 --- a/tools/regression/pipe/pipe-reverse.c +++ /dev/null @@ -1,113 +0,0 @@ -/* -Copyright (C) 2004 Michael J. Silbersack. 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. - -THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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 <stdio.h> -#include <unistd.h> -#include <sys/stat.h> - -/* - * $FreeBSD$ - * This program simply tests writing through the reverse direction of - * a pipe. Nothing too fancy, it's only needed because most pipe-using - * programs never touch the reverse direction (it doesn't exist on - * Linux.) - */ - -int main (void) -{ -char buffer[65535], buffer2[65535]; -int desc[2]; -int buggy, error, i, successes, total; -struct stat status; -pid_t new_pid; - -buggy = 0; -total = 0; - -error = pipe(desc); - -if (error) - err(0, "Couldn't allocate fds\n"); - -buffer[0] = 'A'; - -for (i = 1; i < 65535; i++) { - buffer[i] = buffer[i - 1] + 1; - if (buffer[i] > 'Z') - buffer[i] = 'A'; - } - -new_pid = fork(); - -if (new_pid == 0) { - error = write(desc[0], &buffer, 4096); - total += error; - error = write(desc[0], &buffer[total], 4096); - total += error; - error = write(desc[0], &buffer[total], 4096); - total += error; - error = write(desc[0], &buffer[total], 4096); - total += error; - error = write(desc[0], &buffer[total], 4096); - total += error; - error = write(desc[0], &buffer[total], 4096); - total += error; - error = write(desc[0], &buffer[total], 4096); - total += error; - error = write(desc[0], &buffer[total], 4096); - total += error; - printf("Wrote %d bytes, sleeping\n", total); - usleep(1000000); - error = write(desc[0], &buffer[total], 4096); - total += error; - error = write(desc[0], &buffer[total], 4096); - total += error; - printf("Wrote another 8192 bytes, %d total, done\n", total); -} else { - usleep(500000); - error = read(desc[1], &buffer2, 32768); - total += error; - printf("Read %d bytes, going back to sleep\n", error); - usleep(1000000); - error = read(desc[1], &buffer2[total], 8192); - total += error; - printf("Read %d bytes, done\n", error); - - for (i = 0; i < total; i++) { - if (buffer[i] != buffer2[i]) { - buggy = 1; - printf("Location %d input: %hhx output: %hhx\n", - i, buffer[i], buffer2[i]); - } - } - -if ((buggy == 1) || (total != 40960)) - printf("FAILURE\n"); -else - printf("SUCCESS\n"); - -} - -} diff --git a/tools/regression/pipe/pipe-reverse2.c b/tools/regression/pipe/pipe-reverse2.c deleted file mode 100644 index cd54190..0000000 --- a/tools/regression/pipe/pipe-reverse2.c +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 2010 Jilles Tjoelker - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. - * - * $FreeBSD$ - */ - -#include <sys/select.h> - -#include <err.h> -#include <stdio.h> -#include <unistd.h> - -/* - * Check that pipes can be selected for writing in the reverse direction. - */ -int -main(int argc, char *argv[]) -{ - int pip[2]; - fd_set set; - int n; - - if (pipe(pip) == -1) - err(1, "FAIL: pipe"); - - FD_ZERO(&set); - FD_SET(pip[0], &set); - n = select(pip[1] + 1, NULL, &set, NULL, &(struct timeval){ 0, 0 }); - if (n != 1) - errx(1, "FAIL: select initial reverse direction"); - - n = write(pip[0], "x", 1); - if (n != 1) - err(1, "FAIL: write reverse direction"); - - FD_ZERO(&set); - FD_SET(pip[0], &set); - n = select(pip[1] + 1, NULL, &set, NULL, &(struct timeval){ 0, 0 }); - if (n != 1) - errx(1, "FAIL: select reverse direction after write"); - - printf("PASS\n"); - - return (0); -} diff --git a/tools/regression/pipe/pipe-wraparound.c b/tools/regression/pipe/pipe-wraparound.c deleted file mode 100644 index 5cf09fa..0000000 --- a/tools/regression/pipe/pipe-wraparound.c +++ /dev/null @@ -1,103 +0,0 @@ -/* -Copyright (C) 2004 Michael J. Silbersack. 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. - -THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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 <stdio.h> -#include <unistd.h> -#include <sys/stat.h> - -/* - * $FreeBSD$ - * This program tests to make sure that wraparound writes and reads - * are working, assuming that 16K socket buffers are used. In order - * to really stress the pipe code with this test, kernel modifications - * nay be necessary. - */ - -int main (void) -{ -char buffer[32768], buffer2[32768]; -int desc[2]; -int buggy, error, i, successes, total; -struct stat status; -pid_t new_pid; - -buggy = 0; -total = 0; - -error = pipe(desc); - -if (error) - err(0, "Couldn't allocate fds\n"); - -buffer[0] = 'A'; - -for (i = 1; i < 32768; i++) { - buffer[i] = buffer[i - 1] + 1; - if (buffer[i] > 'Z') - buffer[i] = 'A'; - } - -new_pid = fork(); - -if (new_pid == 0) { - error = write(desc[1], &buffer, 4096); - total += error; - error = write(desc[1], &buffer[total], 4096); - total += error; - error = write(desc[1], &buffer[total], 4000); - total += error; - printf("Wrote %d bytes, sleeping\n", total); - usleep(1000000); - error = write(desc[1], &buffer[total], 3000); - total += error; - error = write(desc[1], &buffer[total], 3000); - total += error; - printf("Wrote another 6000 bytes, %d total, done\n", total); -} else { - usleep(500000); - error = read(desc[0], &buffer2, 8192); - total += error; - printf("Read %d bytes, going back to sleep\n", error); - usleep(1000000); - error = read(desc[0], &buffer2[total], 16384); - total += error; - printf("Read %d bytes, done\n", error); - - for (i = 0; i < total; i++) { - if (buffer[i] != buffer2[i]) { - buggy = 1; - printf("Location %d input: %hhx output: %hhx\n", - i, buffer[i], buffer2[i]); - } - } - -if (buggy) - printf("FAILURE\n"); -else - printf("SUCCESS\n"); -} - - -} |