Index: projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/db/t_db.sh =================================================================== --- projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/db/t_db.sh (revision 313470) +++ projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/db/t_db.sh (revision 313471) @@ -1,940 +1,960 @@ # $NetBSD: t_db.sh,v 1.4 2013/07/29 10:43:15 skrll Exp $ # # Copyright (c) 2008 The NetBSD Foundation, Inc. # 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. # prog() { echo $(atf_get_srcdir)/h_db } dict() { if [ -f /usr/share/dict/words ]; then echo /usr/share/dict/words elif [ -f /usr/dict/words ]; then echo /usr/dict/words else + echo "" atf_fail "no dictionary found" fi } # Begin FreeBSD dict() { - if [ -f /usr/share/dict/words ]; then - echo /usr/share/dict/words - else - echo /nonexistent - atf_skip "Test requires dict/words" - fi + echo /usr/share/dict/words } # End FreeBSD SEVEN_SEVEN="abcdefg|abcdefg|abcdefg|abcdefg|abcdefg|abcdefg|abcdefg" atf_test_case small_btree small_btree_head() { atf_set "descr" \ "Checks btree database using small keys and small data" \ "pairs: takes the first hundred entries in the dictionary," \ "and makes them be key/data pairs." + # Begin FreeBSD + atf_set "require.files" /usr/share/dict/words + # End FreeBSD } small_btree_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} sed 200q $(dict) >exp for i in `sed 200q $(dict)`; do echo p echo k$i echo d$i echo g echo k$i done >in atf_check -o file:exp "$(prog)" btree in } atf_test_case small_hash small_hash_head() { atf_set "descr" \ "Checks hash database using small keys and small data" \ "pairs: takes the first hundred entries in the dictionary," \ "and makes them be key/data pairs." + # Begin FreeBSD + atf_set "require.files" /usr/share/dict/words + # End FreeBSD } small_hash_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} sed 200q $(dict) >exp for i in `sed 200q $(dict)`; do echo p echo k$i echo d$i echo g echo k$i done >in atf_check -o file:exp "$(prog)" hash in } atf_test_case small_recno small_recno_head() { atf_set "descr" \ "Checks recno database using small keys and small data" \ "pairs: takes the first hundred entries in the dictionary," \ "and makes them be key/data pairs." + # Begin FreeBSD + atf_set "require.files" /usr/share/dict/words + # End FreeBSD } small_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} sed 200q $(dict) >exp sed 200q $(dict) | awk '{ ++i; printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); }' >in atf_check -o file:exp "$(prog)" recno in } atf_test_case medium_btree medium_btree_head() { atf_set "descr" \ "Checks btree database using small keys and medium" \ "data pairs: takes the first 200 entries in the" \ "dictionary, and gives them each a medium size data entry." + # Begin FreeBSD + atf_set "require.files" /usr/share/dict/words + # End FreeBSD } medium_btree_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz echo $mdata | awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp for i in $(sed 200q $(dict)); do echo p echo k$i echo d$mdata echo g echo k$i done >in atf_check -o file:exp "$(prog)" btree in } atf_test_case medium_hash medium_hash_head() { atf_set "descr" \ "Checks hash database using small keys and medium" \ "data pairs: takes the first 200 entries in the" \ "dictionary, and gives them each a medium size data entry." + # Begin FreeBSD + atf_set "require.files" /usr/share/dict/words + # End FreeBSD } medium_hash_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz echo $mdata | awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp for i in $(sed 200q $(dict)); do echo p echo k$i echo d$mdata echo g echo k$i done >in atf_check -o file:exp "$(prog)" hash in } atf_test_case medium_recno medium_recno_head() { atf_set "descr" \ "Checks recno database using small keys and medium" \ "data pairs: takes the first 200 entries in the" \ "dictionary, and gives them each a medium size data entry." } medium_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz echo $mdata | awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp echo $mdata | awk '{ for (i = 1; i < 201; ++i) printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); }' >in atf_check -o file:exp "$(prog)" recno in } atf_test_case big_btree big_btree_head() { atf_set "descr" \ "Checks btree database using small keys and big data" \ "pairs: inserts the programs in /bin with their paths" \ "as their keys." } big_btree_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} (find /bin -type f -print | xargs cat) >exp for psize in 512 16384 65536; do echo "checking page size: $psize" for i in `find /bin -type f -print`; do echo p echo k$i echo D$i echo g echo k$i done >in atf_check "$(prog)" -o out btree in cmp -s exp out || atf_fail "test failed for page size: $psize" done } atf_test_case big_hash big_hash_head() { atf_set "descr" \ "Checks hash database using small keys and big data" \ "pairs: inserts the programs in /bin with their paths" \ "as their keys." } big_hash_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} (find /bin -type f -print | xargs cat) >exp for i in `find /bin -type f -print`; do echo p echo k$i echo D$i echo g echo k$i done >in atf_check "$(prog)" -o out hash in cmp -s exp out || atf_fail "test failed" } atf_test_case big_recno big_recno_head() { atf_set "descr" \ "Checks recno database using small keys and big data" \ "pairs: inserts the programs in /bin with their paths" \ "as their keys." } big_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} (find /bin -type f -print | xargs cat) >exp find /bin -type f -print | awk '{ ++i; printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i); }' >in for psize in 512 16384 65536; do echo "checking page size: $psize" atf_check "$(prog)" -o out recno in cmp -s exp out || atf_fail "test failed for page size: $psize" done } atf_test_case random_recno random_recno_head() { atf_set "descr" "Checks recno database using random entries" } random_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk '{ for (i = 37; i <= 37 + 88 * 17; i += 17) { if (i % 41) s = substr($0, 1, i % 41); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } for (i = 1; i <= 15; ++i) { if (i % 41) s = substr($0, 1, i % 41); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } for (i = 19234; i <= 19234 + 61 * 27; i += 27) { if (i % 41) s = substr($0, 1, i % 41); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } exit }' >exp cat exp | awk 'BEGIN { i = 37; incr = 17; } { printf("p\nk%d\nd%s\n", i, $0); if (i == 19234 + 61 * 27) exit; if (i == 37 + 88 * 17) { i = 1; incr = 1; } else if (i == 15) { i = 19234; incr = 27; } else i += incr; } END { for (i = 37; i <= 37 + 88 * 17; i += 17) printf("g\nk%d\n", i); for (i = 1; i <= 15; ++i) printf("g\nk%d\n", i); for (i = 19234; i <= 19234 + 61 * 27; i += 27) printf("g\nk%d\n", i); }' >in atf_check -o file:exp "$(prog)" recno in } atf_test_case reverse_recno reverse_recno_head() { atf_set "descr" "Checks recno database using reverse order entries" } reverse_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk ' { for (i = 1500; i; --i) { if (i % 34) s = substr($0, 1, i % 34); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } exit; }' >exp cat exp | awk 'BEGIN { i = 1500; } { printf("p\nk%d\nd%s\n", i, $0); --i; } END { for (i = 1500; i; --i) printf("g\nk%d\n", i); }' >in atf_check -o file:exp "$(prog)" recno in } atf_test_case alternate_recno alternate_recno_head() { atf_set "descr" "Checks recno database using alternating order entries" } alternate_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk ' { for (i = 1; i < 1200; i += 2) { if (i % 34) s = substr($0, 1, i % 34); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } for (i = 2; i < 1200; i += 2) { if (i % 34) s = substr($0, 1, i % 34); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } exit; }' >exp cat exp | awk 'BEGIN { i = 1; even = 0; } { printf("p\nk%d\nd%s\n", i, $0); i += 2; if (i >= 1200) { if (even == 1) exit; even = 1; i = 2; } } END { for (i = 1; i < 1200; ++i) printf("g\nk%d\n", i); }' >in atf_check "$(prog)" -o out recno in sort -o exp exp sort -o out out cmp -s exp out || atf_fail "test failed" } h_delete() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} type=$1 echo $SEVEN_SEVEN | awk '{ for (i = 1; i <= 120; ++i) printf("%05d: input key %d: %s\n", i, i, $0); }' >exp cat exp | awk '{ printf("p\nk%d\nd%s\n", ++i, $0); } END { printf("fR_NEXT\n"); for (i = 1; i <= 120; ++i) printf("s\n"); printf("fR_CURSOR\ns\nkXX\n"); printf("r\n"); printf("fR_NEXT\ns\n"); printf("fR_CURSOR\ns\nk1\n"); printf("r\n"); printf("fR_FIRST\ns\n"); }' >in # For btree, the records are ordered by the string representation # of the key value. So sort the expected output file accordingly, # and set the seek_last key to the last expected key value. if [ "$type" = "btree" ] ; then sed -e 's/kXX/k99/' < in > tmp mv tmp in sort -d -k4 < exp > tmp mv tmp exp echo $SEVEN_SEVEN | awk '{ printf("%05d: input key %d: %s\n", 99, 99, $0); printf("seq failed, no such key\n"); printf("%05d: input key %d: %s\n", 1, 1, $0); printf("%05d: input key %d: %s\n", 10, 10, $0); exit; }' >> exp else # For recno, records are ordered by numerical key value. No sort # is needed, but still need to set proper seek_last key value. sed -e 's/kXX/k120/' < in > tmp mv tmp in echo $SEVEN_SEVEN | awk '{ printf("%05d: input key %d: %s\n", 120, 120, $0); printf("seq failed, no such key\n"); printf("%05d: input key %d: %s\n", 1, 1, $0); printf("%05d: input key %d: %s\n", 2, 2, $0); exit; }' >> exp fi atf_check "$(prog)" -o out $type in atf_check -o file:exp cat out } atf_test_case delete_btree delete_btree_head() { atf_set "descr" "Checks removing records in btree database" } delete_btree_body() { h_delete btree } atf_test_case delete_recno delete_recno_head() { atf_set "descr" "Checks removing records in recno database" } delete_recno_body() { h_delete recno } h_repeated() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo "" | awk 'BEGIN { for (i = 1; i <= 10; ++i) { printf("p\nkkey1\nD/bin/sh\n"); printf("p\nkkey2\nD/bin/csh\n"); if (i % 8 == 0) { printf("c\nkkey2\nD/bin/csh\n"); printf("c\nkkey1\nD/bin/sh\n"); printf("e\t%d of 10 (comparison)\n", i); } else printf("e\t%d of 10 \n", i); printf("r\nkkey1\nr\nkkey2\n"); } }' >in $(prog) btree in } atf_test_case repeated_btree repeated_btree_head() { atf_set "descr" \ "Checks btree database with repeated small keys and" \ "big data pairs. Makes sure that overflow pages are reused" } repeated_btree_body() { h_repeated btree } atf_test_case repeated_hash repeated_hash_head() { atf_set "descr" \ "Checks hash database with repeated small keys and" \ "big data pairs. Makes sure that overflow pages are reused" } repeated_hash_body() { h_repeated hash } atf_test_case duplicate_btree duplicate_btree_head() { atf_set "descr" "Checks btree database with duplicate keys" } duplicate_btree_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk '{ for (i = 1; i <= 543; ++i) printf("%05d: input key %d: %s\n", i, i, $0); exit; }' >exp cat exp | awk '{ if (i++ % 2) printf("p\nkduplicatekey\nd%s\n", $0); else printf("p\nkunique%dkey\nd%s\n", i, $0); } END { printf("o\n"); }' >in atf_check -o file:exp -x "$(prog) -iflags=1 btree in | sort" } h_cursor_flags() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} type=$1 echo $SEVEN_SEVEN | awk '{ for (i = 1; i <= 20; ++i) printf("%05d: input key %d: %s\n", i, i, $0); exit; }' >exp # Test that R_CURSOR doesn't succeed before cursor initialized cat exp | awk '{ if (i == 10) exit; printf("p\nk%d\nd%s\n", ++i, $0); } END { printf("fR_CURSOR\nr\n"); printf("eR_CURSOR SHOULD HAVE FAILED\n"); }' >in atf_check -o ignore -e ignore -s ne:0 "$(prog)" -o out $type in atf_check -s ne:0 test -s out cat exp | awk '{ if (i == 10) exit; printf("p\nk%d\nd%s\n", ++i, $0); } END { printf("fR_CURSOR\np\nk1\ndsome data\n"); printf("eR_CURSOR SHOULD HAVE FAILED\n"); }' >in atf_check -o ignore -e ignore -s ne:0 "$(prog)" -o out $type in atf_check -s ne:0 test -s out } atf_test_case cursor_flags_btree cursor_flags_btree_head() { atf_set "descr" \ "Checks use of cursor flags without initialization in btree database" } cursor_flags_btree_body() { h_cursor_flags btree } atf_test_case cursor_flags_recno cursor_flags_recno_head() { atf_set "descr" \ "Checks use of cursor flags without initialization in recno database" } cursor_flags_recno_body() { h_cursor_flags recno } atf_test_case reverse_order_recno reverse_order_recno_head() { atf_set "descr" "Checks reverse order inserts in recno database" } reverse_order_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk '{ for (i = 1; i <= 779; ++i) printf("%05d: input key %d: %s\n", i, i, $0); exit; }' >exp cat exp | awk '{ if (i == 0) { i = 1; printf("p\nk1\nd%s\n", $0); printf("%s\n", "fR_IBEFORE"); } else printf("p\nk1\nd%s\n", $0); } END { printf("or\n"); }' >in atf_check -o file:exp "$(prog)" recno in } atf_test_case small_page_btree small_page_btree_head() { atf_set "descr" \ "Checks btree database with lots of keys and small page" \ "size: takes the first 20000 entries in the dictionary," \ "reverses them, and gives them each a small size data" \ "entry. Uses a small page size to make sure the btree" \ "split code gets hammered." + # Begin FreeBSD + atf_set "require.files" /usr/share/dict/words + # End FreeBSD } small_page_btree_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} mdata=abcdefghijklmnopqrstuvwxy echo $mdata | awk '{ for (i = 1; i < 20001; ++i) print $0 }' >exp for i in `sed 20000q $(dict) | rev`; do echo p echo k$i echo d$mdata echo g echo k$i done >in atf_check -o file:exp "$(prog)" -i psize=512 btree in } h_byte_orders() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} type=$1 sed 50q $(dict) >exp for order in 1234 4321; do for i in `sed 50q $(dict)`; do echo p echo k$i echo d$i echo g echo k$i done >in atf_check -o file:exp "$(prog)" -ilorder=$order -f byte.file $type in for i in `sed 50q $(dict)`; do echo g echo k$i done >in atf_check -o file:exp "$(prog)" -s -ilorder=$order -f byte.file $type in done } atf_test_case byte_orders_btree byte_orders_btree_head() { atf_set "descr" "Checks btree database using differing byte orders" + # Begin FreeBSD + atf_set "require.files" /usr/share/dict/words + # End FreeBSD } byte_orders_btree_body() { h_byte_orders btree } atf_test_case byte_orders_hash byte_orders_hash_head() { atf_set "descr" "Checks hash database using differing byte orders" } byte_orders_hash_body() { h_byte_orders hash } h_bsize_ffactor() { bsize=$1 ffactor=$2 echo "bucketsize $bsize, fill factor $ffactor" atf_check -o file:exp "$(prog)" "-ibsize=$bsize,\ ffactor=$ffactor,nelem=25000,cachesize=65536" hash in } atf_test_case bsize_ffactor bsize_ffactor_head() { atf_set "timeout" "480" atf_set "descr" "Checks hash database with various" \ "bucketsizes and fill factors" + # Begin FreeBSD + atf_set "require.files" /usr/share/dict/words + # End FreeBSD } bsize_ffactor_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk '{ for (i = 1; i <= 10000; ++i) { if (i % 34) s = substr($0, 1, i % 34); else s = substr($0, 1); printf("%s\n", s); } exit; }' >exp sed 10000q $(dict) | awk 'BEGIN { ds="'$SEVEN_SEVEN'" } { if (++i % 34) s = substr(ds, 1, i % 34); else s = substr(ds, 1); printf("p\nk%s\nd%s\n", $0, s); }' >in sed 10000q $(dict) | awk '{ ++i; printf("g\nk%s\n", $0); }' >>in h_bsize_ffactor 256 11 h_bsize_ffactor 256 14 h_bsize_ffactor 256 21 h_bsize_ffactor 512 21 h_bsize_ffactor 512 28 h_bsize_ffactor 512 43 h_bsize_ffactor 1024 43 h_bsize_ffactor 1024 57 h_bsize_ffactor 1024 85 h_bsize_ffactor 2048 85 h_bsize_ffactor 2048 114 h_bsize_ffactor 2048 171 h_bsize_ffactor 4096 171 h_bsize_ffactor 4096 228 h_bsize_ffactor 4096 341 h_bsize_ffactor 8192 341 h_bsize_ffactor 8192 455 h_bsize_ffactor 8192 683 } # FIXME: what does it test? atf_test_case four_char_hash four_char_hash_head() { atf_set "descr" \ "Checks hash database with 4 char key and" \ "value insert on a 65536 bucket size" } four_char_hash_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} cat >in <, Oct. 2002. * Public domain. */ #include #include #include #include #include #include struct { const char *input; const char *output; } test_basename_table[] = { /* * The following are taken from the "Sample Input and Output Strings * for basename()" table in IEEE Std 1003.1-2001. */ { "/usr/lib", "lib" }, { "/usr/", "usr" }, { "/", "/" }, { "///", "/" }, { "//usr//lib//", "lib" }, /* * IEEE Std 1003.1-2001: * * If path is a null pointer or points to an empty string, * basename() shall return a pointer to the string "." . */ { "", "." }, { NULL, "." }, /* * IEEE Std 1003.1-2001: * * If the string is exactly "//", it is implementation-defined * whether "/" or "//" is returned. * * The NetBSD implementation returns "/". */ { "//", "/" }, { NULL, NULL } }; struct { const char *input; const char *output; } test_dirname_table[] = { /* * The following are taken from the "Sample Input and Output Strings * for dirname()" table in IEEE Std 1003.1-2001. */ { "/usr/lib", "/usr" }, { "/usr/", "/" }, { "usr", "." }, { "/", "/" }, { ".", "." }, { "..", "." }, /* * IEEE Std 1003.1-2001: * * If path is a null pointer or points to an empty string, * dirname() shall return a pointer to the string "." . */ { "", "." }, { NULL, "." }, /* * IEEE Std 1003.1-2001: * * Since the meaning of the leading "//" is implementation-defined, * dirname("//foo") may return either "//" or "/" (but nothing else). * * The NetBSD implementation returns "/". */ { "//foo", "/" }, /* * Make sure the trailing slashes after the directory name component * get trimmed. The Std does not talk about this, but this is what * Solaris 8's dirname(3) does. */ { "/usr///lib", "/usr" }, { NULL, NULL } }; ATF_TC(basename_posix); ATF_TC_HEAD(basename_posix, tc) { atf_tc_set_md_var(tc, "descr", "Test basename(3) with POSIX examples"); } ATF_TC_BODY(basename_posix, tc) { char testbuf[32], *base; int i; for (i = 0; test_basename_table[i].output != NULL; i++) { if (test_basename_table[i].input != NULL) { if (strlen(test_basename_table[i].input) >= sizeof(testbuf)) atf_tc_skip("Testbuf too small!"); strcpy(testbuf, test_basename_table[i].input); base = basename(testbuf); } else base = basename(NULL); +#ifdef __NetBSD__ /* * basename(3) is allowed to modify the input buffer. * However, that is considered hostile by some programs, * and so we elect to consider this an error. * * This is not a problem, as basename(3) is also allowed * to return a pointer to a statically-allocated buffer * (it is explicitly not required to be reentrant). */ if (test_basename_table[i].input != NULL && strcmp(test_basename_table[i].input, testbuf) != 0) { fprintf(stderr, "Input buffer for \"%s\" was modified\n", test_basename_table[i].input); atf_tc_fail("Input buffer was modified."); } +#endif /* Make sure the result is correct. */ if (strcmp(test_basename_table[i].output, base) != 0) { fprintf(stderr, "Input \"%s\", output \"%s\", expected \"%s\"\n", test_basename_table[i].input == NULL ? "(null)" : test_basename_table[i].input, base, test_basename_table[i].output); atf_tc_fail("Output does not match expected value."); } } } ATF_TC(dirname_posix); ATF_TC_HEAD(dirname_posix, tc) { atf_tc_set_md_var(tc, "descr", "Test dirname(3) with POSIX examples"); } ATF_TC_BODY(dirname_posix, tc) { char testbuf[32], *base; int i; for (i = 0; test_dirname_table[i].output != NULL; i++) { if (test_dirname_table[i].input != NULL) { if (strlen(test_dirname_table[i].input) >= sizeof(testbuf)) atf_tc_skip("Testbuf too small!"); strcpy(testbuf, test_dirname_table[i].input); base = dirname(testbuf); } else base = dirname(NULL); +#ifdef __NetBSD__ /* * dirname(3) is allowed to modify the input buffer. * However, that is considered hostile by some programs, * and so we elect to consider this an error. * * This is not a problem, as dirname(3) is also allowed * to return a pointer to a statically-allocated buffer * (it is explicitly not required to be reentrant). */ if (test_dirname_table[i].input != NULL && strcmp(test_dirname_table[i].input, testbuf) != 0) { fprintf(stderr, "Input buffer for \"%s\" was modified\n", test_dirname_table[i].input); atf_tc_fail("Input buffer was modified."); } +#endif /* Make sure the result is correct. */ if (strcmp(test_dirname_table[i].output, base) != 0) { fprintf(stderr, "Input \"%s\", output \"%s\", expected \"%s\"\n", test_dirname_table[i].input == NULL ? "(null)" : test_dirname_table[i].input, base, test_dirname_table[i].output); atf_tc_fail("Output does not match expected value."); } } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, basename_posix); ATF_TP_ADD_TC(tp, dirname_posix); return atf_no_error(); } Index: projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c =================================================================== --- projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c (revision 313470) +++ projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c (revision 313471) @@ -1,196 +1,196 @@ /* $NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. */ /* * Copyright (c) 1994 Christopher G. Demetriou * 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed for the * NetBSD Project. See http://www.NetBSD.org/ for * information about NetBSD. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * <> */ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $"); #include #include #include #include #include #include #include #include #include #define REQUIRE_ERRNO(x) ATF_REQUIRE_MSG(x, "%s", strerror(errno)) #define TEST_SETJMP 0 #define TEST_U_SETJMP 1 #define TEST_SIGSETJMP_SAVE 2 #define TEST_SIGSETJMP_NOSAVE 3 static int expectsignal; static void -aborthandler(int signo) +aborthandler(int signo __unused) { ATF_REQUIRE_MSG(expectsignal, "kill(SIGABRT) succeeded"); atf_tc_pass(); } static void h_check(int test) { struct sigaction sa; jmp_buf jb; sigjmp_buf sjb; sigset_t ss; int i, x; i = getpid(); if (test == TEST_SETJMP || test == TEST_SIGSETJMP_SAVE) expectsignal = 0; else if (test == TEST_U_SETJMP || test == TEST_SIGSETJMP_NOSAVE) expectsignal = 1; else atf_tc_fail("unknown test"); sa.sa_handler = aborthandler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; REQUIRE_ERRNO(sigaction(SIGABRT, &sa, NULL) != -1); REQUIRE_ERRNO(sigemptyset(&ss) != -1); REQUIRE_ERRNO(sigaddset(&ss, SIGABRT) != -1); REQUIRE_ERRNO(sigprocmask(SIG_BLOCK, &ss, NULL) != -1); if (test == TEST_SETJMP) x = setjmp(jb); else if (test == TEST_U_SETJMP) x = _setjmp(jb); else x = sigsetjmp(sjb, !expectsignal); if (x != 0) { ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value"); kill(i, SIGABRT); ATF_REQUIRE_MSG(!expectsignal, "kill(SIGABRT) failed"); atf_tc_pass(); } REQUIRE_ERRNO(sigprocmask(SIG_UNBLOCK, &ss, NULL) != -1); if (test == TEST_SETJMP) longjmp(jb, i); else if (test == TEST_U_SETJMP) _longjmp(jb, i); else siglongjmp(sjb, i); atf_tc_fail("jmp failed"); } ATF_TC(setjmp); ATF_TC_HEAD(setjmp, tc) { atf_tc_set_md_var(tc, "descr", "Checks setjmp(3)"); } ATF_TC_BODY(setjmp, tc) { h_check(TEST_SETJMP); } ATF_TC(_setjmp); ATF_TC_HEAD(_setjmp, tc) { atf_tc_set_md_var(tc, "descr", "Checks _setjmp(3)"); } ATF_TC_BODY(_setjmp, tc) { h_check(TEST_U_SETJMP); } ATF_TC(sigsetjmp_save); ATF_TC_HEAD(sigsetjmp_save, tc) { atf_tc_set_md_var(tc, "descr", "Checks sigsetjmp(3) with savemask enabled"); } ATF_TC_BODY(sigsetjmp_save, tc) { h_check(TEST_SIGSETJMP_SAVE); } ATF_TC(sigsetjmp_nosave); ATF_TC_HEAD(sigsetjmp_nosave, tc) { atf_tc_set_md_var(tc, "descr", "Checks sigsetjmp(3) with savemask disabled"); } ATF_TC_BODY(sigsetjmp_nosave, tc) { h_check(TEST_SIGSETJMP_NOSAVE); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, setjmp); ATF_TP_ADD_TC(tp, _setjmp); ATF_TP_ADD_TC(tp, sigsetjmp_save); ATF_TP_ADD_TC(tp, sigsetjmp_nosave); return atf_no_error(); } Index: projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c =================================================================== --- projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c (revision 313470) +++ projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c (revision 313471) @@ -1,218 +1,218 @@ /* $NetBSD: t_threadjmp.c,v 1.1 2011/04/21 18:58:20 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. */ /* * Copyright (c) 1994 Christopher G. Demetriou * 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed for the * NetBSD Project. See http://www.NetBSD.org/ for * information about NetBSD. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * <> */ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_threadjmp.c,v 1.1 2011/04/21 18:58:20 martin Exp $"); #include #include #include #include #include #include #include #include #include #include #define REQUIRE_ERRNO(x) ATF_REQUIRE_MSG(x, "%s", strerror(errno)) #define TEST_SETJMP 0 #define TEST_U_SETJMP 1 #define TEST_SIGSETJMP_SAVE 2 #define TEST_SIGSETJMP_NOSAVE 3 static pthread_t myself = NULL; static int expectsignal; static void -aborthandler(int signo) +aborthandler(int signo __unused) { ATF_REQUIRE(myself == pthread_self()); ATF_REQUIRE_MSG(expectsignal, "kill(SIGABRT) succeeded"); atf_tc_pass(); } static void h_check(int test) { struct sigaction sa; jmp_buf jb; sigjmp_buf sjb; sigset_t ss; int i, x; myself = pthread_self(); i = getpid(); if (test == TEST_SETJMP || test == TEST_SIGSETJMP_SAVE) expectsignal = 0; else if (test == TEST_U_SETJMP || test == TEST_SIGSETJMP_NOSAVE) expectsignal = 1; else atf_tc_fail("unknown test"); sa.sa_handler = aborthandler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; REQUIRE_ERRNO(sigaction(SIGABRT, &sa, NULL) != -1); REQUIRE_ERRNO(sigemptyset(&ss) != -1); REQUIRE_ERRNO(sigaddset(&ss, SIGABRT) != -1); REQUIRE_ERRNO(sigprocmask(SIG_BLOCK, &ss, NULL) != -1); ATF_REQUIRE(myself == pthread_self()); if (test == TEST_SETJMP) x = setjmp(jb); else if (test == TEST_U_SETJMP) x = _setjmp(jb); else x = sigsetjmp(sjb, !expectsignal); if (x != 0) { ATF_REQUIRE(myself == pthread_self()); ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value"); kill(i, SIGABRT); ATF_REQUIRE_MSG(!expectsignal, "kill(SIGABRT) failed"); ATF_REQUIRE(myself == pthread_self()); atf_tc_pass(); } ATF_REQUIRE(myself == pthread_self()); REQUIRE_ERRNO(sigprocmask(SIG_UNBLOCK, &ss, NULL) != -1); if (test == TEST_SETJMP) longjmp(jb, i); else if (test == TEST_U_SETJMP) _longjmp(jb, i); else siglongjmp(sjb, i); atf_tc_fail("jmp failed"); } ATF_TC(setjmp); ATF_TC_HEAD(setjmp, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_self() and setjmp(3)"); } ATF_TC_BODY(setjmp, tc) { h_check(TEST_SETJMP); } ATF_TC(_setjmp); ATF_TC_HEAD(_setjmp, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_self() and _setjmp(3)"); } ATF_TC_BODY(_setjmp, tc) { h_check(TEST_U_SETJMP); } ATF_TC(sigsetjmp_save); ATF_TC_HEAD(sigsetjmp_save, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_self() and sigsetjmp(3) with savemask enabled"); } ATF_TC_BODY(sigsetjmp_save, tc) { h_check(TEST_SIGSETJMP_SAVE); } ATF_TC(sigsetjmp_nosave); ATF_TC_HEAD(sigsetjmp_nosave, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_self() and sigsetjmp(3) with savemask disabled"); } ATF_TC_BODY(sigsetjmp_nosave, tc) { h_check(TEST_SIGSETJMP_NOSAVE); } ATF_TP_ADD_TCS(tp) { /* * These test cases try to verify setjmp and friends in a program * linked with pthreads, and verify that pthread_self() stays * consistent throughout the program. A setcontext() call invoked * by *setjmp() might clobber the TLS special register used to * implement pthread_self(). */ ATF_TP_ADD_TC(tp, setjmp); ATF_TP_ADD_TC(tp, _setjmp); ATF_TP_ADD_TC(tp, sigsetjmp_save); ATF_TP_ADD_TC(tp, sigsetjmp_nosave); return atf_no_error(); } Index: projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c =================================================================== --- projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c (revision 313470) +++ projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c (revision 313471) @@ -1,139 +1,145 @@ /* $NetBSD: t_getcontext.c,v 1.3 2011/07/14 04:59:14 jruoho Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_getcontext.c,v 1.3 2011/07/14 04:59:14 jruoho Exp $"); #include #include #include #include #include #define STACKSZ (10*1024) #define DEPTH 3 static int calls; static void run(int n, ...) { va_list va; int i, ia; ATF_REQUIRE_EQ(n, DEPTH - calls - 1); va_start(va, n); #if defined(__FreeBSD__) && defined(__amd64__) for (i = 0; i < 5; i++) { +#elif defined(__FreeBSD__) && defined(__aarch64__) + for (i = 0; i < 7; i++) { #else for (i = 0; i < 9; i++) { #endif ia = va_arg(va, int); ATF_REQUIRE_EQ(i, ia); } va_end(va); calls++; } ATF_TC(getcontext_err); ATF_TC_HEAD(getcontext_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from getcontext(2)"); } ATF_TC_BODY(getcontext_err, tc) { errno = 0; ATF_REQUIRE_ERRNO(EFAULT, getcontext((void *)-1) == -1); } ATF_TC(setcontext_err); ATF_TC_HEAD(setcontext_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from setcontext(2)"); } ATF_TC_BODY(setcontext_err, tc) { errno = 0; ATF_REQUIRE_ERRNO(EFAULT, setcontext((void *)-1) == -1); } ATF_TC(setcontext_link); ATF_TC_HEAD(setcontext_link, tc) { atf_tc_set_md_var(tc, "descr", "Checks get/make/setcontext(), context linking via uc_link(), " "and argument passing to the new context"); } ATF_TC_BODY(setcontext_link, tc) { ucontext_t uc[DEPTH]; ucontext_t save; volatile int i = 0; /* avoid longjmp clobbering */ for (i = 0; i < DEPTH; ++i) { ATF_REQUIRE_EQ(getcontext(&uc[i]), 0); uc[i].uc_stack.ss_sp = malloc(STACKSZ); uc[i].uc_stack.ss_size = STACKSZ; uc[i].uc_link = (i > 0) ? &uc[i - 1] : &save; #if defined(__FreeBSD__) && defined(__amd64__) /* FreeBSD/amd64 only permits up to 6 arguments. */ makecontext(&uc[i], (void *)run, 6, i, 0, 1, 2, 3, 4); +#elif defined(__FreeBSD__) && defined(__aarch64__) + /* FreeBSD/arm64 only permits up to 8 arguments. */ + makecontext(&uc[i], (void *)run, 8, i, + 0, 1, 2, 3, 4, 5, 6); #else makecontext(&uc[i], (void *)run, 10, i, 0, 1, 2, 3, 4, 5, 6, 7, 8); #endif } ATF_REQUIRE_EQ(getcontext(&save), 0); if (calls == 0) ATF_REQUIRE_EQ(setcontext(&uc[DEPTH-1]), 0); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, getcontext_err); ATF_TP_ADD_TC(tp, setcontext_err); ATF_TP_ADD_TC(tp, setcontext_link); return atf_no_error(); } Index: projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c =================================================================== --- projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c (revision 313470) +++ projects/stable-10-backport-test-changes/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c (revision 313471) @@ -1,211 +1,330 @@ /* $NetBSD: t_timer_create.c,v 1.4 2012/03/18 07:00:52 jruoho Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 #include #include #include #include #include #include static timer_t t; static bool fail = true; static void #ifdef __FreeBSD__ timer_signal_handler(int signo, siginfo_t *si, void *osi __unused) #else timer_signal_handler(int signo, siginfo_t *si, void *osi) #endif { timer_t *tp; tp = si->si_value.sival_ptr; if (*tp == t && signo == SIGALRM) fail = false; (void)fprintf(stderr, "%s: %s\n", __func__, strsignal(signo)); } static void timer_signal_create(clockid_t cid, bool expire) { struct itimerspec tim; struct sigaction act; struct sigevent evt; sigset_t set; t = 0; fail = true; (void)memset(&evt, 0, sizeof(struct sigevent)); (void)memset(&act, 0, sizeof(struct sigaction)); (void)memset(&tim, 0, sizeof(struct itimerspec)); /* * Set handler. */ act.sa_flags = SA_SIGINFO; act.sa_sigaction = timer_signal_handler; ATF_REQUIRE(sigemptyset(&set) == 0); ATF_REQUIRE(sigemptyset(&act.sa_mask) == 0); /* * Block SIGALRM while configuring the timer. */ ATF_REQUIRE(sigaction(SIGALRM, &act, NULL) == 0); ATF_REQUIRE(sigaddset(&set, SIGALRM) == 0); ATF_REQUIRE(sigprocmask(SIG_SETMASK, &set, NULL) == 0); /* * Create the timer (SIGEV_SIGNAL). */ evt.sigev_signo = SIGALRM; evt.sigev_value.sival_ptr = &t; evt.sigev_notify = SIGEV_SIGNAL; ATF_REQUIRE(timer_create(cid, &evt, &t) == 0); /* * Start the timer. After this, unblock the signal. */ tim.it_value.tv_sec = expire ? 5 : 1; tim.it_value.tv_nsec = 0; ATF_REQUIRE(timer_settime(t, 0, &tim, NULL) == 0); (void)sigprocmask(SIG_UNBLOCK, &set, NULL); (void)sleep(2); if (expire) { if (!fail) atf_tc_fail("timer fired too soon"); } else { if (fail) atf_tc_fail("timer failed to fire"); } ATF_REQUIRE(timer_delete(t) == 0); } +#ifdef __FreeBSD__ +static void +timer_callback(union sigval value) +{ + timer_t *tp; + + tp = value.sival_ptr; + + if (*tp == t) + fail = false; +} + +static void +timer_thread_create(clockid_t cid, bool expire) +{ + struct itimerspec tim; + struct sigevent evt; + + t = 0; + fail = true; + + (void)memset(&evt, 0, sizeof(struct sigevent)); + (void)memset(&tim, 0, sizeof(struct itimerspec)); + + /* + * Create the timer (SIGEV_THREAD). + */ + evt.sigev_notify_function = timer_callback; + evt.sigev_value.sival_ptr = &t; + evt.sigev_notify = SIGEV_THREAD; + + ATF_REQUIRE(timer_create(cid, &evt, &t) == 0); + + /* + * Start the timer. + */ + tim.it_value.tv_sec = expire ? 5 : 1; + tim.it_value.tv_nsec = 0; + + ATF_REQUIRE(timer_settime(t, 0, &tim, NULL) == 0); + + (void)sleep(2); + + if (expire) { + if (!fail) + atf_tc_fail("timer fired too soon"); + } else { + if (fail) + atf_tc_fail("timer failed to fire"); + } + + ATF_REQUIRE(timer_delete(t) == 0); +} +#endif + ATF_TC(timer_create_err); ATF_TC_HEAD(timer_create_err, tc) { atf_tc_set_md_var(tc, "descr", "Check errors from timer_create(2) (PR lib/42434"); } ATF_TC_BODY(timer_create_err, tc) { struct sigevent ev; (void)memset(&ev, 0, sizeof(struct sigevent)); errno = 0; ev.sigev_signo = -1; ev.sigev_notify = SIGEV_SIGNAL; ATF_REQUIRE_ERRNO(EINVAL, timer_create(CLOCK_REALTIME, &ev, &t) == -1); errno = 0; ev.sigev_signo = SIGUSR1; ev.sigev_notify = SIGEV_THREAD + 100; ATF_REQUIRE_ERRNO(EINVAL, timer_create(CLOCK_REALTIME, &ev, &t) == -1); } ATF_TC(timer_create_real); ATF_TC_HEAD(timer_create_real, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_REALTIME and sigevent(3), " "SIGEV_SIGNAL"); } ATF_TC_BODY(timer_create_real, tc) { timer_signal_create(CLOCK_REALTIME, false); } ATF_TC(timer_create_mono); ATF_TC_HEAD(timer_create_mono, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_MONOTONIC and sigevent(3), " "SIGEV_SIGNAL"); } ATF_TC_BODY(timer_create_mono, tc) { timer_signal_create(CLOCK_MONOTONIC, false); } ATF_TC(timer_create_real_expire); ATF_TC_HEAD(timer_create_real_expire, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_REALTIME and sigevent(3), " "SIGEV_SIGNAL, with expiration"); } ATF_TC_BODY(timer_create_real_expire, tc) { timer_signal_create(CLOCK_REALTIME, true); } ATF_TC(timer_create_mono_expire); ATF_TC_HEAD(timer_create_mono_expire, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_MONOTONIC and sigevent(3), " "SIGEV_SIGNAL, with expiration"); } ATF_TC_BODY(timer_create_mono_expire, tc) { timer_signal_create(CLOCK_MONOTONIC, true); } +ATF_TC(timer_thread_create_real); +ATF_TC_HEAD(timer_thread_create_real, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Checks timer_create(2) with CLOCK_REALTIME and sigevent(3), " + "SIGEV_THREAD"); +} + +#ifdef __FreeBSD__ +ATF_TC_BODY(timer_thread_create_real, tc) +{ + timer_thread_create(CLOCK_REALTIME, false); +} + +ATF_TC(timer_thread_create_mono); +ATF_TC_HEAD(timer_thread_create_mono, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Checks timer_create(2) with CLOCK_MONOTONIC and sigevent(3), " + "SIGEV_THREAD"); +} + +ATF_TC_BODY(timer_thread_create_mono, tc) +{ + timer_thread_create(CLOCK_MONOTONIC, false); +} + +ATF_TC(timer_thread_create_real_expire); +ATF_TC_HEAD(timer_thread_create_real_expire, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Checks timer_create(2) with CLOCK_REALTIME and sigevent(3), " + "SIGEV_THREAD, with expiration"); +} + +ATF_TC_BODY(timer_thread_create_real_expire, tc) +{ + timer_thread_create(CLOCK_REALTIME, true); +} + +ATF_TC(timer_thread_create_mono_expire); +ATF_TC_HEAD(timer_thread_create_mono_expire, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Checks timer_create(2) with CLOCK_MONOTONIC and sigevent(3), " + "SIGEV_THREAD, with expiration"); +} + +ATF_TC_BODY(timer_thread_create_mono_expire, tc) +{ + timer_thread_create(CLOCK_MONOTONIC, true); +} +#endif + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, timer_create_err); ATF_TP_ADD_TC(tp, timer_create_real); ATF_TP_ADD_TC(tp, timer_create_mono); ATF_TP_ADD_TC(tp, timer_create_real_expire); ATF_TP_ADD_TC(tp, timer_create_mono_expire); +#ifdef __FreeBSD__ + ATF_TP_ADD_TC(tp, timer_thread_create_real); + ATF_TP_ADD_TC(tp, timer_thread_create_mono); + ATF_TP_ADD_TC(tp, timer_thread_create_real_expire); + ATF_TP_ADD_TC(tp, timer_thread_create_mono_expire); +#endif return atf_no_error(); } Index: projects/stable-10-backport-test-changes/etc/mtree/BSD.tests.dist =================================================================== --- projects/stable-10-backport-test-changes/etc/mtree/BSD.tests.dist (revision 313470) +++ projects/stable-10-backport-test-changes/etc/mtree/BSD.tests.dist (revision 313471) @@ -1,480 +1,482 @@ # $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 .. .. 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 .. .. iconv .. inet .. locale .. net getaddrinfo data .. .. .. nss .. regex data .. .. resolv .. rpc .. ssp .. + setjmp + .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcrypt .. libmp .. libnv .. librt .. libthr dlopen .. .. libutil .. msun .. .. libexec atf atf-check .. atf-sh .. .. .. sbin dhclient .. devd .. growfs .. mdconfig .. .. secure lib .. libexec .. usr.bin .. usr.sbin .. .. share examples tests atf .. plain .. .. .. .. sys acl .. aio .. fifo .. file .. geom class concat .. eli .. gate .. gpt .. mirror .. nop .. raid3 .. shsec .. stripe .. uzip etalon .. .. .. .. kern acct .. execve .. pipe .. .. kqueue .. mac bsdextended .. portacl .. .. mqueue .. netinet .. 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 .. .. .. bsdcat .. calendar .. cmp .. cpio .. col .. comm .. cut .. dirname .. file2c .. grep .. gzip .. join .. jot .. lastcomm .. limits .. m4 .. ncal .. opensm .. printf .. sed regress.multitest.out .. .. tar .. timeout .. tr .. truncate .. uudecode .. uuencode .. xargs .. yacc yacc .. .. .. usr.sbin etcupdate .. extattr .. fstyp .. makefs .. newsyslog .. nmtree .. pw .. rpcbind .. sa .. .. .. # vim: set expandtab ts=4 sw=4: Index: projects/stable-10-backport-test-changes/lib/libc/tests/Makefile =================================================================== --- projects/stable-10-backport-test-changes/lib/libc/tests/Makefile (revision 313470) +++ projects/stable-10-backport-test-changes/lib/libc/tests/Makefile (revision 313471) @@ -1,40 +1,41 @@ # $FreeBSD$ .include TESTSDIR= ${TESTSBASE}/lib/libc SUBDIR= tls_dso TESTS_SUBDIRS= c063 TESTS_SUBDIRS+= db TESTS_SUBDIRS+= gen TESTS_SUBDIRS+= hash TESTS_SUBDIRS+= iconv TESTS_SUBDIRS+= inet TESTS_SUBDIRS+= net TESTS_SUBDIRS+= nss TESTS_SUBDIRS+= regex TESTS_SUBDIRS+= resolv TESTS_SUBDIRS+= rpc +TESTS_SUBDIRS+= setjmp TESTS_SUBDIRS+= stdio TESTS_SUBDIRS+= stdlib TESTS_SUBDIRS+= string TESTS_SUBDIRS+= sys TESTS_SUBDIRS+= termios TESTS_SUBDIRS+= tls TESTS_SUBDIRS+= ttyio .if ${MK_ICONV} != "no" TESTS_SUBDIRS+= iconv .endif .if ${MK_LOCALES} != "no" TESTS_SUBDIRS+= locale .endif .if ${MK_SSP} != "no" TESTS_SUBDIRS+= ssp .endif .include Index: projects/stable-10-backport-test-changes =================================================================== --- projects/stable-10-backport-test-changes (revision 313470) +++ projects/stable-10-backport-test-changes (revision 313471) Property changes on: projects/stable-10-backport-test-changes ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r288444,296586,301753,303840,304175