/* $NetBSD: t_strcpy.c,v 1.1 2011/07/07 08:59:33 jruoho Exp $ */ /* * Written by J.T. Conklin * Public domain. */ #include #include #include #include #include ATF_TC(strcpy_basic); ATF_TC_HEAD(strcpy_basic, tc) { atf_tc_set_md_var(tc, "descr", "Test strcpy(3) results"); } ATF_TC_BODY(strcpy_basic, tc) { /* try to trick the compiler */ char * (*f)(char *, const char *s) = strcpy; unsigned int a0, a1, t; char buf0[64]; char buf1[64]; char *ret; struct tab { const char* val; size_t len; }; const struct tab tab[] = { /* * patterns that check for all combinations of leading and * trailing unaligned characters (on a 64 bit processor) */ { "", 0 }, { "a", 1 }, { "ab", 2 }, { "abc", 3 }, { "abcd", 4 }, { "abcde", 5 }, { "abcdef", 6 }, { "abcdefg", 7 }, { "abcdefgh", 8 }, { "abcdefghi", 9 }, { "abcdefghij", 10 }, { "abcdefghijk", 11 }, { "abcdefghijkl", 12 }, { "abcdefghijklm", 13 }, { "abcdefghijklmn", 14 }, { "abcdefghijklmno", 15 }, { "abcdefghijklmnop", 16 }, { "abcdefghijklmnopq", 17 }, { "abcdefghijklmnopqr", 18 }, { "abcdefghijklmnopqrs", 19 }, { "abcdefghijklmnopqrst", 20 }, { "abcdefghijklmnopqrstu", 21 }, { "abcdefghijklmnopqrstuv", 22 }, { "abcdefghijklmnopqrstuvw", 23 }, /* * patterns that check for the cases where the expression: * * ((word - 0x7f7f..7f) & 0x8080..80) * * returns non-zero even though there are no zero bytes in * the word. */ { "" "\xff\xff\xff\xff\xff\xff\xff\xff" "abcdefgh", 16 }, { "a" "\xff\xff\xff\xff\xff\xff\xff\xff" "bcdefgh", 16 }, { "ab" "\xff\xff\xff\xff\xff\xff\xff\xff" "cdefgh", 16 }, { "abc" "\xff\xff\xff\xff\xff\xff\xff\xff" "defgh", 16 }, { "abcd" "\xff\xff\xff\xff\xff\xff\xff\xff" "efgh", 16 }, { "abcde" "\xff\xff\xff\xff\xff\xff\xff\xff" "fgh", 16 }, { "abcdef" "\xff\xff\xff\xff\xff\xff\xff\xff" "gh", 16 }, { "abcdefg" "\xff\xff\xff\xff\xff\xff\xff\xff" "h", 16 }, { "abcdefgh" "\xff\xff\xff\xff\xff\xff\xff\xff" "", 16 }, }; for (a0 = 0; a0 < sizeof(long); ++a0) { for (a1 = 0; a1 < sizeof(long); ++a1) { for (t = 0; t < (sizeof(tab) / sizeof(tab[0])); ++t) { memcpy(&buf1[a1], tab[t].val, tab[t].len + 1); ret = f(&buf0[a0], &buf1[a1]); /* * verify strcpy returns address of * first parameter */ if (&buf0[a0] != ret) { fprintf(stderr, "a0 %d, a1 %d, t %d\n", a0, a1, t); atf_tc_fail("strcpy did not return " "its first arg"); } /* * verify string was copied correctly */ if (memcmp(&buf0[a0], &buf1[a1], tab[t].len + 1) != 0) { fprintf(stderr, "a0 %d, a1 %d, t %d\n", a0, a1, t); atf_tc_fail("not correctly copied"); } } } } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strcpy_basic); return atf_no_error(); } span title='2021-07-23 20:18:24 +0000'>2021-07-23Various disk queue "peek" routines were only ever used in the simulatoroster 2021-07-23Extensive mechanical changes to the pools used in RAIDframe.oster 2021-07-23getiobuf() can return NULL if there are no IO buffers available.oster 2020-06-19remove unnnecessary splbio() in rf_FreeDiskQueueData()jdolecek 2020-06-19pass down b_flags B_PHYS|B_RAW|B_MEDIA_FLAGS from bio subsystemjdolecek 2019-10-10fix the function pointer and callback mess:christos 2019-02-10Introduce PR_ZERO to avoid open-coding memset()s everywhere. OK riastradh@.christos 2019-02-09- Change the allocation macros to be more like function callschristos 2011-05-05convert the diskqueue mutex into a kmutexmrg 2009-03-23Rework/simplify the disk queuing code. A bunch of this was stilloster 2008-06-17Mark a buffer `busy` in getnewbuf() when it came from the pool_cache sincereinoud 2008-01-02Merge vmlocking2 to head.ad 2007-03-04Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.christos 2006-11-16__unused removal on arguments; approved by core.christos 2006-10-12- sprinkle __unused on function decls.christos 2006-10-05Protect calls to pool_put/pool_get that may occur in interrupt contexttls 2006-01-08Cleanup the initialization of buffers a bit, and remove some old codeoster 2006-01-06initialize necessary members of struct buf. PR/32462 from Reinoud Zandijk.yamt 2006-01-04- add simple functions to allocate/free a buffer for i/o.yamt 2005-12-11merge ktrace-lwp.christos 2005-05-29- avoid variable shadowingchristos 2005-02-27nuke trailing whitespaceperry 2005-02-12The 'next' argument to rf_CreateDiskQueueData is always NULL. Sinceoster 2005-02-12Add a 'waitflag' argument to rf_CreateDiskQueueData() and use it tooster 2005-02-05CreateDiskQueueData() doesn't need to use void * for raidPtr.oster 2004-11-24Only touch bufpool whilst in splbio(). (That should be the caseoster