Index: head/etc/mtree/BSD.tests.dist =================================================================== --- head/etc/mtree/BSD.tests.dist (revision 290904) +++ head/etc/mtree/BSD.tests.dist (revision 290905) @@ -1,616 +1,618 @@ # $FreeBSD$ # # Please see the file src/etc/mtree/README before making changes to this file. # /set type=dir uname=root gname=wheel mode=0755 . bin cat .. chown .. date .. dd .. expr .. ls .. mv .. pax .. pkill .. sh builtins .. errors .. execution .. expansion .. parameters .. parser .. set-e .. .. sleep .. test .. .. cddl lib .. sbin .. usr.bin .. usr.sbin dtrace common aggs .. arithmetic .. arrays .. assocs .. begin .. bitfields .. buffering .. builtinvar .. cg .. clauses .. cpc .. decls .. drops .. dtraceUtil .. end .. enum .. error .. exit .. fbtprovider .. funcs .. grammar .. include .. inline .. io .. ip .. java_api .. json .. lexer .. llquantize .. mdb .. mib .. misc .. multiaggs .. offsetof .. operators .. pid .. plockstat .. pointers .. pragma .. predicates .. preprocessor .. print .. printa .. printf .. privs .. probes .. proc .. profile-n .. providers .. raise .. rates .. safety .. scalars .. sched .. scripting .. sdt .. sizeof .. speculation .. stability .. stack .. stackdepth .. stop .. strlen .. strtoll .. struct .. syscall .. sysevent .. tick-n .. trace .. tracemem .. translators .. typedef .. types .. uctf .. union .. usdt .. ustack .. vars .. version .. .. .. .. .. etc rc.d .. .. games .. gnu lib .. usr.bin diff .. .. .. lib atf libatf-c detail .. .. libatf-c++ detail .. .. test-programs .. .. libarchive .. libc c063 .. db .. gen execve .. posix_spawn .. .. hash data .. .. inet .. locale .. net getaddrinfo data .. .. .. regex data .. .. rpc .. ssp .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcrypt .. libmp .. libnv .. libpam .. libproc .. librt .. libthr dlopen .. .. libutil .. libxo .. msun .. .. libexec atf atf-check .. atf-sh .. .. rtld-elf .. .. sbin dhclient .. devd .. growfs .. ifconfig .. mdconfig .. .. secure lib .. libexec .. usr.bin .. usr.sbin .. .. share examples tests atf .. plain .. .. .. .. sys acl .. aio .. fifo .. file .. kern + acct + .. execve .. .. kqueue .. mqueue .. netinet .. opencrypto .. pjdfstest chflags .. chmod .. chown .. ftruncate .. granular .. link .. mkdir .. mkfifo .. mknod .. open .. rename .. rmdir .. symlink .. truncate .. unlink .. .. posixshm .. vfs .. vm .. .. usr.bin apply .. basename .. bmake archives fmt_44bsd .. fmt_44bsd_mod .. fmt_oldbsd .. .. basic t0 .. t1 .. t2 .. t3 .. .. execution ellipsis .. empty .. joberr .. plus .. .. shell builtin .. meta .. path .. path_select .. replace .. select .. .. suffixes basic .. src_wild1 .. src_wild2 .. .. syntax directive-t0 .. enl .. funny-targets .. semi .. .. sysmk t0 2 1 .. .. mk .. .. t1 2 1 .. .. mk .. .. t2 2 1 .. .. mk .. .. .. variables modifier_M .. modifier_t .. opt_V .. t0 .. .. .. calendar .. cmp .. cpio .. col .. comm .. cut .. dirname .. file2c .. grep .. gzip .. ident .. join .. jot .. lastcomm .. limits .. m4 .. mkimg .. ncal .. opensm .. printf .. sed regress.multitest.out .. .. soelim .. tar .. timeout .. tr .. truncate .. units .. uudecode .. uuencode .. xargs .. xo .. yacc yacc .. .. .. usr.sbin etcupdate .. fstyp .. makefs .. newsyslog .. nmtree .. pw .. sa .. .. .. # vim: set expandtab ts=4 sw=4: Index: head/tests/sys/kern/Makefile =================================================================== --- head/tests/sys/kern/Makefile (revision 290904) +++ head/tests/sys/kern/Makefile (revision 290905) @@ -1,18 +1,19 @@ # $FreeBSD$ TESTSDIR= ${TESTSBASE}/sys/kern ATF_TESTS_C+= kern_copyin ATF_TESTS_C+= kern_descrip_test ATF_TESTS_C+= ptrace_test ATF_TESTS_C+= unix_seqpacket_test TEST_METADATA.unix_seqpacket_test+= timeout="15" LDADD.ptrace_test+= -lpthread LDADD.unix_seqpacket_test+= -lpthread WARNS?= 5 +TESTS_SUBDIRS+= acct TESTS_SUBDIRS+= execve .include Index: head/tests/sys/kern/acct/Makefile =================================================================== --- head/tests/sys/kern/acct/Makefile (nonexistent) +++ head/tests/sys/kern/acct/Makefile (revision 290905) @@ -0,0 +1,17 @@ +# $FreeBSD$ + +TESTSDIR= ${TESTSBASE}/sys/kern/acct + +ATF_TESTS_C= acct_test + +CFLAGS+= -I${.OBJDIR} + +CLEANFILES+= convert.c + +DPSRCS.acct_test= convert.c + +convert.c: ${SRCTOP}/sys/kern/kern_acct.c + sed -n -e 's/log(/syslog(/g' \ + -e '/FLOAT_CONVERSION_START/,/FLOAT_CONVERSION_END/p' ${.ALLSRC} >>${.TARGET} + +.include Property changes on: head/tests/sys/kern/acct/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/tests/sys/kern/acct/acct_test.c =================================================================== --- head/tests/sys/kern/acct/acct_test.c (nonexistent) +++ head/tests/sys/kern/acct/acct_test.c (revision 290905) @@ -0,0 +1,237 @@ +/*- + * Copyright (c) 2011 Giorgos Keramidas. All rights reserved. + * 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 +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define KASSERT(val, msg) assert(val) + +typedef u_int32_t comp_t; + +#define AHZ 1000000 + +#include "convert.c" + +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; + ATF_CHECK(eps <= FLT_EPSILON); + 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); + } +} + +/* + * Test case for encoding {0 sec, 0 usec} within a reasonable epsilon. + */ + +ATF_TC_WITHOUT_HEAD(encode_tv_zero); +ATF_TC_BODY(encode_tv_zero, tc) +{ + union cf v; + struct timeval tv; + + tv.tv_sec = 0; + tv.tv_usec = 0; + v.c = encode_timeval(tv); + ATF_CHECK(fabs(v.f - 0.0) < FLT_EPSILON); +} + +/* + * Test case for encoding a random long number. + */ + +ATF_TC_WITHOUT_HEAD(encode_long); +ATF_TC_BODY(encode_long, tc) +{ + union cf v; + long l; + + l = random(); + v.c = encode_long(l); + check_result(atf_tc_get_ident(tc), l, v); +} + +/* + * Test case for encoding a small number of seconds {1 sec, 0 usec}. + */ + +ATF_TC_WITHOUT_HEAD(encode_tv_only_sec); +ATF_TC_BODY(encode_tv_only_sec, tc) +{ + union cf v; + struct timeval tv; + + tv.tv_sec = 1; + tv.tv_usec = 0; + v.c = encode_timeval(tv); + check_result(atf_tc_get_ident(tc), + (float)tv.tv_sec * AHZ + tv.tv_usec, v); +} + +/* + * Test case for encoding a small number of usec {0 sec, 1 usec}. + */ + +ATF_TC_WITHOUT_HEAD(encode_tv_only_usec); +ATF_TC_BODY(encode_tv_only_usec, tc) +{ + union cf v; + struct timeval tv; + + tv.tv_sec = 0; + tv.tv_usec = 1; + v.c = encode_timeval(tv); + check_result(atf_tc_get_ident(tc), + (float)tv.tv_sec * AHZ + tv.tv_usec, v); +} + +/* + * Test case for encoding a large number of usec {1 sec, 999.999 usec}. + */ + +ATF_TC_WITHOUT_HEAD(encode_tv_many_usec); +ATF_TC_BODY(encode_tv_many_usec, tc) +{ + union cf v; + struct timeval tv; + + tv.tv_sec = 1; + tv.tv_usec = 999999L; + v.c = encode_timeval(tv); + check_result(atf_tc_get_ident(tc), + (float)tv.tv_sec * AHZ + tv.tv_usec, v); +} + +/* + * Test case for encoding a huge number of usec {1 sec, 1.000.000 usec} that + * overflows the usec counter and should show up as an increase in timeval's + * seconds instead. + */ + +ATF_TC_WITHOUT_HEAD(encode_tv_usec_overflow); +ATF_TC_BODY(encode_tv_usec_overflow, tc) +{ + union cf v; + struct timeval tv; + + tv.tv_sec = 1; + tv.tv_usec = 1000000L; + v.c = encode_timeval(tv); + check_result(atf_tc_get_ident(tc), + (float)tv.tv_sec * AHZ + tv.tv_usec, v); +} + +/* + * Test case for encoding a very large number of seconds, one that is very + * near to the limit of 32-bit signed values. With a usec value of 999.999 + * microseconds this should result in the largest value we can represent with + * a timeval struct. + */ + +ATF_TC_WITHOUT_HEAD(encode_tv_upper_limit); +ATF_TC_BODY(encode_tv_upper_limit, tc) +{ + union cf v; + struct timeval tv; + + tv.tv_sec = 2147483647L; + tv.tv_usec = 999999L; + v.c = encode_timeval(tv); + check_result(atf_tc_get_ident(tc), + (float)tv.tv_sec * AHZ + tv.tv_usec, v); +} + +/* + * Test case for encoding a million random timeval objects, and checking that + * the conversion does not diverge too much from the expected values. + */ + +ATF_TC_WITHOUT_HEAD(encode_tv_random_million); +ATF_TC_BODY(encode_tv_random_million, tc) +{ + union cf v; + struct timeval tv; + long k; + + atf_tc_expect_fail("the testcase violates FLT_EPSILON"); + + ATF_REQUIRE_MSG(unsetenv("TZ") == 0, "unsetting TZ failed; errno=%d", errno); + + for (k = 1; k < 1000000L; k++) { + tv.tv_sec = random(); + tv.tv_usec = (random() % 1000000L); + v.c = encode_timeval(tv); + check_result(atf_tc_get_ident(tc), + (float)tv.tv_sec * AHZ + tv.tv_usec, v); + } +} + +/* --------------------------------------------------------------------- + * Main. + * --------------------------------------------------------------------- */ + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, encode_long); + ATF_TP_ADD_TC(tp, encode_tv_zero); + ATF_TP_ADD_TC(tp, encode_tv_only_sec); + ATF_TP_ADD_TC(tp, encode_tv_only_usec); + ATF_TP_ADD_TC(tp, encode_tv_many_usec); + ATF_TP_ADD_TC(tp, encode_tv_usec_overflow); + ATF_TP_ADD_TC(tp, encode_tv_upper_limit); + ATF_TP_ADD_TC(tp, encode_tv_random_million); + + return atf_no_error(); +} Property changes on: head/tests/sys/kern/acct/acct_test.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head =================================================================== --- head (revision 290904) +++ head (revision 290905) Property changes on: head ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /user/ngie/more-tests2:r290904