Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/cgd/t_cgd_3des.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/cgd/t_cgd_3des.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/cgd/t_cgd_3des.c (revision 312126) @@ -1,913 +1,913 @@ -/* $NetBSD: t_cgd_3des.c,v 1.1 2016/11/11 07:39:58 alnsn Exp $ */ +/* $NetBSD: t_cgd_3des.c,v 1.2 2017/01/13 21:30:39 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Alexander Nasonov. * * 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 COPYRIGHT HOLDERS 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 * COPYRIGHT HOLDERS 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 #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #define SECSIZE 512 struct testvec { unsigned int blkno; const uint8_t *ptxt; /* PlainText */ const uint8_t *ctxt; /* CipherText */ }; /* * 192 bits CBC key, NUL terminated. */ static const char c3des_cbc_192_key[25] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, /* ABCDEFGH */ 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* IJKLMNOP */ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* QRSTUVWX */ 0 }; static const uint8_t c3des_cbc_ptxt[SECSIZE] = " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop"; /* * IV method encblkno1, blkno 0. */ static const uint8_t c3des_cbc_192_encblkno1_vec0_ctxt[SECSIZE] = { 0x19, 0x92, 0xc8, 0xce, 0xdf, 0xa3, 0x14, 0xef, 0xff, 0x88, 0x9f, 0x01, 0xfa, 0x6f, 0xfa, 0xa6, 0xdd, 0x2b, 0x43, 0x67, 0xfa, 0xce, 0x37, 0x95, 0x73, 0x4d, 0x18, 0x33, 0x0c, 0x29, 0xb6, 0xbb, 0x37, 0x77, 0x31, 0x74, 0xf6, 0x62, 0x03, 0xd2, 0x78, 0x13, 0x55, 0xf6, 0x58, 0x49, 0xaf, 0x2a, 0x15, 0x4c, 0xc2, 0x4a, 0x55, 0x99, 0x82, 0xb9, 0xfb, 0x8b, 0x4f, 0x92, 0xe3, 0xbc, 0x9b, 0x09, 0x42, 0x7b, 0x5f, 0x54, 0xed, 0xf0, 0xcb, 0x5d,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4b, 0x1a, 0x34, 0x69, 0x96, 0xd0, 0x0f, 0x01, 0x27, 0x2e, 0x19, 0x02, 0xf0, 0x17, 0x8c, 0x89, 0xbf, 0x05, 0xf0, 0xfe, 0xc3, 0xe6, 0x90, 0x9d, 0xa2, 0xb1, 0x40, 0x06, 0x7e, 0xcd, 0x20, 0x7e, 0x5f, 0x54, 0x31, 0xfb, 0x79, 0x84, 0x47, 0x38, 0x71, 0x69, 0xe1, 0xd5, 0x4e, 0x84, 0xa3, 0x2b, 0x4a, 0x86, 0xc2, 0x21, 0x5b, 0x15, 0xc3, 0x63, 0xbb, 0xc5, 0x5c, 0xc1, 0xfb, 0x31, 0x3a, 0x4d, 0xb1, 0x9e, 0xe1, 0xd8, 0x67, 0x4b, 0x08, 0x42, 0xc4, 0xe8, }; /* * IV method encblkno1, blkno 1. */ static const uint8_t c3des_cbc_192_encblkno1_vec1_ctxt[SECSIZE] = { 0x1d, 0x65, 0xdf, 0x01, 0x9b, 0x24, 0xa5, 0x10, 0x94, 0x9a, 0x5b, 0x81, 0x96, 0x4e, 0xa3, 0x42, 0x42, 0xd5, 0x05, 0x52, 0xab, 0x3c, 0x67, 0x40, 0x79, 0xf9, 0x4b, 0x58, 0x39, 0xf6, 0xd0, 0x97, 0x48, 0xf4, 0x77, 0xb8, 0xac, 0xe2, 0x10, 0x66, 0xa8, 0x04, 0x0a, 0x1e, 0xa6, 0xbb, 0x4c, 0xd9, 0x5d, 0x0c, 0x11, 0xb5, 0xe0, 0x26, 0x84, 0x50, 0x10, 0x80, 0xbf, 0xd6, 0xdc, 0x82, 0x53, 0x0a, 0xcf, 0xf6, 0xd3, 0x07, 0x45, 0xb0, 0x8e, 0x36, 0x2e, 0x60, 0x0f, 0xd0, 0xc1, 0xb9, 0xd8, 0x29, 0x6e, 0x13, 0x8e, 0xc1, 0xa8, 0x63, 0x20, 0xe0, 0x8d, 0x47, 0x8b, 0xf9, 0xa0, 0x60, 0x55, 0x53, 0x1d, 0xaf, 0x43, 0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0x92, 0xd1, 0x15, 0x45, 0x86, 0x40, 0xac, 0xf1, 0x6f, 0x3c, 0x29, 0xef, 0x8d, 0x12, 0xe1, 0x9d, 0x04, 0x17, 0x3a, 0xcc, 0xa6, 0xc5, 0xe4, 0x27, 0x41, 0xcb, 0xfb, 0x5e, 0x77, 0x73, 0x5a, 0x2c, 0x03, 0xe9, 0x2b, 0x76, 0x4e, 0x69, 0xea, 0xcb, 0xb3, }; /* * IV method encblkno1, blkno 2. */ static const uint8_t c3des_cbc_192_encblkno1_vec2_ctxt[SECSIZE] = { 0x87, 0xb1, 0x3c, 0xd6, 0x60, 0xa0, 0x5a, 0x35, 0xf7, 0xe1, 0x6b, 0x87, 0xa0, 0x90, 0x2f, 0xc7, 0x8c, 0xed, 0x53, 0xda, 0x93, 0x32, 0x78, 0x5d, 0x24, 0x23, 0x42, 0xdd, 0x93, 0x5b, 0x2e, 0x40, 0xa1, 0xb1, 0x3b, 0xbb, 0xf0, 0x50, 0xb4, 0x61, 0xea, 0x15, 0x37, 0xf3, 0x49, 0xe1, 0xa0, 0x32, 0x88, 0x85, 0x81, 0xfd, 0xb7, 0x96, 0xd7, 0x9d, 0xd7, 0x29, 0x4b, 0x14, 0xf9, 0x18, 0x6a, 0xf6, 0x46, 0xae, 0x69, 0xdf, 0x63, 0x9a, 0xe0, 0x0b, 0x2c, 0x53, 0xd7, 0x82, 0x6f, 0xe5, 0xa0, 0x95, 0x2f, 0x61, 0x7f, 0x15, 0xff, 0xc7, 0xe8, 0x83, 0xfc, 0xfc, 0x16, 0x1c, 0x37, 0x0f, 0x9b, 0xbb, 0x14, 0xb2, 0xe2, 0xb7, 0x1f, 0x85, 0xb7, 0x07, 0x8a, 0x18, 0xed, 0xf7, 0x5f, 0x27, 0xff, 0x2f, 0x07, 0xf9, 0x9d, 0xe3, 0x79, 0x45, 0x1f, 0x51, 0x08, 0x54, 0x0f, 0x56, 0x84, 0xee, 0x87, 0x9a, 0xa9, 0x46, 0xb8, 0x77, 0x85,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1, 0x46, 0xac, 0xb0, 0x73, 0xca, 0x24, 0x7c, 0x71, }; /* * IV method encblkno1, blkno 3. */ static const uint8_t c3des_cbc_192_encblkno1_vec3_ctxt[SECSIZE] = { 0xb1, 0xef, 0x7c, 0xd0, 0xa0, 0x6b, 0xe4, 0x88, 0x5c, 0xd7, 0xf1, 0xbf, 0x5f, 0xce, 0xda, 0x19, 0x81, 0x32, 0xbb, 0x96, 0x7e, 0xb9, 0x6e, 0xa1, 0x43, 0xde, 0x53, 0x66, 0x9c, 0x27, 0x94, 0x85, 0xcb, 0x09, 0x4e, 0x16, 0xd8, 0x60, 0x7a, 0x38, 0x27, 0x21, 0x4d, 0x08, 0xaa, 0xe2, 0x1e, 0x6e, 0xa3, 0xcb, 0x9a, 0x7f, 0xd1, 0xbf, 0x18, 0x36, 0x5a, 0x4d, 0x7a, 0x7f, 0xcf, 0x3f, 0xba, 0xa5, 0x77, 0x5b, 0xb4, 0x79, 0xdc, 0xbf, 0x2a, 0x28, 0x16, 0x27, 0x0f, 0x8b, 0xd7, 0x95, 0xc3, 0xcb, 0xa1, 0x6a, 0x49, 0x53, 0xa8, 0x0c, 0x70, 0xde, 0x90, 0x2e, 0x36, 0x74, 0x40, 0x5d, 0x81, 0x74, 0x03, 0x11, 0xbd, 0xba, 0x40, 0x8d, 0x03, 0x86, 0x2b, 0x17, 0x55, 0x20, 0xd8, 0x81, 0x30, 0xd2, 0x2a, 0xbd, 0xea, 0xff, 0x5c, 0x69, 0x9b, 0xe6, 0xe3, 0x21, 0x9a, 0x10, 0x3e, 0xb0, 0xf4, 0x7a, 0xfc, 0x6e, 0x66, 0xec, 0x44, 0x0b, 0x95, 0x8d, 0x13, 0xd4, 0xf6, 0x3e, 0xa1, 0xa1, 0xac, 0xb1, 0xd8, 0x3d, 0x86, 0xaf, 0x5e, 0xef, 0x14, 0x6a, 0x32, 0xf3, 0x13, 0x75, 0x3b, 0x64, 0x9a, 0xf4, 0xd0, 0xf5, 0x00, 0x36, 0x9e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 0xf6, 0x00, 0x87, 0xc4, 0x29, 0xee, 0x2b, 0xa1, 0xa9, 0x1a, 0x46, 0x05, 0x5a, 0x12, 0x3f, 0x32, 0x81, 0x25, 0x20, 0x71, 0xb6, 0xfa, 0x1f, 0x27, 0x2a, 0x33, 0x49, 0xfc, 0x95, 0x00, 0x72, 0x6b, 0x03, 0x53, 0x94, 0x57, 0x2f, 0x47, 0x3d, 0x2d, 0x7c, 0xb4, 0xde, 0xa7, 0x96, 0x81, 0x12, 0xff, 0x2c, 0xec, 0x5c, 0x03, 0x2a, 0x8c, 0x76, 0xc4, 0xed, 0x09, 0xe6, 0x00, 0x28, 0xdb, 0x9b, 0x44, 0xb0, 0xb4, 0x7b, 0x57, 0x3b, 0xb6, 0x4f, 0x0b, 0xff, 0xf2, 0xf5, 0x02, 0x56, 0xcf, 0xd5, 0xbf, 0x71, 0xe6, 0x66, 0xf3, 0x08, 0x8e, 0x8b, 0x15, 0x57, 0x07, 0x41, 0xa3, 0x91, 0xc1, 0xe4, 0x64, 0x92, 0x89, 0xed, 0x22, 0x88, 0x8f, 0x17, 0x91, 0xde, 0xea, 0x0c, 0xa6, 0x86, 0x8e, 0x4c, 0xd9, 0x63, 0xc9, 0xe5, 0xdc, 0xd6, 0xd3, 0x7b, 0x2b, 0x65, 0xfa, 0x36, 0x47, 0x20, 0xa4, 0xe7, 0x0b, 0x52, 0xfa, 0xa6, 0xeb, 0x1d, 0x20, 0xd0, 0x4b, 0xfd, 0x88, 0x8c, 0xbb, 0x52, 0x9c, 0x2f, 0xb7, 0xba, 0x8b, 0xdd, 0x10, 0x2d, 0x7d, 0x77, 0x79, 0x40, 0xa7, 0xed, 0xf9, 0xbd, 0x2a, 0x55, 0x1f, 0x87, 0x1e, 0x3c, 0xfc, }; const struct testvec c3des_cbc_192_1_vectors[] = { { .blkno = 0, .ptxt = c3des_cbc_ptxt, .ctxt = c3des_cbc_192_encblkno1_vec0_ctxt, }, { .blkno = 1, .ptxt = c3des_cbc_ptxt, .ctxt = c3des_cbc_192_encblkno1_vec1_ctxt, }, { .blkno = 2, .ptxt = c3des_cbc_ptxt, .ctxt = c3des_cbc_192_encblkno1_vec2_ctxt, }, { .blkno = 3, .ptxt = c3des_cbc_ptxt, .ctxt = c3des_cbc_192_encblkno1_vec3_ctxt, }, }; /* * IV method encblkno8, blkno 0. */ static const uint8_t c3des_cbc_192_encblkno8_vec0_ctxt[SECSIZE] = { 0x9e, 0x5d, 0x35, 0x56, 0xa7, 0xcc, 0xc0, 0x1c, 0x60, 0x4c, 0x42, 0x90, 0x35, 0xf3, 0xc1, 0x20, 0xf2, 0x07, 0x6f, 0xf8, 0x7c, 0x33, 0x6a, 0x74, 0xdc, 0x85, 0xbc, 0x9c, 0xa2, 0x29, 0xc6, 0x69, 0x0e, 0xef, 0x0f, 0xa9, 0x6e, 0xec, 0xf2, 0x23, 0x2f, 0x9a, 0xbe, 0x1a, 0x89, 0x22, 0x00, 0xc4, 0x5a, 0xaf, 0x4a, 0xa0, 0x4f, 0x30, 0x8f, 0x99, 0xd2, 0x93, 0x6d, 0xfa, 0xcd, 0x2f, 0xad, 0x19, 0x10, 0x14, 0x90, 0x3a, 0x4b, 0xab, 0x17, 0x2e, 0x2c, 0xe1, 0x26, 0xe5, 0x76, 0xf1, 0xd1, 0x1d, 0x4c, 0x77, 0x68, 0xfb, 0x45, 0x9a, 0x3e, 0x19, 0xe0, 0xfb, 0xdc, 0xd4, 0x0e, 0x29, 0x7c, 0x06, 0xd3, 0x45, 0xa8, 0xf7, 0x39, 0x91, 0xe6, 0x18, 0x0f, 0x81, 0xe6, 0x7d, 0x6c, 0x65, 0x2e, 0x16, 0x24, 0xa4, 0x16, 0x96, 0x0a, 0x7b, 0x5f, 0x3a, 0x0c, 0xe9, 0x0e, 0x3f, 0x34, 0x38, 0xb0, 0xe1, 0x39, 0x23, 0x5c, 0x3c, 0x00, 0xb4, 0xa0, 0xf7, 0x42, 0x18, 0x70, 0x25, 0x82, 0x13, 0x24, 0x49, 0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8, blkno 1. */ static const uint8_t c3des_cbc_192_encblkno8_vec1_ctxt[SECSIZE] = { 0xf4, 0xb0, 0xb0, 0xcb, 0x79, 0xcc, 0x8c, 0x0a, 0x3b, 0xc7, 0x43, 0x4e, 0x62, 0x9d, 0xde, 0xb4, 0xab, 0xa5, 0x62, 0x63, 0x32, 0xa7, 0x18, 0x2b, 0xe3, 0xee, 0x44, 0xc6, 0x6f, 0xb2, 0xdc, 0x21, 0xc5, 0xc8, 0x9e, 0x32, 0x71, 0x4c, 0x7a, 0x82, 0x8d, 0xe0, 0xad, 0x91, 0x88, 0x0c, 0x41, 0x83, 0x28, 0x0d, 0xed, 0xa7, 0xeb, 0x48, 0xb1, 0x31, 0xfa, 0x40, 0xd9, 0x44, 0x19, 0xee, 0x8d, 0x2c, 0x7d, 0xe2, 0x39, 0xa0, 0x39, 0xaa, 0x86, 0xab, 0xb5, 0x68, 0xe5, 0x83, 0x06, 0x61, 0xec, 0xe6, 0xc2, 0x85, 0xb2, 0x46, 0xf4, 0x5b, 0x0e, 0x34, 0x7e, 0x0c, 0xa0, 0xda, 0xef, 0x58, 0x9c, 0x39, 0x95, 0xa2, 0xca, 0xd3, 0x3b, 0x4d, 0x76, 0xe3, 0x34, 0x6d, 0x08, 0xa4, 0xba, 0x88, 0x58, 0x39, 0xb4, 0xe4, 0x6b, 0xb6, 0x32, 0x50, 0x2c, 0xe2, 0x0a, 0x37, 0xbc, 0x98, 0x38, 0x32, 0x17, 0x1b, 0x12, 0xef, 0xdc, 0x9d, 0x91, 0x09, 0x8e, 0xd8, 0xc3, 0xf8, 0x7b, 0x35, 0x41, 0x3b, 0xf8, 0xf5, 0x37, 0x48, 0x04, 0xf7, 0x94, 0xbf, 0x54, 0x8d, 0x79, 0x49, 0x8f, 0xf0, 0x3f, 0xb7, 0x90, 0x76, 0x14, 0x09, 0xc6, 0x8c, 0xba, 0x1a, 0x30, 0x1b, 0xbb, 0xd9, 0xe2, 0xb5, 0xe8, 0xd9, 0x9b, 0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0x1b, 0x9c, 0x09, 0xe3, 0x1d, 0xdf, 0x0e, 0xfa, 0x39, 0xc8, 0x48, 0x43, 0x84, 0xec, 0x79, 0xc8, 0x7f, 0x4f, 0xa8, 0xc0, 0xb4, 0xde, 0x8b, 0x79, 0xcb, 0x9c, 0x42, 0x81, 0x49, 0xdc, 0x39, 0xb5, 0x31, 0xa6, 0x22, 0xba, 0x71, 0xb8, 0x2d, 0x1d, 0xc8, 0x17, 0xd8, 0x9d, 0x26, 0x2b, 0xd5, 0xcf, 0x57, 0x46, 0x0a, 0x61, 0x7e, 0xb7, 0xc3, 0x9c, 0xa6, 0x44, 0x60, 0x2d, 0x30, 0xb8, 0x10, 0x47, 0x7d, 0x7e, 0x87, 0x76, 0xc1, 0x4e, 0x85, 0x77, 0xbc, 0x30, 0x32, 0x56, 0x0a, 0x5b, 0x1c, 0xd0, 0xf6, 0x47, 0x48, 0x22, 0xf4, 0x6e, 0x38, 0xc5, 0xab, 0xe2, 0xd0, 0x4d, 0x40, 0x27, 0xab, 0x8f, 0x43, 0xb1, 0x60, 0x29, 0x07, 0xd0, 0xf5, 0x25, 0xe5, 0xfa, 0xe7, 0x46, 0x32, 0x37, 0xb9, 0xae, 0x2e, 0x02, 0x8c, 0x94, 0x15, 0x69, 0xd6, 0x74, 0xb4, 0x36, 0xdd, 0x94, 0x70, 0xa7, 0x16, 0x7b, 0x4c, 0xd3, 0x48, 0x83, 0xc5, 0xb2, 0xb0, 0x6a, 0xfe, 0x7e, 0xd4, 0xe5, 0x6d, 0xa5, 0x96, 0x20, 0x08, 0x59, 0xbd, 0x0c, 0x3d, 0x55, 0xa5, 0x03, }; /* * IV method encblkno8, blkno 2. */ static const uint8_t c3des_cbc_192_encblkno8_vec2_ctxt[SECSIZE] = { 0xea, 0x7c, 0x8c, 0x8e, 0x3e, 0x61, 0x34, 0x3d, 0xe0, 0x7f, 0xd3, 0xe1, 0x3a, 0xb9, 0xc8, 0xf2, 0x98, 0xdc, 0x59, 0x26, 0xd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d, 0x3b, 0x71, 0xfc, 0x06, 0x17, 0xec, 0x6c, 0x77, 0x98, 0x27, 0xc7, 0x4b, 0x65, 0x17, 0x81, 0xe7, 0xcb, 0xce, 0x09, 0x76, 0x82, 0x82, 0x4a, 0x53, 0x67, 0xa0, 0x05, 0x25, 0x4c, 0xc4, 0xa7, 0xad, 0xa7, 0xaf, 0xa0, 0x11, 0xd7, 0x73, 0x3b, 0x30, 0xbf, 0x53, 0x50, 0x9b, 0xd8, 0xf3, 0x32, 0x15, 0xdd, 0x36, 0x88, 0xc2, 0x39, 0x51, 0xb6, 0xb8, 0x0d, 0x5c, 0x20, 0x4e, 0x24, 0xee, 0x95, 0x32, 0x61, 0x25, 0xda, 0x73, 0x0d, 0x8a, 0x58, 0xe6, 0xcc, 0xad, 0x79, 0x3d, 0xef, 0x29, 0x0c, 0x9f, 0xe1, 0xa7, 0x22, 0x1e, 0xea, 0x7a, 0x4f, 0xfb, 0xc1, 0x1f, 0x17, 0xca, 0x69, 0xd6, 0xa4, 0xce, 0x6e, 0xc0, 0x70, 0xa3, 0x08, 0x32, 0x87, 0xb4, 0x6b, 0x80, 0x5c, 0x7f, 0x88, 0x5c, 0xbf, 0x07, 0xd8, 0xe9, 0xdd, 0xd2, 0x76, 0xa9, 0xaa, 0xd9, 0x55, 0x48, }; /* * IV method encblkno8, blkno 3. */ static const uint8_t c3des_cbc_192_encblkno8_vec3_ctxt[SECSIZE] = { 0xf3, 0x49, 0xda, 0x5c, 0xde, 0x9d, 0x3e, 0x9d, 0xb9, 0xc2, 0x6e, 0x96, 0xa9, 0x93, 0x10, 0x73, 0x0e, 0x26, 0x39, 0xd6, 0x9f, 0x04, 0x5f, 0x69, 0x54, 0xa3, 0x7c, 0x46, 0x7b, 0x18, 0x93, 0xc0, 0xbb, 0x0c, 0x96, 0x6f, 0xb0, 0xbf, 0xce, 0x67, 0x33, 0x3e, 0x56, 0xe8, 0x6b, 0x4d, 0x3f, 0xc8, 0x3c, 0xc6, 0x89, 0x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0e, 0x68, 0x14, 0x1c, 0xe8, 0x23, 0x9e, 0xe3, 0x8f, 0x71, 0x02, 0x9b, 0x87, 0xd4, 0xd9, 0x1b, 0xd1, 0x9e, 0x9e, 0xa0, 0x7e, 0x49, 0x8e, 0xaa, 0x89, 0xb5, 0x16, 0x48, 0x07, 0xb3, 0x3d, 0x9e, 0x4c, 0x35, 0x3e, 0x94, 0xa9, 0xf8, 0x82, 0x50, 0x6a, 0x41, 0x28, 0x3e, 0x9f, 0x9a, 0x1a, 0x5d, 0x02, 0x7c, 0xd0, 0x32, 0x52, 0xa5, 0xee, 0x09, 0x27, 0x2d, 0x49, 0x17, 0xf7, 0x92, 0xa1, 0x63, 0x9d, 0x2a, 0xfd, 0x53, 0x26, 0x14, 0x7c, 0x92, 0x72, 0xa6, 0x38, 0x18, 0x8f, 0xb5, 0x54, 0xb3, 0x69, 0x63, 0x6a, 0xdc, 0xb1, 0x5a, 0x12, 0x7a, 0x0b, 0xa3, }; const struct testvec c3des_cbc_192_8_vectors[] = { { .blkno = 0, .ptxt = c3des_cbc_ptxt, .ctxt = c3des_cbc_192_encblkno8_vec0_ctxt, }, { .blkno = 1, .ptxt = c3des_cbc_ptxt, .ctxt = c3des_cbc_192_encblkno8_vec1_ctxt, }, { .blkno = 2, .ptxt = c3des_cbc_ptxt, .ctxt = c3des_cbc_192_encblkno8_vec2_ctxt, }, { .blkno = 3, .ptxt = c3des_cbc_ptxt, .ctxt = c3des_cbc_192_encblkno8_vec3_ctxt, }, }; static int open_disk(const char *devpath, const char *imgpath, size_t size) { int fd; fd = open(imgpath, O_CREAT | O_RDWR | O_TRUNC, 0600); if (fd < 0) return -1; if (ftruncate(fd, size) < 0) goto fail; if (rump_pub_etfs_register_withsize(devpath, imgpath, RUMP_ETFS_BLK, 0, size) < 0) { goto fail; } unlink(imgpath); return fd; fail: close(fd); unlink(imgpath); return -1; } static int open_cgd(int devno) { char devpath[32]; sprintf(devpath, "/dev/rcgd%d%c", devno, getrawpartition() + 'a'); return rump_sys_open(devpath, O_RDWR, 0); } static int configure_cgd(int fd, const char *dkpath, const char *alg, const char *ivmethod, const char *key, size_t keylen) { struct cgd_ioctl ci; memset(&ci, 0, sizeof(ci)); ci.ci_disk = dkpath; ci.ci_alg = alg; ci.ci_ivmethod = ivmethod; ci.ci_keylen = 8 * keylen - 8; /* Exclude the NUL terminator. */ ci.ci_key = key; ci.ci_blocksize = 64; return rump_sys_ioctl(fd, CGDIOCSET, &ci); } static int unconfigure_cgd(int fd) { struct cgd_ioctl ci; return rump_sys_ioctl(fd, CGDIOCCLR, &ci); } static int write_testvec(int cgdfd, const struct testvec *tv) { if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) return -1; if (rump_sys_write(cgdfd, tv->ptxt, SECSIZE) != SECSIZE) return -1; return 0; } static int read_testvec(int cgdfd, const struct testvec *tv) { char *buf; int res = -1; buf = malloc(SECSIZE); if (buf == NULL) return -1; if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) goto fail; if (rump_sys_read(cgdfd, buf, SECSIZE) != SECSIZE) goto fail; res = memcmp(buf, tv->ptxt, SECSIZE); fail: free(buf); return res; } static int check_testvec(int dkfd, const struct testvec *tv) { char *buf; int res = -1; buf = malloc(SECSIZE); if (buf == NULL) return -1; if (lseek(dkfd, tv->blkno * SECSIZE, SEEK_SET) < 0) goto fail; if (read(dkfd, buf, SECSIZE) != SECSIZE) goto fail; res = memcmp(buf, tv->ctxt, SECSIZE); fail: free(buf); return res; } ATF_TC(cgd_3des_cbc_192_encblkno1); ATF_TC_HEAD(cgd_3des_cbc_192_encblkno1, tc) { atf_tc_set_md_var(tc, "descr", "Test 3des-cbc with 192 bits key, ivmethod encblkno1"); } ATF_TC_BODY(cgd_3des_cbc_192_encblkno1, tc) { const char imgpath[] = "3des-cbc-192-encblkno1.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno1", c3des_cbc_192_key, sizeof(c3des_cbc_192_key))); ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[0]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[1]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[2]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno1", c3des_cbc_192_key, sizeof(c3des_cbc_192_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_3des_cbc_192_encblkno8); ATF_TC_HEAD(cgd_3des_cbc_192_encblkno8, tc) { atf_tc_set_md_var(tc, "descr", "Test 3des-cbc with 192 bits key, ivmethod encblkno8"); } ATF_TC_BODY(cgd_3des_cbc_192_encblkno8, tc) { const char imgpath[] = "3des-cbc-192-encblkno8.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno8", c3des_cbc_192_key, sizeof(c3des_cbc_192_key))); ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[0]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[1]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[2]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno8", c3des_cbc_192_key, sizeof(c3des_cbc_192_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[3]), 0); RL(close(dkfd)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, cgd_3des_cbc_192_encblkno1); ATF_TP_ADD_TC(tp, cgd_3des_cbc_192_encblkno8); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c (revision 312126) @@ -1,3606 +1,3606 @@ -/* $NetBSD: t_cgd_aes.c,v 1.5 2016/12/11 00:23:44 alnsn Exp $ */ +/* $NetBSD: t_cgd_aes.c,v 1.6 2017/01/13 21:30:39 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. * Copyright (c) 2007 The Institute of Electrical and Electronics Engineers, Inc * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Alexander Nasonov. * * 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 COPYRIGHT HOLDERS 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 * COPYRIGHT HOLDERS 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 #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #define SECSIZE 512 struct testvec { unsigned int blkno; const uint8_t *ptxt; /* PlainText */ const uint8_t *ctxt; /* CipherText */ }; /* * 128 bits CBC key, NUL terminated. */ static const char aes_cbc_128_key[17] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */ 0 }; /* * 192 bits CBC key, NUL terminated. */ static const char aes_cbc_192_key[25] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, /* ABCDEFGH */ 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* IJKLMNOP */ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* QRSTUVWX */ 0 }; /* * 256 bits CBC key, NUL terminated. */ static const char aes_cbc_256_key[33] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* 89abcdef */ 0 }; static const uint8_t aes_cbc_ptxt[SECSIZE] = " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop"; /* * IV method encblkno1, blkno 0. */ static const uint8_t aes_cbc_128_encblkno1_vec0_ctxt[SECSIZE] = { 0x1e, 0x95, 0x12, 0x15, 0xf6, 0xe0, 0x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41, 0x07, 0xc1, 0xa1, 0x91, 0xa4, 0x59, 0x09, 0x75, 0x57, 0x5b, 0x53, 0x79, 0x58, 0xa2, 0x9e, 0x49, 0xa2, 0x5e, 0xf7, 0x28, 0x1c, 0x43, 0xa6, 0xcb, 0x88, 0x46, 0x84, 0xc9, 0x7f, 0x84, 0xdb, 0x45, 0x0c, 0xb3, 0x7f, 0x01, 0x40, 0x71, 0x3e, 0x48, 0x12, 0x1f, 0xbc, 0x1e, 0xdf, 0x41, 0x50, 0xb2, 0x11, 0x67, 0x83, 0x19, 0x04, 0x0e, 0x21, 0xd5, 0xf2, 0x54, 0x99, 0xfb, 0x47, 0xf2, 0x5e, 0x02, 0x4b, 0x61, 0x6d, 0xef, 0x78, 0x29, 0xe4, 0x3a, 0x56, 0x14, 0x20, 0x6f, 0x70, 0x82, 0xea, 0x5d, 0xbc, 0x48, 0x89, 0x34, 0x69, 0xdb, 0x4a, 0x06, 0xa7, 0xd6, 0xc7, 0xb7, 0x06, 0x8e, 0x64, 0x21, 0x3e, 0xa6, 0x32, 0x61, 0x59, 0x03, 0xea, 0xc3, 0x71, 0xf0, 0x26, 0x02, 0xe0, 0x71, 0x95, 0x38, 0x11, 0x32, 0xe6, 0x3b, 0x25, 0x53, 0x14, 0x24, 0x34, 0xe8, 0x8c, 0xa8, 0xef, 0x52, 0xfe, 0x06, 0x2c, 0x20, 0x88, 0x4f, 0xa6, }; /* * IV method encblkno1, blkno 1. */ static const uint8_t aes_cbc_128_encblkno1_vec1_ctxt[SECSIZE] = { 0x2f, 0x69, 0x3e, 0x95, 0x87, 0x91, 0x99, 0xd4, 0xd9, 0x5d, 0xf2, 0x52, 0x32, 0x54, 0x2a, 0x80, 0xa0, 0x77, 0x6e, 0x73, 0x15, 0xb4, 0xc9, 0x13, 0x85, 0xed, 0x79, 0x9b, 0x84, 0x0a, 0x7e, 0xdb, 0xee, 0x09, 0x78, 0x11, 0x28, 0xd5, 0x26, 0xec, 0x1d, 0x52, 0xba, 0x33,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0, 0xf8, 0xa2, 0x11, 0x14, 0x88, 0xf0, 0x1e, 0x4a, 0x4b, 0x13, 0xf6, 0xd6, 0x09, 0xac, 0xf8, 0x39, 0x5d, 0x4c, 0x68, 0x69, 0x99, 0x08, 0xd4, 0xf5, 0x39, 0x6d, 0x78, 0xde, 0xb5, 0x6f, 0x34, 0xc4, 0x28, 0x73, 0x6c, 0x29, 0xa1, 0xef, 0xfe, 0xed, 0x56, 0xb2, 0x70, 0x7b, 0xd5, 0x5b, 0xd1, 0x09, 0x6a, 0x9a, 0x59, 0xe9, 0x79, 0xe9, 0xee, 0xa4, 0x03, 0xc1, 0x67, 0xce, 0x62, 0xf6, 0x4f, 0x04, 0xa5, 0x04, 0x71, 0x13, 0xeb, 0x3d, 0x0a, 0x65, 0x2f, 0x57, 0xb0, 0xc0, 0xa4, 0xf2, 0x8d, 0x78, 0x90, 0xeb, 0xc9, 0x5e, 0x8b, 0xd8, 0xfb, 0xbc, 0x74, 0x1a, 0x70, 0x94, 0x2c, 0xeb, 0xf2, 0x5e, 0x6d, 0xbb, 0x96, 0x7a, 0x2c, }; /* * IV method encblkno1, blkno 2. */ static const uint8_t aes_cbc_128_encblkno1_vec2_ctxt[SECSIZE] = { 0xbc, 0x49, 0x35, 0x2c, 0xe3, 0x10, 0x12, 0x65, 0x7a, 0xf4, 0xde, 0xd3, 0xf8, 0xe1, 0x49, 0x97, 0x0a, 0x07, 0x93, 0x6c, 0xf8, 0x0e, 0xb7, 0xdf, 0x53, 0xba, 0x1e, 0x8e, 0x14, 0xbd, 0xf6, 0x81, 0xd6, 0xf6, 0x3d, 0xb2, 0xe7, 0x6a, 0x9d, 0x50, 0x68, 0xc2, 0x75, 0x8e, 0xfb, 0x44, 0xfa, 0xc8, 0x9f, 0x30, 0x15, 0xd5, 0xbe, 0xce, 0x04, 0xc1, 0x99, 0xde, 0x3d, 0x2b, 0xc1, 0xc4, 0x8a, 0xb1, 0xc5, 0x54, 0x47, 0x52, 0xf6, 0x38, 0x11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, 0x9f, 0x8d, 0x7a, 0x4e, 0x1e, 0x32, 0x6d, 0xb1, 0x82, 0x1e, 0x0c, 0xb6, 0x0b, 0xe6, 0x15, 0x82, 0x5c, 0xcc, 0xc8, 0x4a, 0x73, 0x56, 0x9d, 0x11, 0xfa, 0xcd, 0x21, 0x95, 0x23, 0x71, 0xe8, 0xfe, 0x06, 0x43, 0xf6, 0x17, 0x51, 0x28, 0x0d, 0xfb, 0x0a, 0x49, 0x1b, 0x35, 0x1e, 0x4a, 0x38, 0x08, 0x6b, 0xcd, 0x67, 0x21, 0x94, 0x09, 0x28, 0xca, 0x0a, 0x18, 0xdf, 0x6c, 0x86, 0x47, 0x10, 0x29, 0x81, 0x9a, 0x73, 0xba, 0x78, 0xbd, 0xc0, 0x61, 0xee, 0x23, }; /* * IV method encblkno1, blkno 3. */ static const uint8_t aes_cbc_128_encblkno1_vec3_ctxt[SECSIZE] = { 0x29, 0x9f, 0xb1, 0x0f, 0x7d, 0xb4, 0xd9, 0xbb, 0xf9, 0x06, 0x60, 0xdc, 0xb9, 0xeb, 0x73, 0x6e, 0xfe, 0xdb, 0x99, 0x29, 0xe8, 0x42, 0x46, 0xe7, 0x49, 0xcf, 0x90, 0x2d, 0x08, 0xd7, 0xd5, 0xbf, 0x0f, 0x4f, 0x66, 0xce, 0xcd, 0xb1, 0x8a, 0xc7, 0x47, 0xc9, 0x8e, 0xe3, 0x9f, 0x80, 0x79, 0xc6, 0xa8, 0xe5, 0x20, 0x66, 0x58, 0xde, 0xab, 0x87, 0x5e, 0x7e, 0xcd, 0x55, 0x81, 0x09, 0x40, 0xd9, 0x8b, 0x7e, 0xd3, 0xf9, 0x16, 0x55, 0x72, 0x7d, 0xe8, 0x36, 0x76, 0x06, 0x77, 0x47, 0xa5, 0xdc, 0x80, 0x33, 0x7d, 0x88, 0x5f, 0x56, 0x48, 0x0f, 0x66, 0xb5, 0x91, 0x9d, 0xf8, 0xdb, 0x83, 0x0d, 0xd4, 0xc6, 0x13, 0xf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, 0x45, 0xad, 0x0b, 0x64, 0x96, 0x7d, 0x84, 0xf2, 0x20, 0xa8, 0x95, 0x78, 0xb3, 0xb5, 0x98, 0x1f, 0xa7, 0x3e, 0x30, 0x77, 0x43, 0xd2, 0x8c, 0x20, 0xc5, 0x5e, 0x76, 0xcd, 0x2c, 0x7c, 0xfa, 0x34, 0x36, 0xda, 0x39, 0x00, 0x2e, 0x69, 0x4a, 0xb3, 0x0f, 0x6f, }; const struct testvec aes_cbc_128_1_vectors[] = { { .blkno = 0, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_128_encblkno1_vec0_ctxt, }, { .blkno = 1, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_128_encblkno1_vec1_ctxt, }, { .blkno = 2, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_128_encblkno1_vec2_ctxt, }, { .blkno = 3, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_128_encblkno1_vec3_ctxt, }, }; /* * IV method encblkno8, blkno 0. */ static const uint8_t aes_cbc_128_encblkno8_vec0_ctxt[SECSIZE] = { 0xa6, 0x64, 0xef, 0x0f, 0xc4, 0x45, 0xcc, 0x5e, 0xf8, 0x27, 0x42, 0x5e, 0xbd, 0x93, 0x99, 0xcd, 0x79, 0xa8, 0x7d, 0x72, 0xc4, 0x02, 0x99, 0xa6, 0xe4, 0x69, 0x57, 0x82, 0xdf, 0x32, 0x4e, 0x67, 0x2a, 0xd9, 0x58, 0x8c, 0x9f, 0xfc, 0x4d, 0xcf, 0x7b, 0xa4, 0xa1, 0xfa, 0xd9, 0x4d, 0xb5, 0x67, 0x06, 0x4a, 0x9e, 0x6d, 0xe8, 0xaa, 0xdd, 0xae, 0x8c, 0xda, 0xcf, 0x26, 0xd5, 0x94, 0x8d, 0x12, 0xf8, 0xdd, 0x21, 0x4c, 0xcb, 0xc8, 0x5d, 0xd1, 0x6a, 0x89, 0x37, 0xd0, 0x32, 0xe4, 0x87, 0xbc, 0x5d, 0xef, 0xca,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0xab, 0x3b, 0xc7, 0xba, 0x75, 0x20, 0xe6, 0x9f, 0x93, 0xb5, 0xcf, 0x8f, 0x7c, 0x1c, 0xf3, 0xdb, 0x6a, 0xf4, 0xde, 0x00, 0xe9, 0xaf, 0xd5, 0xf4, 0x36, 0x98, 0x14, 0x2d, 0x53, 0x20, 0x74, 0xab, 0x0c, 0xf6, 0xcd, 0x15, 0x32, 0xa6, 0x01, 0x8d, 0x24, 0x1b, 0x4b, 0x1f, 0xa3, 0xfc, 0x38, 0x82, 0x3a, 0xa1, 0xb5, 0x52, 0x53, 0xc7, 0x2b, 0x30, 0x7c, 0x65, 0xb9, 0x7d, }; /* * IV method encblkno8, blkno 1. */ static const uint8_t aes_cbc_128_encblkno8_vec1_ctxt[SECSIZE] = { 0x63, 0x45, 0x16, 0x0c, 0xe4, 0x4f, 0x51, 0xde, 0x74, 0xf8, 0x7b, 0xf5, 0x05, 0x17, 0x13, 0x1e, 0xa5, 0x3d, 0x84, 0xfa, 0x35, 0x5a, 0x2d, 0x3c, 0xb7, 0x61, 0x68, 0xff, 0xcd, 0x33, 0x1f, 0x0b, 0x53, 0x79, 0xf2, 0x2f, 0xbc, 0x8d, 0xac, 0xb9, 0xf9, 0xb7, 0x9c, 0x0a, 0x9d, 0xa1, 0x4d, 0x78, 0x9e, 0x4e, 0xfa, 0xe8, 0xc8, 0x46, 0x4b, 0x99, 0x91, 0x7e, 0x33, 0x6e, 0x18, 0x24, 0x01, 0xc3, 0x9f, 0x8c, 0x43, 0xb5, 0x15, 0x7e, 0xdd, 0xf9, 0x1b, 0xb0, 0xf2, 0xc3, 0x97, 0x1f, 0x7c, 0x3f, 0x43, 0x4c, 0x9f, 0x93, 0x29, 0x83, 0x8f, 0xad, 0xd1, 0x5e, 0x92, 0x1a, 0x17, 0xd1, 0xa0, 0x05, 0x6e, 0x62, 0x59, 0x80, 0x50, 0x6d, 0xe3, 0x28, 0x9a, 0x43, 0xdc, 0x81, 0x4f, 0x49, 0xc4, 0x98, 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0x81, 0xf5, 0xcf, 0x98, 0x92, 0xd3, 0x92, 0xf5, 0x6a, 0x74, 0x28, 0x10, 0x6b, 0xd4, 0x1d, 0x64, 0x7e, 0x05, 0x32, 0xba, 0xf7, 0x4c, 0xe9, 0xa8, 0xa9, 0xc5, 0x35, 0x34, 0x26, 0x41, }; /* * IV method encblkno8, blkno 2. */ static const uint8_t aes_cbc_128_encblkno8_vec2_ctxt[SECSIZE] = { 0x64, 0x7b, 0x62, 0x7a, 0xa6, 0xa9, 0xb3, 0x47, 0xbc, 0x03, 0x14, 0x3d, 0x9b, 0x56, 0xfc, 0x13, 0x08, 0x32, 0x81, 0xe3, 0x57, 0x3c, 0x0d, 0xbb, 0x85, 0x44, 0x47, 0x12, 0xc4, 0x80, 0x35, 0x37, 0xe1, 0xb4, 0x3f, 0x35, 0x98, 0x7c, 0xb0, 0x3b, 0x85, 0xab, 0x3d, 0x0b, 0xd3, 0x6f, 0xf9, 0x92, 0x00, 0x6b, 0x18, 0xe7, 0x31, 0x8b, 0x77, 0x4c, 0xd0, 0x7b, 0x1d, 0xfc, 0x95, 0xe6, 0x02, 0x01, 0x9c, 0x17, 0x4d, 0x9b, 0x3a, 0x1d, 0x12, 0x23, 0xd4, 0x24, 0xf8, 0x47, 0x5e, 0x2d, 0xfd, 0xc8, 0x74, 0x28, 0xb4, 0x3a, 0x99, 0x6b, 0xcc, 0xba, 0xe5, 0x51, 0x0b, 0xab, 0x4d, 0x63, 0xfc, 0x6d, 0x2d, 0xd9, 0x2b, 0x4f, 0xa4, 0x26, 0xc7, 0x8d, 0x9d, 0x12, 0x7f, 0xc7, 0x6b, 0x15, 0x8b, 0x4a, 0x41, 0xf8, 0x50, 0x32, 0x76, 0x10, 0xca, 0x8e, 0xfe, 0x08, 0x7d, 0x9a, 0xb5, 0x1a, 0xdb, 0x10, 0xb3, 0x6a, 0x5f, 0xd9, 0x0a, 0x5f, 0x31, 0x19, 0x3e, 0xa9, 0xa1, 0x72, 0x1f, 0x6c, 0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* IV method encblkno8, blkno 3. */ static const uint8_t aes_cbc_128_encblkno8_vec3_ctxt[SECSIZE] = { 0x98, 0xae, 0x82, 0x1d, 0x76, 0x3a, 0xfe, 0x80, 0x04, 0xa3, 0x43, 0xf0, 0x06, 0x45, 0x83, 0xb7, 0xe2, 0xb5, 0x73, 0x46, 0x78, 0x01, 0x2f, 0xd6, 0x0d, 0x49, 0x64, 0x4c, 0xeb, 0x8d, 0xdc, 0xa9, 0xdc, 0xea, 0x22, 0x25, 0xd4, 0x8f, 0xba, 0x9f, 0xd4, 0x7a, 0x3c, 0x9e, 0xd0, 0xd9, 0xcd, 0xa4, 0x12, 0xdf, 0x8f, 0x50, 0x24, 0x18, 0xa2, 0x0b, 0xd9, 0x7f, 0xda, 0x78, 0xd6, 0x11, 0xf3, 0x99, 0xc4, 0xec, 0x95, 0xe2, 0x85, 0xe1, 0xa0, 0x0d, 0x07, 0x22, 0x56, 0xaf, 0x2f, 0xf5, 0x7d, 0x63, 0xf2, 0x90, 0x6c, 0x26, 0x4f, 0xa5, 0x47, 0xcd, 0x66, 0x2d, 0x4c, 0x4d, 0x94, 0x6a, 0x3c, 0x98, 0xe4, 0x5e, 0x3b, 0x42, 0x3a, 0x93, 0x02, 0xd0, 0x90, 0xc7, 0xcd, 0x87, 0x0e, 0x84, 0x82, 0xf5, 0x77, 0x7b, 0x29, 0xe4, 0xea, 0x5b, 0x60, 0x50, 0xf7, 0x60, 0x8d, 0xf7, 0xd8, 0xd7, 0x7d, 0x99, 0x8a, 0xdc, 0xe2, 0xb9, 0x40, 0xac, 0x4b, 0x9f, 0x55, 0x30, 0xcb, 0x5a, 0x73, 0x64, 0xf2, 0xca, 0x76, 0x88, 0xf7, 0x55, 0xb5, 0x33, 0xc0, 0x44, 0xdf, 0x42, 0xee, 0xc9, 0xc5, 0x2a, 0x47, 0x18, 0x8b, 0x74, 0xb9, 0x4f, 0x2c, 0xd8, 0x7a, 0xd1, 0x12, 0x19, 0xf9, 0x21, 0x8d, 0x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0x18, 0xee, 0xa9, 0x56, 0x9c, 0x3c, 0xc3, 0x67, 0x84, 0x57, 0x77, 0x8d, 0xff, 0xea, 0x34, 0x3c, 0xf9, 0x58, 0xb8, 0xdc, 0x4e, 0xa1, 0x92, 0x2d, 0x9a, 0x91, 0x61, 0x23, 0x6a, 0xd9, 0xb7, 0x41, 0xc5, 0x0d, 0xb6, 0x57, 0x58, 0x42, 0x39, 0x4a, 0x86, 0x7e, 0x9d, 0xeb, 0x7d, 0xa8, 0x14, 0x1a, 0x5c, 0xa1, 0x54, 0x34, 0xb6, 0xb6, 0xbc, 0x1f, 0xf5, 0xe2, 0xb5, 0xe4, 0xa8, 0x42, 0xe3, 0x3d, 0x06, 0x6b, 0x50, 0xbb, 0xa1, 0x6b, 0x63, 0xe5, 0x60, 0x28, 0x07, 0x49, 0x06, 0x61, 0x0e, 0xa3, 0x6c, 0xc3, 0xc8, 0x3e, 0x5a, 0x9c, 0xa5, 0xb3, 0x9b, 0x8d, 0x46, 0xb9, 0xf5, 0x4a, 0x4d, 0xbe, 0xc0, 0xc1, 0x24, 0x92, 0x09, 0x7c, 0x9a, 0x21, 0x2c, 0x08, 0x8a, 0x0d, 0xfc, 0xff, 0xda, 0xdc, 0xf1, 0x45, 0x66, 0xf9, 0xcd, 0x64, 0x7c, 0x2f, 0x0e, 0x95, 0x5e, 0xec, 0x92, 0xd1, 0x03, 0x03, 0xa0, 0xcc, 0x73, 0x92, 0x15, 0x74, 0x42, 0x54, 0x48, 0x77, 0xbe, 0x96, 0xfb, 0x1f, 0x0c, 0x7a, 0x25, 0x67, 0x6b, 0x85, 0x71, 0x06, 0x15, 0xd3, 0x11, 0xfe, 0xf7, 0xa9, 0xb1, }; const struct testvec aes_cbc_128_8_vectors[] = { { .blkno = 0, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_128_encblkno8_vec0_ctxt, }, { .blkno = 1, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_128_encblkno8_vec1_ctxt, }, { .blkno = 2, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_128_encblkno8_vec2_ctxt, }, { .blkno = 3, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_128_encblkno8_vec3_ctxt, }, }; /* * IV method encblkno1, blkno 0. */ static const uint8_t aes_cbc_192_encblkno1_vec0_ctxt[SECSIZE] = { 0x7c, 0xc4, 0xec, 0x89, 0x7c, 0x13, 0xac, 0x99, 0x49, 0xa9, 0x96, 0xe7, 0xb1, 0x1a, 0xd6, 0xb0, 0xeb, 0x89, 0x27, 0x0f, 0x8b, 0x1b, 0xab, 0x8e, 0x2c, 0xd4, 0x00, 0x66, 0x12, 0x3a, 0x9a, 0x03, 0xc4, 0x49, 0xa4, 0xf0, 0xc1, 0x90, 0xf9, 0x38, 0xb2, 0x5c, 0xa5, 0x0d, 0x1b, 0x60, 0x94, 0xf6, 0x31, 0x4a, 0x72, 0xdb, 0xfc, 0xe1, 0x3c, 0xd6, 0x9d, 0x03, 0x07, 0x45, 0xdb, 0xad, 0xdb, 0xb3, 0x86, 0xfa, 0xce, 0x2c, 0xeb, 0xa2, 0xac, 0x05, 0xd9, 0x52, 0xb8, 0xae, 0xa9, 0x91, 0x86, 0x4b, 0xbb, 0xf8, 0x03, 0xb0, 0x6c, 0x40, 0xcc, 0xbf, 0xa3, 0x76, 0x60, 0xf7, 0x29, 0x03, 0xe6, 0x44, 0xcc, 0x2a, 0xe7, 0x74, 0x8e, 0x62, 0xfe, 0x99, 0x6a, 0x6d, 0x04, 0x1b, 0xe7, 0xf7, 0x9f, 0x13, 0xa7, 0x1d, 0x93, 0x0e, 0x8f, 0xe0, 0x77, 0x9b, 0xe3, 0x91, 0x67, 0x12, 0x33, 0x12, 0x42, 0x55, 0x28, 0x04, 0x2d, 0x01, 0x2b, 0xd2, 0xda, 0xbe, 0x7c, 0x83, 0xf2, 0x87, 0x71, 0x67, 0xaf, 0x6b, 0x50, 0x6c, 0x8c, 0x9f, 0x48, 0xee, 0x90, 0x0c, 0x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87, 0xb1, 0xe6, 0x87, 0x2f, 0x86, 0xd8, 0x9c, 0x7b, 0xec, 0xcf, 0xa4, 0xe5, 0xd5, 0x50, 0x3f, 0xdf, 0xc9, 0xb7, 0x29, 0x97, 0xd6, 0x33, 0xba, 0xf0, 0x72, 0xf0, 0x76, 0x12, 0xd3, 0x99, 0x4f, 0x1b, 0x36, 0xda, 0xa1, 0x83, 0xfe, 0xf5, 0x94, 0x9e, 0x61, 0x82, 0x62, 0xe0, 0x08, 0x3a, 0xbd, 0xba, 0x8b, 0x3d, 0xd6, 0xbd, 0x16, 0x5f, 0xd7, 0x1d, 0x6c, 0x0e, 0x92, 0x89, 0x8c, 0x38, 0x62, 0x80, 0xee, 0x7e, 0x63, 0x82, 0x88, 0x0b, 0xbf, 0xdd, 0x9f, 0xbc, 0xba, 0xa7, 0x5a, 0xc6, 0x0d, 0x87, 0x59, 0xbf, 0x0a, 0x85, 0x06, 0xa3, 0xb4, 0x66, 0x63, 0xda, 0x12, 0x29, 0x5f, 0x2e, 0x4d, 0x60, 0xfd, 0x85, 0x76, 0xaf, 0xf7, 0x87, 0xed, 0x1f, 0x46, 0xc2, 0xd6, 0x6c, 0x98, 0x6b, 0x4b, 0x60, 0x04, 0xed, 0x89, 0x3b, 0x85, 0x6c, 0xe9, 0x46, 0xd9, 0xfa, 0x35, 0x61, 0xe8, 0x0c, 0x84, 0x1b, 0x93, 0xc0, 0xfe, 0x5d, 0x29, 0x14, 0xe1, 0x1c, 0x66, 0x73, 0xc8, 0x0b, 0x98, 0xff, 0x1a, 0x78, 0x2b, 0x6a, 0x93, 0x7a, 0x29, 0xd8, 0x7b, 0xb1, 0x39, 0xf0, 0xad, 0x93, 0x4d, 0x2d, 0xab, 0x67, 0x3c, 0xa4, 0xa1, 0x08, 0x36, 0x0b, 0xe9, 0x77, 0xd0, 0xe3, 0x45, 0x7d, 0x99, 0x75, 0xc3, }; /* * IV method encblkno1, blkno 1. */ static const uint8_t aes_cbc_192_encblkno1_vec1_ct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, 0x73, 0x49, 0xea, 0x91, 0x4d, 0x62, 0xf8, 0x23, 0xe4, 0x3d, 0x91, 0xfb, 0x53, 0x2c, 0x8c, 0xa4, 0xfe, 0x81, 0x05, 0x5d, 0x4b, 0x9a, 0x75, 0x29, 0xf8, 0xbe, 0x3f, 0x05, 0xb4, 0x8f, 0xdc, 0xcc, 0xfa, 0xcc, 0xd7, 0xb2, 0x06, 0x03, 0xd4, 0xf3, 0x8e, 0x09, 0x09, 0x80, 0xf8, 0xc3, 0x3b, 0x66, 0xe9, 0x9c, 0x5b, 0x16, 0xed, 0x2d, 0x35, 0x1c, 0x99, 0x3b, 0x1f, 0x0e, 0x04, 0x30, 0x23, 0x3a, 0x83, 0x0c, 0xec, 0x76, 0xf2, 0x5d, 0x13, 0x54, 0x15, 0x62, 0x36, 0x26, 0x6b, 0x21, 0x62, 0xdd, 0xb4, 0x1a, 0x57, 0x16, 0xfd, 0xa0, 0x9c, 0xfa, 0x37, 0xb3, 0xda, 0xe0, 0x46, 0x91, 0xb3, 0x20, 0xe7, 0xe2, 0xf3, 0x0e, 0x20, 0x3c, 0x98, 0x1b, 0xe4, 0xc2, 0xd3, 0xa9, 0x97, 0xaf, 0x12, 0x69, 0x23, 0x97, 0x62, 0x6e, 0xae, 0x54, 0x9c, 0x82, 0x92, 0x50, 0x74, 0x07, 0x4a, 0xb1, 0xdc, 0xcf, 0x53, 0x1d, 0xc8, 0x29, 0x1f, 0x6e, 0xf1, 0x13, 0xec, 0xb6, 0x60, 0xb1, 0x4c, 0x9d, 0xd7, 0x77, }; /* * IV method encblkno1, blkno 2. */ static const uint8_t aes_cbc_192_encblkno1_vec2_ctxt[SECSIZE] = { 0x33, 0xfd, 0xfa, 0x44, 0x64, 0x75, 0x22, 0x7e, 0xe3, 0xb3, 0xa0, 0x75, 0x99, 0x96, 0xc0, 0xec, 0x56, 0x06, 0x7d, 0x19, 0x0b, 0x66, 0x89, 0xe0, 0x69, 0x1d, 0x93, 0x91, 0xd7, 0x0f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xf2, 0x96, 0x53, 0x6b, 0x8e, 0xd3, 0x1e, 0xe7, 0x92, 0xd4, 0xea, 0x41, 0xee, 0x92, 0x4d, 0x10, 0x9f, 0x68, 0xd8, 0xe9, 0xac, 0x1f, 0x38, 0x0b, 0x12, 0xa4, 0x1c, 0xb2, 0x63, 0x2b, 0x87, 0x07, 0xb8, 0x1e, 0x02, 0x2b, 0x4d, 0xad, 0x99, 0xdf, 0xe3, 0x98, 0x69, 0x29, 0x11, 0xe3, 0x77, 0x45, 0x9a, 0xe9, 0x6c, 0x47, 0x4e, 0xc0, 0x85, 0x15, 0x68, 0x58, 0x41, 0x37, 0xab, 0x96, 0x11, 0x94, 0x9e, 0xbb, 0xa8, 0x5d, 0x51, 0x05, 0x93, 0xdd, 0x2e, 0xb8, 0xdf, 0xcf, 0x83, 0xbc, 0xf6, 0x53, 0x95, 0x93, 0x27, 0xda, 0xa5, 0x20, 0x1b, 0x7d, 0x1d, 0xd9, 0x0c, 0xde, 0xe5, 0x3f, 0xc8, 0x60, 0x16, 0x32, 0x95, 0x24, 0xa7, 0x2b, 0x74, 0xf1, 0x67, 0xf9, 0xf2, 0x49, 0xda, 0x12, 0x97, 0xdd, }; /* * IV method encblkno1, blkno 3. */ static const uint8_t aes_cbc_192_encblkno1_vec3_ctxt[SECSIZE] = { 0xa5, 0x81, 0x86, 0x78, 0x4a, 0xd7, 0x5b, 0x83, 0xcf, 0xbf, 0x7e, 0x3c, 0xd7, 0xcd, 0xaf, 0xfa, 0x82, 0x18, 0xce, 0xbd, 0x8b, 0xe6, 0xd9, 0x39, 0x22, 0x2d, 0x1e, 0x75, 0x65, 0xee, 0x61, 0xf2, 0xc3, 0x8b, 0xf4, 0x40, 0x03, 0x73, 0x8a, 0x21, 0x9f, 0xf3, 0xcc, 0x93, 0x08, 0x3d, 0xff, 0x8a, 0xbc, 0x0f, 0x19, 0xa1, 0x9f, 0xc8, 0x73, 0xe8, 0xa6, 0x14, 0x2e, 0x43, 0x19, 0x79, 0x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34, 0xe0, 0xf5, 0xe3, 0x58, 0x06, 0xd7, 0x49, 0x00, 0x95, 0x3a, 0xb3, 0xc8, 0xcd, 0x2b, 0x3e, 0xe8, 0x1b, 0x60, 0xe8, 0xea, 0xaf, 0x09, 0xbb, 0xee, 0xce, 0xbc, 0xa0, 0x9b, 0x17, 0x90, 0x42, 0x40, 0x18, 0x35, 0x2e, 0x17, 0xa0, 0x6e, 0x43, 0xe7, 0xac, 0x89, 0x96, 0x3c, 0x16, 0xe0, 0xdb, 0x09, 0x51, 0x4a, 0x45, 0x33, 0x63, 0xe9, 0x4e, 0x3f, 0x32, 0x34, 0x36, 0x43, 0xd5, 0x0c, 0x5a, 0x2e, 0x0e, 0x8b, 0x80, 0xb7, 0xf4, 0xe4, 0x99, 0x9b, 0x05, 0xf5, 0xb2, 0xe4, 0x03, 0xe4, }; const struct testvec aes_cbc_192_1_vectors[] = { { .blkno = 0, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_192_encblkno1_vec0_ctxt, }, { .blkno = 1, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_192_encblkno1_vec1_ctxt, }, { .blkno = 2, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_192_encblkno1_vec2_ctxt, }, { .blkno = 3, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_192_encblkno1_vec3_ctxt, }, }; /* * IV method encblkno8, blkno 0. */ static const uint8_t aes_cbc_192_encblkno8_vec0_ctxt[SECSIZE] = { 0x87, 0x9c, 0x05, 0xd6, 0x25, 0xb9, 0xe0, 0xbe, 0x78, 0x21, 0x85, 0x81, 0x8e, 0x2f, 0x13, 0x5e, 0xf2, 0x73, 0x11, 0xfa, 0x73, 0x77, 0x93, 0x5e, 0x71, 0x16, 0x98, 0x68, 0x6f, 0xe8, 0x22, 0x34, 0xf5, 0x11, 0xfa, 0x61, 0xe6, 0x1a, 0xfb, 0x42, 0xa7, 0xa3, 0x2e, 0x0d, 0xc1, 0x9d, 0x7d, 0xd9, 0xfb, 0xbb, 0xc5, 0x08, 0x9d, 0xc2, 0xab, 0x5c, 0xdf, 0x9b, 0x3c, 0x1a, 0xbd, 0x66, 0x5a, 0x91, 0x1c, 0x00, 0x59, 0x2e, 0x92, 0xe9, 0x23, 0xf6, 0x90, 0x3d, 0x5b, 0x72, 0x76, 0x78, 0xd9, 0xa2, 0x48, 0x33, 0x29, 0xe2, 0xfd, 0x77, 0x14, 0xda, 0x01, 0x92, 0x63, 0xdd, 0x8c, 0x1c, 0x2e, 0xf7, 0x61, 0xfb, 0xc5, 0x76, 0xec, 0x7f, 0xef, 0xdc, 0xbe, 0x2d, 0x3b, 0x69, 0x30, 0xb9, 0x08, 0x00, 0xe8, 0x37, 0x09, 0xaa, 0x2a, 0x02, 0x80, 0x11, 0x91, 0x16, 0x94, 0x7d, 0xb5, 0xdc, 0x9f, 0xb3, 0xb0, 0x26, 0x72, 0x85, 0x93, 0x85, 0x19, 0x08, 0x97, 0xef, 0x97, 0x57, 0xa8, 0x76, 0x0e, 0x85, 0xb1, 0x1d, 0x79, 0xe3, 0x7a, 0xe8, 0x06, 0x3b, 0xc4, 0x00, 0xbd, 0xaa, 0xd9, 0x17, 0x81, 0x37, 0x12, 0x86, 0x52, 0xea, 0x04, 0xb2, 0x11, 0x0f, 0x5a, 0x08, 0x68, 0xcb, 0x48, 0xca, 0x2f, 0xda, 0xa3, 0x0a, 0x60, 0x57, 0xc7, 0x80, 0x36, 0x60, 0x05, 0xce, 0xd5, 0x43, 0xc9, 0xbc, 0x6c, 0xe6, 0x63, 0x38, 0x2e, 0x81, 0x90, 0x34, 0x11, 0x2c, 0x84, 0x0c, 0x62, 0x68, 0xde, 0x17, 0x57, 0x43, 0x19, 0xa5, 0x92, 0x9d, 0x91, 0x2b, 0xa2, 0x95, 0x7c, 0x20, 0x72, 0xaa, 0x83, 0x24, 0x54, 0x94, 0x10, 0x80, 0xd4, 0x3f, 0x58, 0xb9, 0x7b, 0x74, 0x68, 0xd5, 0xfb, 0x3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xd1, 0x2f, 0x50, 0x3e, 0xf1, 0x08, 0x49, 0x17, 0x08, 0xd2, 0xac, 0x5d, 0x58, 0xe7, 0x27, 0xe6, 0x59, 0x02, 0x9f, 0x1c, 0x40, 0xff, 0x6c, 0x67, 0xae, 0x49, 0x1a, 0x2a, 0xab, 0xd9, 0x63, 0x25, 0x2d, 0x9b, 0xd8, 0x1a, 0x41, 0xa6, 0xea, 0x72, 0xfd, 0x56, 0xa1, 0x57, 0x59, 0xdd, 0xf5, 0xa3, 0xb2, 0x2f, 0x64, 0xb1, 0xc5, 0xfe, 0x8d, 0x9b, 0x93, 0xd1, 0x51, 0x77, 0x13, 0x50, 0x74, 0x30, 0x28, 0xe4, 0x7a, 0x06, 0x69, 0xd4, 0xa8, 0x0a, 0xae, 0x02, 0x4a, 0x61, 0x24, 0xc2, 0xcd, 0xc8, 0xd3, 0x12, 0x2e, 0xac, 0x9a, 0x0c, 0x24, 0x06, 0xb8, 0x1e, 0x3d, 0x29, }; /* * IV method encblkno8, blkno 1. */ static const uint8_t aes_cbc_192_encblkno8_vec1_ctxt[SECSIZE] = { 0x1e, 0x3b, 0x66, 0x76, 0xd9, 0x9e, 0xf7, 0x82, 0x17, 0x76, 0x69, 0x4d, 0x64, 0x63, 0xf1, 0x01, 0x81, 0x8a, 0xa4, 0x97, 0x05, 0x42, 0xdb, 0x8c, 0x27, 0xc8, 0xfd, 0x08, 0x21, 0x17, 0x87, 0xa9, 0x0c, 0x86, 0x2d, 0xda, 0x17, 0xd5, 0x5d, 0x67, 0x12, 0x93, 0x8d, 0x34, 0x5a, 0xfc, 0x2a, 0x49, 0x1a, 0x1a, 0x77, 0x20, 0xfb, 0x1d, 0x5d, 0xd8, 0x99, 0xb0, 0x8f, 0x1c, 0x13, 0x4d, 0x28, 0x6d, 0x2d, 0x79, 0xa9, 0x8e, 0x04, 0x0c, 0x5a, 0xd5, 0x52, 0x09, 0x15, 0x4a, 0xfb, 0x7a, 0xf8, 0xdc, 0x3b, 0x77, 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 0x07, 0xa6, 0x20, 0x7b, 0x49, 0x47, 0x87, 0xff, 0xf0, 0xe8, 0x7e, 0xcf, 0xc4, 0x2c, 0x02, 0xdd, 0x53, 0xe9, 0x79, 0xc7, 0x6d, 0x16, 0x9f, 0x2b, 0xd7, 0x1a, 0x36, 0x25, 0x5c, 0xba, 0x5c, 0xdb, 0x44, 0x88, 0x99, 0x32, 0x2e, 0xb6, 0x3f, 0xb4, 0xdd, 0x15, 0xeb, 0xec, 0x2a, 0x9e, 0xc5, 0x37, 0x30, 0x2a, 0xd5, 0xc4, 0x2a, 0x9b, 0x40, 0x97, 0x83, 0x94, 0xe7, 0x79, 0x79, 0x63, 0x4b, }; /* * IV method encblkno8, blkno 2. */ static const uint8_t aes_cbc_192_encblkno8_vec2_ctxt[SECSIZE] = { 0x34, 0x07, 0x20, 0x14, 0x64, 0x0b, 0xa2, 0x2c, 0xed, 0xba, 0x46, 0x24, 0xa0, 0xe6, 0x99, 0x8a, 0x20, 0x75, 0x5f, 0x9f, 0x2a, 0x10, 0xa6, 0x1c, 0x52, 0x60, 0x18, 0x67, 0xd6, 0x0d, 0x90, 0x4e, 0xbc, 0x25, 0x5f, 0x81, 0xb4, 0x10, 0xdb, 0xd9, 0xaf, 0x36, 0x84, 0x5c, 0x20, 0x25, 0x25, 0xbf, 0x0d, 0xfa, 0xc5, 0x75, 0x2b, 0xec, 0xf2, 0xa6, 0x69, 0x5c, 0xfe, 0xee, 0x21, 0xd8, 0x87, 0xdf, 0xe3, 0x83, 0xeb, 0xb3, 0x3f, 0x5b, 0xda, 0x37, 0x11, 0x05, 0xf7, 0xd8, 0xe0, 0x94, 0x08, 0x2b, 0x75, 0x6b, 0xf3, 0x40, 0x53, 0x85, 0xde, 0x7a, 0x64, 0xb1, 0x0e, 0x5f, 0x01, 0xb5, 0xfb, 0x74, 0x48, 0x9a, 0xd4, 0x41, 0x33, 0x70, 0x9b, 0x08, 0x7e, 0x34, 0x60, 0xfc, 0xfa, 0xe6, 0x2c,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25, 0x9c, 0xcd, 0xa5, 0x7e, 0xd3, 0x30, 0xda, 0x46, 0xf5, 0x48, 0x9e, 0x39, 0x34, 0x94, 0xd6, 0x24, 0x10, 0xfc, 0x74, 0x2b, 0x6d, 0xcc, 0x00, 0x76, 0x3e, 0x3b, 0x85, 0xfa, 0xef, 0x87, 0x70, 0x53, 0x4e, }; /* * IV method encblkno8, blkno 3. */ static const uint8_t aes_cbc_192_encblkno8_vec3_ctxt[SECSIZE] = { 0xfe, 0xad, 0xf3, 0x4a, 0x9d, 0x64, 0x4e, 0x5d, 0xaf, 0xa8, 0x44, 0x7e, 0xc9, 0x75, 0xe8, 0xd0, 0x87, 0x73, 0x66, 0x4c, 0x77, 0x00, 0xfb, 0x7b, 0x04, 0xe7, 0xd8, 0x82, 0x75, 0xe3, 0xa5, 0xbc, 0xf3, 0x80, 0xae, 0x7c, 0xc9, 0x75, 0x9a, 0xc1, 0x73, 0x49, 0x69, 0xf6, 0xa0, 0x49, 0x6e, 0x77, 0x5f, 0x9b, 0x95, 0x9b, 0x9f, 0x41, 0x54, 0x57, 0x0e, 0x3c, 0xe5, 0x2c, 0xbb, 0xbf, 0xd5, 0x76, 0xf6, 0xb6, 0x05, 0xaa, 0x20, 0x5b, 0xdb, 0xcb, 0x81, 0xad, 0x0c, 0x8a, 0x68, 0x94, 0x7d, 0x88, 0xdc, 0x15, 0x6c, 0x89, 0x97, 0x53, 0x30, 0x96, 0x4a, 0x54, 0xf9, 0x88, 0x00, 0xf7, 0x3b, 0x99, 0xfc, 0x82, 0xe3, 0x48, 0xd2, 0x16, 0x2b, 0xba, 0xd4, 0xba, 0x24, 0xd0, 0xd1, 0xb0, 0x8e, 0xcd, 0x77, 0xdc, 0x01, 0xdf, 0xb2, 0x20, 0xc5, 0xa7, 0x48, 0x2a, 0xcf, 0x56, 0xc8, 0x63, 0x6e, 0xc9, 0xa8, 0xa4, 0xc2, 0x9c, 0x66, 0x25, 0x50, 0x77, 0x08, 0x51, 0x92, 0xce, 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b8, 0x89, 0x21, 0x3b, }; const struct testvec aes_cbc_192_8_vectors[] = { { .blkno = 0, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_192_encblkno8_vec0_ctxt, }, { .blkno = 1, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_192_encblkno8_vec1_ctxt, }, { .blkno = 2, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_192_encblkno8_vec2_ctxt, }, { .blkno = 3, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_192_encblkno8_vec3_ctxt, }, }; /* * IV method encblkno1, blkno 0. */ static const uint8_t aes_cbc_256_encblkno1_vec0_ctxt[SECSIZE] = { 0x1a, 0xa4, 0xe3, 0x09, 0x23, 0x2e, 0x91, 0x1b, 0xa8, 0x3e, 0xda, 0x92, 0xb3, 0x22, 0xd2, 0xe8, 0x8b, 0xed, 0x6c, 0xa7, 0x78, 0xe6, 0x32, 0x25, 0xc4, 0x88, 0xd5, 0xb7, 0x6e, 0xef, 0xbf, 0x37, 0x00, 0xd9, 0xb2, 0x55, 0x10, 0x4f, 0x7d, 0x84, 0x3a, 0xae, 0xd2, 0xc6, 0x48, 0xdd, 0x3c, 0xd5, 0x9b, 0xa7, 0xf8, 0xc2, 0xda, 0x6d, 0x14, 0xa2, 0xdc, 0x54, 0x12, 0x8f, 0x1c, 0x22, 0x98, 0x6a, 0xc0, 0x5f, 0x47, 0xa7, 0x78, 0xec, 0x79, 0x5d, 0x04, 0xed, 0x5e, 0x20, 0x33, 0x53, 0x66, 0x40, 0x83, 0x94, 0x5b, 0x34, 0x05, 0x25, 0x2e, 0x17, 0xba, 0x23, 0x60, 0xb1, 0xd0, 0x27, 0xf0, 0x24, 0xd2, 0x0b, 0xd3, 0xea, 0xa7, 0x13, 0x1e, 0xf9, 0x56, 0xe1, 0xd4, 0xa2, 0x89, 0x5a, 0xaa, 0x42, 0xa9, 0xd7, 0x85, 0x64, 0x9e, 0x44, 0x71, 0xa2, 0xf9, 0xc3, 0xf4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0xd9, 0xbe, 0xc7, 0x23, 0x44, 0x37, 0xb3, 0x98, 0x36, 0x33, 0x1a, 0x11, 0xfe, 0x41, 0xea, 0x59, 0x48, 0x75, 0x34, 0xf6, 0xc4, }; /* * IV method encblkno1, blkno 1. */ static const uint8_t aes_cbc_256_encblkno1_vec1_ctxt[SECSIZE] = { 0x58, 0xfc, 0x1e, 0x48, 0x66, 0x7d, 0x91, 0xc7, 0x56, 0xa3, 0x41, 0x89, 0xe8, 0x1e, 0x02, 0x77, 0x93, 0x38, 0x12, 0x99, 0x06, 0x0d, 0xf3, 0x6d, 0x2a, 0x5d, 0x3d, 0x7b, 0x4e, 0x05, 0x4f, 0x8f, 0xe3, 0x86, 0x76, 0xfe, 0x11, 0x9d, 0xde, 0xd4, 0x83, 0xd9, 0x47, 0x8d, 0x51, 0xdf, 0x4a, 0x24, 0x2d, 0x11, 0xf0, 0xbd, 0xde, 0x17, 0x7e, 0x52, 0x20, 0xc7, 0x17, 0x88, 0x2e, 0xa4, 0xd5, 0xa0, 0x1e, 0xbc, 0x61, 0x15, 0x1e, 0x52, 0xa1, 0x8b, 0xe9, 0xe4, 0x1f, 0x81, 0x49, 0x64, 0x17, 0xd4, 0xef, 0xb6, 0x40, 0x05, 0x2f, 0x36, 0xf7, 0x39, 0x03, 0x05, 0x80, 0xff, 0xf2, 0x1a, 0x15, 0xf1, 0xfc, 0xaf, 0x71, 0x51, 0x73, 0xc5, 0x9e, 0x2f, 0xd1, 0x7a, 0x2d, 0xd7, 0xed, 0x90, 0x11, 0xd2, 0x80, 0x49, 0x46, 0x9f, 0x13, 0xa7, 0x32, 0x33, 0x24, 0x39, 0x59, 0xf1, 0xed, 0x64, 0x75, 0x61, 0xc3, 0x14, 0x68, 0x48, 0xf7, 0xc7, 0xbd, 0xe0, 0x21, 0x59, 0x91, 0x07, 0x70, 0x83, 0x8f, 0xfc, 0x59, 0x72, 0xca, 0xdd, 0x60, 0xa0, 0xbb, 0xb1, 0x2f, 0xb8, 0x98,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x12, 0x0e, 0xd3, 0x37, 0x0b, 0xbf, 0x67, 0xb7, 0x9d, 0xb7, 0x6b, 0x38, 0xeb, 0x17, 0xd8, 0xb9, 0x5a, 0x37, 0x9f, 0x98, 0xa6, 0xca, 0x7e, 0x95, 0xa7, 0x27, 0xc4, 0xd3, 0x15, 0x00, 0x7b, 0x5e, 0x05, 0xc0, 0xc1, 0xb0, 0xe0, 0x13, 0x7d, 0x91, 0xed, 0x2b, 0x99, 0x74, 0x1c, 0x16, 0x45, 0x55, 0x21, 0xbc, 0x7c, 0x52, 0x87, 0x0f, 0xb9, 0xbf, 0x71, 0x7c, 0x3a, 0x81, 0x72, 0x97, 0xf8, 0x86, 0x61, 0x20, 0x17, 0xd8, 0xc8, 0xe0, 0xfc, 0x42, 0x0f, 0x5b, 0xd6, 0x7e, 0x99, 0x81, 0x5c, 0x2e, 0x2e, 0x3e, 0xe8, 0xce, 0x12, 0xcf, 0x2c, 0xe6, 0x7a, 0x00, 0x5d, 0x36, 0x00, 0x92, 0x60, 0xc5, 0xc0, 0xfd, 0xe0, 0xa3, 0xb9, 0x3e, 0x92, 0xf8, 0x8f, 0xe2, 0x0f, 0xe5, 0xb4, 0x6a, 0xd6, 0x5b, 0xa4, 0x5d, 0xf9, 0xef, 0x7e, 0xae, 0xdd, 0xd0, 0x5d, 0x40, 0xfe, 0xa7, 0xed, 0xda, 0xa9, 0x48, 0x1d, 0x6f, 0xc2, 0xd3, 0x35, 0x65, 0xd8, 0x67, 0xc2, 0x9d, 0xed, 0xf7, 0x9f, 0x7b, 0x7c, 0xd4, 0x03, 0xe0, 0xa6, 0xf9, 0x3c, 0xd0, 0x21, 0x98, 0x60, 0xa6, 0x59, 0x86, 0xbd, 0x40, 0x17, 0x47, 0x82, 0xb9, 0xe1, 0x11, 0x8d, 0x4b, 0xcd, 0x1f, 0x54, 0x96, 0x17, 0x42, 0x22, 0x44, }; /* * IV method encblkno1, blkno 2. */ static const uint8_t aes_cbc_256_encblkno1_vec2_ctxt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 0xc3, 0x57, 0xd5, 0x5a, 0x6f, 0xdc, 0xe5, 0xcc, 0x64, 0xc7, 0x80, 0x2a, 0xef, 0x90, 0x91, 0x96, 0xb4, 0xeb, 0xda, 0x3b, 0x7b, 0xbc, 0x14, 0x60, 0x52, 0xe5, 0xe5, 0xc8, 0x6a, 0x99, 0x46, 0x9d, 0x00, 0x77, 0x3b, 0x60, 0x75, 0x04, 0x06, 0x4a, 0x5a, 0x64, 0x6f, 0x2f, 0x58, 0x77, 0x27, 0x9a, 0xc5, 0x90, 0x37, 0xa7, 0xf3, 0x89, 0x72, 0x47, 0x4e, 0x08, 0xa5, 0x79, 0x11, 0x2f, 0x22, 0x5a, 0xbb, 0xcf, 0x76, 0xb9, 0x28, 0xc8, 0xc4, 0x5a, 0xe5, 0x90, 0xf7, 0x02, 0xe4, 0xf9, 0x0c, 0x4c, 0x9a, 0xb1, 0xa7, 0x99, 0x34, 0xd4, 0x77, 0x66, 0xff, 0x3c, 0x50, 0x9a, 0xff, 0x13, 0x49, 0xd6, 0x5a, 0xf6, 0x17, 0x6f, 0xca, 0x1a, 0xef, 0x0a, 0x2d, 0xf1, 0xdf, 0xd0, 0xa5, 0x6f, 0xa6, 0x22, 0x3c, 0x1f, 0xcf, 0xe7, 0xec, 0x23, 0x39, 0x6e, 0xc0, 0x37, 0x31, 0x84, 0xff, 0xe2, 0x5a, 0xd6, 0x88, 0x74, 0x15, 0x15, 0x46, 0x21, 0x00, 0xe4, 0x13, 0x9a, 0xfa, 0xb2, 0x49, 0x7e, 0x79, 0xfb, 0x8a, 0x2a, }; /* * IV method encblkno1, blkno 3. */ static const uint8_t aes_cbc_256_encblkno1_vec3_ctxt[SECSIZE] = { 0xc1, 0x4a, 0x3c, 0x90, 0xba, 0xd4, 0x9c, 0xe7, 0xf2, 0x5b, 0x3a, 0xc4, 0xce, 0x4a, 0x26, 0x4a, 0x9c, 0x3f, 0xe5, 0x7a, 0x15, 0xbb, 0xbd, 0x3e, 0xc6, 0x49, 0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, 0x6d, 0x72, 0xca, 0x43, 0xef, 0xb7, 0xa0, 0x4c, 0x62, 0xba, 0x7e, 0x59, 0x0b, 0xff, 0x90, 0x49, 0x63, 0xf6, 0x31, 0x8b, 0x50, 0x20, 0x82, 0x7d, 0xf0, 0x2d, 0xe4, 0x5b, 0xda, 0xdf, 0xb0, 0xfb, 0x07, 0x7b, 0xe3, 0x5f, 0xac, 0xd8, 0xe5, 0xa0, 0x3e, 0xc5, 0x60, 0x94, 0xbc, 0xf7, 0x7e, 0xdc, 0x18, 0x27, 0x20, 0xb1, 0xdd, 0x51, 0x4a, 0xb2, 0xe0, 0xc0, 0xe7, 0x5d, 0x0f, 0x88, 0xb2, 0xa0, 0x42, 0x73, 0xfb, 0xc4, 0x24, 0xa7, 0x17, 0x8a, 0xc9, 0x6d, 0x34, 0xe8, 0x7b, 0x51, 0x37, 0x32, 0x3f, 0xf8, 0x7e, 0x92, 0xe4, 0x87, 0xd2, 0x89, 0x66, 0xb0, 0xf6, 0xc2, 0xba, 0x2f, 0x42, 0x8f, 0x1d, 0x5d, 0x81, 0xad, 0xfd, 0x00, 0xbc, 0xa9, 0x11, 0x96, 0xae, 0x80, 0xf1, 0x27, 0xe0, 0xeb, 0x5b, 0x60, 0x39, }; const struct testvec aes_cbc_256_1_vectors[] = { { .blkno = 0, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_256_encblkno1_vec0_ctxt, }, { .blkno = 1, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_256_encblkno1_vec1_ctxt, }, { .blkno = 2, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_256_encblkno1_vec2_ctxt, }, { .blkno = 3, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_256_encblkno1_vec3_ctxt, }, }; /* * IV method encblkno8, blkno 0. */ static const uint8_t aes_cbc_256_encblkno8_vec0_ctxt[SECSIZE] = { 0xe5, 0x55, 0xd9, 0xae, 0xc0, 0x66, 0x2d, 0x2f, 0x11, 0xb1, 0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0xb3, 0x95, 0xd3, 0x42, 0x2d, 0x6b, 0xd8, 0x5c, 0x43, 0x31, 0x5b, 0x9c, 0x18, 0x30, 0x0d, 0x61, 0x9c, 0xab, 0x29, 0x55, 0xdd, 0x84, 0x24, 0x21, 0xec, 0x44, 0xad, 0xf3, 0xb3, 0x70, 0x77, 0x2b, 0xfc, 0x3f, 0x99, 0xb8, 0x50, 0x26, 0x8d, 0x96, 0xa2, 0x22, 0x99, 0x33, 0x53, 0xa8, 0x5d, 0x84, 0x9b, 0x76, 0x26, 0x6e, 0x75, 0x14, 0x7e, 0x63, 0xc6, 0x7a, 0x4f, 0x5c, 0xfe, 0x4b, 0x80, 0xee, 0xb3, 0x32, 0x8d, 0x25, 0x1c, 0x80, 0x7b, 0x3d, 0xd3, 0x84, 0x01, 0x1e, 0x16, 0xa4, 0xca, 0x0d, 0x38, 0x40, 0x03, 0x6f, 0x81, 0x8b, 0x5c, 0xad, 0x22, 0xfa, 0x6f, 0xeb, 0x60, 0xa1, 0xcb, 0x2d, 0x97, 0xf8, 0xa6, 0x5e, 0xbe, 0x93, 0xb7, 0xe6, 0x66, 0xbf, 0x9b, 0xd2, 0x5c, 0x31, 0xcc, 0x70, 0x0c, 0xf1, 0xfb, 0x9f, 0x09, 0x1b, 0xc2, 0x85, 0x2f, 0x22, 0x7c, 0x95, 0x58, 0x09, 0xce, 0x9c, 0x7c, 0x50, 0xca, 0x89, }; /* * IV method encblkno8, blkno 1. */ static const uint8_t aes_cbc_256_encblkno8_vec1_ctxt[SECSIZE] = { 0x37, 0x4d, 0x25, 0xdb, 0x35, 0xe0, 0x8b, 0x82, 0x5f, 0x77, 0xd2, 0x53, 0xd1, 0x1f, 0xf0, 0x91, 0x5b, 0xd8, 0x93, 0x2f, 0xb2, 0x81, 0xbd, 0x75, 0xf0, 0xd8, 0xff, 0x46, 0x8c, 0x9d, 0xf6, 0xe2, 0x99, 0x1e, 0x76, 0x9d, 0x00, 0x3a, 0xe3, 0xcf, 0x6d, 0x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, 0x04, 0x87, 0x2c, 0x89, 0x86, 0x24, 0xec, 0x52, 0x12, 0x6a, 0x51, 0x1e, 0x2a, 0x5e, 0x96, 0xfb, 0xac, 0x95, 0x4a, 0x1a, 0x06, 0x8f, 0xdf, 0xa7, 0x26, 0xeb, 0x6c, 0x79, 0x4a, 0x77, 0xea, 0xb3, 0xb1, 0x3a, 0x19, 0xe6, 0x5e, 0xe2, 0x26, 0x1b, 0x85, 0x3c, 0x9b, 0x1d, 0x05, 0x1d, 0xbe, 0x5c, 0x25, 0x7f, 0x45, 0x4c, 0x09, 0x4c, 0xc1, 0x47, 0xa5, 0x44, 0xfc, 0x04, 0x2b, 0xad, 0x53, 0xac, 0x57, 0x22, 0x54, 0x13, 0x7c, 0xc9, 0x96, 0x44, 0xda, 0x74, 0x95, 0x6e, 0x8c, 0xe6, 0x6a, 0x05, 0x05, 0xf3, 0x8c, 0x81, 0xaf, 0xbc, 0xb1, 0x91, 0xe7, 0xfd, 0x81, 0x3f, 0x47, 0xc2, 0x6f, 0x0d, 0x62, 0xf6, 0x6e, }; /* * IV method encblkno8, blkno 2. */ static const uint8_t aes_cbc_256_encblkno8_vec2_ctxt[SECSIZE] = { 0x5a, 0x24, 0xfd, 0xee, 0x9a, 0x44, 0xfb, 0xac, 0x3e, 0x46, 0x53, 0x95, 0x9e, 0xeb, 0x1f, 0xd9, 0xfd, 0xc6, 0x4f, 0xae, 0x0b, 0xc8, 0xf2, 0xbd, 0x77, 0x16, 0x7a, 0x2e, 0x8e, 0xec, 0x7a, 0x53, 0xf4, 0xe0, 0x34, 0xba, 0x6e, 0xfa, 0xc4, 0x69, 0xd7, 0x50, 0x13, 0x03, 0xfb, 0xb9, 0x66, 0x96, 0xd4, 0x21, 0x67, 0xcc, 0x4c, 0x4d, 0x10, 0x2f, 0x17, 0xeb, 0x41, 0xf4, 0x65, 0x80, 0x0b, 0x57, 0x2d, 0xdf, 0xcf, 0x9f, 0xb9, 0xd8, 0x53, 0x36, 0xbc, 0x1d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, 0x2c, 0xc8, 0xa8, 0x11, 0x82, 0x1b, 0xde, 0xad, 0x20, 0x5b, 0xd2, 0x63, 0xfb, 0x6d, 0xba, 0xd4, 0xcc, 0xb4, 0x9d, 0xe8, 0xa8, 0xd1, 0x06, 0x81, 0xf0, 0xb9, 0xd4, 0x90, 0x30, 0xcd, 0x0a, 0xe8, 0xd2, 0x8c, 0x7a, 0xbf, 0xf6, 0x0d, 0xa0, 0xae, 0x1b, 0x21, 0x18, 0x93, 0x18, 0x71, 0xe1, 0xa0, 0x63, 0x5a, 0x9d, 0x4e, 0x6a, 0x52, 0x90, 0xaf, 0xdb, 0x26, 0x1e, 0xa9, 0xa1, 0xc7, 0xf9, 0xf8, 0xa7, 0x3f, 0x85, 0xa1, 0xa4, }; /* * IV method encblkno8, blkno 3. */ static const uint8_t aes_cbc_256_encblkno8_vec3_ctxt[SECSIZE] = { 0x83, 0x77, 0xd8, 0xa8, 0x6a, 0x36, 0x41, 0x72, 0xb6, 0x03, 0x4e, 0x5e, 0x39, 0x36, 0xe3, 0xf5, 0xd0, 0x1b, 0x0d, 0x97, 0x78, 0x46, 0xee, 0xfd, 0x34, 0x34, 0x16, 0xa0, 0x44, 0xcf, 0x0b, 0xdc, 0xfb, 0x82, 0x98, 0xa2, 0x79, 0xc2, 0xe7, 0x1c, 0x43, 0x43, 0x4c, 0x7f, 0xe7, 0xa6, 0xe6, 0x10, 0x9e, 0x65, 0xb2, 0x09, 0xc7, 0x5f, 0xaa, 0xb7, 0xb8, 0xad, 0x83, 0xd5, 0x9e, 0xd1, 0xb2, 0xce, 0x4b, 0xa4, 0x5d, 0xbc, 0xd6, 0xf6, 0x0a, 0xe7, 0x1b, 0xe9, 0x86, 0xbc, 0x72, 0xcc, 0x6f, 0xcc, 0xf2, 0xde, 0x08, 0x48, 0xa2, 0x20, 0x31, 0x6a, 0xdd, 0xbe, 0xc5, 0x36, 0x55, 0xff, 0xce, 0xfa, 0xdf, 0x60, 0x26, 0x77, 0x7f, 0xd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0x0f, 0xfc, 0xbe, 0xa8, 0x0b, 0xbc, 0xaa, 0x32, 0xf0, 0xa5, 0x21, 0x50, 0x15, 0x7e, 0x46, 0xb9, 0x76, 0x09, 0x4e, 0x4b, 0x6f, 0x9f, 0xc7, 0x8c, 0x6d, 0x80, 0x37, 0xf9, 0xaa, 0xd1, 0x5f, 0x12, 0xb9, 0xb3, 0x15, 0xe4, 0x96, 0xa1, 0x01, 0xd5, 0xa0, }; const struct testvec aes_cbc_256_8_vectors[] = { { .blkno = 0, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_256_encblkno8_vec0_ctxt, }, { .blkno = 1, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_256_encblkno8_vec1_ctxt, }, { .blkno = 2, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_256_encblkno8_vec2_ctxt, }, { .blkno = 3, .ptxt = aes_cbc_ptxt, .ctxt = aes_cbc_256_encblkno8_vec3_ctxt, }, }; /* * 256 bits key from IEEE 1619/D16, NUL terminated. */ static const char aes_xts_256_key[33] = { 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45, 0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26, 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93, 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95, 0 }; /* * 512 bits key from IEEE 1619/D16, NUL terminated. */ static const char aes_xts_512_key[65] = { 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45, 0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26, 0x62, 0x49, 0x77, 0x57, 0x24, 0x70, 0x93, 0x69, 0x99, 0x59, 0x57, 0x49, 0x66, 0x96, 0x76, 0x27, 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93, 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95, 0x02, 0x88, 0x41, 0x97, 0x16, 0x93, 0x99, 0x37, 0x51, 0x05, 0x82, 0x09, 0x74, 0x94, 0x45, 0x92, 0 }; /* * Vector 4 from IEEE 1619/D16, blkno 0. */ static const uint8_t aes_xts_256_vec4_ptxt[SECSIZE] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa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 0xbd, 0x74, 0xd2, 0x0c, 0xc3, 0x98, 0x81, 0xc2, 0x13, 0xee, 0x77, 0x0b, 0x10, 0x10, 0xe4, 0xbe, 0xa7, 0x18, 0x84, 0x69, 0x77, 0xae, 0x11, 0x9f, 0x7a, 0x02, 0x3a, 0xb5, 0x8c, 0xca, 0x0a, 0xd7, 0x52, 0xaf, 0xe6, 0x56, 0xbb, 0x3c, 0x17, 0x25, 0x6a, 0x9f, 0x6e, 0x9b, 0xf1, 0x9f, 0xdd, 0x5a, 0x38, 0xfc, 0x82, 0xbb, 0xe8, 0x72, 0xc5, 0x53, 0x9e, 0xdb, 0x60, 0x9e, 0xf4, 0xf7, 0x9c, 0x20, 0x3e, 0xbb, 0x14, 0x0f, 0x2e, 0x58, 0x3c, 0xb2, 0xad, 0x15, 0xb4, 0xaa, 0x5b, 0x65, 0x50, 0x16, 0xa8, 0x44, 0x92, 0x77, 0xdb, 0xd4, 0x77, 0xef, 0x2c, 0x8d, 0x6c, 0x01, 0x7d, 0xb7, 0x38, 0xb1, 0x8d, 0xeb, 0x4a, 0x42, 0x7d, 0x19, 0x23, 0xce, 0x3f, 0xf2, 0x62, 0x73, 0x57, 0x79, 0xa4, 0x18, 0xf2, 0x0a, 0x28, 0x2d, 0xf9, 0x20, 0x14, 0x7b, 0xea, 0xbe, 0x42, 0x1e, 0xe5, 0x31, 0x9d, 0x05, 0x68, }; /* * Vector 5 from IEEE 1619/D16, blkno 1. */ static const uint8_t aes_xts_256_vec5_ptxt[SECSIZE] = { 0x27, 0xa7, 0x47, 0x9b, 0xef, 0xa1, 0xd4, 0x76, 0x48, 0x9f, 0x30, 0x8c, 0xd4, 0xcf, 0xa6, 0xe2, 0xa9, 0x6e, 0x4b, 0xbe, 0x32, 0x08, 0xff, 0x25, 0x28, 0x7d, 0xd3, 0x81, 0x96, 0x16, 0xe8, 0x9c, 0xc7, 0x8c, 0xf7, 0xf5, 0xe5, 0x43, 0x44, 0x5f, 0x83, 0x33, 0xd8, 0x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0x32, 0xff, 0x47, 0x9c, 0x57, 0xa0, 0x7d, 0x3e, 0xab, 0x5d, 0x54, 0xde, 0x5f, 0x97, 0x38, 0xb8, 0xd2, 0x7f, 0x27, 0xa9, 0xf0, 0xab, 0x11, 0x79, 0x9d, 0x7b, 0x7f, 0xfe, 0xfb, 0x27, 0x04, 0xc9, 0x5c, 0x6a, 0xd1, 0x2c, 0x39, 0xf1, 0xe8, 0x67, 0xa4, 0xb7, 0xb1, 0xd7, 0x81, 0x8a, 0x4b, 0x75, 0x3d, 0xfd, 0x2a, 0x89, 0xcc, 0xb4, 0x5e, 0x00, 0x1a, 0x03, 0xa8, 0x67, 0xb1, 0x87, 0xf2, 0x25, 0xdd, }; /* * Vector 6 from IEEE 1619/D16, blkno 2. */ static const uint8_t aes_xts_256_vec6_ptxt[SECSIZE] = { 0x26, 0x4d, 0x3c, 0xa8, 0x51, 0x21, 0x94, 0xfe, 0xc3, 0x12, 0xc8, 0xc9, 0x89, 0x1f, 0x27, 0x9f, 0xef, 0xdd, 0x60, 0x8d, 0x0c, 0x02, 0x7b, 0x60, 0x48, 0x3a, 0x3f, 0xa8, 0x11, 0xd6, 0x5e, 0xe5, 0x9d, 0x52, 0xd9, 0xe4, 0x0e, 0xc5, 0x67, 0x2d, 0x81, 0x53, 0x2b, 0x38, 0xb6, 0xb0, 0x89, 0xce, 0x95, 0x1f, 0x0f, 0x9c, 0x35, 0x59, 0x0b, 0x8b, 0x97, 0x8d, 0x17, 0x52, 0x13, 0xf3, 0x29, 0xbb, 0x1c, 0x2f, 0xd3, 0x0f, 0x2f, 0x7f, 0x30, 0x49, 0x2a, 0x61, 0xa5, 0x32, 0xa7, 0x9f, 0x51, 0xd3, 0x6f, 0x5e, 0x31, 0xa7, 0xc9, 0xa1, 0x2c, 0x28, 0x60, 0x82, 0xff, 0x7d, 0x23, 0x94, 0xd1, 0x8f, 0x78, 0x3e, 0x1a, 0x8e, 0x72, 0xc7, 0x22, 0xca, 0xaa, 0xa5, 0x2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b, 0x27, 0x04, 0xc9, 0x5c, 0x6a, 0xd1, 0x2c, 0x39, 0xf1, 0xe8, 0x67, 0xa4, 0xb7, 0xb1, 0xd7, 0x81, 0x8a, 0x4b, 0x75, 0x3d, 0xfd, 0x2a, 0x89, 0xcc, 0xb4, 0x5e, 0x00, 0x1a, 0x03, 0xa8, 0x67, 0xb1, 0x87, 0xf2, 0x25, 0xdd, }; static const uint8_t aes_xts_256_vec6_ctxt[SECSIZE] = { 0xfa, 0x76, 0x2a, 0x36, 0x80, 0xb7, 0x60, 0x07, 0x92, 0x8e, 0xd4, 0xa4, 0xf4, 0x9a, 0x94, 0x56, 0x03, 0x1b, 0x70, 0x47, 0x82, 0xe6, 0x5e, 0x16, 0xce, 0xcb, 0x54, 0xed, 0x7d, 0x01, 0x7b, 0x5e, 0x18, 0xab, 0xd6, 0x7b, 0x33, 0x8e, 0x81, 0x07, 0x8f, 0x21, 0xed, 0xb7, 0x86, 0x8d, 0x90, 0x1e, 0xbe, 0x9c, 0x73, 0x1a, 0x7c, 0x18, 0xb5, 0xe6, 0xde, 0xc1, 0xd6, 0xa7, 0x2e, 0x07, 0x8a, 0xc9, 0xa4, 0x26, 0x2f, 0x86, 0x0b, 0xee, 0xfa, 0x14, 0xf4, 0xe8, 0x21, 0x01, 0x82, 0x72, 0xe4, 0x11, 0xa9, 0x51, 0x50, 0x2b, 0x6e, 0x79, 0x06, 0x6e, 0x84, 0x25, 0x2c, 0x33, 0x46, 0xf3, 0xaa, 0x62, 0x34, 0x43, 0x51, 0xa2, 0x91, 0xd4, 0xbe, 0xdc, 0x7a, 0x07, 0x61, 0x8b, 0xde, 0xa2, 0xaf, 0x63, 0x14, 0x5c, 0xc7, 0xa4, 0xb8, 0xd4, 0x07, 0x06, 0x91, 0xae, 0x89, 0x0c, 0xd6, 0x57, 0x33, 0xe7, 0x94, 0x6e, 0x90, 0x21, 0xa1, 0xdf, 0xfc, 0x4c, 0x59, 0xf1, 0x59, 0x42, 0x5e, 0xe6, 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* * Vector 7 from IEEE 1619/D16, blkno 0xfd. */ static const uint8_t aes_xts_256_vec7_ptxt[SECSIZE] = { 0x8e, 0x41, 0xb7, 0x8c, 0x39, 0x0b, 0x5a, 0xf9, 0xd7, 0x58, 0xbb, 0x21, 0x4a, 0x67, 0xe9, 0xf6, 0xbf, 0x77, 0x27, 0xb0, 0x9a, 0xc6, 0x12, 0x40, 0x84, 0xc3, 0x76, 0x11, 0x39, 0x8f, 0xa4, 0x5d, 0xaa, 0xd9, 0x48, 0x68, 0x60, 0x0e, 0xd3, 0x91, 0xfb, 0x1a, 0xcd, 0x48, 0x57, 0xa9, 0x5b, 0x46, 0x6e, 0x62, 0xef, 0x9f, 0x4b, 0x37, 0x72, 0x44, 0xd1, 0xc1, 0x52, 0xe7, 0xb3, 0x0d, 0x73, 0x1a, 0xad, 0x30, 0xc7, 0x16, 0xd2, 0x14, 0xb7, 0x07, 0xae, 0xd9, 0x9e, 0xb5, 0xb5, 0xe5, 0x80, 0xb3, 0xe8, 0x87, 0xcf, 0x74, 0x97, 0x46, 0x56, 0x51, 0xd4, 0xb6, 0x0e, 0x60, 0x42, 0x05, 0x1d, 0xa3, 0x69, 0x3c, 0x3b, 0x78, 0xc1, 0x44, 0x89, 0x54, 0x3b, 0xe8, 0xb6, 0xad, 0x0b, 0xa6, 0x29, 0x56, 0x5b, 0xba, 0x20, 0x23, 0x13, 0xba, 0x7b, 0x0d, 0x0c, 0x94, 0xa3, 0x25, 0x2b, 0x67, 0x6f, 0x46, 0xcc, 0x02, 0xce, 0x0f, 0x8a, 0x7d, 0x34, 0xc0, 0xed, 0x22, 0x91, 0x29, 0x67, 0x3c, 0x1f, 0x61, 0xae, 0xd5, 0x79, 0xd0, 0x8a, 0x92, 0x03, 0xa2, 0x5a, 0xac, 0x3a, 0x77, 0xe9, 0xdb, 0x60, 0x26, 0x79, 0x96, 0xdb, 0x38, 0xdf, 0x63, 0x73, 0x56, 0xd9, 0xdc, 0xd1, 0x63, 0x2e, 0x36, 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 0x93, 0x92, 0xc9, 0xff, 0x05, 0xf5, 0x1f, 0x31, 0x66, 0xaa, 0xac, 0x4a, 0xc5, 0xf2, 0x38, 0x03, 0x8a, 0x30, 0x45, 0xe6, 0xf7, 0x2e, 0x48, 0xef, 0x0f, 0xe8, 0xbc, 0x67, 0x5e, 0x82, 0xc3, 0x18, 0xa2, 0x68, 0xe4, 0x39, 0x70, 0x27, 0x1b, 0xf1, 0x19, 0xb8, 0x1b, 0xf6, 0xa9, 0x82, 0x74, 0x65, 0x54, 0xf8, 0x4e, 0x72, 0xb9, 0xf0, 0x02, 0x80, 0xa3, 0x20, 0xa0, 0x81, 0x42, 0x92, 0x3c, 0x23, 0xc8, 0x83, 0x42, 0x3f, 0xf9, 0x49, 0x82, 0x7f, 0x29, 0xbb, 0xac, 0xdc, 0x1c, 0xcd, 0xb0, 0x49, 0x38, 0xce, 0x60, 0x98, 0xc9, 0x5b, 0xa6, 0xb3, 0x25, 0x28, 0xf4, 0xef, 0x78, 0xee, 0xd7, 0x78, 0xb2, 0xe1, 0x22, 0xdd, 0xfd, 0x1c, 0xbd, 0xd1, 0x1d, 0x1c, 0x0a, 0x67, 0x83, 0xe0, 0x11, 0xfc, 0x53, 0x6d, 0x63, 0xd0, 0x53, 0x26, 0x06, 0x37, }; /* * Vector 8 from IEEE 1619/D16, blkno 0xfe. */ static const uint8_t aes_xts_256_vec8_ptxt[SECSIZE] = { 0xd5, 0x5f, 0x68, 0x4f, 0x81, 0xf4, 0x42, 0x6e, 0x9f, 0xde, 0x92, 0xa5, 0xff, 0x02, 0xdf, 0x2a, 0xc8, 0x96, 0xaf, 0x63, 0x96, 0x28, 0x88, 0xa9, 0x79, 0x10, 0xc1, 0x37, 0x9e, 0x20, 0xb0, 0xa3, 0xb1, 0xdb, 0x61, 0x3f, 0xb7, 0xfe, 0x2e, 0x07, 0x00, 0x43, 0x29, 0xea, 0x5c, 0x22, 0xbf, 0xd3, 0x3e, 0x3d, 0xbe, 0x4c, 0xf5, 0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 0x82, 0xc3, 0x18, 0xa2, 0x68, 0xe4, 0x39, 0x70, 0x27, 0x1b, 0xf1, 0x19, 0xb8, 0x1b, 0xf6, 0xa9, 0x82, 0x74, 0x65, 0x54, 0xf8, 0x4e, 0x72, 0xb9, 0xf0, 0x02, 0x80, 0xa3, 0x20, 0xa0, 0x81, 0x42, 0x92, 0x3c, 0x23, 0xc8, 0x83, 0x42, 0x3f, 0xf9, 0x49, 0x82, 0x7f, 0x29, 0xbb, 0xac, 0xdc, 0x1c, 0xcd, 0xb0, 0x49, 0x38, 0xce, 0x60, 0x98, 0xc9, 0x5b, 0xa6, 0xb3, 0x25, 0x28, 0xf4, 0xef, 0x78, 0xee, 0xd7, 0x78, 0xb2, 0xe1, 0x22, 0xdd, 0xfd, 0x1c, 0xbd, 0xd1, 0x1d, 0x1c, 0x0a, 0x67, 0x83, 0xe0, 0x11, 0xfc, 0x53, 0x6d, 0x63, 0xd0, 0x53, 0x26, 0x06, 0x37, }; static const uint8_t aes_xts_256_vec8_ctxt[SECSIZE] = { 0x72, 0xef, 0xc1, 0xeb, 0xfe, 0x1e, 0xe2, 0x59, 0x75, 0xa6, 0xeb, 0x3a, 0xa8, 0x58, 0x9d, 0xda, 0x2b, 0x26, 0x1f, 0x1c, 0x85, 0xbd, 0xab, 0x44, 0x2a, 0x9e, 0x5b, 0x2d, 0xd1, 0xd7, 0xc3, 0x95, 0x7a, 0x16, 0xfc, 0x08, 0xe5, 0x26, 0xd4, 0xb1, 0x22, 0x3f, 0x1b, 0x12, 0x32, 0xa1, 0x1a, 0xf2, 0x74, 0xc3, 0xd7, 0x0d, 0xac, 0x57, 0xf8, 0x3e, 0x09, 0x83, 0xc4, 0x98, 0xf1, 0xa6, 0xf1, 0xae, 0xcb, 0x02, 0x1c, 0x3e, 0x70, 0x08, 0x5a, 0x1e, 0x52, 0x7f, 0x1c, 0xe4, 0x1e, 0xe5, 0x91, 0x1a, 0x82, 0x02, 0x01, 0x61, 0x52, 0x9c, 0xd8, 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b, 0xd8, 0xc9, 0xd7, 0xec, 0x77, 0xcf, 0x3c, 0x89, 0xc1, 0xec, 0x87, 0x18, 0xce, 0xff, 0x85, 0x16, 0xd9, 0x6b, 0x34, 0xc3, 0xc6, 0x14, 0xf1, 0x06, 0x99, 0xc9, 0xab, 0xc4, 0xed, 0x04, 0x11, 0x50, 0x62, 0x23, 0xbe, 0xa1, 0x6a, 0xf3, 0x5c, 0x88, 0x3a, 0xcc, 0xdb, 0xe1, 0x10, 0x4e, 0xef, 0x0c, 0xfd, 0xb5, 0x4e, 0x12, 0xfb, 0x23, 0x0a, }; /* * Vector 9 from IEEE 1619/D16, blkno 0xff. */ static const uint8_t aes_xts_256_vec9_ptxt[SECSIZE] = { 0x72, 0xef, 0xc1, 0xeb, 0xfe, 0x1e, 0xe2, 0x59, 0x75, 0xa6, 0xeb, 0x3a, 0xa8, 0x58, 0x9d, 0xda, 0x2b, 0x26, 0x1f, 0x1c, 0x85, 0xbd, 0xab, 0x44, 0x2a, 0x9e, 0x5b, 0x2d, 0xd1, 0xd7, 0xc3, 0x95, 0x7a, 0x16, 0xfc, 0x08, 0xe5, 0x26, 0xd4, 0xb1, 0x22, 0x3f, 0x1b, 0x12, 0x32, 0xa1, 0x1a, 0xf2, 0x74, 0xc3, 0xd7, 0x0d, 0xac, 0x57, 0xf8, 0x3e, 0x09, 0x83, 0xc4, 0x98, 0xf1, 0xa6, 0xf1, 0xae, 0xcb, 0x02, 0x1c, 0x3e, 0x70, 0x08, 0x5a, 0x1e, 0x52, 0x7f, 0x1c, 0xe4, 0x1e, 0xe5, 0x91, 0x1a, 0x82, 0x02, 0x01, 0x61, 0x52, 0x9c, 0xd8, 0x27, 0x73, 0x76, 0x2d, 0xaf, 0x54, 0x59, 0xde, 0x94, 0xa0, 0xa8, 0x2a, 0xda, 0xe7, 0xe1, 0x70, 0x3c, 0x80, 0x85, 0x43, 0xc2, 0x9e, 0xd6, 0xfb, 0x32, 0xd9, 0xe0, 0x04, 0x32, 0x7c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, 0x5d, 0xcd, 0x8c, 0xbf, 0x54, 0x78, 0x2f, 0x8f, 0xe7, 0x76, 0x6d, 0x47, 0x23, 0x81, 0x99, 0x13, 0xac, 0x77, 0x34, 0x21, 0xe3, 0xa3, 0x10, 0x95, 0x86, 0x6b, 0xad, 0x22, 0xc8, 0x6a, 0x60, 0x36, 0xb2, 0x51, 0x8b, 0x20, 0x59, 0xb4, 0x22, 0x9d, 0x18, 0xc8, 0xc2, 0xcc, 0xbd, 0xf9, 0x06, 0xc6, 0xcc, 0x6e, 0x82, 0x46, 0x4e, 0xe5, 0x7b, 0xdd, 0xb0, 0xbe, 0xbc, 0xb1, 0xdc, 0x64, 0x53, 0x25, 0xbf, 0xb3, 0xe6, 0x65, 0xef, 0x72, 0x51, 0x08, 0x2c, 0x88, 0xeb, 0xb1, 0xcf, 0x20, 0x3b, 0xd7, 0x79, 0xfd, 0xd3, 0x86, 0x75, 0x71, 0x3c, 0x8d, 0xaa, 0xdd, 0x17, 0xe1, 0xca, 0xbe, 0xe4, 0x32, 0xb0, 0x97, 0x87, 0xb6, 0xdd, 0xf3, 0x30, 0x4e, 0x38, 0xb7, 0x31, 0xb4, 0x5d, 0xf5, 0xdf, 0x51, 0xb7, 0x8f, 0xcf, 0xb3, 0xd3, 0x24, 0x66, 0x02, 0x8d, 0x0b, 0xa3, 0x65, 0x55, 0xe7, 0xe1, 0x1a, 0xb0, 0xee, 0x06, 0x66, 0x06, 0x1d, 0x16, 0x45, 0xd9, 0x62, 0x44, 0x4b, 0xc4, 0x7a, 0x38, 0x18, 0x89, 0x30, 0xa8, 0x4b, 0x4d, 0x56, 0x13, 0x95, 0xc7, 0x3c, 0x08, 0x70, 0x21, 0x92, 0x7c, 0xa6, 0x38, 0xb7, 0xaf, 0xc8, 0xa8, 0x67, 0x9c, 0xcb, 0x84, 0xc2, 0x65, 0x55, 0x44, 0x0e, 0xc7, 0xf1, 0x04, 0x45, 0xcd, }; const struct testvec aes_xts_256_vectors[] = { { .blkno = 0, .ptxt = aes_xts_256_vec4_ptxt, .ctxt = aes_xts_256_vec4_ctxt, }, { .blkno = 1, .ptxt = aes_xts_256_vec5_ptxt, .ctxt = aes_xts_256_vec5_ctxt, }, { .blkno = 2, .ptxt = aes_xts_256_vec6_ptxt, .ctxt = aes_xts_256_vec6_ctxt, }, { .blkno = 0xfd, .ptxt = aes_xts_256_vec7_ptxt, .ctxt = aes_xts_256_vec7_ctxt, }, { .blkno = 0xfe, .ptxt = aes_xts_256_vec8_ptxt, .ctxt = aes_xts_256_vec8_ctxt, }, { .blkno = 0xff, .ptxt = aes_xts_256_vec9_ptxt, .ctxt = aes_xts_256_vec9_ctxt, }, }; /* * Vector 10 from IEEE 1619/D16, blkno 0xff. */ static const uint8_t aes_xts_512_vec10_ptxt[SECSIZE] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72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xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, }; static const uint8_t aes_xts_512_vec10_ctxt[SECSIZE] = { 0x1c, 0x3b, 0x3a, 0x10, 0x2f, 0x77, 0x03, 0x86, 0xe4, 0x83, 0x6c, 0x99, 0xe3, 0x70, 0xcf, 0x9b, 0xea, 0x00, 0x80, 0x3f, 0x5e, 0x48, 0x23, 0x57, 0xa4, 0xae, 0x12, 0xd4, 0x14, 0xa3, 0xe6, 0x3b, 0x5d, 0x31, 0xe2, 0x76, 0xf8, 0xfe, 0x4a, 0x8d, 0x66, 0xb3, 0x17, 0xf9, 0xac, 0x68, 0x3f, 0x44, 0x68, 0x0a, 0x86, 0xac, 0x35, 0xad, 0xfc, 0x33, 0x45, 0xbe, 0xfe, 0xcb, 0x4b, 0xb1, 0x88, 0xfd, 0x57, 0x76, 0x92, 0x6c, 0x49, 0xa3, 0x09, 0x5e, 0xb1, 0x08, 0xfd, 0x10, 0x98, 0xba, 0xec, 0x70, 0xaa, 0xa6, 0x69, 0x99, 0xa7, 0x2a, 0x82, 0xf2, 0x7d, 0x84, 0x8b, 0x21, 0xd4, 0xa7, 0x41, 0xb0, 0xc5, 0xcd, 0x4d, 0x5f, 0xff, 0x9d, 0xac, 0x89, 0xae, 0xba, 0x12, 0x29, 0x61, 0xd0, 0x3a, 0x75, 0x71, 0x23, 0xe9, 0x87, 0x0f, 0x8a, 0xcf, 0x10, 0x00, 0x02, 0x08, 0x87, 0x89, 0x14, 0x29, 0xca, 0x2a, 0x3e, 0x7a, 0x7d, 0x7d, 0xf7, 0xb1, 0x03, 0x55, 0x16, 0x5c, 0x8b, 0x9a, 0x6d, 0x0a, 0x7d, 0xe8, 0xb0, 0x62, 0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x15, 0x99, 0x2b, 0x11, 0xb7, 0x7c, 0x04, 0x0f, 0x12, 0xbd, 0x8f, 0x6a, 0x97, 0x5a, 0x44, 0xa0, 0xf9, 0x0c, 0x29, 0xa9, 0xab, 0xc3, 0xd4, 0xd8, 0x93, 0x92, 0x72, 0x84, 0xc5, 0x87, 0x54, 0xcc, 0xe2, 0x94, 0x52, 0x9f, 0x86, 0x14, 0xdc, 0xd2, 0xab, 0xa9, 0x91, 0x92, 0x5f, 0xed, 0xc4, 0xae, 0x74, 0xff, 0xac, 0x6e, 0x33, 0x3b, 0x93, 0xeb, 0x4a, 0xff, 0x04, 0x79, 0xda, 0x9a, 0x41, 0x0e, 0x44, 0x50, 0xe0, 0xdd, 0x7a, 0xe4, 0xc6, 0xe2, 0x91, 0x09, 0x00, 0x57, 0x5d, 0xa4, 0x01, 0xfc, 0x07, 0x05, 0x9f, 0x64, 0x5e, 0x8b, 0x7e, 0x9b, 0xfd, 0xef, 0x33, 0x94, 0x30, 0x54, 0xff, 0x84, 0x01, 0x14, 0x93, 0xc2, 0x7b, 0x34, 0x29, 0xea, 0xed, 0xb4, 0xed, 0x53, 0x76, 0x44, 0x1a, 0x77, 0xed, 0x43, 0x85, 0x1a, 0xd7, 0x7f, 0x16, 0xf5, 0x41, 0xdf, 0xd2, 0x69, 0xd5, 0x0d, 0x6a, 0x5f, 0x14, 0xfb, 0x0a, 0xab, 0x1c, 0xbb, 0x4c, 0x15, 0x50, 0xbe, 0x97, 0xf7, 0xab, 0x40, 0x66, 0x19, 0x3c, 0x4c, 0xaa, 0x77, 0x3d, 0xad, 0x38, 0x01, 0x4b, 0xd2, 0x09, 0x2f, 0xa7, 0x55, 0xc8, 0x24, 0xbb, 0x5e, 0x54, 0xc4, 0xf3, 0x6f, 0xfd, 0xa9, 0xfc, 0xea, 0x70, 0xb9, 0xc6, 0xe6, 0x93, 0xe1, 0x48, 0xc1, 0x51, }; /* * Vector 11 from IEEE 1619/D16, blkno 0xffff. */ static const uint8_t aes_xts_512_vec11_ptxt[SECSIZE] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,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x72, 0xd1, 0x70, 0x58, 0xb8, 0x3b, 0x15, 0xab, 0x08, 0x66, 0xad, 0x8a, 0x58, 0x65, 0x6c, 0x5a, 0x7e, 0x20, 0xdb, 0xdf, 0x30, 0x8b, 0x24, 0x61, 0xd9, 0x7c, 0x0e, 0xc0, 0x02, 0x4a, 0x27, 0x15, 0x05, 0x52, 0x49, 0xcf, 0x3b, 0x47, 0x8d, 0xdd, 0x47, 0x40, 0xde, 0x65, 0x4f, 0x75, 0xca, 0x68, 0x6e, 0x0d, 0x73, 0x45, 0xc6, 0x9e, 0xd5, 0x0c, 0xdc, 0x2a, 0x8b, 0x33, 0x2b, 0x1f, 0x88, 0x24, 0x10, 0x8a, 0xc9, 0x37, 0xeb, 0x05, 0x05, 0x85, 0x60, 0x8e, 0xe7, 0x34, 0x09, 0x7f, 0xc0, 0x90, 0x54, 0xfb, 0xff, 0x89, 0xee, 0xae, 0xea, 0x79, 0x1f, 0x4a, 0x7a, 0xb1, 0xf9, 0x86, 0x82, 0x94, 0xa4, 0xf9, 0xe2, 0x7b, 0x42, 0xaf, 0x81, 0x00, 0xcb, 0x9d, 0x59, 0xce, 0xf9, 0x64, 0x58, 0x03, }; const struct testvec aes_xts_512_vectors[] = { { .blkno = 0xff, .ptxt = aes_xts_512_vec10_ptxt, .ctxt = aes_xts_512_vec10_ctxt, }, { .blkno = 0xffff, .ptxt = aes_xts_512_vec11_ptxt, .ctxt = aes_xts_512_vec11_ctxt, }, }; static int open_disk(const char *devpath, const char *imgpath, size_t size) { int fd; fd = open(imgpath, O_CREAT | O_RDWR | O_TRUNC, 0600); if (fd < 0) return -1; if (ftruncate(fd, size) < 0) goto fail; if (rump_pub_etfs_register_withsize(devpath, imgpath, RUMP_ETFS_BLK, 0, size) < 0) { goto fail; } unlink(imgpath); return fd; fail: close(fd); unlink(imgpath); return -1; } static int open_cgd(int devno) { char devpath[32]; sprintf(devpath, "/dev/rcgd%d%c", devno, getrawpartition() + 'a'); return rump_sys_open(devpath, O_RDWR, 0); } static int configure_cgd(int fd, const char *dkpath, const char *alg, const char *ivmethod, const char *key, size_t keylen) { struct cgd_ioctl ci; memset(&ci, 0, sizeof(ci)); ci.ci_disk = dkpath; ci.ci_alg = alg; ci.ci_ivmethod = ivmethod; ci.ci_keylen = 8 * keylen - 8; /* Exclude the NUL terminator. */ ci.ci_key = key; ci.ci_blocksize = 128; return rump_sys_ioctl(fd, CGDIOCSET, &ci); } static int unconfigure_cgd(int fd) { struct cgd_ioctl ci; return rump_sys_ioctl(fd, CGDIOCCLR, &ci); } static int write_testvec(int cgdfd, const struct testvec *tv) { ssize_t written; if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) return -1; written = rump_sys_write(cgdfd, tv->ptxt, SECSIZE); if (written < 0) return -1; if (written != SECSIZE) { errno = EDOM; /* Something distinct. */ return -1; } return 0; } static int read_testvec(int cgdfd, const struct testvec *tv) { char *buf; int res = -1; buf = malloc(SECSIZE); if (buf == NULL) return -1; if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) goto fail; if (rump_sys_read(cgdfd, buf, SECSIZE) != SECSIZE) goto fail; res = memcmp(buf, tv->ptxt, SECSIZE); fail: free(buf); return res; } static int check_testvec(int dkfd, const struct testvec *tv) { char *buf; int res = -1; buf = malloc(SECSIZE); if (buf == NULL) return -1; if (lseek(dkfd, tv->blkno * SECSIZE, SEEK_SET) < 0) goto fail; if (read(dkfd, buf, SECSIZE) != SECSIZE) goto fail; res = memcmp(buf, tv->ctxt, SECSIZE); fail: free(buf); return res; } ATF_TC(cgd_aes_cbc_128_encblkno1); ATF_TC_HEAD(cgd_aes_cbc_128_encblkno1, tc) { atf_tc_set_md_var(tc, "descr", "Test aes-cbc with 128 bits key, ivmethod encblkno1"); } ATF_TC_BODY(cgd_aes_cbc_128_encblkno1, tc) { const char imgpath[] = "aes-cbc-128-encblkno1.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", aes_cbc_128_key, sizeof(aes_cbc_128_key))); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[0]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[1]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[2]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[3]), -1); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", aes_cbc_128_key, sizeof(aes_cbc_128_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_aes_cbc_128_encblkno8); ATF_TC_HEAD(cgd_aes_cbc_128_encblkno8, tc) { atf_tc_set_md_var(tc, "descr", "Test aes-cbc with 128 bits key, ivmethod encblkno8"); } ATF_TC_BODY(cgd_aes_cbc_128_encblkno8, tc) { const char imgpath[] = "aes-cbc-128-encblkno8.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", aes_cbc_128_key, sizeof(aes_cbc_128_key))); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[0]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[1]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[2]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[3]), -1); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", aes_cbc_128_key, sizeof(aes_cbc_128_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_aes_cbc_192_encblkno1); ATF_TC_HEAD(cgd_aes_cbc_192_encblkno1, tc) { atf_tc_set_md_var(tc, "descr", "Test aes-cbc with 192 bits key, ivmethod encblkno1"); } ATF_TC_BODY(cgd_aes_cbc_192_encblkno1, tc) { const char imgpath[] = "aes-cbc-192-encblkno1.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", aes_cbc_192_key, sizeof(aes_cbc_192_key))); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[0]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[1]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[2]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[3]), -1); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", aes_cbc_192_key, sizeof(aes_cbc_192_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_aes_cbc_192_encblkno8); ATF_TC_HEAD(cgd_aes_cbc_192_encblkno8, tc) { atf_tc_set_md_var(tc, "descr", "Test aes-cbc with 192 bits key, ivmethod encblkno8"); } ATF_TC_BODY(cgd_aes_cbc_192_encblkno8, tc) { const char imgpath[] = "aes-cbc-192-encblkno8.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", aes_cbc_192_key, sizeof(aes_cbc_192_key))); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[0]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[1]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[2]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[3]), -1); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", aes_cbc_192_key, sizeof(aes_cbc_192_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_aes_cbc_256_encblkno1); ATF_TC_HEAD(cgd_aes_cbc_256_encblkno1, tc) { atf_tc_set_md_var(tc, "descr", "Test aes-cbc with 256 bits key, ivmethod encblkno1"); } ATF_TC_BODY(cgd_aes_cbc_256_encblkno1, tc) { const char imgpath[] = "aes-cbc-256-encblkno1.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", aes_cbc_256_key, sizeof(aes_cbc_256_key))); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[0]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[1]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[2]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[3]), -1); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", aes_cbc_256_key, sizeof(aes_cbc_256_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_aes_cbc_256_encblkno8); ATF_TC_HEAD(cgd_aes_cbc_256_encblkno8, tc) { atf_tc_set_md_var(tc, "descr", "Test aes-cbc with 256 bits key, ivmethod encblkno8"); } ATF_TC_BODY(cgd_aes_cbc_256_encblkno8, tc) { const char imgpath[] = "aes-cbc-256-encblkno8.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", aes_cbc_256_key, sizeof(aes_cbc_256_key))); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[0]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[1]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[2]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[3]), -1); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", aes_cbc_256_key, sizeof(aes_cbc_256_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_aes_xts_256); ATF_TC_HEAD(cgd_aes_xts_256, tc) { atf_tc_set_md_var(tc, "descr", "Test aes-xts with 256 bits key"); } ATF_TC_BODY(cgd_aes_xts_256, tc) { const char imgpath[] = "aes-xts-256.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 256 * SECSIZE; /* Last blkno is 0xff. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1", aes_xts_256_key, sizeof(aes_xts_256_key))); CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[0]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[1]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[2]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[3]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[4]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[5]), -1); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1", aes_xts_256_key, sizeof(aes_xts_256_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[3]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[4]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[5]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[3]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[4]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[5]), 0); RL(close(dkfd)); } ATF_TC(cgd_aes_xts_512); ATF_TC_HEAD(cgd_aes_xts_512, tc) { atf_tc_set_md_var(tc, "descr", "Test aes-xts with 512 bits key"); } ATF_TC_BODY(cgd_aes_xts_512, tc) { const char imgpath[] = "aes-xts-512.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 65536 * SECSIZE; /* Last blkno is 0xffff. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1", aes_xts_512_key, sizeof(aes_xts_512_key))); CHECK_LIBC(write_testvec(cgdfd, &aes_xts_512_vectors[0]), -1); CHECK_LIBC(write_testvec(cgdfd, &aes_xts_512_vectors[1]), -1); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1", aes_xts_512_key, sizeof(aes_xts_512_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_512_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_512_vectors[1]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_512_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_512_vectors[1]), 0); RL(close(dkfd)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, cgd_aes_cbc_128_encblkno1); ATF_TP_ADD_TC(tp, cgd_aes_cbc_128_encblkno8); ATF_TP_ADD_TC(tp, cgd_aes_cbc_192_encblkno1); ATF_TP_ADD_TC(tp, cgd_aes_cbc_192_encblkno8); ATF_TP_ADD_TC(tp, cgd_aes_cbc_256_encblkno1); ATF_TP_ADD_TC(tp, cgd_aes_cbc_256_encblkno8); ATF_TP_ADD_TC(tp, cgd_aes_xts_256); ATF_TP_ADD_TC(tp, cgd_aes_xts_512); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c (revision 312126) @@ -1,2341 +1,2341 @@ -/* $NetBSD: t_cgd_blowfish.c,v 1.1 2016/11/10 23:44:36 alnsn Exp $ */ +/* $NetBSD: t_cgd_blowfish.c,v 1.2 2017/01/13 21:30:39 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Alexander Nasonov. * * 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 COPYRIGHT HOLDERS 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 * COPYRIGHT HOLDERS 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 #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #define SECSIZE 512 struct testvec { unsigned int blkno; const uint8_t *ptxt; /* PlainText */ const uint8_t *ctxt; /* CipherText */ }; /* * 128 bits Blowfish key, NUL terminated. */ static const char bf_cbc_128_key[17] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */ 0 }; /* * 256 bits Blowfish key, NUL terminated. */ static const char bf_cbc_256_key[33] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* 89abcdef */ 0 }; /* * 448 bits Blowfish key, NUL terminated. */ static const char bf_cbc_448_key[57] = { 0x3a, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* :ABCDEFG */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* HIJKLMNO */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* PQRSTUVW */ 0x58, 0x59, 0x5a, 0x7e, 0x3a, 0x61, 0x62, 0x63, /* XYZ~:abc */ 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */ 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */ 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x23, /* tuvwxyz# */ 0 }; static const uint8_t bf_cbc_ptxt[SECSIZE] = " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop" " abcdefghijklmnop"; /* * IV method encblkno1, blkno 0. */ static const uint8_t bf_cbc_128_encblkno1_vec0_ctxt[SECSIZE] = { 0x78, 0x53, 0x43, 0x2a, 0x08, 0xe7, 0x84, 0x3f, 0xb7, 0x61, 0x9c, 0x17, 0x81, 0xbe, 0x38, 0xb9, 0x65, 0x51, 0x68, 0xa2, 0x29, 0xd7, 0x45, 0xc9, 0xee, 0x0e, 0x9d, 0xe1, 0x69, 0xc6, 0x81, 0x81, 0xf3, 0x93, 0xa6, 0x62, 0xc9, 0x05, 0x2c, 0x1b, 0x0e, 0x05, 0xca, 0xbe, 0x12, 0x25, 0x37, 0xd8, 0x98, 0x66, 0xa2, 0xd3, 0xd0, 0x8a, 0x89, 0x57, 0x44, 0x91, 0x1e, 0xe9, 0x07, 0x03, 0x5c, 0xa6, 0xb8, 0x30, 0xf1, 0xc7, 0x8c, 0x66, 0x05, 0xb0, 0x2d, 0xc3, 0xc3, 0xd7, 0x60, 0xef, 0x62, 0xd3, 0x34, 0x9c, 0xa9, 0xd2, 0x0c, 0x1a, 0x9c, 0xfe, 0x74, 0x92, 0xcb, 0x90, 0x80, 0xfa, 0x71, 0x5c, 0xaa, 0x29, 0x39, 0xdd, 0x3b, 0x62, 0xa1, 0xfc, 0xa5, 0x35, 0xcd, 0xa3, 0x29, 0x41, 0x1a, 0x03, 0xf7, 0xe1, 0x36, 0xb2, 0xdc, 0x1a, 0xb3, 0x9f, 0x46, 0xa3, 0xf7, 0xc3, 0xd1, 0x29, 0x83, 0xcf, 0x0d, 0x88, 0x0b, 0xd1, 0xb7, 0xc7, 0x87, 0x21, 0xb7, 0x1f, 0xe7, 0xa2, 0x8e, 0x5f, 0xac, 0x6b, 0x49, 0x9c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, blkno 1. */ static const uint8_t bf_cbc_128_encblkno1_vec1_ctxt[SECSIZE] = { 0x87, 0xae, 0x01, 0x52, 0xe8, 0xe9, 0xd9, 0xba, 0xa9, 0x18, 0x31, 0x2c, 0x1b, 0xab, 0x57, 0xad, 0x45, 0x0e, 0x25, 0x5e, 0x0e, 0x04, 0xfa, 0xdd, 0xf1, 0x59, 0xe6, 0xea, 0x78, 0x4b, 0x83, 0x07, 0x8b, 0x46, 0x91, 0x09, 0x58, 0x5a, 0x11, 0x2e, 0x54, 0x43, 0xa4, 0xc1, 0x04, 0x35, 0xd3, 0x3e, 0xc9, 0xc8, 0xf5, 0xff, 0x69, 0x1e, 0x57, 0x85, 0x6d, 0x91, 0x03, 0xeb, 0x8c, 0xa7, 0xe8, 0xcc, 0x3f, 0xac, 0xf9, 0x14, 0x1e, 0x88, 0x50, 0xa5, 0x38, 0x66, 0xa9, 0xf4, 0xf5, 0xc6, 0x30, 0x95, 0xd6, 0x84, 0x0b, 0x81, 0xf9, 0x51, 0x05, 0x80, 0x9a, 0x89, 0xbf, 0xd4, 0x7d, 0x6a, 0x26, 0x59, 0x29, 0x44, 0xe7, 0x1d, 0x0e, 0xad, 0x8c, 0xa0, 0x93, 0xe9, 0x4b, 0x4b, 0x51, 0x46, 0xa5, 0x07, 0xe8, 0xcb, 0x59, 0xf4, 0x63, 0xb5, 0x36, 0xdb, 0xbc, 0x54, 0x2d, 0xec, 0xf0, 0x90, 0x3a, 0xa5, 0xed, 0xc8, 0x28, 0x0e, 0xd3, 0x79, 0xb8, 0x57, 0xc6, 0x7f, 0x02, 0x22, 0x5e, 0x80, 0xe8, 0x7f, 0xdf, 0xa0, 0x0f, 0xbc, 0x98, 0x79, 0x6f, 0xd2, 0xb0, 0xb2, 0x4f, 0x9b, 0x1a, 0x21, 0x8f, 0x63, 0xce, 0x54, 0x41, 0x64, 0xbf, 0xb9, 0xa7, 0x93, 0xd6, 0x5b, 0x89, 0x86, 0xda, 0x90, 0x23, 0x2e, 0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0x03, 0xea, 0x5b, 0xba, 0x6a, 0xac, 0x23, 0x5a, 0x5e, 0x31, 0x08, 0x29, 0x69, 0x64, 0x44, 0x1c, 0x31, 0xae, 0xb1, 0x86, 0x7b, 0x26, 0x89, 0xa6, 0xbe, 0xef, 0x69, 0x81, 0xf7, 0x77, 0xd5, 0x8e, 0x78, 0xa5, 0x11, 0x51, 0xca, 0xec, 0xd0, 0x86, 0xa5, 0x33, 0xf3, 0x65, 0x5d, 0x04, 0xc5, 0xd2, 0x17, 0x2a, 0xfe, 0x4a, 0x58, 0x0f, 0x98, 0x61, 0xad, 0xc3, 0xb8, 0x5b, 0x45, 0xcc, 0x28, 0x3d, 0x4d, 0x00, 0xf5, 0x4a, 0xe2, 0xbc, 0x6c, 0x1b, 0x80, 0x7a, 0x2b, 0x40, 0xb8, 0x34, 0x0e, 0x44, 0x53, 0x16, 0xda, 0x7c, 0x46, 0x8b, 0x42, 0x5e, 0xa8, 0xe1, 0xb8, 0xf8, 0xcf, 0xff, 0x48, 0xcf, 0x2c, 0x4c, 0x98, 0xdb, 0xe5, 0x55, 0xfe, 0x45, 0xfa, 0xf8, 0xde, 0x72, 0xf9, 0x84, 0x3c, 0xc0, 0x0c, 0x1f, 0x86, 0x97, 0x86, 0xb8, 0xfe, 0x7d, 0xff, 0xa3, 0xaf, 0x68, 0x00, 0x66, 0x90, 0xac, 0xb5, 0xd8, 0xde, 0x35, 0x01, 0xf7, 0xab, 0xab, 0xe3, 0xe9, 0x85, 0x4c, 0x6f, 0xe6, 0xbc, 0xce, 0x67, 0x4a, 0xbd, 0xad, 0x7b, 0xec, 0xa1, }; /* * IV method encblkno1, blkno 2. */ static const uint8_t bf_cbc_128_encblkno1_vec2_ctxt[SECSIZE] = { 0x17, 0xdd, 0x0f, 0x4b, 0x28, 0x33, 0x03, 0x89, 0x21, 0x7b, 0x67, 0x15, 0x15, 0x65, 0x08, 0x4f, 0x65, 0x18, 0xa6, 0x4b, 0x62, 0xdb, 0x1e, 0xc2,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, 0x01, 0x57, 0xc4, 0x1d, 0x95, 0x5e, 0xe3, 0xb7, 0x15, 0xde, 0xa7, 0xb5, 0x1a, 0x4e, 0x78, 0x44, 0x5b, 0x9a, 0xee, 0x29, 0xe2, 0x22, 0x8b, 0xe9, 0xe3, 0xe6, 0x70, 0x3e, 0xcb, 0x9f, 0x7f, 0xc3, 0xd0, 0x2c, 0xdc, 0x55, 0xb4, 0x0d, 0x67, 0xf5, 0xd8, 0xff, 0xbb, 0xb1, 0x02, 0xbf, 0xf6, 0x33, 0x4e, 0x7a, 0x3a, 0x50, 0xb1, 0x01, 0x77, 0x51, 0xef, 0xb5, 0x75, 0xb3, 0x66, 0xe8, 0xe6, 0xd6, 0x53, 0x7d, 0x33, 0x51, 0x62, 0x5d, 0xf2, 0x77, 0x02, 0x34, 0x42, 0xda, 0xee, 0xd9, 0xee, 0x0b, 0x4d, 0x71, 0x5c, 0xc0, 0xec, 0xdd, 0xc0, 0x34, 0x6f, 0xf4, 0x65, 0x32, 0xde, 0xc5, 0xb2, 0x97, 0x60, 0x89, 0x4e, 0x3b, 0x0c, 0xf2, 0xa7, 0x74, 0x61, 0xd7, 0xe4, 0xa6, 0x80, 0x78, 0x76, 0xe5, 0x7d, 0xab, 0x96, 0x04, 0x00, 0x76, 0x22, }; /* * IV method encblkno1, blkno 3. */ static const uint8_t bf_cbc_128_encblkno1_vec3_ctxt[SECSIZE] = { 0xdd, 0x8e, 0xce, 0x5b, 0xb8, 0x2a, 0xc8, 0x0e, 0xd2, 0xbe, 0xcf, 0xa7, 0x2a, 0x5b, 0x0c, 0x1a, 0xb2, 0x68, 0x5b, 0xe7, 0x53, 0xaf, 0xce, 0x56, 0xfd, 0xbd, 0x73, 0x3c, 0x44, 0x02, 0x96, 0x57, 0xaa, 0x47, 0x8d, 0xf1, 0x28, 0x59, 0xb6, 0xce, 0xba, 0x1e, 0xc9, 0x78, 0x76, 0xdd, 0x43, 0x3a, 0xbc, 0x43, 0x4c, 0x17, 0xd2, 0x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0x4d, 0x1b, 0x64, 0x49, 0x23, 0x47, 0x30, 0x29, 0x25, 0xb2, 0xc9, 0xaf, 0xcd, 0xae, 0x56, 0x43, 0x28, 0xcf, 0x81, 0x95, 0xa7, 0x3e, 0x51, 0x5b, 0x3b, 0xf7, 0x87, 0x13, 0xc6, 0xee, 0x50, 0x2f, 0x78, 0xdd, 0xcf, 0x63, 0xef, 0x15, 0xb9, 0x4f, 0x21, 0x27, 0x5e, 0x94, 0x78, 0xad, 0xcd, 0x9b, 0x3d, 0xf2, 0xdb, 0xed, 0xf2, 0xa2, 0x39, 0xca, 0xa3, 0xa8, 0x2e, 0x68, 0xd5, 0xc3, 0xcf, 0x71, 0xec, 0x92, 0xdc, 0xce, 0xe7, 0x7d, 0x2b, 0xf7, 0xbc, 0xe9, 0x2b, 0x2e, 0xae, 0xaf, 0x0b, 0x92, 0x72, 0xac, 0x6e, 0x49, 0xe1, 0xb3, 0x1f, 0xe5, 0x43, 0x2f, 0xa7, }; const struct testvec bf_cbc_128_1_vectors[] = { { .blkno = 0, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_128_encblkno1_vec0_ctxt, }, { .blkno = 1, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_128_encblkno1_vec1_ctxt, }, { .blkno = 2, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_128_encblkno1_vec2_ctxt, }, { .blkno = 3, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_128_encblkno1_vec3_ctxt, }, }; /* * IV method encblkno8, blkno 0. */ static const uint8_t bf_cbc_128_encblkno8_vec0_ctxt[SECSIZE] = { 0xb8, 0x65, 0x67, 0x8e, 0xe4, 0xd8, 0xb4, 0x93, 0xa5, 0xbb, 0x13, 0x92, 0x27, 0x4b, 0xdd, 0xeb, 0x0d, 0xad, 0x80, 0x6a, 0x57, 0x37, 0xc0, 0x23, 0x23, 0xbf, 0xed, 0x86, 0x0c, 0x18, 0x48, 0x19, 0xcd, 0x84, 0x66, 0xa7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x10, 0xd7, 0xab, 0x64, 0xce, 0x22, 0x8b, 0x52, 0x76, 0xa1, 0xa1, 0x8b, 0x1e, 0xb2, 0x18, 0x29, 0x8f, 0xc5, 0x24, 0x39, 0xd4, 0xf8, 0x75, 0x1e, 0x30, 0x57, 0x12, 0x01, 0x04, 0x78, 0x68, 0x97, 0xa8, 0x65, 0x8c, 0xac, 0xb4, 0x3b, 0x37, 0x45, 0x41, 0xbc, 0x7d, 0x4b, 0x09, 0xd7, 0x46, 0x40, 0x99, 0x59, 0xa1, 0xb5, 0x9e, 0x84, 0x24, 0x6d, 0xfb, 0x74, 0x22, 0xac, 0x4e, 0x5f, 0x11, 0xd3, 0xa7, 0x9f, 0xa5, 0xca, 0x38, 0x54, 0xe2, 0x65, 0x52, 0x02, 0x69, 0xe9, 0xa8, 0xf1, 0xd7, 0x9d, 0x9a, 0x17, 0x54, 0xa0, 0xda, 0xbb, 0x37, 0xb4, 0x0c, 0xb6, 0x00, 0xad, 0x6f, 0x88, 0x84, 0xa7, 0x69, 0xd7, 0x0b, 0xbe, 0xb4, 0xbe, 0x96, 0xbc, 0xcd, 0x08, 0xf1, 0x28, 0xe0, 0x6f, }; /* * IV method encblkno8, blkno 1. */ static const uint8_t bf_cbc_128_encblkno8_vec1_ctxt[SECSIZE] = { 0x7d, 0x95, 0x5a, 0x66, 0x23, 0x98, 0xa8, 0xbe, 0x53, 0x63, 0x0d, 0x46, 0x4e, 0x38, 0x1b, 0x1d, 0x36, 0xdd, 0x2a, 0x57, 0x3c, 0x17, 0x01, 0xba, 0x4e, 0xf8, 0xaa, 0x22, 0x74, 0x05, 0xa2, 0x40, 0xd0, 0x30, 0x61, 0x6c, 0x65, 0x5e, 0xfb, 0x21, 0x63, 0xef, 0x62, 0x01, 0x74, 0x15, 0xf6, 0x87, 0x92, 0xc1, 0x4e, 0x46, 0xdd, 0x76, 0xdb, 0x8b, 0x20, 0x44, 0xc4, 0xfa, 0x7c, 0xd2, 0x07, 0x32, 0x11, 0xeb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0xeb, 0x4e, 0x53, 0x57, 0x65, 0xe5, 0x43, 0xe8, 0xb4, 0xb6, 0xb8, 0x25, 0x8a, 0xe2, 0xb3, 0x99, 0x95, 0x2c, 0xd0, 0xc7, 0x89, 0xad, 0xdb, 0x72, 0xf0, 0x83, 0xe3, 0x2f, 0x30, 0x33, 0xf4, 0x03, 0x14, 0x86, 0xa0, 0xe0, 0x57, 0x15, 0x53, 0x26, 0xd0, 0x6d, 0x12, 0x51, 0x96, 0x9b, 0x00, 0x8e, 0x41, 0xea, 0x05, 0x75, 0x5d, 0xb3, 0x8d, 0x44, 0x7f, 0x41, 0x7f, 0xd1, 0xed, 0x7c, 0xf7, 0xac, 0x6b, 0x21, 0xc7, 0x0c, 0x49, 0xa1, 0x2e, 0x57, 0xa1, 0x21, 0xe2, }; /* * IV method encblkno8, blkno 2. */ static const uint8_t bf_cbc_128_encblkno8_vec2_ctxt[SECSIZE] = { 0x28, 0x0c, 0x49, 0x08, 0x84, 0xcb, 0xba, 0x4a, 0xa5, 0xb6, 0x12, 0x4c, 0x14, 0x11, 0x1f, 0x88, 0x57, 0x78, 0x1e, 0x51, 0x7c, 0x9d, 0xba, 0x31, 0x80, 0x14, 0xeb, 0x4a, 0x98, 0x8a, 0xb5, 0x4d, 0xc5, 0xbd, 0xd2, 0x48, 0x1e, 0x19, 0x43, 0x54, 0x48, 0x1d, 0x24, 0x76, 0x7d, 0xd8, 0xcc, 0xe9, 0xd9, 0x7b, 0xa9, 0xdf, 0xe3, 0x65, 0x85, 0x10, 0xb8, 0x11, 0xce, 0xa3, 0x07, 0x4d, 0x87, 0x3f, 0x95, 0xfb, 0xa5, 0x06, 0xa4, 0x37, 0xb0, 0x89, 0x03, 0xa9, 0xef, 0x62, 0x98, 0xd3, 0x85, 0xe8, 0xb3, 0x21, 0xab, 0xe9, 0xdc, 0x03, 0x2a, 0x20, 0xf7, 0xb1, 0xa4, 0x7a, 0xd5, 0xdc, 0x61, 0x2e, 0x15, 0x81, 0x3e, 0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x2e, 0x81, 0x02, 0x0d, 0x17, 0x66, 0x6f, 0x04, 0xe0, 0x1e, 0x03, 0x27, 0xd3, 0xcf, 0x45, 0xc6, 0x08, 0xdb, 0xdf, 0x83, 0xd5, 0xc2, 0x7f, 0xe8, 0x5f, 0x4a, 0x36, 0x0a, 0x6d, 0x3c, 0x91, 0x8e, 0x52, 0xf3, 0xdd, 0x62, 0xff, 0x78, 0x87, 0xd9, 0x4c, 0xad, 0x5c, 0x9f, }; /* * IV method encblkno8, blkno 3. */ static const uint8_t bf_cbc_128_encblkno8_vec3_ctxt[SECSIZE] = { 0xa3, 0x9a, 0x21, 0xbd, 0x1c, 0x97, 0x4f, 0xe2, 0x7d, 0x63, 0xfe, 0x52, 0x07, 0xac, 0x81, 0x75, 0x15, 0x04, 0x8c, 0xc7, 0x7c, 0x11, 0x8d, 0x53, 0x17, 0x87, 0xe8, 0x5d, 0xb1, 0xe8, 0xcb, 0x43, 0xe2, 0x4b, 0xce, 0x9b, 0xf7, 0x51, 0x0a, 0xee, 0x0a, 0x49, 0xae, 0x9a, 0xbd, 0x33, 0x3f, 0x0b, 0xd4, 0xe8, 0x57, 0x77, 0xb1, 0xe1, 0xa5, 0x22, 0x83, 0xbf, 0x7c, 0x63, 0x6c, 0x3b, 0x25, 0xde, 0x2c, 0x6a, 0x28, 0x66, 0x0e, 0xc4, 0x8d, 0x66, 0x66, 0xb6, 0xc6, 0xb5, 0x38, 0x40, 0x84, 0x81, 0xec, 0x03, 0xdb, 0xbf, 0xe1, 0x8f, 0xf4, 0xb3, 0xc4, 0x50, 0x24, 0xa2, 0x48, 0x66, 0x73, 0xed, 0x4b, 0x00, 0x12, 0xd5, 0x15, 0x5f, 0xfb, 0xd9, 0x6c, 0x76, 0x3b, 0xa2, 0x68, 0x41, 0xc1, 0x96, 0x50, 0xff, 0x8a, 0x83, 0xac, 0x02, 0x42, 0xcb, 0xed, 0x93, 0xbf, 0xd9, 0x51, 0x46, 0x50, 0xd1, 0xeb, 0x02, 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b, 0xec, 0x2c, 0x2e, 0x2e, 0x74, 0xed, 0xfc, 0x85, 0x53, 0x01, 0x87, 0xa7, 0xa0, 0x1f, }; const struct testvec bf_cbc_128_8_vectors[] = { { .blkno = 0, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_128_encblkno8_vec0_ctxt, }, { .blkno = 1, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_128_encblkno8_vec1_ctxt, }, { .blkno = 2, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_128_encblkno8_vec2_ctxt, }, { .blkno = 3, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_128_encblkno8_vec3_ctxt, }, }; /* * IV method encblkno1, blkno 0. */ static const uint8_t bf_cbc_256_encblkno1_vec0_ctxt[SECSIZE] = { 0x14, 0xec, 0xa9, 0xa0, 0x51, 0x9f, 0x5e, 0xb5, 0x81, 0x6f, 0xa2, 0xbf, 0x5e, 0xf7, 0x91, 0xad, 0xc5, 0x1a, 0x7e, 0xe6, 0x7a, 0x82, 0x4a, 0xba, 0x54, 0x60, 0xcb, 0xc3, 0x2f, 0x69, 0x5c, 0xd9, 0x1e, 0x58, 0xa1, 0x88, 0xa1, 0xe5, 0xa8, 0x52, 0xdf, 0xf3, 0x8d, 0x5e, 0x2f, 0x81, 0x54, 0xab, 0x67, 0xb5, 0x05, 0x63, 0x20, 0x10, 0x98, 0xf5, 0xa5, 0xc3, 0x9e, 0x6d, 0x80, 0x4d, 0xb6, 0x82, 0x80, 0x5e, 0xb3, 0xc5, 0xd8, 0x77, 0x94, 0xa0, 0xb8, 0x67, 0xb8, 0x2d, 0x9b, 0x11, 0x3c, 0x24, 0xbd, 0xb7, 0x0b, 0x1d, 0xeb, 0x1d, 0x6c, 0xab, 0x3f, 0x8c, 0x91, 0xa0, 0x3a, 0xa6, 0x0c, 0x5a, 0x88, 0xa0, 0xb5, 0xea, 0x49, 0x58, 0xfb, 0x37, 0x7c, 0x94, 0xc4, 0x22, 0x35, 0x84, 0x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a, 0x73, 0x2f, 0x1c, 0xd8, 0x13, 0x4a, 0xd1, 0x78, 0xb2, 0xc8, 0x19, 0x09, 0xce, 0x7b, 0xb6, 0x77, 0xcc, 0xc3, 0xe6, 0xee, 0x3a, 0x82, 0xf9, 0xc6, 0x5a, 0x36, 0x46, 0xc0, 0x25, 0xee, 0xaf, 0x78, }; /* * IV method encblkno1, blkno 1. */ static const uint8_t bf_cbc_256_encblkno1_vec1_ctxt[SECSIZE] = { 0x0b, 0xb6, 0x26, 0x92, 0x1d, 0x74, 0xc2, 0x10, 0xb5, 0x99, 0x5f, 0x62, 0x7f, 0x3b, 0x49, 0x10, 0xc1, 0x20, 0x9f, 0x38, 0x25, 0x0f, 0x59, 0xde, 0xe4, 0xc8, 0xb5, 0x27, 0xb1, 0xec, 0x96, 0x40, 0xe8, 0x05, 0x15, 0x40, 0x96, 0xe0, 0xff, 0xaf, 0x53, 0x73, 0xa1, 0xa6, 0x73, 0x03, 0xcf, 0x1f, 0x87, 0x48, 0x7d, 0x81, 0x0e, 0x35, 0x23, 0x7b, 0xde, 0x12, 0xd8, 0xcd, 0x0a, 0xcb, 0x03, 0xc5, 0x07, 0xf7, 0x7a, 0x04, 0xf3, 0xda, 0x7d, 0x3b, 0x73, 0xc6, 0x31, 0xbc, 0x24, 0xde, 0x23, 0x05, 0x3a, 0xdc, 0xe2, 0x96, 0x85, 0x06, 0xeb, 0x89, 0xb0, 0x49, 0x3c, 0x79, 0x8e, 0xcf, 0x49, 0x0e, 0x34, 0x04, 0xa5, 0xcf, 0x45, 0x56, 0xb6, 0xc2, 0xf1, 0xf1, 0xab, 0x7c, 0x8a, 0xfc, 0xeb, 0xa0, 0x8a, 0xe6, 0x73, 0xb4, 0xc3, 0x0c, 0x03, 0x5f, 0x03, 0x53, 0x6f, 0x69, 0xa2, 0xd0, 0xa7, 0x48, 0xc4, 0x11, 0x88, 0x75, 0xe1, 0xf3, 0xd0, 0x72, 0x98, 0x6f, 0x84, 0xa6, 0xa8, 0x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0x75, }; /* * IV method encblkno1, blkno 2. */ static const uint8_t bf_cbc_256_encblkno1_vec2_ctxt[SECSIZE] = { 0x91, 0x45, 0x4e, 0xe8, 0xad, 0xe3, 0x95, 0x0f, 0x40, 0x35, 0x21, 0x21, 0x77, 0x62, 0x1d, 0x65, 0xe4, 0x93, 0x11, 0xd2, 0x20, 0xa4, 0xe4, 0x53, 0x44, 0xff, 0x60, 0xe9, 0x34, 0xb2, 0x33, 0x87, 0x3d, 0xb0, 0xd8, 0x37, 0x7e, 0x0e, 0x9a, 0x53, 0x92, 0xeb, 0xee, 0x16, 0x41, 0x25, 0xe3, 0x80, 0x0c, 0x53, 0xd8, 0x1f, 0xf0, 0x99, 0xcb, 0x31, 0xd1, 0x00, 0x82, 0x03, 0xcc, 0xa9, 0x5c, 0x8d, 0x1a, 0xbb, 0x03, 0x81, 0x80, 0x0d, 0x5d, 0x4a, 0x96, 0x74, 0x79, 0xf4, 0xa7, 0x46, 0x97, 0x42, 0x5e, 0xb6, 0x8d, 0xc1, 0x95, 0x1d, 0x98, 0x4d, 0xe5, 0xe9, 0x70, 0x1a, 0x5a, 0xad, 0xf4, 0x3d, 0xe1, 0xa7, 0x25, 0xc7, 0xfa, 0x0a, 0x75, 0x98, 0x2f, 0xef, 0x16, 0x2e, 0xf2, 0x02, 0x8a, 0x4c, 0x1f, 0x5a, 0xbb, 0x06, 0x1b, 0x4e, 0x50, 0xfb, 0x03, 0xed, 0x2a, 0x53, 0xdc, 0x2a, 0x65, 0xad, 0x57, 0x84, 0x48, 0xdb, 0xd2, 0x9b, 0xc0, 0x01, 0x5f, 0x7d, 0x3e, 0x84, 0xe5, 0x15, 0x7d, 0xc5, 0x60, 0x4b, 0x18, 0xa1, 0xf3, 0x00, 0x82, 0xd3, 0x39, 0x2a, 0x1f, 0x8f, 0x6a, 0xb7, 0xeb, 0x76, 0xfb, 0xf0, 0x5e, 0x66, 0xd8, 0xf1, 0x85, 0xa8, 0x17, 0xdc, 0x6a, 0xee, 0x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d0, 0xe1, 0x8e, 0xfb, 0x28, 0xc5, 0xa2, 0x42, 0xed, 0x4c, 0x12, 0x15, 0x2a, 0x08, 0xfb, 0x0b, 0xfb, 0x94, 0x64, 0xc0, 0x8b, 0xbb, 0xbb, 0x2c, 0xef, 0xab, 0x0b, 0x4c, 0x27, 0x40, 0x94, 0x3e, 0x93, 0x77, 0x98, 0xcc, 0x64, 0xe3, 0xba, 0x22, 0x95, 0xd7, 0xc1, 0xe3, 0xa7, 0xcd, 0xf9, 0x25, 0xdc, 0xc4, 0xd2, 0xee, 0x5b, 0x53, 0x72, 0x59, 0x8b, 0xea, 0xbf, 0xde, 0x2b, 0x35, 0xd5, 0x27, 0x57, 0x2e, 0x13, 0xa7, 0x50, 0x2d, 0xa5, 0xd5, 0x43, 0x0b, 0x49, 0x87, 0xd0, 0xbd, 0xdd, 0xec, 0x4b, 0xd1, 0x8b, 0xf6, 0xf6, 0xd0, 0x97, 0xcb, 0x8d, 0x58, 0x35, 0x27, 0xa5, 0x7e, 0x4a, 0xda, 0x93, 0xa4, 0x1e, 0x39, 0x53, 0x59, 0x87, 0xfe, 0x82, 0x09, 0xda, 0x03, 0x33, 0xcf, 0x94, 0x60, 0xb1, 0x0c, 0xa1, 0x0e, 0xd6, 0xaa, 0xb0, 0x09, 0x96, 0x8b, 0x72, 0x15, 0xfb, 0xb0, 0x7d, 0x06, 0xf5, 0x2d, 0x64, 0xcd, 0x03, 0xf0, 0xfa, 0xed, 0x6f, 0x43, 0xe3, 0xf3, 0x33, 0xaf, 0x65, 0x82, 0x1d, 0xad, 0x03, 0x62, 0xbe, 0x12, 0x14, 0x85, 0x66, 0x45, 0x03, 0x79, }; /* * IV method encblkno1, blkno 3. */ static const uint8_t bf_cbc_256_encblkno1_vec3_ctxt[SECSIZE] = { 0x65, 0xbb, 0x30, 0x13, 0x9a, 0x26, 0xe9, 0x3d, 0x54, 0x28, 0x77, 0xf1, 0x3f, 0x9b, 0xe1, 0x3e, 0x70, 0x90, 0x6f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2, 0x71, 0xcc, 0x07, 0xae, 0x67, 0x00, 0xa8, 0xd4, 0x09, 0x7c, 0xee, 0x0d, 0x29, 0x17, 0x67, 0x96, 0x68, 0x41, 0xfa, 0x72, 0x29, 0x98, 0x2b, 0x23, 0xd1, 0xa9, 0x89, 0x1c, 0xcc, 0xaf, 0x88, 0xdb, 0xb5, 0x1e, 0xb1, 0xae, 0x17, 0x5f, 0x29, 0x8d, 0x1c, 0x0a, 0x5c, 0xb9, 0xa7, 0x59, 0x8b, 0x91, 0x41, 0xee, 0x89, 0xe1, 0x0e, 0x7e, 0x0a, 0xee, 0xbc, 0x35, 0xab, 0xf1, 0x5a, 0x58, 0x03, 0xa2, 0xcf, 0x33, 0xa3, 0x74, 0x82, 0xd3, 0xa0, 0x32, 0xfc, 0x3b, 0x9c, 0xdf, 0xc0, 0x3a, 0x76, 0xe1, 0xea, 0xf0, 0x6d, 0xc8, 0xe7, 0x97, 0xec, 0x03, 0xc1, 0x72, 0x94, 0xe5, 0xc4, 0x04, 0x2a, 0x38, 0xb4, 0xef, 0x47, 0x1d, 0xf9, 0xb8, 0x0a, 0xa9, 0x45, 0xc1, 0x63, 0xf8, 0x32, 0xdb, 0x5d, 0xb1, 0xa2, 0x80, 0x8c, 0x23, 0xd3, 0x60, 0xfb, 0xf8, 0x84, 0x57, 0x8b, }; const struct testvec bf_cbc_256_1_vectors[] = { { .blkno = 0, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_256_encblkno1_vec0_ctxt, }, { .blkno = 1, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_256_encblkno1_vec1_ctxt, }, { .blkno = 2, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_256_encblkno1_vec2_ctxt, }, { .blkno = 3, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_256_encblkno1_vec3_ctxt, }, }; /* * IV method encblkno8, blkno 0. */ static const uint8_t bf_cbc_256_encblkno8_vec0_ctxt[SECSIZE] = { 0x90, 0x3d, 0xd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, 0xa6, 0x22, 0x25, 0x79, 0x07, 0xe5, 0x3e, 0x49, 0x6b, 0x12, 0x9e, 0xfc, 0x91, 0xdb, 0xf3, 0x7c, 0xdf, 0x03, 0x9c, 0x78, 0xa7, 0xc3, 0x5e, 0x14, 0xde, 0xb5, 0x6a, 0x7b, 0x3b, 0xe3, 0x4f, 0x8a, 0x49, 0xce, 0xc9, 0x14, 0x29, 0x96, 0x84, 0xca, 0xe1, 0x49, 0x41, 0x73, 0xb3, 0x2a, 0xbe, 0x37, 0xb6, 0x2d, 0xff, 0xf2, 0x8e, 0x3d, 0x02, 0xeb, 0xd4, 0xd3, 0x15, 0x8f, 0xc0, 0x00, 0x91, 0xd5, 0xe7, 0x76, 0xf5, 0x6e, 0x81, 0x38, 0x38, 0x07, 0xa6, 0xe8, 0x72, 0x14, 0x3b, 0x36, 0xef, 0xbc, 0x5b, 0x26, 0xb0, 0x60, 0x25, 0x49, 0x7e, 0xfc, 0xd8, 0x3b, 0x63, 0xdc, 0x7f, 0x80, 0xd5, 0x43, 0x78, 0xbb, 0xf1, 0xf9, 0x3e, 0x75, 0x1d, 0x58, 0xb2, 0xc7, 0xb6, 0x52, 0xfb, 0xe7, 0x42, 0xef, 0x87, 0xfd, 0x3a, 0x02, 0x7a, 0xf9, 0xbc, 0xa8, 0x2f, 0xd6, 0xc1, 0x5f, 0xa4, 0x57, 0x62, 0x83, 0x82, 0x8e, 0x1e, 0xbb, 0x85, 0xf7, 0x1b, 0x2e, 0xe2, 0xb0, }; /* * IV method encblkno8, blkno 1. */ static const uint8_t bf_cbc_256_encblkno8_vec1_ctxt[SECSIZE] = { 0x2b, 0xf6, 0xd4, 0x61, 0x3b, 0x1f, 0x5b, 0xe9, 0x32, 0xab, 0x27, 0xa1, 0xaf, 0x5e, 0xf4, 0xa7, 0xaa, 0xc5, 0x2a, 0x3c, 0x0d, 0x34, 0xd8, 0xb3, 0xfd, 0xb2, 0xca, 0xfb, 0x3c, 0x38, 0x96, 0x71, 0x47, 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, 0x35, 0x41, 0x16, 0x0c, 0x4e, 0x73, 0x90, 0x52, 0xc5, 0x65, 0xb8, 0x0c, 0xdc, 0x36, 0x8d, 0xdc, 0xca, 0x97, 0x0b, 0xbc, 0xcb, 0x79, 0xc7, 0x4c, 0xd2, 0x21, 0x5c, 0xbd, 0xeb, 0xea, 0xfb, 0x87, 0xe1, 0xe0, 0x75, 0x39, 0xb9, 0x84, 0x1e, 0xa7, 0xfe, 0x7d, 0x41, 0x75, 0x15, 0x88, 0x98, 0xd4, 0x80, 0x42, 0x57, 0xb5, 0x65, 0xbf, 0xb8, 0xbd, 0x19, 0x28, 0xd8, 0xa7, 0x6c, 0xe7, 0xc1, 0x00, 0xdc, 0xde, 0xcb, 0x30, 0x3d, 0x29, 0x5e, 0xa6, 0x9c, 0xbb, 0xb8, 0xec, 0x28, 0x23, 0x36, 0x23, 0x27, 0xee, 0xdd, 0x24, 0x7d, 0x9a, 0xc9, 0xb5, 0x3c, 0x7a, 0x3f, 0x1d, 0xd9, 0x32, 0x47, 0xc0, 0x4d, 0x86, 0x9b, 0x2d, 0xa9, 0x5c, 0x93, 0x90, 0x51, 0x70, 0xe6, 0x8f, 0x35, 0x96, 0xe0, 0x11, 0x00, }; /* * IV method encblkno8, blkno 2. */ static const uint8_t bf_cbc_256_encblkno8_vec2_ctxt[SECSIZE] = { 0x28, 0x93, 0x0f, 0x23, 0xfb, 0xa4, 0x9e, 0xe5, 0x11, 0x38, 0x2b, 0xbd, 0x8d, 0x2d, 0xdb, 0x11, 0xfa, 0xac, 0x74, 0x28, 0x95, 0x29, 0xf2, 0x92, 0x8d, 0x00, 0x8a, 0x8a, 0x04, 0x92, 0x92, 0x33, 0x8c, 0x4b, 0x29, 0x8e, 0xde, 0x59, 0xf4, 0x72, 0xae, 0x2f, 0xe4, 0xe9, 0xd4, 0xe4, 0xb6, 0x69, 0xc5, 0x1b, 0xbe, 0x02, 0x85, 0x4b, 0x24, 0x1e, 0x79, 0xb9, 0x22, 0x29, 0x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 0xd0, 0x4d, 0xe6, 0xd6, 0x0e, 0x2d, 0x77, 0xa3, 0xb3, 0x27, 0xda, 0x99, 0x62, 0x88, 0x35, 0xba, 0x64, 0x15, 0xec, 0xaf, 0x70, 0x97, 0x94, 0x81, 0x30, 0x6d, 0x63, 0x42, 0x71, 0x3e, 0x06, 0xec, 0x50, 0x96, 0x87, 0x59, 0xe7, 0x26, 0x9c, 0xcf, 0xc7, 0xe7, 0x62, 0x82, 0x3b, 0xd7, 0xfe, 0xb4, 0x48, 0x45, 0x9d, 0x54, 0x18, 0x15, 0x13, 0x74, 0x92, 0x6f, 0x43, 0xb3, 0xa9, 0x82, 0xd4, 0xc2, 0xef, 0x61, 0x9d, 0x5e, 0x1d, 0xc6, 0x80, 0xd3, 0xe9, 0xdd, 0x52, 0x9c, 0x4d, 0x04, 0x05, 0xa0, 0x43, 0x36, 0xb6, 0x89, }; /* * IV method encblkno8, blkno 3. */ static const uint8_t bf_cbc_256_encblkno8_vec3_ctxt[SECSIZE] = { 0x60, 0x91, 0x19, 0x89, 0xee, 0xac, 0x12, 0xe5, 0x60, 0x6c, 0xfd, 0xf9, 0xe4, 0xc6, 0xc9, 0xbd, 0x75, 0xe1, 0xa5, 0xe6, 0xf4, 0xed, 0x4b, 0xf4, 0x16, 0xf4, 0x57, 0xa4, 0xe6, 0x60, 0x8e, 0x1b, 0x97, 0x0e, 0xd5, 0x09, 0xa1, 0x3c, 0x6c, 0xe8, 0x91, 0xaf, 0x19, 0x96, 0x2a, 0x7b, 0x77, 0x30, 0xc7, 0x99, 0xe6, 0xaa, 0xb0, 0xe2, 0x29, 0x1c, 0x39, 0x54, 0x1c, 0x0a, 0x4a, 0x51, 0xa2, 0xa2, 0x22, 0x96, 0x05, 0x8b, 0x12, 0x80, 0x16, 0x28, 0xdc, 0xfa, 0x22, 0x90, 0xa4, 0x33, 0xb1, 0x84, 0x13, 0x52, 0x5d, 0xb5, 0xd4, 0xe8, 0x60, 0x18, 0x6a, 0xb8, 0x1b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, 0xc7, 0xe0, 0x1e, 0x8e, 0xec, 0x16, 0x2b, 0xeb, 0xff, 0xaa, 0xba, 0x83, 0x1f, 0xdc, 0x32, 0x23, 0x27, 0xea, 0xea, 0x0c, 0x3a, 0x5f, 0x2b, 0xb4, 0xee, 0x0c, 0xf2, 0x73, 0xbb, 0x59, 0x9b, 0x73, 0xf7, 0xfa, 0xe1, 0x1f, 0x3b, 0xdb, 0x40, 0x29, 0xf0, 0x6c, 0xbe, 0x8f, 0x2e, 0xd0, 0x83, 0xf7, 0xe8, 0x2a, 0x81, 0x82, }; const struct testvec bf_cbc_256_8_vectors[] = { { .blkno = 0, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_256_encblkno8_vec0_ctxt, }, { .blkno = 1, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_256_encblkno8_vec1_ctxt, }, { .blkno = 2, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_256_encblkno8_vec2_ctxt, }, { .blkno = 3, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_256_encblkno8_vec3_ctxt, }, }; /* * IV method encblkno1, blkno 0. */ static const uint8_t bf_cbc_448_encblkno1_vec0_ctxt[SECSIZE] = { 0xb0, 0x1b, 0x43, 0xc9, 0x84, 0x53, 0x51, 0x72, 0x1f, 0x93, 0x62, 0x94, 0x13, 0x1f, 0xe3, 0xc1, 0x30, 0xee, 0xc4, 0x35, 0x98, 0xb8, 0x11, 0x9b, 0xd1, 0x23, 0xfa, 0x2d, 0xc1, 0xe6, 0xf3, 0x8f, 0x8b, 0x05, 0x8d, 0xc5, 0x1d, 0xc3, 0x29, 0x1a, 0xff, 0x08, 0xb0, 0x97, 0x88, 0x50, 0x8f, 0x41, 0x66, 0xc6, 0x70, 0x37, 0xca, 0xb2, 0xcd, 0x91, 0x89, 0x41, 0x1b, 0x42, 0xce, 0x02, 0xec, 0xe8, 0x9b, 0xf3, 0x50, 0x95, 0x5f, 0xba, 0xda, 0xd5, 0x0c, 0x2f,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61, 0xab, 0x7f, 0x15, 0x56, 0x7f, 0x1a, 0xf5, 0x08, 0xf1, 0x1c, 0x59, 0x70, 0x92, 0x3a, 0xda, 0x1a, 0xfd, 0xfc, 0x4d, 0xe1, 0x12, 0x61, 0xc1, 0xd8, 0xdb, 0x63, 0x6e, 0x6b, 0x19, 0x96, 0x68, 0x17, 0x9b, 0xf5, 0xa9, 0x5d, 0x2c, 0xaf, 0xad, 0xc6, 0x26, 0x9e, 0x09, 0xcb, 0x67, 0x4e, 0x50, 0x7d, 0x2f, 0xae, 0x4e, 0x73, 0xd9, 0x5a, 0xaa, 0x5d, 0x54, 0x20, 0x7b, 0x77, 0xcf, 0xf8, 0xad, 0x88, 0x6b, 0xc8, }; /* * IV method encblkno1, blkno 1. */ static const uint8_t bf_cbc_448_encblkno1_vec1_ctxt[SECSIZE] = { 0x8b, 0x2a, 0xcf, 0x7d, 0x38, 0x1b, 0xaa, 0x33, 0x1c, 0xe6, 0xa1, 0x37, 0x6e, 0x9e, 0xb3, 0x48, 0x2a, 0xb8, 0x61, 0x11, 0x00, 0xe5, 0x48, 0xea, 0xb5, 0x9f, 0x6c, 0xa4, 0xdf, 0x8d, 0x5a, 0xd8, 0x03, 0x55, 0x4d, 0x07, 0x7d, 0x5f, 0x1b, 0x18, 0xd1, 0x86, 0x52, 0xc1, 0x13, 0xda, 0x99, 0x23, 0xeb, 0xab, 0xb2, 0x93, 0x40, 0x7c, 0x6a, 0x8a, 0xaa, 0xf8, 0xf1, 0x66, 0xf1, 0x10, 0x1d, 0xcd, 0x25, 0xc7, 0x84, 0x55, 0x02, 0x1d, 0xc0, 0x3c, 0xba, 0xf4, 0xbf, 0xe2, 0xe4, 0xc3, 0x57, 0xdc, 0x0d, 0xfd, 0xeb, 0xb3, 0x7d, 0x31, 0x82, 0x6b, 0x5c, 0x0e, 0x92, 0xa5, 0x42, 0x8b, 0x7f, 0x36, 0x74, 0x4d, 0xfd, 0x2f, 0xd7, 0x19, 0x0d, 0x23, 0xa7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2, 0xea, 0x79, 0xc5, 0x3e, 0xcf, 0xf0, 0x40, 0x00, 0x8c, 0x81, 0x97, 0xed, 0xac, 0xf9, 0x61, 0x75, 0x4e, 0xd7, 0xb7, 0xb2, 0x02, 0x14, 0x04, 0xf6, 0xbf, 0x25, 0xbe, 0x78, 0x2a, 0xea, 0xd2, 0x61, 0xf2, 0x7e, 0x45, 0x6b, 0x20, 0xca, }; /* * IV method encblkno1, blkno 2. */ static const uint8_t bf_cbc_448_encblkno1_vec2_ctxt[SECSIZE] = { 0x35, 0x34, 0x49, 0x29, 0x12, 0x3f, 0xc6, 0x2f, 0xc9, 0x3d, 0xc9, 0x54, 0x46, 0xf3, 0x26, 0xf9, 0x5e, 0x45, 0xb4, 0xba, 0x6d, 0x0f, 0x98, 0x53, 0x8b, 0x7a, 0x00, 0x47, 0xb6, 0xbd, 0x70, 0x89, 0x60, 0x8e, 0x52, 0x0b, 0xe3, 0x0a, 0xd8, 0x0e, 0x48, 0xf3, 0xcc, 0x66, 0x8d, 0x71, 0xaa, 0x0e, 0xc2, 0x68, 0x03, 0x05, 0xf9, 0xef, 0x1d, 0x14, 0x5a, 0x85, 0x88, 0x70, 0x77, 0xcf, 0xe3, 0xdf, 0x18, 0xe5, 0xfb, 0xea, 0xe1, 0xe8, 0xe0, 0x25, 0xb2, 0x14, 0x61, 0x5d, 0x2f, 0xce, 0x61, 0xec, 0x68, 0xc8, 0x06, 0x60, 0x41, 0xc1, 0xe3, 0x0a, 0x5e, 0x96, 0x15, 0x9b, 0x2c, 0x5b, 0xfd, 0xba, 0x17, 0x2e, 0x50, 0xb6, 0x68, 0x39, 0x21, 0x56, 0x31, 0x2e, 0xb5, 0x29, 0xff, 0x4a, 0x12, 0x34, 0x02, 0x54, 0xb1, 0x7f, 0xd8, 0x35, 0xec, 0x79, 0x9e, 0xef, 0x62, 0xf3, 0x4b, 0x58, 0x96, 0xf1, 0x83, 0x26, 0x57, 0x3d, 0x55, 0xb9, 0xb0, 0xa7, 0x48,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0a, 0x18, 0xdc, 0x9a, }; /* * IV method encblkno1, blkno 3. */ static const uint8_t bf_cbc_448_encblkno1_vec3_ctxt[SECSIZE] = { 0xc3, 0xd3, 0xae, 0x7e, 0x4f, 0xbe, 0x0d, 0x50, 0xd6, 0x63, 0x2c, 0xa2, 0xfd, 0x07, 0xf1, 0x33, 0x2a, 0x15, 0x8f, 0xd7, 0x63, 0xb6, 0x5f, 0x04, 0x69, 0x90, 0xa3, 0x1a, 0xd3, 0xdd, 0xe0, 0x70, 0xb1, 0xcd, 0xd5, 0xe0, 0x75, 0xd2, 0x31, 0x38, 0xcc, 0x65, 0xbb, 0xc3, 0x3b, 0xc6, 0xc9, 0x33, 0x43, 0x9c, 0x32, 0x69, 0x95, 0x10, 0x74, 0x36, 0x3a, 0x05, 0x9c, 0x26, 0x2f, 0x80, 0x20, 0x92, 0x74, 0x31, 0xc0, 0xf4, 0xb1, 0x42, 0x58, 0xc8, 0x3e, 0xaa, 0xd4, 0xba, 0xba, 0x4b, 0x5f, 0x47, 0x1a, 0x9e, 0x43, 0xaf, 0x25, 0x64, 0x0c, 0x2e, 0xa3, 0xf5, 0xde, 0x6e, 0x28, 0x5e, 0xb9, 0x9e, 0xc9, 0xdf, 0x85, 0xda, 0xc9, 0xa8, 0x30, 0xf9, 0x44, 0x9b, 0x16, 0xcb, 0x4b, 0x47, 0x6f, 0x11, 0x5c, 0xd7, 0xc9, 0xb7, 0x9c, 0x50, 0x04, 0x3b, 0x2f, 0x13, 0xab, 0xb6, 0x72, 0xe7, 0x11, 0x29, 0x35, 0xf3, 0xae, 0x5e, 0x2a, 0xa7, 0x1a, 0xac, 0xb7, 0x4c, 0x7b, 0x69, 0x89, 0xfc, 0xff, 0x37, 0x24, 0xf8, 0x65, 0xc0, 0x87, 0x89, 0x69, 0x1e, 0xa6, 0x7e, 0xe7, 0xb3, 0xb7, 0xa8, 0x42, 0x73, 0x83, 0xdb, 0x56, 0x4f, 0xce, 0xb9, 0x6e, 0x38, 0x40, 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x63, 0x89, 0x12, 0x12, 0x59, 0x38, 0xe3, 0xcf, 0xa0, 0xda, 0xbc, 0x69, 0x75, 0x48, 0x7c, 0x3e, 0x56, 0x75, 0x12, 0x10, 0xc5, 0x96, 0x5b, 0x34, 0x52, 0x2e, 0xce, 0xba, 0xd2, 0x7f, 0x8f, 0x1c, 0xbd, 0x35, 0x3b, 0x74, 0x5b, 0x6c, 0xfe, 0xa7, 0xf1, 0x4a, 0x07, 0x95, 0xff, 0xa8, 0xa0, 0x2a, 0x85, 0xec, 0xd7, 0x56, 0x3b, 0x28, 0x2e, 0x09, 0x50, 0x43, 0xbd, 0x49, 0x22, 0xdc, 0x78, 0x0e, 0x7e, 0x68, 0x78, 0xd5, 0x57, 0xc2, 0xd6, 0x7c, 0x2f, 0xd0, 0x4a, 0x62, 0x16, 0x38, 0x04, 0x23, 0x43, 0x21, 0xaa, 0xe1, 0x96, 0x0e, 0xa9, 0x22, 0xe7, 0x2c, 0xb8, 0x5e, 0x8f, 0xc6, 0x2d, 0xbd, 0x99, 0x25, 0x33, 0xb8, 0x47, 0x99, 0x8d, 0xf5, 0x22, 0x08, 0x9b, 0xd5, 0xad, 0x83, 0x67, 0xec, 0x05, 0x89, 0xda, 0xd6, 0xe4, 0xe2, 0xd5, 0xef, 0x7f, 0x61, 0x1e, 0x03, 0x81, 0x03, 0xb1, 0x98, 0x5a, 0x29, 0x69, 0x13, 0xb2, 0xe6, 0xe1, 0x2c, 0x66, 0x88, 0x39, 0x90, 0xf9, 0xae, 0x5d, 0x71, 0xfe, 0x07, 0x30, 0x7d, 0xba, 0xa9, 0x37, 0xb5, 0xff, 0x2c, 0xa9, 0xe6, 0x95, 0x48, 0xb2, 0xc8, }; const struct testvec bf_cbc_448_1_vectors[] = { { .blkno = 0, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_448_encblkno1_vec0_ctxt, }, { .blkno = 1, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_448_encblkno1_vec1_ctxt, }, { .blkno = 2, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_448_encblkno1_vec2_ctxt, }, { .blkno = 3, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_448_encblkno1_vec3_ctxt, }, }; /* * IV method encblkno8, blkno 0. */ static const uint8_t bf_cbc_448_encblkno8_vec0_ctxt[SECSIZE] = { 0x91, 0xb4, 0x8f, 0x78, 0x34, 0xbe, 0x03, 0xe9, 0x4b, 0xca, 0xf4, 0xfa, 0x27, 0x99, 0xa0, 0xd0, 0xa0, 0x85, 0xf9, 0xca, 0xcc, 0x2e, 0x0d, 0x41, 0x91, 0xdb, 0xf9, 0x71, 0xcd, 0x49, 0xf7, 0x66, 0x9b, 0x0c, 0x70, 0x49, 0x36, 0x72, 0xf4, 0xc0, 0x17, 0xdd, 0xd8, 0x6a, 0xd2, 0x17, 0xfe, 0x50, 0xa3, 0x2b, 0xa8, 0x7c, 0x9c, 0x12, 0x8c, 0x08, 0x3d, 0xb5, 0x20, 0xc0, 0x83, 0xc1, 0xf5, 0x34, 0x4b, 0xa5, 0xcc, 0x7c, 0xc6, 0x9f, 0x4b, 0x7f, 0x09, 0x0c, 0x04, 0xe3, 0x02, 0xfe, 0xe2, 0x5a, 0x45, 0xee, 0x4a, 0xcb, 0xc0, 0xe1, 0xf1, 0xae, 0x1a, 0x22, 0x95, 0xb9, 0x30, 0xe8, 0x2d, 0x90, 0xe5, 0x6a, 0x2f, 0x0a, 0x59, 0x15, 0xfc, 0x60, 0xa5, 0x91, 0x95, 0x1a, 0xa2, 0xf5, 0x87, 0xa3, 0x97, 0x45, 0x1b, 0xfb, 0x78, 0x62, 0x8b, 0xb6, 0x86, 0xc6, 0x94, 0x9a, 0x9d, 0x09, 0x46, 0xc9, 0x1f, 0x5f, 0x2e, 0x6c, 0xed, 0x5e, 0xe2, 0xab, 0xca, 0x30, 0xdb, 0x13, 0x37, 0x8d, 0xb7, 0xc6, 0xce, 0x74, 0xe3, 0xe2, 0x64, 0x7b, 0x74, 0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, 0x25, 0x86, 0x05, 0xfc, 0xd9, 0x39, 0x11, 0x2b, 0x7e, 0x07, 0xfd, 0x6b, 0xb3, 0x28, 0x57, 0x66, 0x94, 0xc6, 0xfc, 0x48, 0x71, 0xeb, 0x7b, 0x9a, 0x26, 0x8f, 0x9f, 0x97, 0xb6, 0x83, 0x9a, 0xdc, 0x5d, 0x84, 0x96, 0x9d, 0xe3, 0xa5, 0x12, 0x97, 0x8c, 0x87, 0xa6, 0x2a, 0xa8, 0x15, 0x9a, 0xb0, 0x0e, 0x31, 0x55, 0xf7, 0x1b, 0x5c, 0x9c, 0xaf, 0x13, 0x20, 0x13, 0x50, 0xaf, 0xc9, 0xf4, 0xd9, 0x47, 0x16, 0xcc, 0x9d, 0xec, 0xa9, 0x2d, 0xfc, 0x3d, 0x5d, 0x48, 0x89, 0x86, 0x91, 0x6f, 0x1a, 0xa5, 0xf0, 0xb6, 0x9b, 0xa9, 0x08, 0xf2, 0x05, 0xad, 0xe5, 0xe0, 0xd8, 0x2e, 0x09, 0xbe, 0x3a, 0xf2, 0xdc, 0xeb, 0x14, 0xe6, 0x8c, 0x21, 0x20, 0xbb, 0x42, 0x6a, 0xba, 0x55, 0x79, 0x54, 0x8b, 0xa8, 0x43, 0x14, 0x28, 0x66, 0xd2, 0x44, 0x65, 0x9c, 0xa9, 0xdc, 0x3b, 0x3f, 0xab, 0x36, 0xb4, 0xbc, 0x9d, 0x22, 0x92, 0x24, 0xa8, 0x29, 0x18, 0x98, 0x3a, 0xbe, 0xa1, 0xb4, 0xf8, 0x7f, 0xea, 0x2f, 0x58, 0x69, 0xce, 0xee, 0x99, 0x76, 0x2c, 0x53, 0x84, 0xf5, 0x9e, 0xa3, 0x98, 0xe6, 0x94, 0x39, 0xfa, 0xfa, 0x6d, 0x66, 0xe2, 0x39, 0x2b, 0x4b, 0x84, 0x14, 0x89, 0x18, 0xa2, 0x03, 0xdd, }; /* * IV method encblkno8, blkno 1. */ static const uint8_t bf_cbc_448_encblkno8_vec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 0xb8, 0x76, 0xbc, 0xf5, 0x9b, 0xd6, 0x98, 0x26, 0x58, 0xec, 0xdd, 0xa8, 0xf1, 0xee, 0x9e, 0x14, 0x24, 0x94, 0x7c, 0xb6, 0x45, 0x8b, 0xc7, 0x85, 0x50, 0x4e, 0x30, 0xd7, 0x51, 0x8c, 0x33, 0xeb, 0xeb, 0x5d, 0x52, 0x58, 0x43, 0xcb, 0x25, 0x4a, 0x77, 0x34, 0xe6, 0x70, 0x5b, 0x6f, 0x8f, 0xe8, 0x07, 0xee, 0x76, 0x4a, 0xad, 0xab, 0x11, 0x8a, 0x1b, 0x92, 0x60, 0x79, 0xb8, 0xe0, 0x88, 0xa7, 0x3a, 0xe0, 0x15, 0xf6, 0x57, 0xf0, 0xe8, 0x87, 0xda, 0xf8, 0x90, 0x4e, 0xe7, 0xb3, 0xb4, 0xe7, 0x73, 0x5c, 0xd3, 0x69, 0xfb, 0x23, 0x4f, 0x4f, 0xc8, 0xd2, 0xfb, 0xf5, 0xf5, 0x76, 0x80, 0xb6, 0xb7, 0xe2, 0xb7, 0x96, 0x1a, 0x97, 0x12, 0x40, 0x16, 0x86, 0xd6, 0x66, 0xf5, 0x46, 0x9e, 0x04, 0x62, 0xaa, 0x9c, 0xc9, 0x45, 0x39, 0x5c, 0xd3, 0x58, 0x40, 0xb4, 0x32, 0xd8, 0x6c, 0x19, 0xfa, 0xa5, 0x5f, 0x1e, 0x83, 0x5a, 0x32, 0x5e, 0x1d, 0xab, 0xa9, 0x48, 0x1b, 0x1b, 0x37, 0x66, 0xf8, 0x67, 0xd7, }; /* * IV method encblkno8, blkno 2. */ static const uint8_t bf_cbc_448_encblkno8_vec2_ctxt[SECSIZE] = { 0xb3, 0x2d, 0x0d, 0x90, 0x7a, 0x50, 0xb6, 0x29, 0x9d, 0xd4, 0x12, 0x1a, 0xc9, 0x71, 0x56, 0xc4, 0xce, 0x3d, 0x74, 0xf9, 0x91, 0xe4, 0x79, 0x8a, 0x42, 0x34, 0x1a, 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 0x37, 0xd1, 0xb8, 0xef, 0xdc, 0x04, 0x1b, 0x0d, 0x60, 0xbf, 0xbc, 0xc0, 0xff, 0x56, 0x8b, 0xd3, 0x6e, 0x71, 0xfc, 0x87, 0x00, 0x86, 0x10, 0x78, 0x3b, 0xce, 0x8b, 0xe8, 0x5f, 0x8c, 0xce, 0x03, 0xa2, 0x89, 0x8c, 0x16, 0x00, 0x0e, 0xd8, 0x53, 0xaf, 0x7f, 0x77, 0x78, 0x40, 0x5e, 0x5e, 0xd1, 0x7d, 0xf8, 0x41, 0xa8, 0x1e, 0xa5, 0xe5, 0xe9, 0xd6, 0x17, 0x2c, 0x2f, 0x1b, 0xff, 0xef, 0xf5, 0x53, 0x31, 0xf3, 0x5b, 0xe4, 0x84, 0x7c, 0xe2, 0x45, 0x3c, 0x82, 0x5b, 0xf6, 0x03, 0x35, 0xdd, 0x03, 0x22, 0xbe, 0x77, 0x9c, 0x6a, 0x7d, 0xc8, 0x29, 0x41, 0x53, 0xbb, 0xab, 0x6e, 0xa5, 0x00, 0xaf, 0x3b, 0x1d, 0x76, 0x12, 0xac, 0x44, 0x5c, 0x7d, 0xd2, 0x3b, 0x3a, 0x95, 0xb0, 0xa9, 0x4f, 0x27, 0x76, 0x17, }; /* * IV method encblkno8, blkno 3. */ static const uint8_t bf_cbc_448_encblkno8_vec3_ctxt[SECSIZE] = { 0x8e, 0xc4, 0x56, 0x64, 0x1e, 0x2a, 0x0d, 0x60, 0x54, 0x5c, 0xcd, 0xe0, 0x6d, 0xa7, 0x4c, 0x30, 0x7e, 0x85, 0x21, 0xdf, 0xaa, 0xb2, 0x32, 0xde, 0xc0, 0xc6, 0x56, 0xe0, 0x43, 0xc2, 0x3e, 0x6c, 0x8c, 0x62, 0x35, 0xaa, 0xf9, 0xba, 0xc9, 0x52, 0x38, 0x72, 0x06, 0xcc, 0x02, 0xa2, 0xb8, 0x85, 0xf7, 0xcc, 0xe6, 0x8c, 0x86, 0x8f, 0x9c, 0xd6, 0x1f,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xec, 0x9d, 0x93, 0x81, 0xb7, 0x9a, 0xa4, 0x35, 0xe7, 0xef, 0xef, 0x2d, 0x4c, 0x02, 0xf7, 0x2b, 0x26, 0xe0, 0x9e, 0x3a, 0x31, 0xfd, 0x94, 0xb3, 0xa7, 0x8a, 0x93, 0xf3, 0xe1, 0x77, 0x79, 0xdf, 0xcf, 0x1f, 0x99, 0x55, 0x20, 0xc3, 0x7d, 0x8a, 0xbc, 0xff, 0x63, 0x64, 0x87, 0xa9, 0x42, 0x63, 0xc9, 0x67, 0x7e, 0x51, 0x99, 0x9c, 0xcb, 0x47, 0xa9, 0xc8, 0x5e, 0x83, 0x87, 0x55, 0x7c, 0x45, 0x3a, 0xb4, 0xfe, 0x97, 0x24, 0x17, 0x1d, 0x5e, 0xdf, 0xe0, 0xe8, 0x17, 0xa6, 0x31, 0x99, 0xeb, 0xb7, 0xb5, 0xd5, 0xd7, 0x7c, 0x2f, 0x22, 0x26, }; const struct testvec bf_cbc_448_8_vectors[] = { { .blkno = 0, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_448_encblkno8_vec0_ctxt, }, { .blkno = 1, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_448_encblkno8_vec1_ctxt, }, { .blkno = 2, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_448_encblkno8_vec2_ctxt, }, { .blkno = 3, .ptxt = bf_cbc_ptxt, .ctxt = bf_cbc_448_encblkno8_vec3_ctxt, }, }; static int open_disk(const char *devpath, const char *imgpath, size_t size) { int fd; fd = open(imgpath, O_CREAT | O_RDWR | O_TRUNC, 0600); if (fd < 0) return -1; if (ftruncate(fd, size) < 0) goto fail; if (rump_pub_etfs_register_withsize(devpath, imgpath, RUMP_ETFS_BLK, 0, size) < 0) { goto fail; } unlink(imgpath); return fd; fail: close(fd); unlink(imgpath); return -1; } static int open_cgd(int devno) { char devpath[32]; sprintf(devpath, "/dev/rcgd%d%c", devno, getrawpartition() + 'a'); return rump_sys_open(devpath, O_RDWR, 0); } static int configure_cgd(int fd, const char *dkpath, const char *alg, const char *ivmethod, const char *key, size_t keylen) { struct cgd_ioctl ci; memset(&ci, 0, sizeof(ci)); ci.ci_disk = dkpath; ci.ci_alg = alg; ci.ci_ivmethod = ivmethod; ci.ci_keylen = 8 * keylen - 8; /* Exclude the NUL terminator. */ ci.ci_key = key; ci.ci_blocksize = 64; return rump_sys_ioctl(fd, CGDIOCSET, &ci); } static int unconfigure_cgd(int fd) { struct cgd_ioctl ci; return rump_sys_ioctl(fd, CGDIOCCLR, &ci); } static int write_testvec(int cgdfd, const struct testvec *tv) { if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) return -1; if (rump_sys_write(cgdfd, tv->ptxt, SECSIZE) != SECSIZE) return -1; return 0; } static int read_testvec(int cgdfd, const struct testvec *tv) { char *buf; int res = -1; buf = malloc(SECSIZE); if (buf == NULL) return -1; if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) goto fail; if (rump_sys_read(cgdfd, buf, SECSIZE) != SECSIZE) goto fail; res = memcmp(buf, tv->ptxt, SECSIZE); fail: free(buf); return res; } static int check_testvec(int dkfd, const struct testvec *tv) { char *buf; int res = -1; buf = malloc(SECSIZE); if (buf == NULL) return -1; if (lseek(dkfd, tv->blkno * SECSIZE, SEEK_SET) < 0) goto fail; if (read(dkfd, buf, SECSIZE) != SECSIZE) goto fail; res = memcmp(buf, tv->ctxt, SECSIZE); fail: free(buf); return res; } ATF_TC(cgd_bf_cbc_128_encblkno1); ATF_TC_HEAD(cgd_bf_cbc_128_encblkno1, tc) { atf_tc_set_md_var(tc, "descr", "Test blowfish-cbc with 128 bits key, ivmethod encblkno1"); } ATF_TC_BODY(cgd_bf_cbc_128_encblkno1, tc) { const char imgpath[] = "blowfish-cbc-128-encblkno1.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", bf_cbc_128_key, sizeof(bf_cbc_128_key))); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[0]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[1]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[2]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", bf_cbc_128_key, sizeof(bf_cbc_128_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_bf_cbc_128_encblkno8); ATF_TC_HEAD(cgd_bf_cbc_128_encblkno8, tc) { atf_tc_set_md_var(tc, "descr", "Test blowfish-cbc with 128 bits key, ivmethod encblkno8"); } ATF_TC_BODY(cgd_bf_cbc_128_encblkno8, tc) { const char imgpath[] = "blowfish-cbc-128-encblkno8.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", bf_cbc_128_key, sizeof(bf_cbc_128_key))); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[0]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[1]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[2]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", bf_cbc_128_key, sizeof(bf_cbc_128_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_bf_cbc_256_encblkno1); ATF_TC_HEAD(cgd_bf_cbc_256_encblkno1, tc) { atf_tc_set_md_var(tc, "descr", "Test blowfish-cbc with 256 bits key, ivmethod encblkno1"); } ATF_TC_BODY(cgd_bf_cbc_256_encblkno1, tc) { const char imgpath[] = "blowfish-cbc-256-encblkno1.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", bf_cbc_256_key, sizeof(bf_cbc_256_key))); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[0]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[1]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[2]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", bf_cbc_256_key, sizeof(bf_cbc_256_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_bf_cbc_256_encblkno8); ATF_TC_HEAD(cgd_bf_cbc_256_encblkno8, tc) { atf_tc_set_md_var(tc, "descr", "Test blowfish-cbc with 256 bits key, ivmethod encblkno8"); } ATF_TC_BODY(cgd_bf_cbc_256_encblkno8, tc) { const char imgpath[] = "blowfish-cbc-256-encblkno8.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", bf_cbc_256_key, sizeof(bf_cbc_256_key))); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[0]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[1]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[2]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", bf_cbc_256_key, sizeof(bf_cbc_256_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_bf_cbc_448_encblkno1); ATF_TC_HEAD(cgd_bf_cbc_448_encblkno1, tc) { atf_tc_set_md_var(tc, "descr", "Test blowfish-cbc with 448 bits key, ivmethod encblkno1"); } ATF_TC_BODY(cgd_bf_cbc_448_encblkno1, tc) { const char imgpath[] = "blowfish-cbc-448-encblkno1.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", bf_cbc_448_key, sizeof(bf_cbc_448_key))); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[0]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[1]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[2]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", bf_cbc_448_key, sizeof(bf_cbc_448_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[3]), 0); RL(close(dkfd)); } ATF_TC(cgd_bf_cbc_448_encblkno8); ATF_TC_HEAD(cgd_bf_cbc_448_encblkno8, tc) { atf_tc_set_md_var(tc, "descr", "Test blowfish-cbc with 448 bits key, ivmethod encblkno8"); } ATF_TC_BODY(cgd_bf_cbc_448_encblkno8, tc) { const char imgpath[] = "blowfish-cbc-448-encblkno8.img"; const char *dkpath = "/dev/dk"; const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ int dkfd, cgdfd; rump_init(); RL(dkfd = open_disk(dkpath, imgpath, dksize)); RL(cgdfd = open_cgd(0)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", bf_cbc_448_key, sizeof(bf_cbc_448_key))); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[0]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[1]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[2]), 0); ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", bf_cbc_448_key, sizeof(bf_cbc_448_key))); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[0]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[1]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[2]), 0); ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[3]), 0); RL(unconfigure_cgd(cgdfd)); RL(rump_sys_close(cgdfd)); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[0]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[1]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[2]), 0); ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[3]), 0); RL(close(dkfd)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, cgd_bf_cbc_128_encblkno1); ATF_TP_ADD_TC(tp, cgd_bf_cbc_128_encblkno8); ATF_TP_ADD_TC(tp, cgd_bf_cbc_256_encblkno1); ATF_TP_ADD_TC(tp, cgd_bf_cbc_256_encblkno8); ATF_TP_ADD_TC(tp, cgd_bf_cbc_448_encblkno1); ATF_TP_ADD_TC(tp, cgd_bf_cbc_448_encblkno8); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/clock_subr/clock_subr_test_data_gen.sh =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/clock_subr/clock_subr_test_data_gen.sh (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/clock_subr/clock_subr_test_data_gen.sh (revision 312126) @@ -0,0 +1,25 @@ +#!/bin/ksh + +export TZ=Etc/Universal + +datesub() { + gdate "$@" '+ FILL(%_11s,%_4Y,%_m,%_d,%w,%_H,%_M,%_S), // %a %b %e %H:%M:%S %Z %Y' +} + +( + datesub -d '1970/01/01 00:00:00' + datesub -d '1981/04/12 12:00:03' + datesub -d '2011/07/21 09:57:00' + datesub -d @2147483647 + datesub -d @2147483648 + datesub -d '2063/04/05 00:00:00' + for year in `seq 1970 1 2030`; do + datesub -d "${year}/01/01 00:00:00" + datesub -d "${year}/07/01 00:00:00" + done + for year in `seq 2000 25 2600`; do + datesub -d "$((${year} - 1))/12/31 23:59:59" + datesub -d "$((${year} + 0))/01/01 00:00:00" + datesub -d "$((${year} + 1))/01/01 00:00:00" + done +)|sort -u Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/clock_subr/clock_subr_test_data_gen.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ 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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/clock_subr/t_clock_subr.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/clock_subr/t_clock_subr.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/clock_subr/t_clock_subr.c (revision 312126) @@ -0,0 +1,309 @@ +/* $NetBSD: t_clock_subr.c,v 1.3 2017/01/13 21:30:39 christos Exp $ */ + +/* + * Copyright (c) 2016 Jonathan A. Kollasch + * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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) 2016\ + Jonathan A. Kollasch. All rights reserved."); +__RCSID("$NetBSD: t_clock_subr.c,v 1.3 2017/01/13 21:30:39 christos Exp $"); + +#include +#include + +#include +#include +#include + +#include + +#include "h_macros.h" + +#define FILL(ti,ye,mo,da,wd,ho,mi,se) \ +{ .time = (ti), .clock = { .dt_year = (ye), .dt_mon = (mo), .dt_day = (da), \ + .dt_wday = (wd), .dt_hour = (ho), .dt_min = (mi), .dt_sec = (se), } } + +static struct clock_test { + time_t time; + struct clock_ymdhms clock; +} const clock_tests[] = { + FILL( 0,1970, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 1970 + FILL( 15638400,1970, 7, 1,3, 0, 0, 0), // Wed Jul 1 00:00:00 UTC 1970 + FILL( 31536000,1971, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 1971 + FILL( 47174400,1971, 7, 1,4, 0, 0, 0), // Thu Jul 1 00:00:00 UTC 1971 + FILL( 63072000,1972, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 1972 + FILL( 78796800,1972, 7, 1,6, 0, 0, 0), // Sat Jul 1 00:00:00 UTC 1972 + FILL( 94694400,1973, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 1973 + FILL( 110332800,1973, 7, 1,0, 0, 0, 0), // Sun Jul 1 00:00:00 UTC 1973 + FILL( 126230400,1974, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 1974 + FILL( 141868800,1974, 7, 1,1, 0, 0, 0), // Mon Jul 1 00:00:00 UTC 1974 + FILL( 157766400,1975, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 1975 + FILL( 173404800,1975, 7, 1,2, 0, 0, 0), // Tue Jul 1 00:00:00 UTC 1975 + FILL( 189302400,1976, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 1976 + FILL( 205027200,1976, 7, 1,4, 0, 0, 0), // Thu Jul 1 00:00:00 UTC 1976 + FILL( 220924800,1977, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 1977 + FILL( 236563200,1977, 7, 1,5, 0, 0, 0), // Fri Jul 1 00:00:00 UTC 1977 + FILL( 252460800,1978, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 1978 + FILL( 268099200,1978, 7, 1,6, 0, 0, 0), // Sat Jul 1 00:00:00 UTC 1978 + FILL( 283996800,1979, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 1979 + FILL( 299635200,1979, 7, 1,0, 0, 0, 0), // Sun Jul 1 00:00:00 UTC 1979 + FILL( 315532800,1980, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 1980 + FILL( 331257600,1980, 7, 1,2, 0, 0, 0), // Tue Jul 1 00:00:00 UTC 1980 + FILL( 347155200,1981, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 1981 + FILL( 355924803,1981, 4,12,0,12, 0, 3), // Sun Apr 12 12:00:03 UTC 1981 + FILL( 362793600,1981, 7, 1,3, 0, 0, 0), // Wed Jul 1 00:00:00 UTC 1981 + FILL( 378691200,1982, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 1982 + FILL( 394329600,1982, 7, 1,4, 0, 0, 0), // Thu Jul 1 00:00:00 UTC 1982 + FILL( 410227200,1983, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 1983 + FILL( 425865600,1983, 7, 1,5, 0, 0, 0), // Fri Jul 1 00:00:00 UTC 1983 + FILL( 441763200,1984, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 1984 + FILL( 457488000,1984, 7, 1,0, 0, 0, 0), // Sun Jul 1 00:00:00 UTC 1984 + FILL( 473385600,1985, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 1985 + FILL( 489024000,1985, 7, 1,1, 0, 0, 0), // Mon Jul 1 00:00:00 UTC 1985 + FILL( 504921600,1986, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 1986 + FILL( 520560000,1986, 7, 1,2, 0, 0, 0), // Tue Jul 1 00:00:00 UTC 1986 + FILL( 536457600,1987, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 1987 + FILL( 552096000,1987, 7, 1,3, 0, 0, 0), // Wed Jul 1 00:00:00 UTC 1987 + FILL( 567993600,1988, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 1988 + FILL( 583718400,1988, 7, 1,5, 0, 0, 0), // Fri Jul 1 00:00:00 UTC 1988 + FILL( 599616000,1989, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 1989 + FILL( 615254400,1989, 7, 1,6, 0, 0, 0), // Sat Jul 1 00:00:00 UTC 1989 + FILL( 631152000,1990, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 1990 + FILL( 646790400,1990, 7, 1,0, 0, 0, 0), // Sun Jul 1 00:00:00 UTC 1990 + FILL( 662688000,1991, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 1991 + FILL( 678326400,1991, 7, 1,1, 0, 0, 0), // Mon Jul 1 00:00:00 UTC 1991 + FILL( 694224000,1992, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 1992 + FILL( 709948800,1992, 7, 1,3, 0, 0, 0), // Wed Jul 1 00:00:00 UTC 1992 + FILL( 725846400,1993, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 1993 + FILL( 741484800,1993, 7, 1,4, 0, 0, 0), // Thu Jul 1 00:00:00 UTC 1993 + FILL( 757382400,1994, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 1994 + FILL( 773020800,1994, 7, 1,5, 0, 0, 0), // Fri Jul 1 00:00:00 UTC 1994 + FILL( 788918400,1995, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 1995 + FILL( 804556800,1995, 7, 1,6, 0, 0, 0), // Sat Jul 1 00:00:00 UTC 1995 + FILL( 820454400,1996, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 1996 + FILL( 836179200,1996, 7, 1,1, 0, 0, 0), // Mon Jul 1 00:00:00 UTC 1996 + FILL( 852076800,1997, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 1997 + FILL( 867715200,1997, 7, 1,2, 0, 0, 0), // Tue Jul 1 00:00:00 UTC 1997 + FILL( 883612800,1998, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 1998 + FILL( 899251200,1998, 7, 1,3, 0, 0, 0), // Wed Jul 1 00:00:00 UTC 1998 + FILL( 915148800,1999, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 1999 + FILL( 930787200,1999, 7, 1,4, 0, 0, 0), // Thu Jul 1 00:00:00 UTC 1999 + FILL( 946684799,1999,12,31,5,23,59,59), // Fri Dec 31 23:59:59 UTC 1999 + FILL( 946684800,2000, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2000 + FILL( 962409600,2000, 7, 1,6, 0, 0, 0), // Sat Jul 1 00:00:00 UTC 2000 + FILL( 978307200,2001, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2001 + FILL( 993945600,2001, 7, 1,0, 0, 0, 0), // Sun Jul 1 00:00:00 UTC 2001 + FILL( 1009843200,2002, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 2002 + FILL( 1025481600,2002, 7, 1,1, 0, 0, 0), // Mon Jul 1 00:00:00 UTC 2002 + FILL( 1041379200,2003, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 2003 + FILL( 1057017600,2003, 7, 1,2, 0, 0, 0), // Tue Jul 1 00:00:00 UTC 2003 + FILL( 1072915200,2004, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 2004 + FILL( 1088640000,2004, 7, 1,4, 0, 0, 0), // Thu Jul 1 00:00:00 UTC 2004 + FILL( 1104537600,2005, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2005 + FILL( 1120176000,2005, 7, 1,5, 0, 0, 0), // Fri Jul 1 00:00:00 UTC 2005 + FILL( 1136073600,2006, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 2006 + FILL( 1151712000,2006, 7, 1,6, 0, 0, 0), // Sat Jul 1 00:00:00 UTC 2006 + FILL( 1167609600,2007, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2007 + FILL( 1183248000,2007, 7, 1,0, 0, 0, 0), // Sun Jul 1 00:00:00 UTC 2007 + FILL( 1199145600,2008, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 2008 + FILL( 1214870400,2008, 7, 1,2, 0, 0, 0), // Tue Jul 1 00:00:00 UTC 2008 + FILL( 1230768000,2009, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 2009 + FILL( 1246406400,2009, 7, 1,3, 0, 0, 0), // Wed Jul 1 00:00:00 UTC 2009 + FILL( 1262304000,2010, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 2010 + FILL( 1277942400,2010, 7, 1,4, 0, 0, 0), // Thu Jul 1 00:00:00 UTC 2010 + FILL( 1293840000,2011, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2011 + FILL( 1309478400,2011, 7, 1,5, 0, 0, 0), // Fri Jul 1 00:00:00 UTC 2011 + FILL( 1311242220,2011, 7,21,4, 9,57, 0), // Thu Jul 21 09:57:00 UTC 2011 + FILL( 1325376000,2012, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 2012 + FILL( 1341100800,2012, 7, 1,0, 0, 0, 0), // Sun Jul 1 00:00:00 UTC 2012 + FILL( 1356998400,2013, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 2013 + FILL( 1372636800,2013, 7, 1,1, 0, 0, 0), // Mon Jul 1 00:00:00 UTC 2013 + FILL( 1388534400,2014, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 2014 + FILL( 1404172800,2014, 7, 1,2, 0, 0, 0), // Tue Jul 1 00:00:00 UTC 2014 + FILL( 1420070400,2015, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 2015 + FILL( 1435708800,2015, 7, 1,3, 0, 0, 0), // Wed Jul 1 00:00:00 UTC 2015 + FILL( 1451606400,2016, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 2016 + FILL( 1467331200,2016, 7, 1,5, 0, 0, 0), // Fri Jul 1 00:00:00 UTC 2016 + FILL( 1483228800,2017, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 2017 + FILL( 1498867200,2017, 7, 1,6, 0, 0, 0), // Sat Jul 1 00:00:00 UTC 2017 + FILL( 1514764800,2018, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2018 + FILL( 1530403200,2018, 7, 1,0, 0, 0, 0), // Sun Jul 1 00:00:00 UTC 2018 + FILL( 1546300800,2019, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 2019 + FILL( 1561939200,2019, 7, 1,1, 0, 0, 0), // Mon Jul 1 00:00:00 UTC 2019 + FILL( 1577836800,2020, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 2020 + FILL( 1593561600,2020, 7, 1,3, 0, 0, 0), // Wed Jul 1 00:00:00 UTC 2020 + FILL( 1609459200,2021, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 2021 + FILL( 1625097600,2021, 7, 1,4, 0, 0, 0), // Thu Jul 1 00:00:00 UTC 2021 + FILL( 1640995200,2022, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2022 + FILL( 1656633600,2022, 7, 1,5, 0, 0, 0), // Fri Jul 1 00:00:00 UTC 2022 + FILL( 1672531200,2023, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 2023 + FILL( 1688169600,2023, 7, 1,6, 0, 0, 0), // Sat Jul 1 00:00:00 UTC 2023 + FILL( 1704067200,2024, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2024 + FILL( 1719792000,2024, 7, 1,1, 0, 0, 0), // Mon Jul 1 00:00:00 UTC 2024 + FILL( 1735689599,2024,12,31,2,23,59,59), // Tue Dec 31 23:59:59 UTC 2024 + FILL( 1735689600,2025, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 2025 + FILL( 1751328000,2025, 7, 1,2, 0, 0, 0), // Tue Jul 1 00:00:00 UTC 2025 + FILL( 1767225600,2026, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 2026 + FILL( 1782864000,2026, 7, 1,3, 0, 0, 0), // Wed Jul 1 00:00:00 UTC 2026 + FILL( 1798761600,2027, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 2027 + FILL( 1814400000,2027, 7, 1,4, 0, 0, 0), // Thu Jul 1 00:00:00 UTC 2027 + FILL( 1830297600,2028, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2028 + FILL( 1846022400,2028, 7, 1,6, 0, 0, 0), // Sat Jul 1 00:00:00 UTC 2028 + FILL( 1861920000,2029, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2029 + FILL( 1877558400,2029, 7, 1,0, 0, 0, 0), // Sun Jul 1 00:00:00 UTC 2029 + FILL( 1893456000,2030, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 2030 + FILL( 1909094400,2030, 7, 1,1, 0, 0, 0), // Mon Jul 1 00:00:00 UTC 2030 + FILL( 2147483647,2038, 1,19,2, 3,14, 7), // Tue Jan 19 03:14:07 UTC 2038 + FILL( 2147483648,2038, 1,19,2, 3,14, 8), // Tue Jan 19 03:14:08 UTC 2038 + FILL( 2524607999,2049,12,31,5,23,59,59), // Fri Dec 31 23:59:59 UTC 2049 + FILL( 2524608000,2050, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2050 + FILL( 2556144000,2051, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 2051 + FILL( 2942956800,2063, 4, 5,4, 0, 0, 0), // Thu Apr 5 00:00:00 UTC 2063 + FILL( 3313526399,2074,12,31,1,23,59,59), // Mon Dec 31 23:59:59 UTC 2074 + FILL( 3313526400,2075, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 2075 + FILL( 3345062400,2076, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 2076 + FILL( 4102444799,2099,12,31,4,23,59,59), // Thu Dec 31 23:59:59 UTC 2099 + FILL( 4102444800,2100, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 2100 + FILL( 4133980800,2101, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2101 + FILL( 4891363199,2124,12,31,0,23,59,59), // Sun Dec 31 23:59:59 UTC 2124 + FILL( 4891363200,2125, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2125 + FILL( 4922899200,2126, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 2126 + FILL( 5680281599,2149,12,31,3,23,59,59), // Wed Dec 31 23:59:59 UTC 2149 + FILL( 5680281600,2150, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 2150 + FILL( 5711817600,2151, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 2151 + FILL( 6469199999,2174,12,31,6,23,59,59), // Sat Dec 31 23:59:59 UTC 2174 + FILL( 6469200000,2175, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 2175 + FILL( 6500736000,2176, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2176 + FILL( 7258118399,2199,12,31,2,23,59,59), // Tue Dec 31 23:59:59 UTC 2199 + FILL( 7258118400,2200, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 2200 + FILL( 7289654400,2201, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 2201 + FILL( 8047036799,2224,12,31,5,23,59,59), // Fri Dec 31 23:59:59 UTC 2224 + FILL( 8047036800,2225, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2225 + FILL( 8078572800,2226, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 2226 + FILL( 8835955199,2249,12,31,1,23,59,59), // Mon Dec 31 23:59:59 UTC 2249 + FILL( 8835955200,2250, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 2250 + FILL( 8867491200,2251, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 2251 + FILL( 9624873599,2274,12,31,4,23,59,59), // Thu Dec 31 23:59:59 UTC 2274 + FILL( 9624873600,2275, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 2275 + FILL( 9656409600,2276, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2276 + FILL(10413791999,2299,12,31,0,23,59,59), // Sun Dec 31 23:59:59 UTC 2299 + FILL(10413792000,2300, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2300 + FILL(10445328000,2301, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 2301 + FILL(11202710399,2324,12,31,3,23,59,59), // Wed Dec 31 23:59:59 UTC 2324 + FILL(11202710400,2325, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 2325 + FILL(11234246400,2326, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 2326 + FILL(11991628799,2349,12,31,6,23,59,59), // Sat Dec 31 23:59:59 UTC 2349 + FILL(11991628800,2350, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 2350 + FILL(12023164800,2351, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2351 + FILL(12780547199,2374,12,31,2,23,59,59), // Tue Dec 31 23:59:59 UTC 2374 + FILL(12780547200,2375, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 2375 + FILL(12812083200,2376, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 2376 + FILL(13569465599,2399,12,31,5,23,59,59), // Fri Dec 31 23:59:59 UTC 2399 + FILL(13569465600,2400, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2400 + FILL(13601088000,2401, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2401 + FILL(14358470399,2424,12,31,2,23,59,59), // Tue Dec 31 23:59:59 UTC 2424 + FILL(14358470400,2425, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 2425 + FILL(14390006400,2426, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 2426 + FILL(15147388799,2449,12,31,5,23,59,59), // Fri Dec 31 23:59:59 UTC 2449 + FILL(15147388800,2450, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2450 + FILL(15178924800,2451, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 2451 + FILL(15936307199,2474,12,31,1,23,59,59), // Mon Dec 31 23:59:59 UTC 2474 + FILL(15936307200,2475, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 2475 + FILL(15967843200,2476, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 2476 + FILL(16725225599,2499,12,31,4,23,59,59), // Thu Dec 31 23:59:59 UTC 2499 + FILL(16725225600,2500, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 2500 + FILL(16756761600,2501, 1, 1,6, 0, 0, 0), // Sat Jan 1 00:00:00 UTC 2501 + FILL(17514143999,2524,12,31,0,23,59,59), // Sun Dec 31 23:59:59 UTC 2524 + FILL(17514144000,2525, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2525 + FILL(17545680000,2526, 1, 1,2, 0, 0, 0), // Tue Jan 1 00:00:00 UTC 2526 + FILL(18303062399,2549,12,31,3,23,59,59), // Wed Dec 31 23:59:59 UTC 2549 + FILL(18303062400,2550, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 2550 + FILL(18334598400,2551, 1, 1,5, 0, 0, 0), // Fri Jan 1 00:00:00 UTC 2551 + FILL(19091980799,2574,12,31,6,23,59,59), // Sat Dec 31 23:59:59 UTC 2574 + FILL(19091980800,2575, 1, 1,0, 0, 0, 0), // Sun Jan 1 00:00:00 UTC 2575 + FILL(19123516800,2576, 1, 1,1, 0, 0, 0), // Mon Jan 1 00:00:00 UTC 2576 + FILL(19880899199,2599,12,31,2,23,59,59), // Tue Dec 31 23:59:59 UTC 2599 + FILL(19880899200,2600, 1, 1,3, 0, 0, 0), // Wed Jan 1 00:00:00 UTC 2600 + FILL(19912435200,2601, 1, 1,4, 0, 0, 0), // Thu Jan 1 00:00:00 UTC 2601 +}; +#undef FILL + +ATF_TC(ymdhms_to_secs); +ATF_TC_HEAD(ymdhms_to_secs, tc) +{ + + atf_tc_set_md_var(tc, "descr", "check clock_ymdhms_to_secs"); +} +ATF_TC_BODY(ymdhms_to_secs, tc) +{ + time_t secs; + size_t i; + + for (i = 0; i < __arraycount(clock_tests); i++) { + secs = clock_ymdhms_to_secs(__UNCONST(&clock_tests[i].clock)); + ATF_CHECK_EQ_MSG(clock_tests[i].time, secs, "%jd != %jd", + (intmax_t)clock_tests[i].time, (intmax_t)secs); + } +} + +ATF_TC(secs_to_ymdhms); +ATF_TC_HEAD(secs_to_ymdhms, tc) +{ + + atf_tc_set_md_var(tc, "descr", "check clock_secs_to_ymdhms"); +} +ATF_TC_BODY(secs_to_ymdhms, tc) +{ + struct clock_ymdhms ymdhms; + size_t i; + +#define CHECK_FIELD(f) \ + ATF_CHECK_EQ_MSG(ymdhms.dt_##f, clock_tests[i].clock.dt_##f, \ + "%jd != %jd for %jd", (intmax_t)ymdhms.dt_##f, \ + (intmax_t)clock_tests[i].clock.dt_##f, \ + (intmax_t)clock_tests[i].time) + + for (i = 0; i < __arraycount(clock_tests); i++) { + clock_secs_to_ymdhms(clock_tests[i].time, &ymdhms); + CHECK_FIELD(year); + CHECK_FIELD(mon); + CHECK_FIELD(day); + CHECK_FIELD(wday); + CHECK_FIELD(hour); + CHECK_FIELD(min); + CHECK_FIELD(sec); + } +#undef CHECK_FIELD +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, ymdhms_to_secs); + ATF_TP_ADD_TC(tp, secs_to_ymdhms); + + return atf_no_error(); +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/clock_subr/t_clock_subr.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/scsipi/t_cd.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/scsipi/t_cd.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/scsipi/t_cd.c (revision 312126) @@ -1,81 +1,81 @@ -/* $NetBSD: t_cd.c,v 1.7 2014/04/25 00:24:39 pooka Exp $ */ +/* $NetBSD: t_cd.c,v 1.8 2017/01/13 21:30:39 christos Exp $ */ /* * Copyright (c) 2010 Antti Kantee. 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 ``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. */ #include #include #include #include #include #include #include #include #include #include "scsitest.h" -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(noisyeject); ATF_TC_HEAD(noisyeject, tc) { atf_tc_set_md_var(tc, "descr", "test for CD eject noisyness " "(PR kern/43785)"); } ATF_TC_BODY(noisyeject, tc) { static char fname[] = "/dev/rcd0_"; int part, fd, arg = 0; RL(part = getrawpartition()); fname[strlen(fname)-1] = 'a' + part; rump_init(); /* * Rump CD emulation has been fixed, so no longer a problem. * atf_tc_expect_signal(SIGSEGV, "PR kern/47646: Broken test or " "a real problem in rump or the driver"); */ RL(fd = rump_sys_open(fname, O_RDWR)); RL(rump_sys_ioctl(fd, DIOCEJECT, &arg)); ATF_REQUIRE_EQ(rump_scsitest_err[RUMP_SCSITEST_NOISYSYNC], 0); RL(rump_sys_close(fd)); // atf_tc_expect_fail("PR kern/43785"); ATF_REQUIRE_EQ(rump_scsitest_err[RUMP_SCSITEST_NOISYSYNC], 0); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, noisyeject); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/sysmon/t_swwdog.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/sysmon/t_swwdog.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/dev/sysmon/t_swwdog.c (revision 312126) @@ -1,193 +1,193 @@ -/* $NetBSD: t_swwdog.c,v 1.6 2015/04/23 04:49:37 pgoyette Exp $ */ +/* $NetBSD: t_swwdog.c,v 1.7 2017/01/13 21:30:39 christos Exp $ */ /* * Copyright (c) 2010 Antti Kantee. 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 ``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. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" static volatile sig_atomic_t tcount; static void sigcount(int sig) { assert(sig == SIGUSR1); tcount++; } /* * Since we are testing for swwdog's ability to reboot/panic, we need * to fork and monitor the exit status from the parent and report * something sensible back to atf. */ static int testbody(int max) { char wname[WDOG_NAMESIZE]; struct wdog_conf wc; struct wdog_mode wm; pid_t p1, p2; int status; int fd; signal(SIGUSR1, sigcount); switch ((p1 = fork())) { case 0: break; case -1: atf_tc_fail_errno("fork"); break; default: p2 = wait(&status); ATF_REQUIRE_EQ(p1, p2); ATF_REQUIRE_EQ(tcount, max); return status; } rump_init(); fd = rump_sys_open("/dev/watchdog", O_RDWR); if (fd == -1) err(1, "open watchdog"); wc.wc_count = 1; wc.wc_names = wname; if (rump_sys_ioctl(fd, WDOGIOC_GWDOGS, &wc) == -1) err(1, "can't fetch watchdog names"); if (wc.wc_count) { assert(wc.wc_count == 1); strlcpy(wm.wm_name, wc.wc_names, sizeof(wm.wm_name)); wm.wm_mode = WDOG_MODE_ETICKLE; wm.wm_period = 1; if (rump_sys_ioctl(fd, WDOGIOC_SMODE, &wm) == -1) atf_tc_fail_errno("failed to set tickle"); usleep(400000); if (max == 1) rump_sys_ioctl(fd, WDOGIOC_TICKLE); else { wm.wm_mode = WDOG_MODE_DISARMED; rump_sys_ioctl(fd, WDOGIOC_SMODE, &wm); } kill(getppid(), SIGUSR1); sleep(2); printf("staying alive\n"); kill(getppid(), SIGUSR1); _exit(2); } /* fail */ printf("no watchdog registered!\n"); _exit(1); } ATF_TC(reboot); ATF_TC_HEAD(reboot, tc) { atf_tc_set_md_var(tc, "descr", "check swwdog reboot capability"); } ATF_TC_BODY(reboot, tc) { extern bool rumpns_swwdog_reboot; int status; /* XXX: should use sysctl */ rumpns_swwdog_reboot = true; status = testbody(1); ATF_REQUIRE(WIFEXITED(status)); ATF_REQUIRE_EQ(WEXITSTATUS(status), 0); } ATF_TC(panic); ATF_TC_HEAD(panic, tc) { atf_tc_set_md_var(tc, "descr", "check swwdog panic capability"); } ATF_TC_BODY(panic, tc) { extern bool rumpns_swwdog_reboot; int status; /* XXX: should use sysctl */ rumpns_swwdog_reboot = false; status = testbody(1); ATF_REQUIRE(WIFSIGNALED(status)); ATF_REQUIRE_EQ(WTERMSIG(status), SIGABRT); } ATF_TC(disarm); ATF_TC_HEAD(disarm, tc) { atf_tc_set_md_var(tc, "descr", "check swwdog disarm capability"); } ATF_TC_BODY(disarm, tc) { int status; status = testbody(2); ATF_REQUIRE(WIFEXITED(status)); ATF_REQUIRE_EQ(WEXITSTATUS(status), 2); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, panic); ATF_TP_ADD_TC(tp, reboot); ATF_TP_ADD_TC(tp, disarm); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/common/h_fsmacros.h =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/common/h_fsmacros.h (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/common/h_fsmacros.h (revision 312126) @@ -1,329 +1,329 @@ -/* $NetBSD: h_fsmacros.h,v 1.40 2015/08/29 19:19:43 dholland Exp $ */ +/* $NetBSD: h_fsmacros.h,v 1.41 2017/01/13 21:30:39 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Nicolas Joly. * * 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. */ #ifndef __H_FSMACROS_H_ #define __H_FSMACROS_H_ #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #define FSPROTOS(_fs_) \ int _fs_##_fstest_newfs(const atf_tc_t *, void **, const char *, \ off_t, void *); \ int _fs_##_fstest_delfs(const atf_tc_t *, void *); \ int _fs_##_fstest_mount(const atf_tc_t *, void *, const char *, int); \ int _fs_##_fstest_unmount(const atf_tc_t *, const char *, int); FSPROTOS(ext2fs); FSPROTOS(ffs); FSPROTOS(ffslog); FSPROTOS(lfs); FSPROTOS(msdosfs); FSPROTOS(nfs); FSPROTOS(nfsro); FSPROTOS(p2k_ffs); FSPROTOS(puffs); FSPROTOS(rumpfs); FSPROTOS(sysvbfs); FSPROTOS(tmpfs); FSPROTOS(udf); FSPROTOS(v7fs); FSPROTOS(zfs); #ifndef FSTEST_IMGNAME #define FSTEST_IMGNAME "image.fs" #endif #ifndef FSTEST_IMGSIZE #define FSTEST_IMGSIZE (10000 * 512) #endif #ifndef FSTEST_MNTNAME #define FSTEST_MNTNAME "/mnt" #endif #define FSTEST_CONSTRUCTOR(_tc_, _fs_, _args_) \ do { \ if (_fs_##_fstest_newfs(_tc_, &_args_, \ FSTEST_IMGNAME, FSTEST_IMGSIZE, NULL) != 0) \ atf_tc_fail_errno("newfs failed"); \ if (_fs_##_fstest_mount(_tc_, _args_, FSTEST_MNTNAME, 0) != 0) \ atf_tc_fail_errno("mount failed"); \ } while (/*CONSTCOND*/0); #define FSTEST_CONSTRUCTOR_FSPRIV(_tc_, _fs_, _args_, _privargs_) \ do { \ if (_fs_##_fstest_newfs(_tc_, &_args_, \ FSTEST_IMGNAME, FSTEST_IMGSIZE, _privargs_) != 0) \ atf_tc_fail_errno("newfs failed"); \ if (_fs_##_fstest_mount(_tc_, _args_, FSTEST_MNTNAME, 0) != 0) \ atf_tc_fail_errno("mount failed"); \ } while (/*CONSTCOND*/0); #define FSTEST_DESTRUCTOR(_tc_, _fs_, _args_) \ do { \ if (_fs_##_fstest_unmount(_tc_, FSTEST_MNTNAME, 0) != 0) { \ rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); \ atf_tc_fail_errno("unmount failed"); \ } \ if (_fs_##_fstest_delfs(_tc_, _args_) != 0) \ atf_tc_fail_errno("delfs failed"); \ } while (/*CONSTCOND*/0); #define ATF_TC_FSADD(fs,type,func,desc) \ ATF_TC(fs##_##func); \ ATF_TC_HEAD(fs##_##func,tc) \ { \ atf_tc_set_md_var(tc, "descr", type " test for " desc); \ atf_tc_set_md_var(tc, "X-fs.type", #fs); \ atf_tc_set_md_var(tc, "X-fs.mntname", type); \ } \ void *fs##func##tmp; \ \ ATF_TC_BODY(fs##_##func,tc) \ { \ if (!atf_check_fstype(tc, #fs)) \ atf_tc_skip("filesystem not selected"); \ FSTEST_CONSTRUCTOR(tc,fs,fs##func##tmp); \ func(tc,FSTEST_MNTNAME); \ if (fs##_fstest_unmount(tc, FSTEST_MNTNAME, 0) != 0) { \ rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); \ atf_tc_fail_errno("unmount failed"); \ } \ } #define ATF_TC_FSADD_RO(_fs_,_type_,_func_,_desc_,_gen_) \ ATF_TC(_fs_##_##_func_); \ ATF_TC_HEAD(_fs_##_##_func_,tc) \ { \ atf_tc_set_md_var(tc, "descr",_type_" test for "_desc_);\ atf_tc_set_md_var(tc, "X-fs.type", #_fs_); \ atf_tc_set_md_var(tc, "X-fs.mntname", _type_); \ } \ void *_fs_##_func_##tmp; \ \ ATF_TC_BODY(_fs_##_##_func_,tc) \ { \ if (!atf_check_fstype(tc, #_fs_)) \ atf_tc_skip("filesystem not selected"); \ FSTEST_CONSTRUCTOR(tc,_fs_,_fs_##_func_##tmp); \ _gen_(tc,FSTEST_MNTNAME); \ if (_fs_##_fstest_unmount(tc, FSTEST_MNTNAME, 0) != 0) \ atf_tc_fail_errno("unmount r/w failed"); \ if (_fs_##_fstest_mount(tc, _fs_##_func_##tmp, \ FSTEST_MNTNAME, MNT_RDONLY) != 0) \ atf_tc_fail_errno("mount ro failed"); \ _func_(tc,FSTEST_MNTNAME); \ if (_fs_##_fstest_unmount(tc, FSTEST_MNTNAME, 0) != 0) {\ rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); \ atf_tc_fail_errno("unmount failed"); \ } \ } #define ATF_TP_FSADD(fs,func) \ ATF_TP_ADD_TC(tp,fs##_##func) #define ATF_TC_FSAPPLY_NOZFS(func,desc) \ ATF_TC_FSADD(ext2fs,MOUNT_EXT2FS,func,desc) \ ATF_TC_FSADD(ffs,MOUNT_FFS,func,desc) \ ATF_TC_FSADD(ffslog,MOUNT_FFS,func,desc) \ ATF_TC_FSADD(lfs,MOUNT_LFS,func,desc) \ ATF_TC_FSADD(msdosfs,MOUNT_MSDOS,func,desc) \ ATF_TC_FSADD(nfs,MOUNT_NFS,func,desc) \ ATF_TC_FSADD(puffs,MOUNT_PUFFS,func,desc) \ ATF_TC_FSADD(p2k_ffs,MOUNT_PUFFS,func,desc) \ ATF_TC_FSADD(rumpfs,MOUNT_RUMPFS,func,desc) \ ATF_TC_FSADD(sysvbfs,MOUNT_SYSVBFS,func,desc) \ ATF_TC_FSADD(tmpfs,MOUNT_TMPFS,func,desc) \ ATF_TC_FSADD(udf,MOUNT_UDF,func,desc) \ ATF_TC_FSADD(v7fs,MOUNT_V7FS,func,desc) #define ATF_TP_FSAPPLY_NOZFS(func) \ ATF_TP_FSADD(ext2fs,func); \ ATF_TP_FSADD(ffs,func); \ ATF_TP_FSADD(ffslog,func); \ ATF_TP_FSADD(lfs,func); \ ATF_TP_FSADD(msdosfs,func); \ ATF_TP_FSADD(nfs,func); \ ATF_TP_FSADD(puffs,func); \ ATF_TP_FSADD(p2k_ffs,func); \ ATF_TP_FSADD(rumpfs,func); \ ATF_TP_FSADD(sysvbfs,func); \ ATF_TP_FSADD(tmpfs,func); \ ATF_TP_FSADD(udf,func); \ ATF_TP_FSADD(v7fs,func); /* XXX: this will not scale */ #ifdef WANT_ZFS_TESTS #define ATF_TC_FSAPPLY(func,desc) \ ATF_TC_FSAPPLY_NOZFS(func,desc) \ ATF_TC_FSADD(zfs,MOUNT_ZFS,func,desc) #define ATF_TP_FSAPPLY(func) \ ATF_TP_FSAPPLY_NOZFS(func) \ ATF_TP_FSADD(zfs,func); #else /* !WANT_ZFS_TESTS */ #define ATF_TC_FSAPPLY(func,desc) \ ATF_TC_FSAPPLY_NOZFS(func,desc) #define ATF_TP_FSAPPLY(func) \ ATF_TP_FSAPPLY_NOZFS(func) #endif /* WANT_ZFS_TESTS */ /* * Same as above, but generate a file system image first and perform * tests for a r/o mount. * * Missing the following file systems: * + lfs (fstest_lfs routines cannot handle remount. FIXME!) * + tmpfs (memory backend) * + rumpfs (memory backend) * + puffs (memory backend, but could be run in theory) */ #define ATF_TC_FSAPPLY_RO(func,desc,gen) \ ATF_TC_FSADD_RO(ext2fs,MOUNT_EXT2FS,func,desc,gen) \ ATF_TC_FSADD_RO(ffs,MOUNT_FFS,func,desc,gen) \ ATF_TC_FSADD_RO(ffslog,MOUNT_FFS,func,desc,gen) \ ATF_TC_FSADD_RO(msdosfs,MOUNT_MSDOS,func,desc,gen) \ ATF_TC_FSADD_RO(nfs,MOUNT_NFS,func,desc,gen) \ ATF_TC_FSADD_RO(nfsro,MOUNT_NFS,func,desc,gen) \ ATF_TC_FSADD_RO(sysvbfs,MOUNT_SYSVBFS,func,desc,gen) \ ATF_TC_FSADD_RO(udf,MOUNT_UDF,func,desc,gen) \ ATF_TC_FSADD_RO(v7fs,MOUNT_V7FS,func,desc,gen) #define ATF_TP_FSAPPLY_RO(func) \ ATF_TP_FSADD(ext2fs,func); \ ATF_TP_FSADD(ffs,func); \ ATF_TP_FSADD(ffslog,func); \ ATF_TP_FSADD(msdosfs,func); \ ATF_TP_FSADD(nfs,func); \ ATF_TP_FSADD(nfsro,func); \ ATF_TP_FSADD(sysvbfs,func); \ ATF_TP_FSADD(udf,func); \ ATF_TP_FSADD(v7fs,func); #define ATF_FSAPPLY(func,desc) \ ATF_TC_FSAPPLY(func,desc); \ ATF_TP_ADD_TCS(tp) \ { \ ATF_TP_FSAPPLY(func); \ return atf_no_error(); \ } static __inline bool atf_check_fstype(const atf_tc_t *tc, const char *fs) { const char *fstype; if (!atf_tc_has_config_var(tc, "fstype")) return true; fstype = atf_tc_get_config_var(tc, "fstype"); if (strcmp(fstype, fs) == 0) return true; return false; } #define FSTYPE_EXT2FS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "ext2fs") == 0) #define FSTYPE_FFS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "ffs") == 0) #define FSTYPE_FFSLOG(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "ffslog") == 0) #define FSTYPE_LFS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "lfs") == 0) #define FSTYPE_MSDOS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "msdosfs") == 0) #define FSTYPE_NFS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "nfs") == 0) #define FSTYPE_NFSRO(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "nfsro") == 0) #define FSTYPE_P2K_FFS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "p2k_ffs") == 0) #define FSTYPE_PUFFS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "puffs") == 0) #define FSTYPE_RUMPFS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "rumpfs") == 0) #define FSTYPE_SYSVBFS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "sysvbfs") == 0) #define FSTYPE_TMPFS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "tmpfs") == 0) #define FSTYPE_UDF(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "udf") == 0) #define FSTYPE_V7FS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "v7fs") == 0) #define FSTYPE_ZFS(tc)\ (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "zfs") == 0) #define FSTEST_ENTER() \ if (rump_sys_chdir(FSTEST_MNTNAME) == -1) \ atf_tc_fail_errno("failed to cd into test mount") #define FSTEST_EXIT() \ if (rump_sys_chdir("/") == -1) \ atf_tc_fail_errno("failed to cd out of test mount") /* * file system args structures */ struct nfstestargs { pid_t ta_childpid; char ta_ethername[MAXPATHLEN]; }; struct puffstestargs { uint8_t *pta_pargs; size_t pta_pargslen; int pta_pflags; pid_t pta_childpid; int pta_rumpfd; int pta_servfd; char pta_dev[MAXPATHLEN]; char pta_dir[MAXPATHLEN]; int pta_mntflags; int pta_vfs_toserv_ops[PUFFS_VFS_MAX]; int pta_vn_toserv_ops[PUFFS_VN_MAX]; }; #endif /* __H_FSMACROS_H_ */ Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c (revision 312126) @@ -1,468 +1,468 @@ -/* $NetBSD: h_quota2_tests.c,v 1.4 2012/09/30 21:26:57 bouyer Exp $ */ +/* $NetBSD: h_quota2_tests.c,v 1.5 2017/01/13 21:30:39 christos Exp $ */ /* * rump server for advanced quota tests * this one includes functions to run against the filesystem before * starting to handle rump requests from clients. */ #include "../common/h_fsmacros.h" #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" int background = 0; #define TEST_NONROOT_ID 1 static int quota_test0(const char *testopts) { static char buf[512]; int fd; int error; unsigned int i; int chowner = 1; for (i =0; testopts && i < strlen(testopts); i++) { switch(testopts[i]) { case 'C': chowner = 0; break; default: errx(1, "test4: unknown option %c", testopts[i]); } } if (chowner) rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); rump_sys_chmod(".", 0777); if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { error = errno; warn("rump_sys_setegid"); return error; } if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { error = errno; warn("rump_sys_seteuid"); return error; } fd = rump_sys_open("test_fillup", O_CREAT | O_RDWR, 0644); if (fd < 0) { error = errno; warn("rump_sys_open"); } else { while (rump_sys_write(fd, buf, sizeof(buf)) == sizeof(buf)) error = 0; error = errno; } rump_sys_close(fd); rump_sys_seteuid(0); rump_sys_setegid(0); return error; } static int quota_test1(const char *testopts) { static char buf[512]; int fd; int error; rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); rump_sys_chmod(".", 0777); if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { error = errno; warn("rump_sys_setegid"); return error; } if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { error = errno; warn("rump_sys_seteuid"); return error; } fd = rump_sys_open("test_fillup", O_CREAT | O_RDWR, 0644); if (fd < 0) { error = errno; warn("rump_sys_open"); } else { /* * write up to the soft limit, wait a bit, an try to * keep on writing */ int i; /* write 2k: with the directory this makes 2.5K */ for (i = 0; i < 4; i++) { error = rump_sys_write(fd, buf, sizeof(buf)); if (error != sizeof(buf)) err(1, "write failed early"); } sleep(2); /* now try to write an extra .5k */ if (rump_sys_write(fd, buf, sizeof(buf)) != sizeof(buf)) error = errno; else error = 0; } rump_sys_close(fd); rump_sys_seteuid(0); rump_sys_setegid(0); return error; } static int quota_test2(const char *testopts) { static char buf[512]; int fd; int error; int i; rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); rump_sys_chmod(".", 0777); if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { error = errno; warn("rump_sys_setegid"); return error; } if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { error = errno; warn("rump_sys_seteuid"); return error; } for (i = 0; ; i++) { sprintf(buf, "file%d", i); fd = rump_sys_open(buf, O_CREAT | O_RDWR, 0644); if (fd < 0) break; sprintf(buf, "test file no %d", i); rump_sys_write(fd, buf, strlen(buf)); rump_sys_close(fd); } error = errno; rump_sys_close(fd); rump_sys_seteuid(0); rump_sys_setegid(0); return error; } static int quota_test3(const char *testopts) { static char buf[512]; int fd; int error; int i; rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); rump_sys_chmod(".", 0777); if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { error = errno; warn("rump_sys_setegid"); return error; } if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { error = errno; warn("rump_sys_seteuid"); return error; } /* * create files one past the soft limit: one less as we already own the * root directory */ for (i = 0; i < 4; i++) { sprintf(buf, "file%d", i); fd = rump_sys_open(buf, O_EXCL| O_CREAT | O_RDWR, 0644); if (fd < 0) err(1, "file create failed early"); sprintf(buf, "test file no %d", i); rump_sys_write(fd, buf, strlen(buf)); rump_sys_close(fd); } /* now create an extra file after grace time: this should fail */ sleep(2); sprintf(buf, "file%d", i); fd = rump_sys_open(buf, O_EXCL| O_CREAT | O_RDWR, 0644); if (fd < 0) error = errno; else error = 0; rump_sys_close(fd); rump_sys_seteuid(0); rump_sys_setegid(0); return error; } static int quota_test4(const char *testopts) { static char buf[512]; int fd, fssfd; struct fss_set fss; unsigned int i; int unl=0; int unconf=0; /* * take an internal snapshot of the filesystem, and create a new * file with some data */ rump_sys_chown(".", 0, 0); rump_sys_chmod(".", 0777); for (i =0; testopts && i < strlen(testopts); i++) { switch(testopts[i]) { case 'L': unl++; break; case 'C': unconf++; break; default: errx(1, "test4: unknown option %c", testopts[i]); } } /* first create the snapshot */ fd = rump_sys_open(FSTEST_MNTNAME "/le_snap", O_CREAT | O_RDWR, 0777); if (fd == -1) err(1, "create " FSTEST_MNTNAME "/le_snap"); rump_sys_close(fd); fssfd = rump_sys_open("/dev/rfss0", O_RDWR); if (fssfd == -1) err(1, "cannot open fss"); memset(&fss, 0, sizeof(fss)); fss.fss_mount = __UNCONST("/mnt"); fss.fss_bstore = __UNCONST(FSTEST_MNTNAME "/le_snap"); fss.fss_csize = 0; if (rump_sys_ioctl(fssfd, FSSIOCSET, &fss) == -1) err(1, "create snapshot"); if (unl) { if (rump_sys_unlink(FSTEST_MNTNAME "/le_snap") == -1) err(1, "unlink snapshot"); } /* now create some extra files */ for (i = 0; i < 4; i++) { sprintf(buf, "file%d", i); fd = rump_sys_open(buf, O_EXCL| O_CREAT | O_RDWR, 0644); if (fd < 0) err(1, "create %s", buf); sprintf(buf, "test file no %d", i); rump_sys_write(fd, buf, strlen(buf)); rump_sys_close(fd); } if (unconf) if (rump_sys_ioctl(fssfd, FSSIOCCLR, NULL) == -1) err(1, "unconfigure snapshot"); return 0; } static int quota_test5(const char *testopts) { static char buf[512]; int fd; int remount = 0; int unlnk = 0; int log = 0; unsigned int i; for (i =0; testopts && i < strlen(testopts); i++) { switch(testopts[i]) { case 'L': log++; break; case 'R': remount++; break; case 'U': unlnk++; break; default: errx(1, "test4: unknown option %c", testopts[i]); } } if (remount) { struct ufs_args uargs; uargs.fspec = __UNCONST("/diskdev"); /* remount the fs read/write */ if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, MNT_UPDATE | (log ? MNT_LOG : 0), &uargs, sizeof(uargs)) == -1) err(1, "mount ffs rw %s", FSTEST_MNTNAME); } if (unlnk) { /* * open and unlink a file */ fd = rump_sys_open("unlinked_file", O_EXCL| O_CREAT | O_RDWR, 0644); if (fd < 0) err(1, "create %s", "unlinked_file"); sprintf(buf, "test unlinked_file"); rump_sys_write(fd, buf, strlen(buf)); if (rump_sys_unlink("unlinked_file") == -1) err(1, "unlink unlinked_file"); if (rump_sys_fsync(fd) == -1) err(1, "fsync unlinked_file"); rump_sys_reboot(RUMP_RB_NOSYNC, NULL); errx(1, "reboot failed"); return 1; } return 0; } struct quota_test { int (*func)(const char *); const char *desc; }; struct quota_test quota_tests[] = { { quota_test0, "write up to hard limit"}, { quota_test1, "write beyond the soft limit after grace time"}, { quota_test2, "create file up to hard limit"}, { quota_test3, "create file beyond the soft limit after grace time"}, { quota_test4, "take a snapshot and add some data"}, { quota_test5, "open and unlink a file"}, }; static void usage(void) { unsigned int test; fprintf(stderr, "usage: %s [-b] [-l] test# diskimage bindurl\n", getprogname()); fprintf(stderr, "available tests:\n"); for (test = 0; test < sizeof(quota_tests) / sizeof(quota_tests[0]); test++) fprintf(stderr, "\t%d: %s\n", test, quota_tests[test].desc); exit(1); } static void die(const char *reason, int error) { warnx("%s: %s", reason, strerror(error)); if (background) rump_daemonize_done(error); exit(1); } static sem_t sigsem; static void sigreboot(int sig) { sem_post(&sigsem); } int main(int argc, char **argv) { int error; u_long test; char *end; struct ufs_args uargs; const char *filename; const char *serverurl; const char *topts = NULL; int mntopts = 0; int ch; while ((ch = getopt(argc, argv, "blo:r")) != -1) { switch(ch) { case 'b': background = 1; break; case 'l': mntopts |= MNT_LOG; break; case 'r': mntopts |= MNT_RDONLY; break; case 'o': topts = optarg; break; default: usage(); } } argc -= optind; argv += optind; if (argc != 3) usage(); filename = argv[1]; serverurl = argv[2]; test = strtoul(argv[0], &end, 10); if (*end != '\0') { usage(); } if (test > sizeof(quota_tests) / sizeof(quota_tests[0])) { usage(); } if (background) { error = rump_daemonize_begin(); if (error) errx(1, "rump daemonize: %s", strerror(error)); } error = rump_init(); if (error) die("rump init failed", error); if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1) err(1, "mount point create"); rump_pub_etfs_register("/diskdev", filename, RUMP_ETFS_BLK); uargs.fspec = __UNCONST("/diskdev"); if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, mntopts, &uargs, sizeof(uargs)) == -1) die("mount ffs", errno); if (rump_sys_chdir(FSTEST_MNTNAME) == -1) err(1, "cd %s", FSTEST_MNTNAME); error = quota_tests[test].func(topts); if (error) { fprintf(stderr, " test %lu: %s returned %d: %s\n", test, quota_tests[test].desc, error, strerror(error)); } if (rump_sys_chdir("/") == -1) err(1, "cd /"); error = rump_init_server(serverurl); if (error) die("rump server init failed", error); if (background) rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS); sem_init(&sigsem, 0, 0); signal(SIGTERM, sigreboot); signal(SIGINT, sigreboot); sem_wait(&sigsem); rump_sys_reboot(0, NULL); /*NOTREACHED*/ return 0; } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_fifos.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_fifos.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_fifos.c (revision 312126) @@ -1,158 +1,158 @@ -/* $NetBSD: t_fifos.c,v 1.5 2010/11/07 17:51:17 jmmv Exp $ */ +/* $NetBSD: t_fifos.c,v 1.6 2017/01/13 21:30:39 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC_WITH_CLEANUP(fifos); ATF_TC_HEAD(fifos, tc) { atf_tc_set_md_var(tc, "descr", "test fifo support in ffs"); atf_tc_set_md_var(tc, "timeout", "5"); } #define teststr1 "raving & drooling" #define teststr2 "haha, charade" static void * w1(void *arg) { int fd; fd = rump_sys_open("sheep", O_WRONLY); if (fd == -1) atf_tc_fail_errno("w1 open"); if (rump_sys_write(fd, teststr1, sizeof(teststr1)) != sizeof(teststr1)) atf_tc_fail_errno("w1 write"); rump_sys_close(fd); return NULL; } static void * w2(void *arg) { int fd; fd = rump_sys_open("pigs", O_WRONLY); if (fd == -1) atf_tc_fail_errno("w2 open"); if (rump_sys_write(fd, teststr2, sizeof(teststr2)) != sizeof(teststr2)) atf_tc_fail_errno("w2 write"); rump_sys_close(fd); return NULL; } static void * r1(void *arg) { char buf[32]; int fd; fd = rump_sys_open("sheep", O_RDONLY); if (fd == -1) atf_tc_fail_errno("r1 open"); if (rump_sys_read(fd, buf, sizeof(buf)) != sizeof(teststr1)) atf_tc_fail_errno("r1 read"); rump_sys_close(fd); if (strcmp(teststr1, buf) != 0) atf_tc_fail("got invalid str, %s vs. %s", buf, teststr1); return NULL; } static void * r2(void *arg) { char buf[32]; int fd; fd = rump_sys_open("pigs", O_RDONLY); if (fd == -1) atf_tc_fail_errno("r2 open"); if (rump_sys_read(fd, buf, sizeof(buf)) != sizeof(teststr2)) atf_tc_fail_errno("r2 read"); rump_sys_close(fd); if (strcmp(teststr2, buf) != 0) atf_tc_fail("got invalid str, %s vs. %s", buf, teststr2); return NULL; } #define IMGNAME "atf.img" const char *newfs = "newfs -F -s 10000 " IMGNAME; #define FAKEBLK "/dev/sp00ka" ATF_TC_BODY(fifos, tc) { struct ufs_args args; pthread_t ptw1, ptw2, ptr1, ptr2; if (system(newfs) == -1) atf_tc_fail_errno("newfs failed"); memset(&args, 0, sizeof(args)); args.fspec = __UNCONST(FAKEBLK); rump_init(); if (rump_sys_mkdir("/animals", 0777) == -1) atf_tc_fail_errno("cannot create mountpoint"); rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK); if (rump_sys_mount(MOUNT_FFS, "/animals", 0, &args, sizeof(args))==-1) atf_tc_fail_errno("rump_sys_mount failed"); /* create fifos */ if (rump_sys_chdir("/animals") == 1) atf_tc_fail_errno("chdir"); if (rump_sys_mkfifo("pigs", S_IFIFO | 0777) == -1) atf_tc_fail_errno("mknod1"); if (rump_sys_mkfifo("sheep", S_IFIFO | 0777) == -1) atf_tc_fail_errno("mknod2"); pthread_create(&ptw1, NULL, w1, NULL); pthread_create(&ptw2, NULL, w2, NULL); pthread_create(&ptr1, NULL, r1, NULL); pthread_create(&ptr2, NULL, r2, NULL); pthread_join(ptw1, NULL); pthread_join(ptw2, NULL); pthread_join(ptr1, NULL); pthread_join(ptr2, NULL); if (rump_sys_chdir("/") == 1) atf_tc_fail_errno("chdir"); if (rump_sys_unmount("/animals", 0) == -1) atf_tc_fail_errno("unmount failed"); } ATF_TC_CLEANUP(fifos, tc) { unlink(IMGNAME); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fifos); return 0; } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_mount.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_mount.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_mount.c (revision 312126) @@ -1,138 +1,138 @@ -/* $NetBSD: t_mount.c,v 1.13 2012/11/27 16:01:49 jakllsch Exp $ */ +/* $NetBSD: t_mount.c,v 1.14 2017/01/13 21:30:39 christos Exp $ */ /* * Basic tests for mounting */ /* * 48Kimage: * Adapted for rump and atf from a testcase supplied * by Hubert Feyrer on netbsd-users@ */ #include #define FSTEST_IMGSIZE (96 * 512) #include "../common/h_fsmacros.h" #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(48Kimage); ATF_TC_HEAD(48Kimage, tc) { atf_tc_set_md_var(tc, "descr", "mount small 48K ffs image"); } ATF_TC_BODY(48Kimage, tc) { void *tmp; atf_tc_expect_fail("PR kern/43573"); FSTEST_CONSTRUCTOR(tc, ffs, tmp); atf_tc_expect_pass(); FSTEST_DESTRUCTOR(tc, ffs, tmp); } ATF_TC(fsbsizeovermaxphys); ATF_TC_HEAD(fsbsizeovermaxphys, tc) { atf_tc_set_md_var(tc, "descr", "mounts file system with " "blocksize > MAXPHYS"); /* PR kern/43727 */ } ATF_TC_BODY(fsbsizeovermaxphys, tc) { char cmd[1024]; struct ufs_args args; struct statvfs svb; /* * We cannot pass newfs parameters via the fstest interface, * so do things the oldfashioned manual way. */ snprintf(cmd, sizeof(cmd), "newfs -G -b %d -F -s 10000 " "ffs.img > /dev/null", MAXPHYS * 2); if (system(cmd)) atf_tc_fail("cannot create file system"); rump_init(); if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK)) atf_tc_fail("cannot register rump fake device"); args.fspec = __UNCONST("/devdisk"); if (rump_sys_mkdir("/mp", 0777) == -1) atf_tc_fail_errno("create mountpoint"); /* mount succeeded? bad omen. confirm we're in trouble. */ if (rump_sys_mount(MOUNT_FFS, "/mp", 0, &args, sizeof(args)) != -1) { rump_sys_statvfs1("/mp", &svb, ST_WAIT); atf_tc_fail("not expecting to be alive"); } /* otherwise we're do-ne */ } ATF_TC(fsbsizeovermaxbsize); ATF_TC_HEAD(fsbsizeovermaxbsize, tc) { atf_tc_set_md_var(tc, "descr", "mounts file system with " "blocksize > MAXBSIZE"); } ATF_TC_BODY(fsbsizeovermaxbsize, tc) { char cmd[1024]; struct ufs_args args; struct statvfs svb; /* * We cannot pass newfs parameters via the fstest interface, * so do things the oldfashioned manual way. */ snprintf(cmd, sizeof(cmd), "newfs -G -b %d -F -s 10000 " "ffs.img > /dev/null", MAXBSIZE * 2); if (system(cmd)) atf_tc_fail("cannot create file system"); rump_init(); if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK)) atf_tc_fail("cannot register rump fake device"); args.fspec = __UNCONST("/devdisk"); if (rump_sys_mkdir("/mp", 0777) == -1) atf_tc_fail_errno("create mountpoint"); /* mount succeeded? bad omen. confirm we're in trouble. */ if (rump_sys_mount(MOUNT_FFS, "/mp", 0, &args, sizeof(args)) != -1) { rump_sys_statvfs1("/mp", &svb, ST_WAIT); atf_tc_fail("not expecting to be alive"); } /* otherwise we're do-ne */ } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, 48Kimage); ATF_TP_ADD_TC(tp, fsbsizeovermaxphys); ATF_TP_ADD_TC(tp, fsbsizeovermaxbsize); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_quota2_1.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_quota2_1.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_quota2_1.c (revision 312126) @@ -1,114 +1,114 @@ -/* $NetBSD: t_quota2_1.c,v 1.4 2012/03/15 02:02:22 joerg Exp $ */ +/* $NetBSD: t_quota2_1.c,v 1.5 2017/01/13 21:30:39 christos Exp $ */ /* * Basic tests for quota2 */ #include #include "../common/h_fsmacros.h" #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" static void do_quota(const atf_tc_t *tc, int n, const char *newfs_opts, int log) { int i; char buf[1024]; int res; int fd; struct ufs_args uargs; snprintf(buf, sizeof(buf), "newfs -q user -q group -F -s 4000 -n %d " "%s %s", (n + 3), newfs_opts, FSTEST_IMGNAME); if (system(buf) == -1) atf_tc_fail_errno("cannot create file system"); rump_init(); if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1) atf_tc_fail_errno("mount point create"); rump_pub_etfs_register("/diskdev", FSTEST_IMGNAME, RUMP_ETFS_BLK); uargs.fspec = __UNCONST("/diskdev"); if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, (log) ? MNT_LOG : 0, &uargs, sizeof(uargs)) == -1) atf_tc_fail_errno("mount ffs %s", FSTEST_MNTNAME); atf_tc_expect_pass(); FSTEST_ENTER(); RL(rump_sys_chown(".", 0, 0)); for (i = 0 ; i < n; i++) { sprintf(buf, "file%d", i); RL(fd = rump_sys_open(buf, O_CREAT | O_RDWR, 0755)); sprintf(buf, "test file no %d", i); RL(rump_sys_write(fd, buf, strlen(buf))); RL(rump_sys_fchown(fd, i, i+80000)); rump_sys_close(fd); } FSTEST_EXIT(); if (rump_sys_unmount(FSTEST_MNTNAME, 0) != 0) { rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); atf_tc_fail_errno("unmount failed"); } snprintf(buf, 1024, "fsck_ffs -fn -F %s", FSTEST_IMGNAME); res = system(buf); if (res != 0) atf_tc_fail("fsck returned %d", res); } #define DECL_TEST(nent, newops, name, descr, log) \ ATF_TC(quota_##name); \ \ ATF_TC_HEAD(quota_##name, tc) \ { \ atf_tc_set_md_var(tc, "descr", \ "test quotas with %d users and groups, %s", \ nent, descr); \ } \ \ ATF_TC_BODY(quota_##name, tc) \ { \ do_quota(tc, nent, newops, log); \ } DECL_TEST(40, "-O1 -B le", 40_O1_le, "UFS1 little-endian", 0) DECL_TEST(40, "-O1 -B be", 40_O1_be, "UFS1 big-endian", 0) DECL_TEST(40, "-O2 -B le", 40_O2_le, "UFS2 little-endian", 0) DECL_TEST(40, "-O2 -B be", 40_O2_be, "UFS2 big-endian", 0) DECL_TEST(40, "-O1", 40_O1_log, "UFS1 log", 1) DECL_TEST(40, "-O2", 40_O2_log, "UFS2 log", 1) DECL_TEST(1000, "-O1 -B le", 1000_O1_le, "UFS1 little-endian", 0) DECL_TEST(1000, "-O1 -B be", 1000_O1_be, "UFS1 big-endian", 0) DECL_TEST(1000, "-O2 -B le", 1000_O2_le, "UFS2 little-endian", 0) DECL_TEST(1000, "-O2 -B be", 1000_O2_be, "UFS2 big-endian", 0) ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, quota_40_O1_le); ATF_TP_ADD_TC(tp, quota_40_O1_be); ATF_TP_ADD_TC(tp, quota_40_O2_le); ATF_TP_ADD_TC(tp, quota_40_O2_be); ATF_TP_ADD_TC(tp, quota_40_O1_log); ATF_TP_ADD_TC(tp, quota_40_O2_log); ATF_TP_ADD_TC(tp, quota_1000_O1_le); ATF_TP_ADD_TC(tp, quota_1000_O1_be); ATF_TP_ADD_TC(tp, quota_1000_O2_le); ATF_TP_ADD_TC(tp, quota_1000_O2_be); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c (revision 312126) @@ -1,139 +1,139 @@ -/* $NetBSD: t_quota2_remount.c,v 1.4 2012/03/15 02:02:22 joerg Exp $ */ +/* $NetBSD: t_quota2_remount.c,v 1.5 2017/01/13 21:30:39 christos Exp $ */ /* * Basic tests for quota2 */ #include #include "../common/h_fsmacros.h" #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" static void do_quota(const atf_tc_t *tc, int n, const char *newfs_opts, int log) { int i; char buf[1024]; int res; int fd; struct ufs_args uargs; struct statvfs fst; snprintf(buf, sizeof(buf), "newfs -q user -q group -F -s 4000 -n %d " "%s %s", (n + 3), newfs_opts, FSTEST_IMGNAME); if (system(buf) == -1) atf_tc_fail_errno("cannot create file system"); rump_init(); if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1) atf_tc_fail_errno("mount point create"); rump_pub_etfs_register("/diskdev", FSTEST_IMGNAME, RUMP_ETFS_BLK); uargs.fspec = __UNCONST("/diskdev"); /* read-only doens't have quota enabled */ if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, MNT_RDONLY, &uargs, sizeof(uargs)) == -1) atf_tc_fail_errno("mount ffs ro %s", FSTEST_MNTNAME); if (rump_sys_statvfs1(FSTEST_MNTNAME, &fst, 0) != 0) atf_tc_fail_errno("statbfs %s (1)", FSTEST_MNTNAME); if ((fst.f_flag & ST_QUOTA) != 0) atf_tc_fail("R/O filesystem has quota"); /* updating to read-write enables quota */ if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, MNT_UPDATE | (log ? MNT_LOG : 0), &uargs, sizeof(uargs)) == -1) atf_tc_fail_errno("mount ffs rw %s", FSTEST_MNTNAME); if (rump_sys_statvfs1(FSTEST_MNTNAME, &fst, 0) != 0) atf_tc_fail_errno("statbfs %s (2)", FSTEST_MNTNAME); if ((fst.f_flag & ST_QUOTA) == 0) atf_tc_fail("R/W filesystem has no quota"); /* we can update a second time */ if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, MNT_UPDATE | (log ? MNT_LOG : 0), &uargs, sizeof(uargs)) == -1) atf_tc_fail_errno("mount ffs rw(2) %s", FSTEST_MNTNAME); if (rump_sys_statvfs1(FSTEST_MNTNAME, &fst, 0) != 0) atf_tc_fail_errno("statbfs %s (3)", FSTEST_MNTNAME); if ((fst.f_flag & ST_QUOTA) == 0) atf_tc_fail("R/W filesystem has no quota"); /* create some files so fsck has something to check */ FSTEST_ENTER(); RL(rump_sys_chown(".", 0, 0)); for (i = 0 ; i < n; i++) { sprintf(buf, "file%d", i); RL(fd = rump_sys_open(buf, O_CREAT | O_RDWR, 0755)); sprintf(buf, "test file no %d", i); RL(rump_sys_write(fd, buf, strlen(buf))); RL(rump_sys_fchown(fd, i, i+80000)); rump_sys_close(fd); } FSTEST_EXIT(); if (rump_sys_unmount(FSTEST_MNTNAME, 0) != 0) { rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); atf_tc_fail_errno("unmount failed"); } snprintf(buf, 1024, "fsck_ffs -fn -F %s", FSTEST_IMGNAME); res = system(buf); if (res != 0) atf_tc_fail("fsck returned %d", res); } #define DECL_TEST(nent, newops, name, descr, log) \ ATF_TC(quota_##name); \ \ ATF_TC_HEAD(quota_##name, tc) \ { \ atf_tc_set_md_var(tc, "descr", \ "test filesystem remount with quotas, %s", descr); \ } \ \ ATF_TC_BODY(quota_##name, tc) \ { \ do_quota(tc, nent, newops, log); \ } DECL_TEST(10, "-O1 -B le", 10_O1_le, "UFS1 little-endian", 0) DECL_TEST(10, "-O1 -B be", 10_O1_be, "UFS1 big-endian", 0) #if 0 /* * this cause fsck to complain about summaries at the end. * This sems to be related to -o log (reproductible on a fs with no * quota enabled). not reproductible with a real kernel ... */ DECL_TEST(10, "-O1", 10_O1_log, "UFS1 log", 1) DECL_TEST(10, "-O2", 10_O2_log, "UFS2 log", 1) #endif ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, quota_10_O1_le); ATF_TP_ADD_TC(tp, quota_10_O1_be); #if 0 ATF_TP_ADD_TC(tp, quota_10_O1_log); ATF_TP_ADD_TC(tp, quota_10_O2_log); #endif return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_snapshot.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_snapshot.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_snapshot.c (revision 312126) @@ -1,43 +1,43 @@ -/* $NetBSD: t_snapshot.c,v 1.6 2013/02/06 09:05:01 hannken Exp $ */ +/* $NetBSD: t_snapshot.c,v 1.7 2017/01/13 21:30:39 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #define IMGNAME "ffs.img" #define NEWFS "newfs -F -s 10000 " IMGNAME #define FSCK "fsck_ffs -fn -F" #define BAKNAME "/mnt/le_snapp" static void mount_diskfs(const char *fspec, const char *path) { struct ufs_args uargs; uargs.fspec = __UNCONST(fspec); if (rump_sys_mount(MOUNT_FFS, path, 0, &uargs, sizeof(uargs)) == -1) atf_tc_fail_errno("mount ffs %s", path); } static void begin(void) { /* empty */ } #include "../common/snapshot.c" Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c (revision 312126) @@ -1,46 +1,46 @@ -/* $NetBSD: t_snapshot_log.c,v 1.2 2013/02/06 09:05:01 hannken Exp $ */ +/* $NetBSD: t_snapshot_log.c,v 1.3 2017/01/13 21:30:39 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #define IMGNAME "ffs.img" #define NEWFS "newfs -F -s 10000 " IMGNAME #define FSCK "fsck_ffs -fn -F" #define BAKNAME "/mnt/le_snapp" static void mount_diskfs(const char *fspec, const char *path) { struct ufs_args uargs; static int flags = MNT_LOG; uargs.fspec = __UNCONST(fspec); if (rump_sys_mount(MOUNT_FFS, path, flags, &uargs, sizeof(uargs)) == -1) atf_tc_fail_errno("mount ffs %s", path); flags = 0; } static void begin(void) { /* empty */ } #include "../common/snapshot.c" Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c (revision 312126) @@ -1,43 +1,43 @@ -/* $NetBSD: t_snapshot_v2.c,v 1.2 2013/02/06 09:05:01 hannken Exp $ */ +/* $NetBSD: t_snapshot_v2.c,v 1.3 2017/01/13 21:30:39 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #define IMGNAME "ffs.img" #define NEWFS "newfs -F -s 10000 -O 2 " IMGNAME #define FSCK "fsck_ffs -fn -F" #define BAKNAME "/mnt/le_snapp" static void mount_diskfs(const char *fspec, const char *path) { struct ufs_args uargs; uargs.fspec = __UNCONST(fspec); if (rump_sys_mount(MOUNT_FFS, path, 0, &uargs, sizeof(uargs)) == -1) atf_tc_fail_errno("mount ffs %s", path); } static void begin(void) { /* empty */ } #include "../common/snapshot.c" Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/hfs/t_pathconvert.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/hfs/t_pathconvert.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/hfs/t_pathconvert.c (revision 312126) @@ -1,83 +1,83 @@ -/* $NetBSD: t_pathconvert.c,v 1.5 2011/02/25 20:54:18 martin Exp $ */ +/* $NetBSD: t_pathconvert.c,v 1.6 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(colonslash); ATF_TC_HEAD(colonslash, tc) { atf_tc_set_md_var(tc, "descr", "HFS+ colons/slashes (PR kern/44523)"); atf_tc_set_md_var(tc, "timeout", "20"); } #define IMGNAME "colon.hfs" #define FAKEBLK "/dev/blk" #define FUNNY_FILENAME "foo:bar" ATF_TC_BODY(colonslash, tc) { struct hfs_args args; int dirfd, fd; char thecmd[1024]; char buf[DIRBLKSIZ]; struct dirent *dirent; int offset, nbytes; bool ok = false; snprintf(thecmd, sizeof(thecmd), "uudecode %s/colon.hfs.bz2.uue", atf_tc_get_config_var(tc, "srcdir")); RZ(system(thecmd)); snprintf(thecmd, sizeof(thecmd), "bunzip2 " IMGNAME ".bz2"); RZ(system(thecmd)); memset(&args, 0, sizeof args); args.fspec = __UNCONST(FAKEBLK); RZ(rump_init()); RL(rump_sys_mkdir("/mp", 0777)); RZ(rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK)); RL(rump_sys_mount(MOUNT_HFS, "/mp", 0, &args, sizeof args)); RL(dirfd = rump_sys_open("/mp", O_RDONLY)); RL(nbytes = rump_sys_getdents(dirfd, buf, sizeof buf)); for (offset = 0; offset < nbytes; offset += dirent->d_reclen) { dirent = (struct dirent *)(buf + offset); if (strchr(dirent->d_name, '/')) atf_tc_fail("dirent with slash: %s", dirent->d_name); if (0 == strcmp(FUNNY_FILENAME, dirent->d_name)) ok = true; } if (!ok) atf_tc_fail("no dirent for file: %s", FUNNY_FILENAME); RL(rump_sys_close(dirfd)); RL(fd = rump_sys_open("/mp/" FUNNY_FILENAME, O_RDONLY)); RL(rump_sys_close(fd)); RL(rump_sys_unmount("/mp", 0)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, colonslash); return 0; } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/kernfs/t_basic.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/kernfs/t_basic.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/kernfs/t_basic.c (revision 312126) @@ -1,133 +1,133 @@ -/* $NetBSD: t_basic.c,v 1.3 2010/05/31 23:44:54 pooka Exp $ */ +/* $NetBSD: t_basic.c,v 1.4 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(getdents); ATF_TC_HEAD(getdents, tc) { atf_tc_set_md_var(tc, "descr", "kernfs directory contains files"); } static void mountkernfs(void) { rump_init(); if (rump_sys_mkdir("/kern", 0777) == -1) atf_tc_fail_errno("mkdir /kern"); if (rump_sys_mount(MOUNT_KERNFS, "/kern", 0, NULL, 0) == -1) atf_tc_fail_errno("could not mount kernfs"); } ATF_TC_BODY(getdents, tc) { struct dirent *dent; char buf[8192]; int dfd; mountkernfs(); if ((dfd = rump_sys_open("/kern", O_RDONLY)) == -1) atf_tc_fail_errno("can't open directory"); if (rump_sys_getdents(dfd, buf, sizeof(buf)) == -1) atf_tc_fail_errno("getdents"); /* * Check that we get the first three values (., .., boottime). * Make more complete by autogenerating list from kernfs_vnops.c? */ dent = (void *)buf; ATF_REQUIRE_STREQ(dent->d_name, "."); dent = _DIRENT_NEXT(dent); ATF_REQUIRE_STREQ(dent->d_name, ".."); dent = _DIRENT_NEXT(dent); ATF_REQUIRE_STREQ(dent->d_name, "boottime"); /* done */ } ATF_TC(hostname); ATF_TC_HEAD(hostname, tc) { atf_tc_set_md_var(tc, "descr", "/kern/hostname changes hostname"); } static char * getthehost(void) { static char buf[8192]; int mib[2]; size_t blen; mib[0] = CTL_KERN; mib[1] = KERN_HOSTNAME; blen = sizeof(buf); if (rump_sys___sysctl(mib, 2, buf, &blen, NULL, 0) == -1) atf_tc_fail_errno("sysctl gethostname"); return buf; } #define NEWHOSTNAME "turboton roos-berg" ATF_TC_BODY(hostname, tc) { char buf[8192]; char *shost, *p; int fd; mountkernfs(); if ((fd = rump_sys_open("/kern/hostname", O_RDWR)) == -1) atf_tc_fail_errno("open hostname"); /* check initial match */ shost = getthehost(); buf[0] = '\0'; if (rump_sys_read(fd, buf, sizeof(buf)) == -1) atf_tc_fail_errno("read hostname"); p = strchr(buf, '\n'); if (p) *p = '\0'; ATF_REQUIRE_STREQ_MSG(buf, shost, "initial hostname mismatch"); /* check changing hostname works */ if (rump_sys_pwrite(fd, NEWHOSTNAME, strlen(NEWHOSTNAME), 0) != strlen(NEWHOSTNAME)) { atf_tc_fail_errno("write new hostname"); } shost = getthehost(); ATF_REQUIRE_STREQ_MSG(NEWHOSTNAME, shost, "modified hostname mismatch"); /* done */ } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, hostname); ATF_TP_ADD_TC(tp, getdents); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/lfs/t_pr.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/lfs/t_pr.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/lfs/t_pr.c (revision 312126) @@ -1,60 +1,60 @@ -/* $NetBSD: t_pr.c,v 1.6 2011/02/22 18:41:05 pooka Exp $ */ +/* $NetBSD: t_pr.c,v 1.7 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(mknod); ATF_TC_HEAD(mknod, tc) { atf_tc_set_md_var(tc, "descr", "mknod(2) hangs on LFS (PR kern/43503)"); atf_tc_set_md_var(tc, "timeout", "20"); } #define IMGNAME "disk.img" #define FAKEBLK "/dev/blk" ATF_TC_BODY(mknod, tc) { struct ufs_args args; /* hmm, maybe i should fix newfs_lfs instead? */ if (system("newfs_lfs -D -F -s 10000 ./" IMGNAME) == -1) atf_tc_fail_errno("newfs failed"); memset(&args, 0, sizeof(args)); args.fspec = __UNCONST(FAKEBLK); rump_init(); if (rump_sys_mkdir("/mp", 0777) == -1) atf_tc_fail_errno("cannot create mountpoint"); rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK); if (rump_sys_mount(MOUNT_LFS, "/mp", 0, &args, sizeof(args)) == -1) atf_tc_fail_errno("rump_sys_mount failed"); //atf_tc_expect_timeout("PR kern/43503"); if (rump_sys_mknod("/mp/node", S_IFCHR | 0777, 0) == -1) atf_tc_fail_errno("mknod failed"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, mknod); return 0; } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c (revision 312126) @@ -1,51 +1,51 @@ -/* $NetBSD: t_snapshot.c,v 1.3 2014/06/10 13:15:18 martin Exp $ */ +/* $NetBSD: t_snapshot.c,v 1.4 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #define IMGNAME "msdosfs.img" #define NEWFS "newfs_msdos -C 5M " IMGNAME #define FSCK "fsck_msdos -fn" #define BAKNAME "/stor/snap" static void mount_diskfs(const char *fspec, const char *path) { struct msdosfs_args margs; memset(&margs, 0, sizeof(margs)); margs.fspec = __UNCONST(fspec); margs.version = MSDOSFSMNT_VERSION; if (rump_sys_mount(MOUNT_MSDOS, path, 0, &margs, sizeof(margs)) == -1) err(1, "mount msdosfs %s", path); } static void begin(void) { struct tmpfs_args targs = { .ta_version = TMPFS_ARGS_VERSION, }; if (rump_sys_mkdir("/stor", 0777) == -1) atf_tc_fail_errno("mkdir /stor"); if (rump_sys_mount(MOUNT_TMPFS, "/stor", 0, &targs,sizeof(targs)) == -1) atf_tc_fail_errno("mount storage"); } #include "../common/snapshot.c" Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/nfs/t_mountd.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/nfs/t_mountd.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/nfs/t_mountd.c (revision 312126) @@ -1,121 +1,121 @@ -/* $NetBSD: t_mountd.c,v 1.5 2012/02/24 13:53:46 joerg Exp $ */ +/* $NetBSD: t_mountd.c,v 1.6 2017/01/13 21:30:40 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. * * 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 ``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. */ #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #include "../common/h_fsmacros.h" ATF_TC(mountdhup); ATF_TC_HEAD(mountdhup, tc) { atf_tc_set_md_var(tc, "descr", "test for service interrupt while " "mountd handles SIGHUP"); } static volatile int quit; static void * wrkwrkwrk(void *unused) { int fd, fail; fail = 0; rump_sys_chdir(FSTEST_MNTNAME); while (!quit) { fd = rump_sys_open("file", O_RDWR | O_CREAT); if (fd == -1) { if (errno == EACCES) { fail++; break; } } rump_sys_close(fd); if (rump_sys_unlink("file") == -1) { if (errno == EACCES) { fail++; break; } } } rump_sys_chdir("/"); quit = 1; return fail ? wrkwrkwrk : NULL; } ATF_TC_BODY(mountdhup, tc) { pthread_t pt; struct nfstestargs *nfsargs; void *voidargs; int attempts; void *fail; FSTEST_CONSTRUCTOR(tc, nfs, voidargs); nfsargs = voidargs; pthread_create(&pt, NULL, wrkwrkwrk, NULL); for (attempts = 100; attempts && !quit; attempts--) { usleep(100000); kill(nfsargs->ta_childpid, SIGHUP); } quit = 1; pthread_join(pt, &fail); FSTEST_DESTRUCTOR(tc, nfs, voidargs); atf_tc_expect_fail("PR kern/5844"); if (fail) atf_tc_fail("op failed with EACCES"); else atf_tc_fail("race did not trigger this time"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, mountdhup); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/nullfs/t_basic.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/nullfs/t_basic.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/nullfs/t_basic.c (revision 312126) @@ -1,174 +1,174 @@ -/* $NetBSD: t_basic.c,v 1.3 2010/06/09 08:37:16 pooka Exp $ */ +/* $NetBSD: t_basic.c,v 1.4 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(basic); ATF_TC_HEAD(basic, tc) { atf_tc_set_md_var(tc, "descr", "basic nullfs functionality"); } #define MSTR "magic bus" static void xput_tfile(const char *path, const char *mstr) { int fd; fd = rump_sys_open(path, O_CREAT | O_RDWR, 0777); if (fd == -1) atf_tc_fail_errno("create %s", path); if (rump_sys_write(fd, MSTR, sizeof(MSTR)) != sizeof(MSTR)) atf_tc_fail_errno("write to testfile"); rump_sys_close(fd); } static int xread_tfile(const char *path, const char *mstr) { char buf[128]; int fd; fd = rump_sys_open(path, O_RDONLY); if (fd == -1) return errno; if (rump_sys_read(fd, buf, sizeof(buf)) == -1) atf_tc_fail_errno("read tfile"); rump_sys_close(fd); if (strcmp(buf, MSTR) == 0) return 0; return EPROGMISMATCH; } static void mountnull(const char *what, const char *mp, int flags) { struct null_args nargs; memset(&nargs, 0, sizeof(nargs)); nargs.nulla_target = __UNCONST(what); if (rump_sys_mount(MOUNT_NULL, mp, flags, &nargs, sizeof(nargs)) == -1) atf_tc_fail_errno("could not mount nullfs"); } ATF_TC_BODY(basic, tc) { struct tmpfs_args targs; struct stat sb; int error; rump_init(); if (rump_sys_mkdir("/td1", 0777) == -1) atf_tc_fail_errno("mp1"); if (rump_sys_mkdir("/td2", 0777) == -1) atf_tc_fail_errno("mp1"); /* use tmpfs because rumpfs doesn't support regular files */ memset(&targs, 0, sizeof(targs)); targs.ta_version = TMPFS_ARGS_VERSION; targs.ta_root_mode = 0777; if (rump_sys_mount(MOUNT_TMPFS, "/td1", 0, &targs, sizeof(targs)) == -1) atf_tc_fail_errno("could not mount tmpfs td1"); mountnull("/td1", "/td2", 0); /* test unnull -> null */ xput_tfile("/td1/tensti", "jeppe"); error = xread_tfile("/td2/tensti", "jeppe"); if (error != 0) atf_tc_fail("null compare failed: %d (%s)", error, strerror(error)); /* test null -> unnull */ xput_tfile("/td2/kiekko", "keppi"); error = xread_tfile("/td1/kiekko", "keppi"); if (error != 0) atf_tc_fail("unnull compare failed: %d (%s)", error, strerror(error)); /* test unnull -> null overwrite */ xput_tfile("/td1/tensti", "se oolannin sota"); error = xread_tfile("/td2/tensti", "se oolannin sota"); if (error != 0) atf_tc_fail("unnull compare failed: %d (%s)", error, strerror(error)); /* test that /td2 is unaffected in "real life" */ if (rump_sys_unmount("/td2", 0) == -1) atf_tc_fail_errno("cannot unmount nullfs"); if ((error = rump_sys_stat("/td2/tensti", &sb)) != -1 || errno != ENOENT) { atf_tc_fail("stat tensti should return ENOENT, got %d", error); } if ((error = rump_sys_stat("/td2/kiekko", &sb)) != -1 || errno != ENOENT) { atf_tc_fail("stat kiekko should return ENOENT, got %d", error); } /* done */ } ATF_TC(twistymount); ATF_TC_HEAD(twistymount, tc) { /* this is expected to fail until the PR is fixed */ atf_tc_set_md_var(tc, "descr", "\"recursive\" mounts deadlock" " (kern/43439)"); } /* * Mapping to identifiers in kern/43439: * /td = /home/current/pkgsrc * /td/dist = /home/current/pkgsrc/distiles * /mp = /usr/pkgsrc * /mp/dist = /usr/pkgsrc/distfiles -- "created" by first null mount */ ATF_TC_BODY(twistymount, tc) { int mkd = 0; rump_init(); if (rump_sys_mkdir("/td", 0777) == -1) atf_tc_fail_errno("mkdir %d", mkd++); if (rump_sys_mkdir("/td/dist", 0777) == -1) atf_tc_fail_errno("mkdir %d", mkd++); if (rump_sys_mkdir("/mp", 0777) == -1) atf_tc_fail_errno("mkdir %d", mkd++); /* MNT_RDONLY doesn't matter, but just for compat with the PR */ mountnull("/td", "/mp", MNT_RDONLY); mountnull("/td/dist", "/mp/dist", 0); /* if we didn't get a locking-against-meself panic, we passed */ } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, basic); ATF_TP_ADD_TC(tp, twistymount); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ptyfs/t_nullpts.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ptyfs/t_nullpts.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ptyfs/t_nullpts.c (revision 312126) @@ -1,128 +1,128 @@ -/* $NetBSD: t_nullpts.c,v 1.5 2011/01/10 11:11:04 hannken Exp $ */ +/* $NetBSD: t_nullpts.c,v 1.6 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" static void mountptyfs(const char *mp, int flags) { struct ptyfs_args args; if (rump_sys_mkdir(mp, 0777) == -1) { if (errno != EEXIST) atf_tc_fail_errno("null create %s", mp); } memset(&args, 0, sizeof(args)); args.version = PTYFS_ARGSVERSION; args.mode = 0777; if (rump_sys_mount(MOUNT_PTYFS, mp, flags, &args, sizeof(args)) == -1) atf_tc_fail_errno("could not mount ptyfs"); } static void mountnull(const char *what, const char *mp, int flags) { struct null_args nargs; if (rump_sys_mkdir(what, 0777) == -1) { if (errno != EEXIST) atf_tc_fail_errno("null create %s", what); } if (rump_sys_mkdir(mp, 0777) == -1) { if (errno != EEXIST) atf_tc_fail_errno("null create %s", mp); } memset(&nargs, 0, sizeof(nargs)); nargs.nulla_target = __UNCONST(what); if (rump_sys_mount(MOUNT_NULL, mp, flags, &nargs, sizeof(nargs)) == -1) atf_tc_fail_errno("could not mount nullfs"); } ATF_TC(nullrevoke); ATF_TC_HEAD(nullrevoke, tc) { atf_tc_set_md_var(tc, "descr", "null mount ptyfs and revoke"); } ATF_TC_BODY(nullrevoke, tc) { char path[MAXPATHLEN]; struct ptmget ptg; int ptm; rump_init(); /* * mount /dev/pts */ mountptyfs("/dev/pts", 0); /* * null mount /dev/pts to /null/dev/pts */ if (rump_sys_mkdir("/null", 0777) == -1) { if (errno != EEXIST) atf_tc_fail_errno("null create /null"); } if (rump_sys_mkdir("/null/dev", 0777) == -1) { if (errno != EEXIST) atf_tc_fail_errno("null create /null/dev"); } mountnull("/dev/pts", "/null/dev/pts", 0); /* * get slave/master pair. */ ptm = rump_sys_open("/dev/ptm", O_RDWR); if (rump_sys_ioctl(ptm, TIOCPTMGET, &ptg) == -1) atf_tc_fail_errno("get pty"); /* * Build nullfs path to slave. */ strcpy(path, "/null"); strcat(path, ptg.sn); /* * Open slave tty via nullfs. */ if (rump_sys_open(path, O_RDWR) == -1) atf_tc_fail_errno("slave null open"); /* * Close slave opened with /dev/ptm. Need purely non-null refs to it. */ rump_sys_close(ptg.sfd); /* revoke slave tty. */ rump_sys_revoke(path); /* done */ } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, nullrevoke); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ptyfs/t_ptyfs.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ptyfs/t_ptyfs.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/ptyfs/t_ptyfs.c (revision 312126) @@ -1,62 +1,62 @@ -/* $NetBSD: t_ptyfs.c,v 1.1 2010/06/11 23:52:38 pooka Exp $ */ +/* $NetBSD: t_ptyfs.c,v 1.2 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" static void mountptyfs(const char *mp, int flags) { struct ptyfs_args args; if (rump_sys_mkdir("/mp", 0777) == -1) { if (errno != EEXIST) atf_tc_fail_errno("mp1"); } memset(&args, 0, sizeof(args)); args.version = PTYFS_ARGSVERSION; args.mode = 0777; if (rump_sys_mount(MOUNT_PTYFS, mp, flags, &args, sizeof(args)) == -1) atf_tc_fail_errno("could not mount ptyfs"); } ATF_TC(basic); ATF_TC_HEAD(basic, tc) { atf_tc_set_md_var(tc, "descr", "mount ptyfs"); } ATF_TC_BODY(basic, tc) { rump_init(); mountptyfs("/mp", 0); if (rump_sys_unmount("/mp", 0) == -1) atf_tc_fail_errno("unmount failed"); /* done */ } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, basic); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/puffs/t_basic.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/puffs/t_basic.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/puffs/t_basic.c (revision 312126) @@ -1,455 +1,455 @@ -/* $NetBSD: t_basic.c,v 1.13 2016/12/01 14:49:04 hannken Exp $ */ +/* $NetBSD: t_basic.c,v 1.14 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #include "../common/h_fsmacros.h" /* * Do a synchronous operation. When this returns, all FAF operations * have at least been delivered to the file system. * * XXX: is this really good enough considering puffs(9)-issued * callback operations? */ static void syncbar(const char *fs) { struct statvfs svb; if (rump_sys_statvfs1(fs, &svb, ST_WAIT) == -1) atf_tc_fail_errno("statvfs"); } #ifdef PUFFSDUMP static void __unused dumpopcount(struct puffstestargs *args) { size_t i; printf("VFS OPS:\n"); for (i = 0; i < MIN(puffsdump_vfsop_count, PUFFS_VFS_MAX); i++) { printf("\t%s: %d\n", puffsdump_vfsop_revmap[i], args->pta_vfs_toserv_ops[i]); } printf("VN OPS:\n"); for (i = 0; i < MIN(puffsdump_vnop_count, PUFFS_VN_MAX); i++) { printf("\t%s: %d\n", puffsdump_vnop_revmap[i], args->pta_vn_toserv_ops[i]); } } #endif ATF_TC(mount); ATF_TC_HEAD(mount, tc) { atf_tc_set_md_var(tc, "descr", "puffs+dtfs un/mount test"); } ATF_TC_BODY(mount, tc) { void *args; FSTEST_CONSTRUCTOR(tc, puffs, args); FSTEST_DESTRUCTOR(tc, puffs, args); } ATF_TC(root_reg); ATF_TC_HEAD(root_reg, tc) { atf_tc_set_md_var(tc, "descr", "root is a regular file"); } #define MAKEOPTS(...) \ char *theopts[] = {NULL, "-s", __VA_ARGS__, "dtfs", "n/a", NULL} ATF_TC_BODY(root_reg, tc) { MAKEOPTS("-r", "reg"); void *args; int fd, rv; FSTEST_CONSTRUCTOR_FSPRIV(tc, puffs, args, theopts); fd = rump_sys_open(FSTEST_MNTNAME, O_RDWR); if (fd == -1) atf_tc_fail_errno("open root"); if (rump_sys_write(fd, &fd, sizeof(fd)) != sizeof(fd)) atf_tc_fail_errno("write to root"); rv = rump_sys_mkdir(FSTEST_MNTNAME "/test", 0777); ATF_REQUIRE(errno == ENOTDIR); ATF_REQUIRE(rv == -1); rump_sys_close(fd); FSTEST_DESTRUCTOR(tc, puffs, args); } ATF_TC(root_lnk); ATF_TC_HEAD(root_lnk, tc) { atf_tc_set_md_var(tc, "descr", "root is a symbolic link"); } #define LINKSTR "/path/to/nowhere" ATF_TC_BODY(root_lnk, tc) { MAKEOPTS("-r", "lnk " LINKSTR); void *args; char buf[PATH_MAX]; ssize_t len; FSTEST_CONSTRUCTOR_FSPRIV(tc, puffs, args, theopts); if ((len = rump_sys_readlink(FSTEST_MNTNAME, buf, sizeof(buf)-1)) == -1) atf_tc_fail_errno("readlink"); buf[len] = '\0'; ATF_REQUIRE_STREQ(buf, LINKSTR); #if 0 /* XXX: unmount uses FOLLOW */ if (rump_sys_unmount("/mp", 0) == -1) atf_tc_fail_errno("unmount"); #endif } ATF_TC(root_fifo); ATF_TC_HEAD(root_fifo, tc) { atf_tc_set_md_var(tc, "descr", "root is a symbolic link"); } #define MAGICSTR "nakit ja muusiperunat maustevoilla" static void * dofifow(void *arg) { int fd = (int)(uintptr_t)arg; char buf[512]; printf("writing\n"); strcpy(buf, MAGICSTR); if (rump_sys_write(fd, buf, strlen(buf)+1) != strlen(buf)+1) atf_tc_fail_errno("write to fifo"); return NULL; } ATF_TC_BODY(root_fifo, tc) { MAKEOPTS("-r", "fifo"); void *args; pthread_t pt; char buf[512]; int fd; FSTEST_CONSTRUCTOR_FSPRIV(tc, puffs, args, theopts); fd = rump_sys_open(FSTEST_MNTNAME, O_RDWR); if (fd == -1) atf_tc_fail_errno("open fifo"); pthread_create(&pt, NULL, dofifow, (void *)(uintptr_t)fd); memset(buf, 0, sizeof(buf)); if (rump_sys_read(fd, buf, sizeof(buf)) == -1) atf_tc_fail_errno("read fifo"); ATF_REQUIRE_STREQ(buf, MAGICSTR); rump_sys_close(fd); FSTEST_DESTRUCTOR(tc, puffs, args); } ATF_TC(root_chrdev); ATF_TC_HEAD(root_chrdev, tc) { atf_tc_set_md_var(tc, "descr", "root is /dev/null"); } ATF_TC_BODY(root_chrdev, tc) { MAKEOPTS("-r", "chr 2 2"); void *args; ssize_t rv; char buf[512]; int fd; FSTEST_CONSTRUCTOR_FSPRIV(tc, puffs, args, theopts); fd = rump_sys_open(FSTEST_MNTNAME, O_RDWR); if (fd == -1) atf_tc_fail_errno("open null"); rv = rump_sys_write(fd, buf, sizeof(buf)); ATF_REQUIRE(rv == sizeof(buf)); rv = rump_sys_read(fd, buf, sizeof(buf)); ATF_REQUIRE(rv == 0); rump_sys_close(fd); FSTEST_DESTRUCTOR(tc, puffs, args); } /* * Inactive/reclaim tests */ ATF_TC(inactive_basic); ATF_TC_HEAD(inactive_basic, tc) { atf_tc_set_md_var(tc, "descr", "inactive gets called"); } ATF_TC_BODY(inactive_basic, tc) { struct puffstestargs *pargs; void *args; int fd; FSTEST_CONSTRUCTOR(tc, puffs, args); FSTEST_ENTER(); pargs = args; fd = rump_sys_open("file", O_CREAT | O_RDWR, 0777); if (fd == -1) atf_tc_fail_errno("create"); /* none yet */ ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE], 0); rump_sys_close(fd); /* one for file */ ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE], 1); FSTEST_EXIT(); /* another for the mountpoint */ ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE], 2); FSTEST_DESTRUCTOR(tc, puffs, args); } ATF_TC(inactive_reclaim); ATF_TC_HEAD(inactive_reclaim, tc) { atf_tc_set_md_var(tc, "descr", "inactive/reclaim gets called"); } ATF_TC_BODY(inactive_reclaim, tc) { struct puffstestargs *pargs; void *args; int fd; FSTEST_CONSTRUCTOR(tc, puffs, args); FSTEST_ENTER(); pargs = args; fd = rump_sys_open("file", O_CREAT | O_RDWR, 0777); if (fd == -1) atf_tc_fail_errno("create"); ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE], 0); if (rump_sys_unlink("file") == -1) atf_tc_fail_errno("remove"); ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE], 0); ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_RECLAIM], 0); rump_sys_close(fd); syncbar(FSTEST_MNTNAME); ATF_REQUIRE(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE] > 0); ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_RECLAIM], 1); FSTEST_EXIT(); FSTEST_DESTRUCTOR(tc, puffs, args); } ATF_TC(reclaim_hardlink); ATF_TC_HEAD(reclaim_hardlink, tc) { atf_tc_set_md_var(tc, "descr", "reclaim gets called only after " "final link is gone"); } ATF_TC_BODY(reclaim_hardlink, tc) { struct puffstestargs *pargs; void *args; int fd; int ianow; FSTEST_CONSTRUCTOR(tc, puffs, args); FSTEST_ENTER(); pargs = args; fd = rump_sys_open("file", O_CREAT | O_RDWR, 0777); if (fd == -1) atf_tc_fail_errno("create"); if (rump_sys_link("file", "anotherfile") == -1) atf_tc_fail_errno("create link"); rump_sys_close(fd); ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_RECLAIM], 0); /* unlink first hardlink */ if (rump_sys_unlink("file") == -1) atf_tc_fail_errno("unlink 1"); ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_RECLAIM], 0); ianow = pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE]; /* unlink second hardlink */ if (rump_sys_unlink("anotherfile") == -1) atf_tc_fail_errno("unlink 2"); syncbar(FSTEST_MNTNAME); ATF_REQUIRE(ianow < pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE]); ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_RECLAIM], 1); FSTEST_EXIT(); FSTEST_DESTRUCTOR(tc, puffs, args); } ATF_TC(unlink_accessible); ATF_TC_HEAD(unlink_accessible, tc) { atf_tc_set_md_var(tc, "descr", "open file is accessible after " "having been unlinked"); } ATF_TC_BODY(unlink_accessible, tc) { MAKEOPTS("-i", "-o", "nopagecache"); struct puffstestargs *pargs; void *args; char buf[512]; int fd, ianow; assert(sizeof(buf) > sizeof(MAGICSTR)); FSTEST_CONSTRUCTOR_FSPRIV(tc, puffs, args, theopts); FSTEST_ENTER(); pargs = args; fd = rump_sys_open("file", O_CREAT | O_RDWR, 0777); if (fd == -1) atf_tc_fail_errno("create"); if (rump_sys_write(fd, MAGICSTR, sizeof(MAGICSTR)) != sizeof(MAGICSTR)) atf_tc_fail_errno("write"); if (rump_sys_unlink("file") == -1) atf_tc_fail_errno("unlink"); ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_RECLAIM], 0); ianow = pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE]; if (rump_sys_pread(fd, buf, sizeof(buf), 0) == -1) atf_tc_fail_errno("read"); rump_sys_close(fd); syncbar(FSTEST_MNTNAME); ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_RECLAIM], 1); ATF_REQUIRE(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE] > ianow); ATF_REQUIRE_STREQ(buf, MAGICSTR); FSTEST_EXIT(); FSTEST_DESTRUCTOR(tc, puffs, args); } ATF_TC(signals); ATF_TC_HEAD(signals, tc) { atf_tc_set_md_var(tc, "descr", "Checks that sending a signal can " "cause an interrupt to puffs wait"); } extern struct proc *rumpns_initproc; extern void rumpns_psignal(struct proc *, int); extern void rumpns_sigclearall(struct proc *, void *, void *); ATF_TC_BODY(signals, tc) { struct stat sb; void *args; rump_boot_setsigmodel(RUMP_SIGMODEL_RECORD); FSTEST_CONSTRUCTOR(tc, puffs, args); FSTEST_ENTER(); RL(rump_sys_stat(".", &sb)); /* send SIGUSR1, should not affect puffs ops */ rump_schedule(); rumpns_psignal(rumpns_initproc, SIGUSR1); rump_unschedule(); RL(rump_sys_stat(".", &sb)); /* send SIGTERM, should get EINTR */ rump_schedule(); rumpns_psignal(rumpns_initproc, SIGTERM); rump_unschedule(); ATF_REQUIRE_ERRNO(EINTR, rump_sys_stat(".", &sb) == -1); /* clear sigmask so that we can unmount */ rump_schedule(); rumpns_sigclearall(rumpns_initproc, NULL, NULL); rump_unschedule(); FSTEST_EXIT(); FSTEST_DESTRUCTOR(tc, puffs, args); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, mount); ATF_TP_ADD_TC(tp, root_fifo); ATF_TP_ADD_TC(tp, root_lnk); ATF_TP_ADD_TC(tp, root_reg); ATF_TP_ADD_TC(tp, root_chrdev); ATF_TP_ADD_TC(tp, inactive_basic); ATF_TP_ADD_TC(tp, inactive_reclaim); ATF_TP_ADD_TC(tp, reclaim_hardlink); ATF_TP_ADD_TC(tp, unlink_accessible); ATF_TP_ADD_TC(tp, signals); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/puffs/t_fuzz.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/puffs/t_fuzz.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/puffs/t_fuzz.c (revision 312126) @@ -1,283 +1,283 @@ -/* $NetBSD: t_fuzz.c,v 1.5 2012/04/21 01:03:46 manu Exp $ */ +/* $NetBSD: t_fuzz.c,v 1.6 2017/01/13 21:30:40 christos 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. */ /* * Fuzztest puffs mount. There are n different levels of testing: * each one pours more and more sane garbage into the args to that * the mount progresses further and further. Level 8 (at least when * writing this comment) should be the one where mounting actually * succeeds. * * Our metric of success is crash / no crash. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #define ITERATIONS 100 static void fixversion(struct puffs_kargs *kargs) { kargs->pa_vers = PUFFSVERSION; } static void fixkflag(struct puffs_kargs *kargs) { kargs->pa_flags &= PUFFS_KFLAG_MASK; /* * PUFFS_KFLAG_CACHE_FS_TTL require extended behavior * from the filesystem for which we have no test right now. */ kargs->pa_flags &= ~PUFFS_KFLAG_CACHE_FS_TTL; } static void fixfhflag(struct puffs_kargs *kargs) { kargs->pa_fhflags &= PUFFS_FHFLAG_MASK; } static void fixspare(struct puffs_kargs *kargs) { memset(&kargs->pa_spare, 0, sizeof(kargs->pa_spare)); } static void fixhandsize(struct puffs_kargs *kargs) { kargs->pa_fhsize %= PUFFS_FHSIZE_MAX+4; } static void fixhandsize2(struct puffs_kargs *kargs) { /* XXX: values */ if (kargs->pa_fhflags & PUFFS_FHFLAG_NFSV3) kargs->pa_fhsize %= 60; if (kargs->pa_fhflags & PUFFS_FHFLAG_NFSV2) kargs->pa_fhsize %= 28; } static void fixputter(struct puffs_kargs *kargs) { kargs->pa_fd = rump_sys_open("/dev/putter", O_RDWR); if (kargs->pa_fd == -1) atf_tc_fail_errno("open putter"); } static void fixroot(struct puffs_kargs *kargs) { kargs->pa_root_vtype %= VBAD; } static void unfixputter(struct puffs_kargs *kargs) { rump_sys_close(kargs->pa_fd); } typedef void (*fixfn)(struct puffs_kargs *); static fixfn fixstack[] = { fixversion, fixkflag, fixfhflag, fixspare, fixhandsize, fixhandsize2, fixputter, fixroot, }; static void fixup(int nfix, struct puffs_kargs *kargs) { int i; assert(nfix <= __arraycount(fixstack)); for (i = 0; i < nfix; i++) fixstack[i](kargs); } static void unfixup(int nfix, struct puffs_kargs *kargs) { if (nfix >= 7) unfixputter(kargs); } static pthread_mutex_t damtx; static pthread_cond_t dacv; static int dafd = -1; static void * respondthread(void *arg) { char buf[PUFFS_MSG_MAXSIZE]; struct puffs_req *preq = (void *)buf; struct pollfd pfd; ssize_t n; pthread_mutex_lock(&damtx); for (;;) { while (dafd == -1) pthread_cond_wait(&dacv, &damtx); while (dafd != -1) { pthread_mutex_unlock(&damtx); pfd.fd = dafd; pfd.events = POLLIN; pfd.revents = 0; if (rump_sys_poll(&pfd, 1, 10) == 0) { pthread_mutex_lock(&damtx); continue; } n = rump_sys_read(dafd, buf, sizeof(buf)); if (n <= 0) { pthread_mutex_lock(&damtx); break; } /* just say it was succesful */ preq->preq_rv = 0; rump_sys_write(dafd, buf, n); pthread_mutex_lock(&damtx); } } return NULL; } static void testbody(int nfix) { pthread_t pt; struct puffs_kargs kargs; unsigned long seed; int i; seed = time(NULL); srandom(seed); printf("test seeded RNG with %lu\n", seed); rump_init(); pthread_mutex_init(&damtx, NULL); pthread_cond_init(&dacv, NULL); pthread_create(&pt, NULL, respondthread, NULL); ATF_REQUIRE(rump_sys_mkdir("/mnt", 0777) == 0); for (i = 0; i < ITERATIONS; i++) { tests_makegarbage(&kargs, sizeof(kargs)); fixup(nfix, &kargs); if (rump_sys_mount(MOUNT_PUFFS, "/mnt", 0, &kargs, sizeof(kargs)) == 0) { struct stat sb; pthread_mutex_lock(&damtx); dafd = kargs.pa_fd; pthread_cond_signal(&dacv); pthread_mutex_unlock(&damtx); rump_sys_stat("/mnt", &sb); rump_sys_unmount("/mnt", MNT_FORCE); } unfixup(nfix, &kargs); pthread_mutex_lock(&damtx); dafd = -1; pthread_mutex_unlock(&damtx); } } #define MAKETEST(_n_) \ ATF_TC(mountfuzz##_n_); \ ATF_TC_HEAD(mountfuzz##_n_, tc) \ {atf_tc_set_md_var(tc, "descr", "garbage kargs, " # _n_ " fix(es)");} \ ATF_TC_BODY(mountfuzz##_n_, tc) {testbody(_n_);} MAKETEST(0); MAKETEST(1); MAKETEST(2); MAKETEST(3); MAKETEST(4); MAKETEST(5); MAKETEST(6); MAKETEST(7); MAKETEST(8); ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, mountfuzz0); ATF_TP_ADD_TC(tp, mountfuzz1); ATF_TP_ADD_TC(tp, mountfuzz2); ATF_TP_ADD_TC(tp, mountfuzz3); ATF_TP_ADD_TC(tp, mountfuzz4); ATF_TP_ADD_TC(tp, mountfuzz5); ATF_TP_ADD_TC(tp, mountfuzz6); ATF_TP_ADD_TC(tp, mountfuzz7); ATF_TP_ADD_TC(tp, mountfuzz8); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/puffs/t_io.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/puffs/t_io.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/puffs/t_io.c (revision 312126) @@ -1,61 +1,61 @@ -/* $NetBSD: t_io.c,v 1.1 2010/11/12 17:33:28 pooka Exp $ */ +/* $NetBSD: t_io.c,v 1.2 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #include "../common/h_fsmacros.h" #define MAKEOPTS(...) \ char *theopts[] = {NULL, "-s", __VA_ARGS__, "dtfs", "n/a", NULL} ATF_TC(nocache); ATF_TC_HEAD(nocache, tc) { atf_tc_set_md_var(tc, "descr", "tests large i/o without page cache"); } ATF_TC_BODY(nocache, tc) { MAKEOPTS("-o", "nopagecache"); char data[1024*1024]; void *args; int fd; FSTEST_CONSTRUCTOR_FSPRIV(tc, puffs, args, theopts); FSTEST_ENTER(); RL(fd = rump_sys_open("afile", O_CREAT | O_RDWR, 0755)); RL(rump_sys_write(fd, data, sizeof(data))); rump_sys_close(fd); FSTEST_EXIT(); FSTEST_DESTRUCTOR(tc, puffs, args); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, nocache); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/tmpfs/t_renamerace.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/tmpfs/t_renamerace.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/tmpfs/t_renamerace.c (revision 312126) @@ -1,115 +1,115 @@ -/* $NetBSD: t_renamerace.c,v 1.13 2011/08/18 21:44:55 riastradh Exp $ */ +/* $NetBSD: t_renamerace.c,v 1.14 2017/01/13 21:30:40 christos Exp $ */ /* * Modified for rump and atf from a program supplied * by Nicolas Joly in kern/40948 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(renamerace2); ATF_TC_HEAD(renamerace2, tc) { atf_tc_set_md_var(tc, "descr", "rename(2) lock order inversion"); atf_tc_set_md_var(tc, "timeout", "6"); } static volatile int quittingtime = 0; static pid_t wrkpid; static void * r2w1(void *arg) { int fd; rump_pub_lwproc_newlwp(wrkpid); fd = rump_sys_open("/file", O_CREAT | O_RDWR, 0777); if (fd == -1) atf_tc_fail_errno("creat"); rump_sys_close(fd); while (!quittingtime) { if (rump_sys_rename("/file", "/dir/file") == -1) atf_tc_fail_errno("rename 1"); if (rump_sys_rename("/dir/file", "/file") == -1) atf_tc_fail_errno("rename 2"); } return NULL; } static void * r2w2(void *arg) { int fd; rump_pub_lwproc_newlwp(wrkpid); while (!quittingtime) { fd = rump_sys_open("/dir/file1", O_RDWR); if (fd != -1) rump_sys_close(fd); } return NULL; } ATF_TC_BODY(renamerace2, tc) { struct tmpfs_args args; pthread_t pt[2]; /* * Force SMP regardless of how many host CPUs there are. * Deadlock is highly unlikely to trigger otherwise. */ setenv("RUMP_NCPU", "2", 1); rump_init(); memset(&args, 0, sizeof(args)); args.ta_version = TMPFS_ARGS_VERSION; args.ta_root_mode = 0777; if (rump_sys_mount(MOUNT_TMPFS, "/", 0, &args, sizeof(args)) == -1) atf_tc_fail_errno("could not mount tmpfs"); if (rump_sys_mkdir("/dir", 0777) == -1) atf_tc_fail_errno("cannot create directory"); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); RL(wrkpid = rump_sys_getpid()); pthread_create(&pt[0], NULL, r2w1, NULL); pthread_create(&pt[1], NULL, r2w2, NULL); /* usually triggers in <<1s for me */ sleep(4); quittingtime = 1; pthread_join(pt[0], NULL); pthread_join(pt[1], NULL); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, renamerace2); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/umapfs/t_basic.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/umapfs/t_basic.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/umapfs/t_basic.c (revision 312126) @@ -1,145 +1,145 @@ -/* $NetBSD: t_basic.c,v 1.4 2010/07/19 15:35:39 pooka Exp $ */ +/* $NetBSD: t_basic.c,v 1.5 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(basic); ATF_TC_HEAD(basic, tc) { atf_tc_set_md_var(tc, "descr", "basic umapfs mapping"); } static void xtouch(const char *path) { int fd; fd = rump_sys_open(path, O_CREAT | O_RDWR, 0777); if (fd == -1) atf_tc_fail_errno("create %s", path); rump_sys_close(fd); } static void xchown(const char *path, uid_t uid, gid_t gid) { if (rump_sys_chown(path, uid, gid) == -1) atf_tc_fail_errno("chown %s failed", path); } static void testuidgid(const char *path, uid_t uid, gid_t gid) { struct stat sb; if (rump_sys_stat(path, &sb) == -1) atf_tc_fail_errno("stat %s", path); if (uid != (uid_t)-1) { if (sb.st_uid != uid) atf_tc_fail("%s: expected uid %d, got %d", path, uid, sb.st_uid); } if (gid != (gid_t)-1) { if (sb.st_gid != gid) atf_tc_fail("%s: expected gid %d, got %d", path, gid, sb.st_gid); } } ATF_TC_BODY(basic, tc) { struct umap_args umargs; struct tmpfs_args targs; u_long umaps[2][2]; u_long gmaps[2][2]; rump_init(); if (rump_sys_mkdir("/td1", 0777) == -1) atf_tc_fail_errno("mp1"); if (rump_sys_mkdir("/td2", 0777) == -1) atf_tc_fail_errno("mp1"); /* use tmpfs because rumpfs doesn't support ownership */ memset(&targs, 0, sizeof(targs)); targs.ta_version = TMPFS_ARGS_VERSION; targs.ta_root_mode = 0777; if (rump_sys_mount(MOUNT_TMPFS, "/td1", 0, &targs, sizeof(targs)) == -1) atf_tc_fail_errno("could not mount tmpfs td1"); memset(&umargs, 0, sizeof(umargs)); /* * Map td1 uid 555 to td2 uid 777 (yes, IMHO the umapfs * mapping format is counter-intuitive). */ umaps[0][0] = 777; umaps[0][1] = 555; umaps[1][0] = 0; umaps[1][1] = 0; gmaps[0][0] = 4321; gmaps[0][1] = 1234; gmaps[1][0] = 0; gmaps[1][1] = 0; umargs.umap_target = __UNCONST("/td1"); umargs.nentries = 2; umargs.gnentries = 2; umargs.mapdata = umaps; umargs.gmapdata = gmaps; if (rump_sys_mount(MOUNT_UMAP, "/td2", 0, &umargs,sizeof(umargs)) == -1) atf_tc_fail_errno("could not mount umapfs"); xtouch("/td1/noch"); testuidgid("/td1/noch", 0, 0); testuidgid("/td2/noch", 0, 0); xtouch("/td1/nomap"); xchown("/td1/nomap", 1, 2); testuidgid("/td1/nomap", 1, 2); testuidgid("/td2/nomap", -1, -1); xtouch("/td1/forwmap"); xchown("/td1/forwmap", 555, 1234); testuidgid("/td1/forwmap", 555, 1234); testuidgid("/td2/forwmap", 777, 4321); /* * this *CANNOT* be correct??? */ xtouch("/td1/revmap"); /* * should be 777 / 4321 (?), but makes first test fail since * it gets 777 / 4321, i.e. unmapped results. */ xchown("/td2/revmap", 555, 1234); testuidgid("/td1/revmap", 555, 1234); testuidgid("/td2/revmap", 777, 4321); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, basic); return 0; /*XXX?*/ } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/union/t_pr.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/union/t_pr.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/union/t_pr.c (revision 312126) @@ -1,130 +1,130 @@ -/* $NetBSD: t_pr.c,v 1.8 2011/08/10 06:27:02 hannken Exp $ */ +/* $NetBSD: t_pr.c,v 1.9 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(multilayer); ATF_TC_HEAD(multilayer, tc) { atf_tc_set_md_var(tc, "descr", "mount_union -b twice"); } ATF_TC_BODY(multilayer, tc) { struct union_args unionargs; rump_init(); if (rump_sys_mkdir("/Tunion", 0777) == -1) atf_tc_fail_errno("mkdir mp1"); if (rump_sys_mkdir("/Tunion2", 0777) == -1) atf_tc_fail_errno("mkdir mp2"); if (rump_sys_mkdir("/Tunion2/A", 0777) == -1) atf_tc_fail_errno("mkdir A"); if (rump_sys_mkdir("/Tunion2/B", 0777) == -1) atf_tc_fail_errno("mkdir B"); unionargs.target = __UNCONST("/Tunion2/A"); unionargs.mntflags = UNMNT_BELOW; if (rump_sys_mount(MOUNT_UNION, "/Tunion", 0, &unionargs, sizeof(unionargs)) == -1) atf_tc_fail_errno("union mount"); unionargs.target = __UNCONST("/Tunion2/B"); unionargs.mntflags = UNMNT_BELOW; rump_sys_mount(MOUNT_UNION, "/Tunion", 0,&unionargs,sizeof(unionargs)); } ATF_TC(devnull1); ATF_TC_HEAD(devnull1, tc) { atf_tc_set_md_var(tc, "descr", "mount_union -b and " "'echo x > /un/null'"); } ATF_TC_BODY(devnull1, tc) { struct union_args unionargs; int fd, res; rump_init(); if (rump_sys_mkdir("/mp", 0777) == -1) atf_tc_fail_errno("mkdir mp"); unionargs.target = __UNCONST("/dev"); unionargs.mntflags = UNMNT_BELOW; if (rump_sys_mount(MOUNT_UNION, "/mp", 0, &unionargs, sizeof(unionargs)) == -1) atf_tc_fail_errno("union mount"); fd = rump_sys_open("/mp/null", O_WRONLY | O_CREAT | O_TRUNC); if (fd == -1) atf_tc_fail_errno("open"); res = rump_sys_write(fd, &fd, sizeof(fd)); if (res != sizeof(fd)) atf_tc_fail("write"); } ATF_TC(devnull2); ATF_TC_HEAD(devnull2, tc) { atf_tc_set_md_var(tc, "descr", "mount_union -b and " "'echo x >> /un/null'"); } ATF_TC_BODY(devnull2, tc) { struct union_args unionargs; int fd, res; rump_init(); if (rump_sys_mkdir("/mp", 0777) == -1) atf_tc_fail_errno("mkdir mp"); unionargs.target = __UNCONST("/dev"); unionargs.mntflags = UNMNT_BELOW; if (rump_sys_mount(MOUNT_UNION, "/mp", 0, &unionargs, sizeof(unionargs)) == -1) atf_tc_fail_errno("union mount"); fd = rump_sys_open("/mp/null", O_WRONLY | O_CREAT | O_APPEND); if (fd == -1) atf_tc_fail_errno("open"); res = rump_sys_write(fd, &fd, sizeof(fd)); if (res != sizeof(fd)) atf_tc_fail("write"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, multilayer); ATF_TP_ADD_TC(tp, devnull1); ATF_TP_ADD_TC(tp, devnull2); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_full.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_full.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_full.c (revision 312126) @@ -1,101 +1,101 @@ -/* $NetBSD: t_full.c,v 1.8 2013/03/16 05:45:37 jmmv Exp $ */ +/* $NetBSD: t_full.c,v 1.9 2017/01/13 21:30:40 christos 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 #include #include #include "../common/h_fsmacros.h" -#include "../../h_macros.h" +#include "h_macros.h" /* * Write this much over the image size. This is to force an NFS commit, * since we might just stuff data into the cache and miss the problem. */ #define NFSBONUS (1<<16) static void fillfs(const atf_tc_t *tc, const char *mp) { char buf[8192]; size_t written; ssize_t n = 0; /* xxxgcc */ size_t bonus; int fd, i = 0; if (FSTYPE_P2K_FFS(tc) || FSTYPE_PUFFS(tc) || FSTYPE_RUMPFS(tc)) { atf_tc_skip("fs does not support explicit block allocation " "(GOP_ALLOC)"); } bonus = 0; if (FSTYPE_NFS(tc)) bonus = NFSBONUS; if (rump_sys_chdir(mp) == -1) atf_tc_fail_errno("chdir mountpoint"); fd = rump_sys_open("afile", O_CREAT | O_RDWR); if (fd == -1) atf_tc_fail_errno("create file"); for (written = 0; written < FSTEST_IMGSIZE + bonus; written +=n) { memset(buf, i++, sizeof(buf)); /* known garbage */ n = rump_sys_write(fd, buf, sizeof(buf)); if (n == -1) break; } if (FSTYPE_ZFS(tc)) atf_tc_expect_fail("PR kern/47656: Test known to be broken"); if (n == -1) { if (errno != ENOSPC) atf_tc_fail_errno("write"); } else { atf_tc_fail("filled file system over size limit"); } rump_sys_close(fd); rump_sys_chdir("/"); } ATF_TC_FSAPPLY(fillfs, "fills file system, expects ENOSPC"); ATF_TP_ADD_TCS(tp) { ATF_TP_FSAPPLY(fillfs); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_io.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_io.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_io.c (revision 312126) @@ -1,268 +1,268 @@ -/* $NetBSD: t_io.c,v 1.16 2015/04/04 12:34:44 riastradh Exp $ */ +/* $NetBSD: t_io.c,v 1.17 2017/01/13 21:30:40 christos 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 #include #include #include "../common/h_fsmacros.h" -#include "../../h_macros.h" +#include "h_macros.h" #define TESTSTR "this is a string. collect enough and you'll have Em" #define TESTSZ sizeof(TESTSTR) static void holywrite(const atf_tc_t *tc, const char *mp) { char buf[1024]; char *b2, *b3; size_t therange = getpagesize()+1; int fd; FSTEST_ENTER(); RL(fd = rump_sys_open("file", O_RDWR|O_CREAT|O_TRUNC, 0666)); memset(buf, 'A', sizeof(buf)); RL(rump_sys_pwrite(fd, buf, 1, getpagesize())); memset(buf, 'B', sizeof(buf)); RL(rump_sys_pwrite(fd, buf, 2, getpagesize()-1)); REQUIRE_LIBC(b2 = malloc(2 * getpagesize()), NULL); REQUIRE_LIBC(b3 = malloc(2 * getpagesize()), NULL); RL(rump_sys_pread(fd, b2, therange, 0)); memset(b3, 0, therange); memset(b3 + getpagesize() - 1, 'B', 2); ATF_REQUIRE_EQ(memcmp(b2, b3, therange), 0); rump_sys_close(fd); FSTEST_EXIT(); } static void extendbody(const atf_tc_t *tc, off_t seekcnt) { char buf[TESTSZ+1]; struct stat sb; int fd; FSTEST_ENTER(); RL(fd = rump_sys_open("testfile", O_CREAT | O_RDWR | (seekcnt ? O_APPEND : 0))); RL(rump_sys_ftruncate(fd, seekcnt)); RL(rump_sys_fstat(fd, &sb)); ATF_REQUIRE_EQ(sb.st_size, seekcnt); ATF_REQUIRE_EQ(rump_sys_write(fd, TESTSTR, TESTSZ), TESTSZ); ATF_REQUIRE_EQ(rump_sys_pread(fd, buf, TESTSZ, seekcnt), TESTSZ); ATF_REQUIRE_STREQ(buf, TESTSTR); RL(rump_sys_fstat(fd, &sb)); ATF_REQUIRE_EQ(sb.st_size, (off_t)TESTSZ + seekcnt); RL(rump_sys_close(fd)); FSTEST_EXIT(); } static void extendfile(const atf_tc_t *tc, const char *mp) { extendbody(tc, 0); } static void extendfile_append(const atf_tc_t *tc, const char *mp) { extendbody(tc, 37); } static void overwritebody(const atf_tc_t *tc, off_t count, bool dotrunc) { char *buf; int fd; REQUIRE_LIBC(buf = malloc(count), NULL); FSTEST_ENTER(); RL(fd = rump_sys_open("testi", O_CREAT | O_RDWR, 0666)); ATF_REQUIRE_EQ(rump_sys_write(fd, buf, count), count); RL(rump_sys_close(fd)); RL(fd = rump_sys_open("testi", O_RDWR)); if (dotrunc) RL(rump_sys_ftruncate(fd, 0)); ATF_REQUIRE_EQ(rump_sys_write(fd, buf, count), count); RL(rump_sys_close(fd)); FSTEST_EXIT(); } static void overwrite512(const atf_tc_t *tc, const char *mp) { overwritebody(tc, 512, false); } static void overwrite64k(const atf_tc_t *tc, const char *mp) { overwritebody(tc, 1<<16, false); } static void overwrite_trunc(const atf_tc_t *tc, const char *mp) { overwritebody(tc, 1<<16, true); } static void shrinkfile(const atf_tc_t *tc, const char *mp) { int fd; FSTEST_ENTER(); RL(fd = rump_sys_open("file", O_RDWR|O_CREAT|O_TRUNC, 0666)); RL(rump_sys_ftruncate(fd, 2)); RL(rump_sys_ftruncate(fd, 1)); rump_sys_close(fd); FSTEST_EXIT(); } #define TBSIZE 9000 static void read_after_unlink(const atf_tc_t *tc, const char *mp) { char buf[TBSIZE], buf2[TBSIZE]; int fd; FSTEST_ENTER(); /* create file and put some content into it */ RL(fd = rump_sys_open("file", O_RDWR|O_CREAT, 0666)); memset(buf, 'D', TBSIZE); ATF_REQUIRE_EQ(rump_sys_write(fd, buf, TBSIZE), TBSIZE); rump_sys_close(fd); /* flush buffers from UBC to file system */ ATF_REQUIRE_ERRNO(EBUSY, rump_sys_unmount(mp, 0) == -1); RL(fd = rump_sys_open("file", O_RDWR)); RL(rump_sys_unlink("file")); ATF_REQUIRE_EQ(rump_sys_read(fd, buf2, TBSIZE), TBSIZE); ATF_REQUIRE_EQ(memcmp(buf, buf2, TBSIZE), 0); rump_sys_close(fd); FSTEST_EXIT(); } static void wrrd_after_unlink(const atf_tc_t *tc, const char *mp) { int value = 0x11; int v2; int fd; FSTEST_ENTER(); RL(fd = rump_sys_open("file", O_RDWR|O_CREAT, 0666)); RL(rump_sys_unlink("file")); RL(rump_sys_pwrite(fd, &value, sizeof(value), 654321)); /* * We can't easily invalidate the buffer since we hold a * reference, but try to get them to flush anyway. */ RL(rump_sys_fsync(fd)); RL(rump_sys_pread(fd, &v2, sizeof(v2), 654321)); rump_sys_close(fd); ATF_REQUIRE_EQ(value, v2); FSTEST_EXIT(); } static void read_fault(const atf_tc_t *tc, const char *mp) { char ch = 123; int fd; FSTEST_ENTER(); RL(fd = rump_sys_open("file", O_CREAT | O_RDWR, 0777)); ATF_REQUIRE_EQ(rump_sys_write(fd, &ch, 1), 1); RL(rump_sys_close(fd)); RL(fd = rump_sys_open("file", O_RDONLY | O_SYNC | O_RSYNC)); ATF_REQUIRE_ERRNO(EFAULT, rump_sys_read(fd, NULL, 1) == -1); RL(rump_sys_close(fd)); FSTEST_EXIT(); } ATF_TC_FSAPPLY(holywrite, "create a sparse file and fill hole"); ATF_TC_FSAPPLY(extendfile, "check that extending a file works"); ATF_TC_FSAPPLY(extendfile_append, "check that extending a file works " "with a append-only fd (PR kern/44307)"); ATF_TC_FSAPPLY(overwrite512, "write a 512 byte file twice"); ATF_TC_FSAPPLY(overwrite64k, "write a 64k byte file twice"); ATF_TC_FSAPPLY(overwrite_trunc, "write 64k + truncate + rewrite"); ATF_TC_FSAPPLY(shrinkfile, "shrink file"); ATF_TC_FSAPPLY(read_after_unlink, "contents can be read off disk after unlink"); ATF_TC_FSAPPLY(wrrd_after_unlink, "file can be written and read after unlink"); ATF_TC_FSAPPLY(read_fault, "read at bad address must return EFAULT"); ATF_TP_ADD_TCS(tp) { ATF_TP_FSAPPLY(holywrite); ATF_TP_FSAPPLY(extendfile); ATF_TP_FSAPPLY(extendfile_append); ATF_TP_FSAPPLY(overwrite512); ATF_TP_FSAPPLY(overwrite64k); ATF_TP_FSAPPLY(overwrite_trunc); ATF_TP_FSAPPLY(shrinkfile); ATF_TP_FSAPPLY(read_after_unlink); ATF_TP_FSAPPLY(wrrd_after_unlink); ATF_TP_FSAPPLY(read_fault); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_renamerace.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_renamerace.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_renamerace.c (revision 312126) @@ -1,190 +1,190 @@ -/* $NetBSD: t_renamerace.c,v 1.33 2016/05/04 08:30:22 dholland Exp $ */ +/* $NetBSD: t_renamerace.c,v 1.34 2017/01/13 21:30:40 christos Exp $ */ /* * Modified for rump and atf from a program supplied * by Nicolas Joly in kern/40948 */ #include #include #include #include #include #include #include #include #include #include #include #include #include /* Bump the size of the test file system image to a larger value. * * These tests cause a lot of churn in the file system by creating and * deleting files/directories in quick succession. A faster CPU will cause * more churn because the tests are capped by a run time period in seconds, * not number of operations. * * This is all fine except for LFS, because the lfs_cleanerd cannot keep up * with the churn and thus causes the test to fail on fast machines. Hence * the reason for this hack. */ #define FSTEST_IMGSIZE (50000 * 512) #include "../common/h_fsmacros.h" -#include "../../h_macros.h" +#include "h_macros.h" static volatile int quittingtime; pid_t wrkpid; static void * w1(void *arg) { int fd; rump_pub_lwproc_newlwp(wrkpid); while (!quittingtime) { fd = rump_sys_open("rename.test1", O_WRONLY|O_CREAT|O_TRUNC, 0666); if (fd == -1 && errno != EEXIST) atf_tc_fail_errno("create"); rump_sys_unlink("rename.test1"); rump_sys_close(fd); } return NULL; } static void * w1_dirs(void *arg) { rump_pub_lwproc_newlwp(wrkpid); while (!quittingtime) { if (rump_sys_mkdir("rename.test1", 0777) == -1) atf_tc_fail_errno("mkdir"); rump_sys_rmdir("rename.test1"); } return NULL; } static void * w2(void *arg) { rump_pub_lwproc_newlwp(wrkpid); while (!quittingtime) { rump_sys_rename("rename.test1", "rename.test2"); } return NULL; } #define NWRK 8 static void renamerace(const atf_tc_t *tc, const char *mp) { pthread_t pt1[NWRK], pt2[NWRK]; int i; /* * Sysvbfs supports only 8 inodes so this test would exhaust * the inode table and creating files would fail with ENOSPC. */ if (FSTYPE_SYSVBFS(tc)) atf_tc_skip("filesystem has not enough inodes"); if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); if (FSTYPE_UDF(tc)) atf_tc_expect_fail("PR kern/49046"); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); RL(wrkpid = rump_sys_getpid()); RL(rump_sys_chdir(mp)); for (i = 0; i < NWRK; i++) pthread_create(&pt1[i], NULL, w1, NULL); for (i = 0; i < NWRK; i++) pthread_create(&pt2[i], NULL, w2, NULL); sleep(5); quittingtime = 1; for (i = 0; i < NWRK; i++) pthread_join(pt1[i], NULL); for (i = 0; i < NWRK; i++) pthread_join(pt2[i], NULL); RL(rump_sys_chdir("/")); if (FSTYPE_UDF(tc)) atf_tc_fail("race did not trigger this time"); if (FSTYPE_MSDOS(tc)) { atf_tc_expect_fail("PR kern/43626"); /* * XXX: race does not trigger every time at least * on amd64/qemu. */ if (msdosfs_fstest_unmount(tc, mp, 0) != 0) { rump_pub_vfs_mount_print(mp, 1); atf_tc_fail_errno("unmount failed"); } atf_tc_fail("race did not trigger this time"); } } static void renamerace_dirs(const atf_tc_t *tc, const char *mp) { pthread_t pt1, pt2; if (FSTYPE_SYSVBFS(tc)) atf_tc_skip("directories not supported by file system"); if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); /* XXX: msdosfs also sometimes hangs */ if (FSTYPE_MSDOS(tc)) atf_tc_expect_signal(-1, "PR kern/43626"); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); RL(wrkpid = rump_sys_getpid()); RL(rump_sys_chdir(mp)); pthread_create(&pt1, NULL, w1_dirs, NULL); pthread_create(&pt2, NULL, w2, NULL); sleep(5); quittingtime = 1; pthread_join(pt1, NULL); pthread_join(pt2, NULL); RL(rump_sys_chdir("/")); /* * Doesn't always trigger when run on a slow backend * (i.e. not on tmpfs/mfs). So do the usual kludge. */ if (FSTYPE_MSDOS(tc)) abort(); } ATF_TC_FSAPPLY(renamerace, "rename(2) race with file unlinked mid-operation"); ATF_TC_FSAPPLY(renamerace_dirs, "rename(2) race with directories"); ATF_TP_ADD_TCS(tp) { ATF_TP_FSAPPLY(renamerace); /* PR kern/41128 */ ATF_TP_FSAPPLY(renamerace_dirs); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_ro.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_ro.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_ro.c (revision 312126) @@ -1,203 +1,203 @@ -/* $NetBSD: t_ro.c,v 1.5 2011/02/22 21:23:19 yamt Exp $ */ +/* $NetBSD: t_ro.c,v 1.6 2017/01/13 21:30:40 christos 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 #include #include #include "../common/h_fsmacros.h" -#include "../../h_macros.h" +#include "h_macros.h" #define AFILE "testfile" #define ADIR "testdir" #define AFIFO "testfifo" #define ASYMLINK "testsymlink" #define ALINK "testlink" #define FUNTEXT "this is some non-humppa text" #define FUNSIZE (sizeof(FUNTEXT)-1) static void nullgen(const atf_tc_t *tc, const char *mp) { return; } static void filegen(const atf_tc_t *tc, const char *mp) { int fd; FSTEST_ENTER(); RL(fd = rump_sys_open(AFILE, O_CREAT | O_RDWR, 0777)); ATF_REQUIRE_EQ(rump_sys_write(fd, FUNTEXT, FUNSIZE), FUNSIZE); RL(rump_sys_close(fd)); FSTEST_EXIT(); } /* * * BEGIN tests * */ static void create(const atf_tc_t *tc, const char *mp) { FSTEST_ENTER(); ATF_REQUIRE_ERRNO(EROFS, rump_sys_open(AFILE, O_CREAT|O_RDONLY) == -1); FSTEST_EXIT(); } static void rmfile(const atf_tc_t *tc, const char *mp) { FSTEST_ENTER(); ATF_REQUIRE_ERRNO(EROFS, rump_sys_unlink(AFILE) == -1); FSTEST_EXIT(); } static void fileio(const atf_tc_t *tc, const char *mp) { int fd; char buf[FUNSIZE+1]; int expected; if (FSTYPE_NFSRO(tc)) expected = EACCES; else expected = EROFS; FSTEST_ENTER(); RL(fd = rump_sys_open(AFILE, O_RDONLY)); ATF_REQUIRE_EQ(rump_sys_read(fd, buf, FUNSIZE), FUNSIZE); buf[FUNSIZE] = '\0'; ATF_REQUIRE_STREQ(buf, FUNTEXT); RL(rump_sys_close(fd)); ATF_REQUIRE_ERRNO(expected, rump_sys_open(AFILE, O_WRONLY) == -1); ATF_REQUIRE_ERRNO(expected, rump_sys_open(AFILE, O_RDWR) == -1); FSTEST_EXIT(); } static void attrs(const atf_tc_t *tc, const char *mp) { struct timeval sometvs[2]; struct stat sb; int fd; FSTEST_ENTER(); RL(rump_sys_stat(AFILE, &sb)); ATF_REQUIRE_ERRNO(EROFS, rump_sys_chmod(AFILE, 0775) == -1); if (!FSTYPE_MSDOS(tc)) ATF_REQUIRE_ERRNO(EROFS, rump_sys_chown(AFILE, 1, 1) == -1); ATF_REQUIRE_ERRNO(EROFS, rump_sys_utimes(AFILE, sometvs) == -1); RL(fd = rump_sys_open(AFILE, O_RDONLY)); ATF_REQUIRE_ERRNO(EROFS, rump_sys_fchmod(fd, 0775) == -1); if (!FSTYPE_MSDOS(tc)) ATF_REQUIRE_ERRNO(EROFS, rump_sys_fchown(fd, 1, 1) == -1); ATF_REQUIRE_ERRNO(EROFS, rump_sys_futimes(fd, sometvs) == -1); RL(rump_sys_close(fd)); FSTEST_EXIT(); } static void createdir(const atf_tc_t *tc, const char *mp) { FSTEST_ENTER(); ATF_REQUIRE_ERRNO(EROFS, rump_sys_mkdir(ADIR, 0775) == -1); FSTEST_EXIT(); } static void createfifo(const atf_tc_t *tc, const char *mp) { FSTEST_ENTER(); ATF_REQUIRE_ERRNO(EROFS, rump_sys_mkfifo(AFIFO, 0775) == -1); FSTEST_EXIT(); } static void createsymlink(const atf_tc_t *tc, const char *mp) { FSTEST_ENTER(); ATF_REQUIRE_ERRNO(EROFS, rump_sys_symlink("hoge", ASYMLINK) == -1); FSTEST_EXIT(); } static void createlink(const atf_tc_t *tc, const char *mp) { FSTEST_ENTER(); ATF_REQUIRE_ERRNO(EROFS, rump_sys_link(AFILE, ALINK) == -1); FSTEST_EXIT(); } ATF_TC_FSAPPLY_RO(create, "create file on r/o mount", nullgen); ATF_TC_FSAPPLY_RO(rmfile, "remove file from r/o mount", filegen); ATF_TC_FSAPPLY_RO(fileio, "can read a file but not write it", filegen); ATF_TC_FSAPPLY_RO(attrs, "can query but not change attributes", filegen); ATF_TC_FSAPPLY_RO(createdir, "create directory on r/o mount", nullgen); ATF_TC_FSAPPLY_RO(createfifo, "create fifo on r/o mount", nullgen); ATF_TC_FSAPPLY_RO(createsymlink, "create symlink on r/o mount", nullgen); ATF_TC_FSAPPLY_RO(createlink, "create hardlink on r/o mount", filegen); ATF_TP_ADD_TCS(tp) { ATF_TP_FSAPPLY_RO(create); ATF_TP_FSAPPLY_RO(rmfile); ATF_TP_FSAPPLY_RO(fileio); ATF_TP_FSAPPLY_RO(attrs); ATF_TP_FSAPPLY_RO(createdir); ATF_TP_FSAPPLY_RO(createfifo); ATF_TP_FSAPPLY_RO(createsymlink); ATF_TP_FSAPPLY_RO(createlink); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_union.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_union.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_union.c (revision 312126) @@ -1,204 +1,204 @@ -/* $NetBSD: t_union.c,v 1.8 2011/08/07 06:01:51 hannken Exp $ */ +/* $NetBSD: t_union.c,v 1.9 2017/01/13 21:30:40 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #include "../common/h_fsmacros.h" #define MSTR "magic bus" static void xput_tfile(const char *mp, const char *path) { char pathb[MAXPATHLEN]; int fd; strcpy(pathb, mp); strcat(pathb, "/"); strcat(pathb, path); RL(fd = rump_sys_open(pathb, O_CREAT | O_RDWR, 0777)); if (rump_sys_write(fd, MSTR, sizeof(MSTR)) != sizeof(MSTR)) atf_tc_fail_errno("write to testfile"); RL(rump_sys_close(fd)); } static int xread_tfile(const char *mp, const char *path) { char pathb[MAXPATHLEN]; char buf[128]; int fd; strcpy(pathb, mp); strcat(pathb, "/"); strcat(pathb, path); fd = rump_sys_open(pathb, O_RDONLY); if (fd == -1) return errno; if (rump_sys_read(fd, buf, sizeof(buf)) == -1) atf_tc_fail_errno("read tfile"); RL(rump_sys_close(fd)); if (strcmp(buf, MSTR) == 0) return 0; return EPROGMISMATCH; } /* * Mount a unionfs for testing. Before calling, "mp" contains * the upper layer. Lowerpath is constructed so that the directory * contains rumpfs. */ static void mountunion(const char *mp, char *lowerpath) { struct union_args unionargs; sprintf(lowerpath, "/lower"); rump_sys_mkdir(lowerpath, 0777); /* mount the union with our testfs as the upper layer */ memset(&unionargs, 0, sizeof(unionargs)); unionargs.target = lowerpath; unionargs.mntflags = UNMNT_BELOW; if (rump_sys_mount(MOUNT_UNION, mp, 0, &unionargs, sizeof(unionargs)) == -1) { if (errno == EOPNOTSUPP) { atf_tc_skip("fs does not support VOP_WHITEOUT"); } else { atf_tc_fail_errno("union mount"); } } } #if 0 static void toggleroot(void) { static int status; status ^= MNT_RDONLY; printf("0x%x\n", status); RL(rump_sys_mount(MOUNT_RUMPFS, "/", status | MNT_UPDATE, NULL, 0)); } #endif #define TFILE "tensti" #define TDIR "testdir" #define TDFILE TDIR "/indir" static void basic(const atf_tc_t *tc, const char *mp) { char lowerpath[MAXPATHLEN]; char dbuf[8192]; struct stat sb; struct dirent *dp; int error, fd, dsize; mountunion(mp, lowerpath); /* create a file in the lower layer */ xput_tfile(lowerpath, TFILE); /* first, test we can read the old file from the new namespace */ error = xread_tfile(mp, TFILE); if (error != 0) atf_tc_fail("union compare failed: %d (%s)", error, strerror(error)); /* then, test upper layer writes don't affect the lower layer */ xput_tfile(mp, "kiekko"); if ((error = xread_tfile(lowerpath, "kiekko")) != ENOENT) atf_tc_fail("invisibility failed: %d (%s)", error, strerror(error)); /* check that we can whiteout stuff in the upper layer */ FSTEST_ENTER(); RL(rump_sys_unlink(TFILE)); ATF_REQUIRE_ERRNO(ENOENT, rump_sys_stat(TFILE, &sb) == -1); FSTEST_EXIT(); /* check that the removed node is not in the directory listing */ RL(fd = rump_sys_open(mp, O_RDONLY)); RL(dsize = rump_sys_getdents(fd, dbuf, sizeof(dbuf))); for (dp = (struct dirent *)dbuf; (char *)dp < dbuf + dsize; dp = _DIRENT_NEXT(dp)) { if (strcmp(dp->d_name, TFILE) == 0 && dp->d_type != DT_WHT) atf_tc_fail("removed file non-white-outed"); } RL(rump_sys_close(fd)); RL(rump_sys_unmount(mp, 0)); } static void whiteout(const atf_tc_t *tc, const char *mp) { char lower[MAXPATHLEN]; struct stat sb; void *fsarg; /* * XXX: use ffs here to make sure any screwups in rumpfs don't * affect the test */ RL(ffs_fstest_newfs(tc, &fsarg, "daimage", 1024*1024*5, NULL)); RL(ffs_fstest_mount(tc, fsarg, "/lower", 0)); /* create a file in the lower layer */ RL(rump_sys_chdir("/lower")); RL(rump_sys_mkdir(TDIR, 0777)); RL(rump_sys_mkdir(TDFILE, 0777)); RL(rump_sys_chdir("/")); RL(ffs_fstest_unmount(tc, "/lower", 0)); RL(ffs_fstest_mount(tc, fsarg, "/lower", MNT_RDONLY)); mountunion(mp, lower); FSTEST_ENTER(); ATF_REQUIRE_ERRNO(ENOTEMPTY, rump_sys_rmdir(TDIR) == -1); RL(rump_sys_rmdir(TDFILE)); RL(rump_sys_rmdir(TDIR)); ATF_REQUIRE_ERRNO(ENOENT, rump_sys_stat(TDFILE, &sb) == -1); ATF_REQUIRE_ERRNO(ENOENT, rump_sys_stat(TDIR, &sb) == -1); RL(rump_sys_mkdir(TDIR, 0777)); RL(rump_sys_stat(TDIR, &sb)); ATF_REQUIRE_ERRNO(ENOENT, rump_sys_stat(TDFILE, &sb) == -1); FSTEST_EXIT(); RL(rump_sys_unmount(mp, 0)); } ATF_TC_FSAPPLY(basic, "check basic union functionality"); ATF_TC_FSAPPLY(whiteout, "create whiteout in upper layer"); ATF_TP_ADD_TCS(tp) { ATF_TP_FSAPPLY(basic); ATF_TP_FSAPPLY(whiteout); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_unpriv.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_unpriv.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_unpriv.c (revision 312126) @@ -1,239 +1,239 @@ -/* $NetBSD: t_unpriv.c,v 1.12 2015/04/09 19:51:13 riastradh Exp $ */ +/* $NetBSD: t_unpriv.c,v 1.13 2017/01/13 21:30:40 christos Exp $ */ /*- * Copyright (c) 2011 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 #include #include "../common/h_fsmacros.h" -#include "../../h_macros.h" +#include "h_macros.h" #define USES_OWNER \ if (FSTYPE_MSDOS(tc)) \ atf_tc_skip("owner not supported by file system") static void owner(const atf_tc_t *tc, const char *mp) { USES_OWNER; FSTEST_ENTER(); rump_pub_lwproc_rfork(RUMP_RFCFDG); if (rump_sys_setuid(1) == -1) atf_tc_fail_errno("setuid"); if (rump_sys_chown(".", 1, -1) != -1 || errno != EPERM) atf_tc_fail_errno("chown"); if (rump_sys_chmod(".", 0000) != -1 || errno != EPERM) atf_tc_fail_errno("chmod"); rump_pub_lwproc_releaselwp(); if (rump_sys_chown(".", 1, -1) == -1) atf_tc_fail_errno("chown"); rump_pub_lwproc_rfork(RUMP_RFCFDG); if (rump_sys_setuid(1) == -1) atf_tc_fail_errno("setuid"); if (rump_sys_chown(".", 1, -1) == -1) atf_tc_fail_errno("chown"); if (rump_sys_chmod(".", 0000) == -1) atf_tc_fail_errno("chmod"); rump_pub_lwproc_releaselwp(); FSTEST_EXIT(); } static void dirperms(const atf_tc_t *tc, const char *mp) { char name[] = "dir.test/file.test"; char *dir = dirname(name); int fd; if (FSTYPE_SYSVBFS(tc)) atf_tc_skip("directories not supported by file system"); FSTEST_ENTER(); if (rump_sys_mkdir(dir, 0777) == -1) atf_tc_fail_errno("mkdir"); rump_pub_lwproc_rfork(RUMP_RFCFDG); if (rump_sys_setuid(1) == -1) atf_tc_fail_errno("setuid"); if (FSTYPE_ZFS(tc)) atf_tc_expect_fail("PR kern/47656: Test known to be broken"); if (rump_sys_open(name, O_RDWR|O_CREAT, 0666) != -1 || errno != EACCES) atf_tc_fail_errno("open"); rump_pub_lwproc_releaselwp(); if ((fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666)) == -1) atf_tc_fail_errno("open"); if (rump_sys_close(fd) == -1) atf_tc_fail_errno("close"); rump_pub_lwproc_rfork(RUMP_RFCFDG); if (rump_sys_setuid(1) == -1) atf_tc_fail_errno("setuid"); if (rump_sys_unlink(name) != -1 || errno != EACCES) atf_tc_fail_errno("unlink"); rump_pub_lwproc_releaselwp(); if (rump_sys_unlink(name) == -1) atf_tc_fail_errno("unlink"); if (rump_sys_rmdir(dir) == -1) atf_tc_fail_errno("rmdir"); FSTEST_EXIT(); } static void times(const atf_tc_t *tc, const char *mp) { const char *name = "file.test"; int fd; unsigned int i, j; struct timeval tmv[2]; static struct timeval tmvs[] = { { QUAD_MIN, 0 }, { 0, 0 }, { QUAD_MAX, 999999 } }; FSTEST_ENTER(); if ((fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666)) == -1) atf_tc_fail_errno("open"); if (rump_sys_close(fd) == -1) atf_tc_fail_errno("close"); rump_pub_lwproc_rfork(RUMP_RFCFDG); if (rump_sys_setuid(1) == -1) atf_tc_fail_errno("setuid"); if (FSTYPE_ZFS(tc)) atf_tc_expect_fail("PR kern/47656: Test known to be broken"); if (rump_sys_utimes(name, NULL) != -1 || errno != EACCES) atf_tc_fail_errno("utimes"); rump_pub_lwproc_releaselwp(); if (rump_sys_utimes(name, NULL) == -1) atf_tc_fail_errno("utimes"); for (i = 0; i < sizeof(tmvs) / sizeof(tmvs[0]); i++) { for (j = 0; j < sizeof(tmvs) / sizeof(tmvs[0]); j++) { tmv[0] = tmvs[i]; tmv[1] = tmvs[j]; rump_pub_lwproc_rfork(RUMP_RFCFDG); if (rump_sys_setuid(1) == -1) atf_tc_fail_errno("setuid"); if (rump_sys_utimes(name, tmv) != -1 || errno != EPERM) atf_tc_fail_errno("utimes"); rump_pub_lwproc_releaselwp(); if (rump_sys_utimes(name, tmv) == -1) atf_tc_fail_errno("utimes"); } } if (rump_sys_unlink(name) == -1) atf_tc_fail_errno("unlink"); FSTEST_EXIT(); } static void flags(const atf_tc_t *tc, const char *mp) { const char *name = "file.test"; int fd, fflags; struct stat st; FSTEST_ENTER(); if ((fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666)) == -1) atf_tc_fail_errno("open"); if (rump_sys_close(fd) == -1) atf_tc_fail_errno("close"); if (rump_sys_stat(name, &st) == -1) atf_tc_fail_errno("stat"); if (FSTYPE_ZFS(tc)) atf_tc_expect_fail("PR kern/47656: Test known to be broken"); if (rump_sys_chflags(name, st.st_flags) == -1) { if (errno == EOPNOTSUPP) atf_tc_skip("file flags not supported by file system"); atf_tc_fail_errno("chflags"); } fflags = st.st_flags | UF_IMMUTABLE; rump_pub_lwproc_rfork(RUMP_RFCFDG); if (rump_sys_setuid(1) == -1) atf_tc_fail_errno("setuid"); fflags |= UF_IMMUTABLE; if (rump_sys_chflags(name, fflags) != -1 || errno != EPERM) atf_tc_fail_errno("chflags"); rump_pub_lwproc_releaselwp(); if (rump_sys_chflags(name, fflags) == -1) atf_tc_fail_errno("chflags"); fflags &= ~UF_IMMUTABLE; if (rump_sys_chflags(name, fflags) == -1) atf_tc_fail_errno("chflags"); if (rump_sys_unlink(name) == -1) atf_tc_fail_errno("unlink"); FSTEST_EXIT(); } ATF_TC_FSAPPLY(owner, "owner unprivileged checks"); ATF_TC_FSAPPLY(dirperms, "directory permission checks"); ATF_TC_FSAPPLY(times, "time set checks"); ATF_TC_FSAPPLY(flags, "file flags checks"); ATF_TP_ADD_TCS(tp) { ATF_TP_FSAPPLY(owner); ATF_TP_FSAPPLY(dirperms); ATF_TP_FSAPPLY(times); ATF_TP_FSAPPLY(flags); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_vfsops.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_vfsops.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_vfsops.c (revision 312126) @@ -1,211 +1,211 @@ -/* $NetBSD: t_vfsops.c,v 1.11 2011/04/04 19:16:58 hannken Exp $ */ +/* $NetBSD: t_vfsops.c,v 1.12 2017/01/13 21:30:40 christos 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 #include #include #include "../common/h_fsmacros.h" -#include "../../h_macros.h" +#include "h_macros.h" static void tmount(const atf_tc_t *tc, const char *path) { return; } static void tstatvfs(const atf_tc_t *tc, const char *path) { const char *fstype = atf_tc_get_md_var(tc, "X-fs.mntname"); struct statvfs svb; if (rump_sys_statvfs1(path, &svb, ST_WAIT) == -1) atf_tc_fail_errno("statvfs"); ATF_REQUIRE(svb.f_namemax > 0 && svb.f_namemax <= MAXNAMLEN); if (!(FSTYPE_PUFFS(tc) || FSTYPE_P2K_FFS(tc))) ATF_REQUIRE_STREQ(svb.f_fstypename, fstype); ATF_REQUIRE_STREQ(svb.f_mntonname, path); } static void tsync(const atf_tc_t *tc, const char *path) { rump_sys_sync(); } #define MAGICSTR "just a string, I like A" static void tfilehandle(const atf_tc_t *tc, const char *path) { char fpath[MAXPATHLEN]; char buf[sizeof(MAGICSTR)]; size_t fhsize; void *fhp; int fd; sprintf(fpath, "%s/file", path); fd = rump_sys_open(fpath, O_RDWR | O_CREAT, 0777); if (fd == -1) atf_tc_fail_errno("open"); if (rump_sys_write(fd, MAGICSTR, sizeof(MAGICSTR)) != sizeof(MAGICSTR)) atf_tc_fail("write to file"); rump_sys_close(fd); /* * Get file handle size. * This also weeds out unsupported file systems. */ fhsize = 0; if (rump_sys_getfh(fpath, NULL, &fhsize) == -1) { if (errno == EOPNOTSUPP) { atf_tc_skip("file handles not supported"); } else if (errno != E2BIG) { atf_tc_fail_errno("getfh size"); } } fhp = malloc(fhsize); if (rump_sys_getfh(fpath, fhp, &fhsize) == -1) atf_tc_fail_errno("getfh"); /* open file based on file handle */ fd = rump_sys_fhopen(fhp, fhsize, O_RDONLY); if (fd == -1) { atf_tc_fail_errno("fhopen"); } /* check that we got the same file */ if (rump_sys_read(fd, buf, sizeof(buf)) != sizeof(MAGICSTR)) atf_tc_fail("read fhopened file"); ATF_REQUIRE_STREQ(buf, MAGICSTR); rump_sys_close(fd); } #define FNAME "a_file" static void tfhremove(const atf_tc_t *tc, const char *path) { size_t fhsize; void *fhp; int fd; RL(rump_sys_chdir(path)); RL(fd = rump_sys_open(FNAME, O_RDWR | O_CREAT, 0777)); RL(rump_sys_close(fd)); fhsize = 0; if (rump_sys_getfh(FNAME, NULL, &fhsize) == -1) { if (errno == EOPNOTSUPP) { atf_tc_skip("file handles not supported"); } else if (errno != E2BIG) { atf_tc_fail_errno("getfh size"); } } fhp = malloc(fhsize); RL(rump_sys_getfh(FNAME, fhp, &fhsize)); RL(rump_sys_unlink(FNAME)); if (FSTYPE_LFS(tc)) atf_tc_expect_fail("fhopen() for removed file succeeds " "(PR kern/43745)"); ATF_REQUIRE_ERRNO(ESTALE, rump_sys_fhopen(fhp, fhsize, O_RDONLY) == -1); atf_tc_expect_pass(); RL(rump_sys_chdir("/")); } #undef FNAME /* * This test only checks the file system doesn't crash. We *might* * try a valid file handle. */ static void tfhinval(const atf_tc_t *tc, const char *path) { size_t fhsize; void *fhp; unsigned long seed; int fd; srandom(seed = time(NULL)); printf("RNG seed %lu\n", seed); RL(rump_sys_chdir(path)); fhsize = 0; if (rump_sys_getfh(".", NULL, &fhsize) == -1) { if (errno == EOPNOTSUPP) { atf_tc_skip("file handles not supported"); } else if (errno != E2BIG) { atf_tc_fail_errno("getfh size"); } } fhp = malloc(fhsize); tests_makegarbage(fhp, fhsize); fd = rump_sys_fhopen(fhp, fhsize, O_RDWR); if (fd != -1) rump_sys_close(fd); RL(rump_sys_chdir("/")); } ATF_TC_FSAPPLY(tmount, "mount/unmount"); ATF_TC_FSAPPLY(tstatvfs, "statvfs"); ATF_TC_FSAPPLY(tsync, "sync"); ATF_TC_FSAPPLY(tfilehandle, "file handles"); ATF_TC_FSAPPLY(tfhremove, "fhtovp for removed file"); ATF_TC_FSAPPLY(tfhinval, "fhopen invalid filehandle"); ATF_TP_ADD_TCS(tp) { ATF_TP_FSAPPLY(tmount); ATF_TP_FSAPPLY(tstatvfs); ATF_TP_FSAPPLY(tsync); ATF_TP_FSAPPLY(tfilehandle); ATF_TP_FSAPPLY(tfhremove); ATF_TP_FSAPPLY(tfhinval); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_vnops.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_vnops.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/fs/vfs/t_vnops.c (revision 312126) @@ -1,1080 +1,1080 @@ -/* $NetBSD: t_vnops.c,v 1.58 2016/08/29 02:31:46 kre Exp $ */ +/* $NetBSD: t_vnops.c,v 1.59 2017/01/13 21:30:40 christos 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 #include #include #include #include #include #include #include "../common/h_fsmacros.h" -#include "../../h_macros.h" +#include "h_macros.h" #define TESTFILE "afile" #define USES_DIRS \ if (FSTYPE_SYSVBFS(tc)) \ atf_tc_skip("directories not supported by file system") #define USES_SYMLINKS \ if (FSTYPE_SYSVBFS(tc) || FSTYPE_MSDOS(tc)) \ atf_tc_skip("symlinks not supported by file system") static char * md(char *buf, size_t buflen, const char *base, const char *tail) { snprintf(buf, buflen, "%s/%s", base, tail); return buf; } static void lookup_simple(const atf_tc_t *tc, const char *mountpath) { char pb[MAXPATHLEN], final[MAXPATHLEN]; struct stat sb1, sb2; strcpy(final, mountpath); snprintf(pb, sizeof(pb), "%s/../%s", mountpath, basename(final)); if (rump_sys_stat(pb, &sb1) == -1) atf_tc_fail_errno("stat 1"); snprintf(pb, sizeof(pb), "%s/./../%s", mountpath, basename(final)); if (rump_sys_stat(pb, &sb2) == -1) atf_tc_fail_errno("stat 2"); ATF_REQUIRE(memcmp(&sb1, &sb2, sizeof(sb1)) == 0); } static void lookup_complex(const atf_tc_t *tc, const char *mountpath) { char pb[MAXPATHLEN]; struct stat sb1, sb2; struct timespec atplus1, onesec; USES_DIRS; snprintf(pb, sizeof(pb), "%s/dir", mountpath); if (rump_sys_mkdir(pb, 0777) == -1) atf_tc_fail_errno("mkdir"); if (rump_sys_stat(pb, &sb1) == -1) atf_tc_fail_errno("stat 1"); snprintf(pb, sizeof(pb), "%s/./dir/../././dir/.", mountpath); if (rump_sys_stat(pb, &sb2) == -1) atf_tc_fail_errno("stat 2"); /* * The lookup is permitted to modify the access time of * any directories searched - such a directory is the * subject of this test. Any difference should cause * the 2nd lookup atime tp be >= the first, if it is ==, all is * OK (atime is not required to be modified by the search, or * both references may happen within the came clock tick), if the * 2nd lookup atime is > the first, but not "too much" greater, * just set it back, so the memcmp just below succeeds * (assuming all else is OK). */ onesec.tv_sec = 1; onesec.tv_nsec = 0; timespecadd(&sb1.st_atimespec, &onesec, &atplus1); if (timespeccmp(&sb2.st_atimespec, &sb1.st_atimespec, >) && timespeccmp(&sb2.st_atimespec, &atplus1, <)) sb2.st_atimespec = sb1.st_atimespec; if (memcmp(&sb1, &sb2, sizeof(sb1)) != 0) { printf("what\tsb1\t\tsb2\n"); #define FIELD(FN) \ printf(#FN "\t%lld\t%lld\n", \ (long long)sb1.FN, (long long)sb2.FN) #define TIME(FN) \ printf(#FN "\t%lld.%ld\t%lld.%ld\n", \ (long long)sb1.FN.tv_sec, sb1.FN.tv_nsec, \ (long long)sb2.FN.tv_sec, sb2.FN.tv_nsec) FIELD(st_dev); FIELD(st_mode); FIELD(st_ino); FIELD(st_nlink); FIELD(st_uid); FIELD(st_gid); FIELD(st_rdev); TIME(st_atimespec); TIME(st_mtimespec); TIME(st_ctimespec); TIME(st_birthtimespec); FIELD(st_size); FIELD(st_blocks); FIELD(st_flags); FIELD(st_gen); #undef FIELD #undef TIME atf_tc_fail("stat results differ, see ouput for more details"); } } static void dir_simple(const atf_tc_t *tc, const char *mountpath) { char pb[MAXPATHLEN]; struct stat sb; USES_DIRS; /* check we can create directories */ snprintf(pb, sizeof(pb), "%s/dir", mountpath); if (rump_sys_mkdir(pb, 0777) == -1) atf_tc_fail_errno("mkdir"); if (rump_sys_stat(pb, &sb) == -1) atf_tc_fail_errno("stat new directory"); /* check we can remove then and that it makes them unreachable */ if (rump_sys_rmdir(pb) == -1) atf_tc_fail_errno("rmdir"); if (rump_sys_stat(pb, &sb) != -1 || errno != ENOENT) atf_tc_fail("ENOENT expected from stat"); } static void dir_notempty(const atf_tc_t *tc, const char *mountpath) { char pb[MAXPATHLEN], pb2[MAXPATHLEN]; int fd, rv; USES_DIRS; /* check we can create directories */ snprintf(pb, sizeof(pb), "%s/dir", mountpath); if (rump_sys_mkdir(pb, 0777) == -1) atf_tc_fail_errno("mkdir"); snprintf(pb2, sizeof(pb2), "%s/dir/file", mountpath); fd = rump_sys_open(pb2, O_RDWR | O_CREAT, 0777); if (fd == -1) atf_tc_fail_errno("create file"); rump_sys_close(fd); rv = rump_sys_rmdir(pb); if (rv != -1 || errno != ENOTEMPTY) atf_tc_fail("non-empty directory removed succesfully"); if (rump_sys_unlink(pb2) == -1) atf_tc_fail_errno("cannot remove dir/file"); if (rump_sys_rmdir(pb) == -1) atf_tc_fail_errno("remove directory"); } static void dir_rmdirdotdot(const atf_tc_t *tc, const char *mp) { char pb[MAXPATHLEN]; int xerrno; USES_DIRS; FSTEST_ENTER(); RL(rump_sys_mkdir("test", 0777)); RL(rump_sys_chdir("test")); RL(rump_sys_mkdir("subtest", 0777)); RL(rump_sys_chdir("subtest")); md(pb, sizeof(pb), mp, "test/subtest"); RL(rump_sys_rmdir(pb)); md(pb, sizeof(pb), mp, "test"); RL(rump_sys_rmdir(pb)); if (FSTYPE_NFS(tc)) xerrno = ESTALE; else xerrno = ENOENT; ATF_REQUIRE_ERRNO(xerrno, rump_sys_chdir("..") == -1); FSTEST_EXIT(); } static void checkfile(const char *path, struct stat *refp) { char buf[MAXPATHLEN]; struct stat sb; static int n = 1; md(buf, sizeof(buf), path, "file"); if (rump_sys_stat(buf, &sb) == -1) atf_tc_fail_errno("cannot stat file %d (%s)", n, buf); if (memcmp(&sb, refp, sizeof(sb)) != 0) atf_tc_fail("stat mismatch %d", n); n++; } static void rename_dir(const atf_tc_t *tc, const char *mp) { char pb1[MAXPATHLEN], pb2[MAXPATHLEN], pb3[MAXPATHLEN]; struct stat ref, sb; if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); USES_DIRS; md(pb1, sizeof(pb1), mp, "dir1"); if (rump_sys_mkdir(pb1, 0777) == -1) atf_tc_fail_errno("mkdir 1"); md(pb2, sizeof(pb2), mp, "dir2"); if (rump_sys_mkdir(pb2, 0777) == -1) atf_tc_fail_errno("mkdir 2"); md(pb2, sizeof(pb2), mp, "dir2/subdir"); if (rump_sys_mkdir(pb2, 0777) == -1) atf_tc_fail_errno("mkdir 3"); md(pb3, sizeof(pb3), mp, "dir1/file"); if (rump_sys_mknod(pb3, S_IFREG | 0777, -1) == -1) atf_tc_fail_errno("create file"); if (rump_sys_stat(pb3, &ref) == -1) atf_tc_fail_errno("stat of file"); /* * First try ops which should succeed. */ /* rename within directory */ md(pb3, sizeof(pb3), mp, "dir3"); if (rump_sys_rename(pb1, pb3) == -1) atf_tc_fail_errno("rename 1"); checkfile(pb3, &ref); /* rename directory onto itself (two ways, should fail) */ md(pb1, sizeof(pb1), mp, "dir3/."); if (rump_sys_rename(pb1, pb3) != -1 || errno != EINVAL) atf_tc_fail_errno("rename 2"); if (rump_sys_rename(pb3, pb1) != -1 || errno != EISDIR) atf_tc_fail_errno("rename 3"); checkfile(pb3, &ref); /* rename father of directory into directory */ md(pb1, sizeof(pb1), mp, "dir2/dir"); md(pb2, sizeof(pb2), mp, "dir2"); if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL) atf_tc_fail_errno("rename 4"); /* same for grandfather */ md(pb1, sizeof(pb1), mp, "dir2/subdir/dir2"); if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL) atf_tc_fail("rename 5"); checkfile(pb3, &ref); /* rename directory over a non-empty directory */ if (rump_sys_rename(pb2, pb3) != -1 || errno != ENOTEMPTY) atf_tc_fail("rename 6"); /* cross-directory rename */ md(pb1, sizeof(pb1), mp, "dir3"); md(pb2, sizeof(pb2), mp, "dir2/somedir"); if (rump_sys_rename(pb1, pb2) == -1) atf_tc_fail_errno("rename 7"); checkfile(pb2, &ref); /* move to parent directory */ md(pb1, sizeof(pb1), mp, "dir2/somedir/../../dir3"); if (rump_sys_rename(pb2, pb1) == -1) atf_tc_fail_errno("rename 8"); md(pb1, sizeof(pb1), mp, "dir2/../dir3"); checkfile(pb1, &ref); /* atomic cross-directory rename */ md(pb3, sizeof(pb3), mp, "dir2/subdir"); if (rump_sys_rename(pb1, pb3) == -1) atf_tc_fail_errno("rename 9"); checkfile(pb3, &ref); /* rename directory over an empty directory */ md(pb1, sizeof(pb1), mp, "parent"); md(pb2, sizeof(pb2), mp, "parent/dir1"); md(pb3, sizeof(pb3), mp, "parent/dir2"); RL(rump_sys_mkdir(pb1, 0777)); RL(rump_sys_mkdir(pb2, 0777)); RL(rump_sys_mkdir(pb3, 0777)); RL(rump_sys_rename(pb2, pb3)); RL(rump_sys_stat(pb1, &sb)); if (! FSTYPE_MSDOS(tc)) ATF_CHECK_EQ(sb.st_nlink, 3); RL(rump_sys_rmdir(pb3)); RL(rump_sys_rmdir(pb1)); } static void rename_dotdot(const atf_tc_t *tc, const char *mp) { if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); USES_DIRS; if (rump_sys_chdir(mp) == -1) atf_tc_fail_errno("chdir mountpoint"); if (rump_sys_mkdir("dir1", 0777) == -1) atf_tc_fail_errno("mkdir 1"); if (rump_sys_mkdir("dir2", 0777) == -1) atf_tc_fail_errno("mkdir 2"); if (rump_sys_rename("dir1", "dir1/..") != -1 || errno != EINVAL) atf_tc_fail_errno("self-dotdot to"); if (rump_sys_rename("dir1/..", "sometarget") != -1 || errno != EINVAL) atf_tc_fail_errno("self-dotdot from"); if (rump_sys_rename("dir1", "dir2/..") != -1 || errno != EINVAL) atf_tc_fail("other-dotdot"); rump_sys_chdir("/"); } static void rename_reg_nodir(const atf_tc_t *tc, const char *mp) { bool haslinks; struct stat sb; ino_t f1ino; if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); if (rump_sys_chdir(mp) == -1) atf_tc_fail_errno("chdir mountpoint"); if (FSTYPE_MSDOS(tc) || FSTYPE_SYSVBFS(tc)) haslinks = false; else haslinks = true; if (rump_sys_mknod("file1", S_IFREG | 0777, -1) == -1) atf_tc_fail_errno("create file"); if (rump_sys_mknod("file2", S_IFREG | 0777, -1) == -1) atf_tc_fail_errno("create file"); if (rump_sys_stat("file1", &sb) == -1) atf_tc_fail_errno("stat"); f1ino = sb.st_ino; if (haslinks) { if (rump_sys_link("file1", "file_link") == -1) atf_tc_fail_errno("link"); if (rump_sys_stat("file_link", &sb) == -1) atf_tc_fail_errno("stat"); ATF_REQUIRE_EQ(sb.st_ino, f1ino); ATF_REQUIRE_EQ(sb.st_nlink, 2); } if (rump_sys_stat("file2", &sb) == -1) atf_tc_fail_errno("stat"); if (rump_sys_rename("file1", "file3") == -1) atf_tc_fail_errno("rename 1"); if (rump_sys_stat("file3", &sb) == -1) atf_tc_fail_errno("stat 1"); if (haslinks) { ATF_REQUIRE_EQ(sb.st_ino, f1ino); } if (rump_sys_stat("file1", &sb) != -1 || errno != ENOENT) atf_tc_fail_errno("source 1"); if (rump_sys_rename("file3", "file2") == -1) atf_tc_fail_errno("rename 2"); if (rump_sys_stat("file2", &sb) == -1) atf_tc_fail_errno("stat 2"); if (haslinks) { ATF_REQUIRE_EQ(sb.st_ino, f1ino); } if (rump_sys_stat("file3", &sb) != -1 || errno != ENOENT) atf_tc_fail_errno("source 2"); if (haslinks) { if (rump_sys_rename("file2", "file_link") == -1) atf_tc_fail_errno("rename hardlink"); if (rump_sys_stat("file2", &sb) != -1 || errno != ENOENT) atf_tc_fail_errno("source 3"); if (rump_sys_stat("file_link", &sb) == -1) atf_tc_fail_errno("stat 2"); ATF_REQUIRE_EQ(sb.st_ino, f1ino); ATF_REQUIRE_EQ(sb.st_nlink, 1); } ATF_CHECK_ERRNO(EFAULT, rump_sys_rename("file2", NULL) == -1); ATF_CHECK_ERRNO(EFAULT, rump_sys_rename(NULL, "file2") == -1); rump_sys_chdir("/"); } /* PR kern/50607 */ static void create_many(const atf_tc_t *tc, const char *mp) { char buf[64]; int nfiles = 2324; /* #Nancy */ int i; /* takes forever with many files */ if (FSTYPE_MSDOS(tc)) nfiles /= 4; RL(rump_sys_chdir(mp)); if (FSTYPE_SYSVBFS(tc)) { /* fs doesn't support many files or subdirectories */ nfiles = 5; } else { /* msdosfs doesn't like many entries in the root directory */ RL(rump_sys_mkdir("subdir", 0777)); RL(rump_sys_chdir("subdir")); } /* create them */ #define TESTFN "testfile" for (i = 0; i < nfiles; i++) { int fd; snprintf(buf, sizeof(buf), TESTFN "%d", i); RL(fd = rump_sys_open(buf, O_RDWR|O_CREAT|O_EXCL, 0666)); RL(rump_sys_close(fd)); } /* wipe them out */ for (i = 0; i < nfiles; i++) { snprintf(buf, sizeof(buf), TESTFN "%d", i); RLF(rump_sys_unlink(buf), "%s", buf); } #undef TESTFN rump_sys_chdir("/"); } /* * Test creating files with one-character names using all possible * character values. Failures to create the file are ignored as the * characters allowed in file names vary by file system, but at least * we can check that the fs does not crash, and if the file is * successfully created, unlinking it should also succeed. */ static void create_nonalphanum(const atf_tc_t *tc, const char *mp) { char buf[64]; int i; RL(rump_sys_chdir(mp)); for (i = 0; i < 256; i++) { int fd; snprintf(buf, sizeof(buf), "%c", i); fd = rump_sys_open(buf, O_RDWR|O_CREAT|O_EXCL, 0666); if (fd == -1) continue; RLF(rump_sys_close(fd), "%d", fd); RLF(rump_sys_unlink(buf), "%s", buf); } printf("\n"); rump_sys_chdir("/"); } static void create_nametoolong(const atf_tc_t *tc, const char *mp) { char *name; int fd; long val; size_t len; if (rump_sys_chdir(mp) == -1) atf_tc_fail_errno("chdir mountpoint"); val = rump_sys_pathconf(".", _PC_NAME_MAX); if (val == -1) atf_tc_fail_errno("pathconf"); len = val + 1; name = malloc(len+1); if (name == NULL) atf_tc_fail_errno("malloc"); memset(name, 'a', len); *(name+len) = '\0'; val = rump_sys_pathconf(".", _PC_NO_TRUNC); if (val == -1) atf_tc_fail_errno("pathconf"); fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666); if (val != 0 && (fd != -1 || errno != ENAMETOOLONG)) atf_tc_fail_errno("open"); if (val == 0 && rump_sys_close(fd) == -1) atf_tc_fail_errno("close"); if (val == 0 && rump_sys_unlink(name) == -1) atf_tc_fail_errno("unlink"); free(name); rump_sys_chdir("/"); } static void create_exist(const atf_tc_t *tc, const char *mp) { const char *name = "hoge"; int fd; RL(rump_sys_chdir(mp)); RL(fd = rump_sys_open(name, O_RDWR|O_CREAT|O_EXCL, 0666)); RL(rump_sys_close(fd)); RL(rump_sys_unlink(name)); RL(fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666)); RL(rump_sys_close(fd)); RL(fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666)); RL(rump_sys_close(fd)); ATF_REQUIRE_ERRNO(EEXIST, (fd = rump_sys_open(name, O_RDWR|O_CREAT|O_EXCL, 0666))); RL(rump_sys_unlink(name)); RL(rump_sys_chdir("/")); } static void rename_nametoolong(const atf_tc_t *tc, const char *mp) { char *name; int res, fd; long val; size_t len; if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); if (rump_sys_chdir(mp) == -1) atf_tc_fail_errno("chdir mountpoint"); val = rump_sys_pathconf(".", _PC_NAME_MAX); if (val == -1) atf_tc_fail_errno("pathconf"); len = val + 1; name = malloc(len+1); if (name == NULL) atf_tc_fail_errno("malloc"); memset(name, 'a', len); *(name+len) = '\0'; fd = rump_sys_open("dummy", O_RDWR|O_CREAT, 0666); if (fd == -1) atf_tc_fail_errno("open"); if (rump_sys_close(fd) == -1) atf_tc_fail_errno("close"); val = rump_sys_pathconf(".", _PC_NO_TRUNC); if (val == -1) atf_tc_fail_errno("pathconf"); res = rump_sys_rename("dummy", name); if (val != 0 && (res != -1 || errno != ENAMETOOLONG)) atf_tc_fail_errno("rename"); if (val == 0 && rump_sys_unlink(name) == -1) atf_tc_fail_errno("unlink"); free(name); rump_sys_chdir("/"); } /* * Test creating a symlink whose length is "len" bytes, not including * the terminating NUL. */ static void symlink_len(const atf_tc_t *tc, const char *mp, size_t len) { char *buf; int r; USES_SYMLINKS; RLF(rump_sys_chdir(mp), "%s", mp); buf = malloc(len + 1); ATF_REQUIRE(buf); memset(buf, 'a', len); buf[len] = '\0'; r = rump_sys_symlink(buf, "afile"); if (r == -1) { ATF_REQUIRE_ERRNO(ENAMETOOLONG, r); } else { RL(rump_sys_unlink("afile")); } free(buf); RL(rump_sys_chdir("/")); } static void symlink_zerolen(const atf_tc_t *tc, const char *mp) { symlink_len(tc, mp, 0); } static void symlink_long(const atf_tc_t *tc, const char *mp) { /* * Test lengths close to powers of two, as those are likely * to be edge cases. */ size_t len; int fuzz; for (len = 2; len <= 65536; len *= 2) { for (fuzz = -1; fuzz <= 1; fuzz++) { symlink_len(tc, mp, len + fuzz); } } } static void symlink_root(const atf_tc_t *tc, const char *mp) { USES_SYMLINKS; RL(rump_sys_chdir(mp)); RL(rump_sys_symlink("/", "foo")); RL(rump_sys_chdir("foo")); } static void attrs(const atf_tc_t *tc, const char *mp) { struct stat sb, sb2; struct timeval tv[2]; int fd; FSTEST_ENTER(); RL(fd = rump_sys_open(TESTFILE, O_RDWR | O_CREAT, 0755)); RL(rump_sys_close(fd)); RL(rump_sys_stat(TESTFILE, &sb)); if (!(FSTYPE_MSDOS(tc) || FSTYPE_SYSVBFS(tc))) { RL(rump_sys_chown(TESTFILE, 1, 2)); sb.st_uid = 1; sb.st_gid = 2; RL(rump_sys_chmod(TESTFILE, 0123)); sb.st_mode = (sb.st_mode & ~ACCESSPERMS) | 0123; } tv[0].tv_sec = 1000000000; /* need something >1980 for msdosfs */ tv[0].tv_usec = 1; tv[1].tv_sec = 1000000002; /* need even seconds for msdosfs */ tv[1].tv_usec = 3; RL(rump_sys_utimes(TESTFILE, tv)); RL(rump_sys_utimes(TESTFILE, tv)); /* XXX: utimes & birthtime */ sb.st_atimespec.tv_sec = 1000000000; sb.st_atimespec.tv_nsec = 1000; sb.st_mtimespec.tv_sec = 1000000002; sb.st_mtimespec.tv_nsec = 3000; RL(rump_sys_stat(TESTFILE, &sb2)); #define CHECK(a) ATF_REQUIRE_EQ(sb.a, sb2.a) if (!(FSTYPE_MSDOS(tc) || FSTYPE_SYSVBFS(tc))) { CHECK(st_uid); CHECK(st_gid); CHECK(st_mode); } if (!FSTYPE_MSDOS(tc)) { /* msdosfs has only access date, not time */ CHECK(st_atimespec.tv_sec); } CHECK(st_mtimespec.tv_sec); if (!(FSTYPE_EXT2FS(tc) || FSTYPE_MSDOS(tc) || FSTYPE_SYSVBFS(tc) || FSTYPE_V7FS(tc))) { CHECK(st_atimespec.tv_nsec); CHECK(st_mtimespec.tv_nsec); } #undef CHECK FSTEST_EXIT(); } static void fcntl_lock(const atf_tc_t *tc, const char *mp) { int fd, fd2; struct flock l; struct lwp *lwp1, *lwp2; FSTEST_ENTER(); l.l_pid = 0; l.l_start = l.l_len = 1024; l.l_type = F_RDLCK | F_WRLCK; l.l_whence = SEEK_END; lwp1 = rump_pub_lwproc_curlwp(); RL(fd = rump_sys_open(TESTFILE, O_RDWR | O_CREAT, 0755)); RL(rump_sys_ftruncate(fd, 8192)); RL(rump_sys_fcntl(fd, F_SETLK, &l)); /* Next, we fork and try to lock the same area */ RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); lwp2 = rump_pub_lwproc_curlwp(); RL(fd2 = rump_sys_open(TESTFILE, O_RDWR, 0)); ATF_REQUIRE_ERRNO(EAGAIN, rump_sys_fcntl(fd2, F_SETLK, &l)); /* Switch back and unlock... */ rump_pub_lwproc_switch(lwp1); l.l_type = F_UNLCK; RL(rump_sys_fcntl(fd, F_SETLK, &l)); /* ... and try to lock again */ rump_pub_lwproc_switch(lwp2); l.l_type = F_RDLCK | F_WRLCK; RL(rump_sys_fcntl(fd2, F_SETLK, &l)); RL(rump_sys_close(fd2)); rump_pub_lwproc_releaselwp(); RL(rump_sys_close(fd)); FSTEST_EXIT(); } static int flock_compare(const void *p, const void *q) { int a = ((const struct flock *)p)->l_start; int b = ((const struct flock *)q)->l_start; return a < b ? -1 : (a > b ? 1 : 0); } /* * Find all locks set by fcntl_getlock_pids test * using GETLK for a range [start, start+end], and, * if there is a blocking lock, recursively find * all locks to the left (toward the beginning of * a file) and to the right of the lock. * The function also understands "until end of file" * convention when len==0. */ static unsigned int fcntl_getlocks(int fildes, off_t start, off_t len, struct flock *lock, struct flock *end) { unsigned int rv = 0; const struct flock l = { start, len, 0, F_RDLCK, SEEK_SET }; if (lock == end) return rv; RL(rump_sys_fcntl(fildes, F_GETLK, &l)); if (l.l_type == F_UNLCK) return rv; *lock++ = l; rv += 1; ATF_REQUIRE(l.l_whence == SEEK_SET); if (l.l_start > start) { unsigned int n = fcntl_getlocks(fildes, start, l.l_start - start, lock, end); rv += n; lock += n; if (lock == end) return rv; } if (l.l_len == 0) /* does l spans until the end? */ return rv; if (len == 0) /* are we looking for locks until the end? */ { rv += fcntl_getlocks(fildes, l.l_start + l.l_len, len, lock, end); } else if (l.l_start + l.l_len < start + len) { len -= l.l_start + l.l_len - start; rv += fcntl_getlocks(fildes, l.l_start + l.l_len, len, lock, end); } return rv; } static void fcntl_getlock_pids(const atf_tc_t *tc, const char *mp) { /* test non-overlaping ranges */ struct flock expect[4]; const struct flock lock[4] = { { 0, 2, 0, F_WRLCK, SEEK_SET }, { 2, 1, 0, F_WRLCK, SEEK_SET }, { 7, 5, 0, F_WRLCK, SEEK_SET }, { 4, 3, 0, F_WRLCK, SEEK_SET }, }; /* Add extra element to make sure recursion does't stop at array end */ struct flock result[5]; /* Add 5th process */ int fd[5]; pid_t pid[5]; struct lwp *lwp[5]; unsigned int i, j; const off_t sz = 8192; int omode = 0755; int oflags = O_RDWR | O_CREAT; memcpy(expect, lock, sizeof(lock)); FSTEST_ENTER(); /* * First, we create 4 processes and let each lock a range of the * file. Note that the third and fourth processes lock in * "reverse" order, i.e. the greater pid locks a range before * the lesser pid. * Then, we create 5th process which doesn't lock anything. */ for (i = 0; i < __arraycount(lwp); i++) { RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); lwp[i] = rump_pub_lwproc_curlwp(); pid[i] = rump_sys_getpid(); RL(fd[i] = rump_sys_open(TESTFILE, oflags, omode)); oflags = O_RDWR; omode = 0; RL(rump_sys_ftruncate(fd[i], sz)); if (i < __arraycount(lock)) { RL(rump_sys_fcntl(fd[i], F_SETLK, &lock[i])); expect[i].l_pid = pid[i]; } } qsort(expect, __arraycount(expect), sizeof(expect[0]), &flock_compare); /* * In the context of each process, recursively find all locks * that would block the current process. Processes 1-4 don't * see their own lock, we insert it to simplify checks. * Process 5 sees all 4 locks. */ for (i = 0; i < __arraycount(lwp); i++) { unsigned int nlocks; rump_pub_lwproc_switch(lwp[i]); memset(result, 0, sizeof(result)); nlocks = fcntl_getlocks(fd[i], 0, sz, result, result + __arraycount(result)); if (i < __arraycount(lock)) { ATF_REQUIRE(nlocks < __arraycount(result)); result[nlocks] = lock[i]; result[nlocks].l_pid = pid[i]; nlocks++; } ATF_CHECK_EQ(nlocks, __arraycount(expect)); qsort(result, nlocks, sizeof(result[0]), &flock_compare); for (j = 0; j < nlocks; j++) { ATF_CHECK_EQ(result[j].l_start, expect[j].l_start ); ATF_CHECK_EQ(result[j].l_len, expect[j].l_len ); ATF_CHECK_EQ(result[j].l_pid, expect[j].l_pid ); ATF_CHECK_EQ(result[j].l_type, expect[j].l_type ); ATF_CHECK_EQ(result[j].l_whence, expect[j].l_whence); } } /* * Release processes. This also releases the fds and locks * making fs unmount possible */ for (i = 0; i < __arraycount(lwp); i++) { rump_pub_lwproc_switch(lwp[i]); rump_pub_lwproc_releaselwp(); } FSTEST_EXIT(); } static void access_simple(const atf_tc_t *tc, const char *mp) { int fd; int tmode; FSTEST_ENTER(); RL(fd = rump_sys_open("tfile", O_CREAT | O_RDWR, 0777)); RL(rump_sys_close(fd)); #define ALLACC (F_OK | X_OK | W_OK | R_OK) if (FSTYPE_SYSVBFS(tc) || FSTYPE_MSDOS(tc)) tmode = F_OK; else tmode = ALLACC; RL(rump_sys_access("tfile", tmode)); /* PR kern/44648 */ ATF_REQUIRE_ERRNO(EINVAL, rump_sys_access("tfile", ALLACC+1) == -1); #undef ALLACC FSTEST_EXIT(); } static void read_directory(const atf_tc_t *tc, const char *mp) { char buf[1024]; int fd, res; ssize_t size; FSTEST_ENTER(); fd = rump_sys_open(".", O_DIRECTORY | O_RDONLY, 0777); ATF_REQUIRE(fd != -1); size = rump_sys_pread(fd, buf, sizeof(buf), 0); ATF_CHECK(size != -1 || errno == EISDIR); size = rump_sys_read(fd, buf, sizeof(buf)); ATF_CHECK(size != -1 || errno == EISDIR); res = rump_sys_close(fd); ATF_REQUIRE(res != -1); FSTEST_EXIT(); } static void lstat_symlink(const atf_tc_t *tc, const char *mp) { const char *src, *dst; int res; struct stat st; USES_SYMLINKS; FSTEST_ENTER(); src = "source"; dst = "destination"; res = rump_sys_symlink(src, dst); ATF_REQUIRE(res != -1); res = rump_sys_lstat(dst, &st); ATF_REQUIRE(res != -1); ATF_CHECK(S_ISLNK(st.st_mode) != 0); ATF_CHECK(st.st_size == (off_t)strlen(src)); FSTEST_EXIT(); } ATF_TC_FSAPPLY(lookup_simple, "simple lookup (./.. on root)"); ATF_TC_FSAPPLY(lookup_complex, "lookup of non-dot entries"); ATF_TC_FSAPPLY(dir_simple, "mkdir/rmdir"); ATF_TC_FSAPPLY(dir_notempty, "non-empty directories cannot be removed"); ATF_TC_FSAPPLY(dir_rmdirdotdot, "remove .. and try to cd out (PR kern/44657)"); ATF_TC_FSAPPLY(rename_dir, "exercise various directory renaming ops " "(PR kern/44288)"); ATF_TC_FSAPPLY(rename_dotdot, "rename dir .. (PR kern/43617)"); ATF_TC_FSAPPLY(rename_reg_nodir, "rename regular files, no subdirectories"); ATF_TC_FSAPPLY(create_nametoolong, "create file with name too long"); ATF_TC_FSAPPLY(create_exist, "create with O_EXCL"); ATF_TC_FSAPPLY(rename_nametoolong, "rename to file with name too long"); ATF_TC_FSAPPLY(symlink_zerolen, "symlink with target of length 0"); ATF_TC_FSAPPLY(symlink_long, "symlink with target of length > 0"); ATF_TC_FSAPPLY(symlink_root, "symlink to root directory"); ATF_TC_FSAPPLY(attrs, "check setting attributes works"); ATF_TC_FSAPPLY(fcntl_lock, "check fcntl F_SETLK"); ATF_TC_FSAPPLY(fcntl_getlock_pids,"fcntl F_GETLK w/ many procs, PR kern/44494"); ATF_TC_FSAPPLY(access_simple, "access(2)"); ATF_TC_FSAPPLY(read_directory, "read(2) on directories"); ATF_TC_FSAPPLY(lstat_symlink, "lstat(2) values for symbolic links"); #undef FSTEST_IMGSIZE #define FSTEST_IMGSIZE (1024*1024*64) ATF_TC_FSAPPLY(create_many, "create many directory entries"); ATF_TC_FSAPPLY(create_nonalphanum, "non-alphanumeric filenames"); ATF_TP_ADD_TCS(tp) { ATF_TP_FSAPPLY(lookup_simple); ATF_TP_FSAPPLY(lookup_complex); ATF_TP_FSAPPLY(dir_simple); ATF_TP_FSAPPLY(dir_notempty); ATF_TP_FSAPPLY(dir_rmdirdotdot); ATF_TP_FSAPPLY(rename_dir); ATF_TP_FSAPPLY(rename_dotdot); ATF_TP_FSAPPLY(rename_reg_nodir); ATF_TP_FSAPPLY(create_many); ATF_TP_FSAPPLY(create_nonalphanum); ATF_TP_FSAPPLY(create_nametoolong); ATF_TP_FSAPPLY(create_exist); ATF_TP_FSAPPLY(rename_nametoolong); ATF_TP_FSAPPLY(symlink_zerolen); ATF_TP_FSAPPLY(symlink_long); ATF_TP_FSAPPLY(symlink_root); ATF_TP_FSAPPLY(attrs); ATF_TP_FSAPPLY(fcntl_lock); ATF_TP_FSAPPLY(fcntl_getlock_pids); ATF_TP_FSAPPLY(access_simple); ATF_TP_FSAPPLY(read_directory); ATF_TP_FSAPPLY(lstat_symlink); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/include/sys/t_socket.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/include/sys/t_socket.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/include/sys/t_socket.c (revision 312126) @@ -1,205 +1,205 @@ -/* $NetBSD: t_socket.c,v 1.4 2015/02/27 08:30:30 martin Exp $ */ +/* $NetBSD: t_socket.c,v 1.5 2017/01/13 21:30:41 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(cmsg_sendfd_bounds); ATF_TC_HEAD(cmsg_sendfd_bounds, tc) { atf_tc_set_md_var(tc, "descr", "Checks that attempting to pass an " "invalid fd returns an error"); } ATF_TC_BODY(cmsg_sendfd_bounds, tc) { struct cmsghdr *cmp; struct msghdr msg; struct iovec iov; int s[2]; int fd; rump_init(); if (rump_sys_socketpair(AF_LOCAL, SOCK_STREAM, 0, s) == -1) atf_tc_fail("rump_sys_socket"); cmp = malloc(CMSG_SPACE(sizeof(int))); iov.iov_base = &fd; iov.iov_len = sizeof(int); cmp->cmsg_level = SOL_SOCKET; cmp->cmsg_type = SCM_RIGHTS; cmp->cmsg_len = CMSG_LEN(sizeof(int)); msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_control = cmp; msg.msg_controllen = CMSG_SPACE(sizeof(int)); /* * ERROR HERE: trying to pass invalid fd * (This value was previously directly used to index the fd * array and therefore we are passing a hyperspace index) */ *(int *)CMSG_DATA(cmp) = 0x12345678; rump_sys_sendmsg(s[0], &msg, 0); if (errno != EBADF) atf_tc_fail("descriptor passing failed: expected EBADF (9), " "got %d\n(%s)", errno, strerror(errno)); } ATF_TC(cmsg_sendfd); ATF_TC_HEAD(cmsg_sendfd, tc) { atf_tc_set_md_var(tc, "descr", "Checks that fd passing works"); atf_tc_set_md_var(tc, "timeout", "10"); } ATF_TC_BODY(cmsg_sendfd, tc) { char buf[128]; struct cmsghdr *cmp; struct msghdr msg; struct sockaddr_un sun; struct lwp *l1; struct iovec iov; socklen_t sl; int s1, s2, sgot; int rfd, fd[2], storage; rump_init(); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); l1 = rump_pub_lwproc_curlwp(); /* create unix socket and bind it to a path */ memset(&sun, 0, sizeof(sun)); sun.sun_family = AF_LOCAL; #define SOCKPATH "/com" strncpy(sun.sun_path, SOCKPATH, sizeof(SOCKPATH)); s1 = rump_sys_socket(AF_LOCAL, SOCK_STREAM, 0); if (s1 == -1) atf_tc_fail_errno("socket 1"); if (rump_sys_bind(s1, (struct sockaddr *)&sun, SUN_LEN(&sun)) == -1) atf_tc_fail_errno("socket 1 bind"); if (rump_sys_listen(s1, 1) == -1) atf_tc_fail_errno("socket 1 listen"); /* create second process for test */ RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); (void)rump_pub_lwproc_curlwp(); /* connect to unix domain socket */ memset(&sun, 0, sizeof(sun)); sun.sun_family = AF_LOCAL; strncpy(sun.sun_path, SOCKPATH, sizeof(SOCKPATH)); s2 = rump_sys_socket(AF_LOCAL, SOCK_STREAM, 0); if (s2 == -1) atf_tc_fail_errno("socket 2"); if (rump_sys_connect(s2, (struct sockaddr *)&sun, SUN_LEN(&sun)) == -1) atf_tc_fail_errno("socket 2 connect"); /* open a pipe and write stuff to it */ if (rump_sys_pipe(fd) == -1) atf_tc_fail_errno("can't open pipe"); #define MAGICSTRING "duam xnaht" if (rump_sys_write(fd[1], MAGICSTRING, sizeof(MAGICSTRING)) != sizeof(MAGICSTRING)) atf_tc_fail_errno("pipe write"); /* XXX: errno */ cmp = malloc(CMSG_SPACE(sizeof(int))); iov.iov_base = &storage; iov.iov_len = sizeof(int); cmp->cmsg_level = SOL_SOCKET; cmp->cmsg_type = SCM_RIGHTS; cmp->cmsg_len = CMSG_LEN(sizeof(int)); msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_control = cmp; msg.msg_controllen = CMSG_SPACE(sizeof(int)); *(int *)CMSG_DATA(cmp) = fd[0]; /* pass the fd */ if (rump_sys_sendmsg(s2, &msg, 0) == -1) atf_tc_fail_errno("sendmsg failed"); /* * We will read to the same cmsg space. Overwrite the space * with an invalid fd to make sure we get an explicit error * if we don't manage to read the fd. */ *(int *)CMSG_DATA(cmp) = -1; /* switch back to original proc */ rump_pub_lwproc_switch(l1); /* accept connection and read fd */ sl = sizeof(sun); sgot = rump_sys_accept(s1, (struct sockaddr *)&sun, &sl); if (sgot == -1) atf_tc_fail_errno("accept"); if (rump_sys_recvmsg(sgot, &msg, 0) == -1) atf_tc_fail_errno("recvmsg failed"); rfd = *(int *)CMSG_DATA(cmp); /* read from the fd */ memset(buf, 0, sizeof(buf)); if (rump_sys_read(rfd, buf, sizeof(buf)) == -1) atf_tc_fail_errno("read rfd"); /* check that we got the right stuff */ if (strcmp(buf, MAGICSTRING) != 0) atf_tc_fail("expected \"%s\", got \"%s\"", MAGICSTRING, buf); } ATF_TC(sock_cloexec); ATF_TC_HEAD(sock_cloexec, tc) { atf_tc_set_md_var(tc, "descr", "SOCK_CLOEXEC kernel invariant failure"); } ATF_TC_BODY(sock_cloexec, tc) { rump_init(); rump_pub_lwproc_rfork(RUMP_RFFDG); if (rump_sys_socket(-1, SOCK_CLOEXEC, 0) != -1) atf_tc_fail("invalid socket parameters unexpectedly worked"); rump_pub_lwproc_releaselwp(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, cmsg_sendfd); ATF_TP_ADD_TC(tp, cmsg_sendfd_bounds); ATF_TP_ADD_TC(tp, sock_cloexec); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait.c (revision 312126) @@ -0,0 +1,1388 @@ +/* $NetBSD: t_ptrace_wait.c,v 1.9 2017/01/13 21:30:41 christos Exp $ */ + +/*- + * Copyright (c) 2016 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 +__RCSID("$NetBSD: t_ptrace_wait.c,v 1.9 2017/01/13 21:30:41 christos Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "h_macros.h" + +#include "../../t_ptrace_wait.h" + + +#if defined(HAVE_GPREGS) +ATF_TC(regs1); +ATF_TC_HEAD(regs1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_GETREGS and iterate over General Purpose registers"); +} + +ATF_TC_BODY(regs1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct reg r; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETREGS for the child process\n"); + ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); + + printf("RAX=%#" PRIxREGISTER "\n", r.regs[_REG_RAX]); + printf("RBX=%#" PRIxREGISTER "\n", r.regs[_REG_RBX]); + printf("RCX=%#" PRIxREGISTER "\n", r.regs[_REG_RCX]); + printf("RDX=%#" PRIxREGISTER "\n", r.regs[_REG_RDX]); + + printf("RDI=%#" PRIxREGISTER "\n", r.regs[_REG_RDI]); + printf("RSI=%#" PRIxREGISTER "\n", r.regs[_REG_RSI]); + + printf("GS=%#" PRIxREGISTER "\n", r.regs[_REG_GS]); + printf("FS=%#" PRIxREGISTER "\n", r.regs[_REG_FS]); + printf("ES=%#" PRIxREGISTER "\n", r.regs[_REG_ES]); + printf("DS=%#" PRIxREGISTER "\n", r.regs[_REG_DS]); + printf("CS=%#" PRIxREGISTER "\n", r.regs[_REG_CS]); + printf("SS=%#" PRIxREGISTER "\n", r.regs[_REG_SS]); + + printf("RSP=%#" PRIxREGISTER "\n", r.regs[_REG_RSP]); + printf("RIP=%#" PRIxREGISTER "\n", r.regs[_REG_RIP]); + + printf("RFLAGS=%#" PRIxREGISTER "\n", r.regs[_REG_RFLAGS]); + + printf("R8=%#" PRIxREGISTER "\n", r.regs[_REG_R8]); + printf("R9=%#" PRIxREGISTER "\n", r.regs[_REG_R9]); + printf("R10=%#" PRIxREGISTER "\n", r.regs[_REG_R10]); + printf("R11=%#" PRIxREGISTER "\n", r.regs[_REG_R11]); + printf("R12=%#" PRIxREGISTER "\n", r.regs[_REG_R12]); + printf("R13=%#" PRIxREGISTER "\n", r.regs[_REG_R13]); + printf("R14=%#" PRIxREGISTER "\n", r.regs[_REG_R14]); + printf("R15=%#" PRIxREGISTER "\n", r.regs[_REG_R15]); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_count); +ATF_TC_HEAD(watchpoint_count, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and assert four available watchpoints"); +} + +ATF_TC_BODY(watchpoint_count, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + int N; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETREGS for the child process\n"); + ATF_REQUIRE((N = ptrace(PT_COUNT_WATCHPOINTS, child, NULL, 0)) != -1); + printf("Reported %d watchpoints\n", N); + + ATF_REQUIRE_EQ_MSG(N, 4, "Expected 4 hw watchpoints - got %d", N); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_read); +ATF_TC_HEAD(watchpoint_read, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and assert four available watchpoints"); +} + +ATF_TC_BODY(watchpoint_read, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + int i, N; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETREGS for the child process\n"); + ATF_REQUIRE((N = ptrace(PT_COUNT_WATCHPOINTS, child, NULL, 0)) != -1); + + ATF_REQUIRE_EQ_MSG(N, 4, "Expected 4 hw watchpoints - got %d", N); + + for (i = 0; i < N; i++) { + printf("Before reading watchpoint %d\n", i); + pw.pw_index = i; + ATF_REQUIRE(ptrace(PT_READ_WATCHPOINT, child, &pw, len) != -1); + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + } + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_write_unmodified); +ATF_TC_HEAD(watchpoint_write_unmodified, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and assert functional write of " + "unmodified data"); +} + +ATF_TC_BODY(watchpoint_write_unmodified, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + int i, N; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETREGS for the child process\n"); + ATF_REQUIRE((N = ptrace(PT_COUNT_WATCHPOINTS, child, NULL, 0)) != -1); + + ATF_REQUIRE_EQ_MSG(N, 4, "Expected 4 hw watchpoints - got %d", N); + + for (i = 0; i < N; i++) { + printf("Before reading watchpoint %d\n", i); + pw.pw_index = i; + ATF_REQUIRE(ptrace(PT_READ_WATCHPOINT, child, &pw, len) != -1); + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d (unmodified)\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) + != -1); + } + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_code0); +ATF_TC_HEAD(watchpoint_trap_code0, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test code trap with watchpoint 0"); +} + +ATF_TC_BODY(watchpoint_trap_code0, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 0; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("check_happy(%d)=%d\n", watchme, check_happy(watchme)); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = i; + pw.pw_lwpid = 0; + pw.pw_md.md_address = (void *)check_happy; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_EXECUTION; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + pw.pw_md.md_address = NULL; + printf("Before writing watchpoint %d (disable it)\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_code1); +ATF_TC_HEAD(watchpoint_trap_code1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test code trap with watchpoint 1"); +} + +ATF_TC_BODY(watchpoint_trap_code1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 1; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("check_happy(%d)=%d\n", watchme, check_happy(watchme)); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = i; + pw.pw_lwpid = 0; + pw.pw_md.md_address = (void *)check_happy; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_EXECUTION; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + pw.pw_md.md_address = NULL; + printf("Before writing watchpoint %d (disable it)\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_code2); +ATF_TC_HEAD(watchpoint_trap_code2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test code trap with watchpoint 2"); +} + +ATF_TC_BODY(watchpoint_trap_code2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 2; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("check_happy(%d)=%d\n", watchme, check_happy(watchme)); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = i; + pw.pw_lwpid = 0; + pw.pw_md.md_address = (void *)check_happy; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_EXECUTION; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + pw.pw_md.md_address = NULL; + printf("Before writing watchpoint %d (disable it)\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_code3); +ATF_TC_HEAD(watchpoint_trap_code3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test code trap with watchpoint 3"); +} + +ATF_TC_BODY(watchpoint_trap_code3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 3; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("check_happy(%d)=%d\n", watchme, check_happy(watchme)); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = i; + pw.pw_lwpid = 0; + pw.pw_md.md_address = (void *)check_happy; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_EXECUTION; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + pw.pw_md.md_address = NULL; + printf("Before writing watchpoint %d (disable it)\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_data_write0); +ATF_TC_HEAD(watchpoint_trap_data_write0, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test write trap with watchpoint 0"); +} + +ATF_TC_BODY(watchpoint_trap_data_write0, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 0; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + ++watchme; + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = 0; + pw.pw_md.md_address = &watchme; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_WRITE; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_data_write1); +ATF_TC_HEAD(watchpoint_trap_data_write1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test write trap with watchpoint 1"); +} + +ATF_TC_BODY(watchpoint_trap_data_write1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 1; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + ++watchme; + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = i; + pw.pw_md.md_address = &watchme; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_WRITE; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_data_write2); +ATF_TC_HEAD(watchpoint_trap_data_write2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test write trap with watchpoint 2"); +} + +ATF_TC_BODY(watchpoint_trap_data_write2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 2; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + ++watchme; + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = i; + pw.pw_md.md_address = &watchme; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_WRITE; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_data_write3); +ATF_TC_HEAD(watchpoint_trap_data_write3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test write trap with watchpoint 3"); +} + +ATF_TC_BODY(watchpoint_trap_data_write3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 3; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + ++watchme; + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = i; + pw.pw_md.md_address = &watchme; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_WRITE; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_data_rw0); +ATF_TC_HEAD(watchpoint_trap_data_rw0, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test write trap with watchpoint 0"); +} + +ATF_TC_BODY(watchpoint_trap_data_rw0, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 0; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("watchme=%d\n", watchme); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = i; + pw.pw_md.md_address = &watchme; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_READWRITE; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_data_rw1); +ATF_TC_HEAD(watchpoint_trap_data_rw1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test write trap with watchpoint 1"); +} + +ATF_TC_BODY(watchpoint_trap_data_rw1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 1; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("watchme=%d\n", watchme); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = i; + pw.pw_md.md_address = &watchme; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_READWRITE; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_data_rw2); +ATF_TC_HEAD(watchpoint_trap_data_rw2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test write trap with watchpoint 2"); +} + +ATF_TC_BODY(watchpoint_trap_data_rw2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 2; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("watchme=%d\n", watchme); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = i; + pw.pw_md.md_address = &watchme; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_READWRITE; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +ATF_TC(watchpoint_trap_data_rw3); +ATF_TC_HEAD(watchpoint_trap_data_rw3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_COUNT_WATCHPOINTS and test write trap with watchpoint 3"); +} + +ATF_TC_BODY(watchpoint_trap_data_rw3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + const int i = 3; + struct ptrace_watchpoint pw; + int len = sizeof(pw); + int watchme = 1234; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("watchme=%d\n", watchme); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Preparing code watchpoint trap %d\n", i); + + pw.pw_index = i; + pw.pw_md.md_address = &watchme; + pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_READWRITE; + pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE; + + printf("struct ptrace {\n"); + printf("\t.pw_index=%d\n", pw.pw_index); + printf("\t.pw_lwpid=%d\n", pw.pw_lwpid); + printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address); + printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition); + printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length); + printf("}\n"); + + printf("Before writing watchpoint %d\n", i); + ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1); + + printf("Before resuming the child process where it left off " + "and without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +ATF_TP_ADD_TCS(tp) +{ + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + + ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs1); + + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_count); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_read); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_write_unmodified); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_code0); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_code1); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_code2); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_code3); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_data_write0); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_data_write1); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_data_write2); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_data_write3); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_data_rw0); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_data_rw1); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_data_rw2); + ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(tp, watchpoint_trap_data_rw3); + + return atf_no_error(); +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait3.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait3.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait3.c (revision 312126) @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_wait3.c,v 1.1 2016/12/02 05:54:15 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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. + */ + +#define TWAIT_WAIT3 +#include "t_ptrace_wait.c" Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait3.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait4.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait4.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait4.c (revision 312126) @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_wait4.c,v 1.1 2016/12/02 05:54:15 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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. + */ + +#define TWAIT_WAIT4 +#include "t_ptrace_wait.c" Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait4.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait6.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait6.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait6.c (revision 312126) @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_wait6.c,v 1.1 2016/12/02 05:54:15 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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. + */ + +#define TWAIT_WAIT6 +#include "t_ptrace_wait.c" Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait6.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitid.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitid.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitid.c (revision 312126) @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_waitid.c,v 1.1 2016/12/02 05:54:15 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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. + */ + +#define TWAIT_WAITID +#include "t_ptrace_wait.c" Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitid.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitpid.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitpid.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitpid.c (revision 312126) @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_waitpid.c,v 1.1 2016/12/02 05:54:15 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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. + */ + +#define TWAIT_WAITPID +#include "t_ptrace_wait.c" Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitpid.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait.c (revision 312126) @@ -0,0 +1,141 @@ +/* $NetBSD: t_ptrace_wait.c,v 1.2 2017/01/13 21:30:41 christos Exp $ */ + +/*- + * Copyright (c) 2016 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 +__RCSID("$NetBSD: t_ptrace_wait.c,v 1.2 2017/01/13 21:30:41 christos Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "h_macros.h" + +#include "../../t_ptrace_wait.h" + + +#if defined(HAVE_GPREGS) +ATF_TC(regs1); +ATF_TC_HEAD(regs1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Call PT_GETREGS and iterate over General Purpose registers"); +} + +ATF_TC_BODY(regs1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct reg r; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETREGS for the child process\n"); + ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); + + printf("EAX=%#" PRIxREGISTER "\n", r.r_eax); + printf("EBX=%#" PRIxREGISTER "\n", r.r_ebx); + printf("ECX=%#" PRIxREGISTER "\n", r.r_ecx); + printf("EDX=%#" PRIxREGISTER "\n", r.r_edx); + + printf("ESP=%#" PRIxREGISTER "\n", r.r_esp); + printf("EBP=%#" PRIxREGISTER "\n", r.r_ebp); + + printf("ESI=%#" PRIxREGISTER "\n", r.r_esi); + printf("EDI=%#" PRIxREGISTER "\n", r.r_edi); + + printf("EIP=%#" PRIxREGISTER "\n", r.r_eip); + + printf("EFLAGS=%#" PRIxREGISTER "\n", r.r_eflags); + + printf("CS=%#" PRIxREGISTER "\n", r.r_cs); + printf("SS=%#" PRIxREGISTER "\n", r.r_ss); + printf("DS=%#" PRIxREGISTER "\n", r.r_ds); + printf("ES=%#" PRIxREGISTER "\n", r.r_es); + printf("FS=%#" PRIxREGISTER "\n", r.r_fs); + printf("GS=%#" PRIxREGISTER "\n", r.r_gs); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +ATF_TP_ADD_TCS(tp) +{ + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + + ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs1); + + return atf_no_error(); +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait3.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait3.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait3.c (revision 312126) @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_wait3.c,v 1.1 2016/12/13 18:00:10 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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. + */ + +#define TWAIT_WAIT3 +#include "t_ptrace_wait.c" Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait3.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait4.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait4.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait4.c (revision 312126) @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_wait4.c,v 1.1 2016/12/13 18:00:10 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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. + */ + +#define TWAIT_WAIT4 +#include "t_ptrace_wait.c" Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait4.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait6.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait6.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait6.c (revision 312126) @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_wait6.c,v 1.1 2016/12/13 18:00:10 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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. + */ + +#define TWAIT_WAIT6 +#include "t_ptrace_wait.c" Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait6.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitid.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitid.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitid.c (revision 312126) @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_waitid.c,v 1.1 2016/12/13 18:00:10 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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. + */ + +#define TWAIT_WAITID +#include "t_ptrace_wait.c" Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitid.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitpid.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitpid.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitpid.c (revision 312126) @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_waitpid.c,v 1.1 2016/12/13 18:00:10 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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. + */ + +#define TWAIT_WAITPID +#include "t_ptrace_wait.c" Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitpid.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c (revision 312126) @@ -1,102 +1,102 @@ -/* $NetBSD: t_fifo.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $ */ +/* $NetBSD: t_fifo.c,v 1.4 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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_fifo.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $"); +__RCSID("$NetBSD: t_fifo.c,v 1.4 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include #include #include -#include "../../../h_macros.h" +#include "h_macros.h" #define FIFONAME "fifo" ATF_TC(fifo); ATF_TC_HEAD(fifo, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_READ on fifo"); } ATF_TC_BODY(fifo, tc) { int kq, n, fd; struct kevent event[1]; char buffer[128]; RL(mkfifo(FIFONAME, 0644)); RL(fd = open(FIFONAME, O_RDWR, 0644)); RL(kq = kqueue()); EV_SET(&event[0], fd, EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); /* make sure there is something in the fifo */ RL(write(fd, "foo", 3)); (void)printf("fifo: wrote 'foo'\n"); (void)memset(event, 0, sizeof(event)); RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d filt %d flags: %#x, fflags: %#x, " #ifdef __FreeBSD__ "data: %" PRIdPTR "\n", n, event[0].filter, event[0].flags, #else "data: %" PRId64 "\n", n, event[0].filter, event[0].flags, #endif event[0].fflags, event[0].data); ATF_REQUIRE_EQ(event[0].filter, EVFILT_READ); RL(n = read(fd, buffer, event[0].data)); buffer[n] = '\0'; (void)printf("fifo: read '%s'\n", buffer); RL(close(fd)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fifo); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_file.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_file.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_file.c (revision 312126) @@ -1,143 +1,143 @@ -/* $NetBSD: t_file.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $ */ +/* $NetBSD: t_file.c,v 1.4 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn. * * 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_file.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $"); +__RCSID("$NetBSD: t_file.c,v 1.4 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../../h_macros.h" +#include "h_macros.h" #define FILENAME "file" #define NLINES 5 static void child(void) { int i, n, fd; (void)sleep(1); for (i = 0; i < NLINES; ++i) { fd = open(FILENAME, O_WRONLY|O_APPEND, 0644); if (fd < 0) err(EXIT_FAILURE, "open()"); n = write(fd, "foo\n", 4); if (n < 0) err(EXIT_FAILURE, "write()"); (void)close(fd); (void)sleep(1); } _exit(0); } ATF_TC(file); ATF_TC_HEAD(file, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_READ on regular file"); } ATF_TC_BODY(file, tc) { char buffer[128]; struct kevent event[1]; pid_t pid; int fd, kq, n, num, status; RL(pid = fork()); if (pid == 0) { child(); /* NOTREACHED */ } RL(fd = open(FILENAME, O_RDONLY|O_CREAT, 0644)); #if 1 /* XXX: why was this disabled? */ RL(lseek(fd, 0, SEEK_END)); #endif RL(kq = kqueue()); EV_SET(&event[0], fd, EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); for (num = 0; num < NLINES;) { RL(n = kevent(kq, NULL, 0, event, 1, NULL)); num += n; (void)printf("kevent num %d flags: %#x, fflags: %#x, data: " #ifdef __FreeBSD__ "%" PRIdPTR "\n", n, event[0].flags, event[0].fflags, #else "%" PRId64 "\n", n, event[0].flags, event[0].fflags, #endif event[0].data); if (event[0].data < 0) #if 1 /* XXXLUKEM */ RL(lseek(fd, 0, SEEK_END)); #else RL(lseek(fd, event[0].data, SEEK_END)); #endif RL(n = read(fd, buffer, 128)); buffer[n] = '\0'; (void)printf("file(%d): %s", num, buffer); } (void)waitpid(pid, &status, 0); (void)printf("read: successful end\n"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, file); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_file2.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_file2.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_file2.c (revision 312126) @@ -1,79 +1,79 @@ -/* $NetBSD: t_file2.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $ */ +/* $NetBSD: t_file2.c,v 1.4 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jaromir Dolecek. * * 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_file2.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $"); +__RCSID("$NetBSD: t_file2.c,v 1.4 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include -#include "../../../h_macros.h" +#include "h_macros.h" ATF_TC(file2); ATF_TC_HEAD(file2, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_READ for regular files. This test used to " "trigger deadlock caused by problem fixed in revision 1.79.2.10 " "of sys/kern/kern_descrip.c"); } ATF_TC_BODY(file2, tc) { int fd1, fd2, kq; struct kevent event[1]; RL(fd1 = open("afile", O_RDONLY|O_CREAT, 0644)); RL(fd2 = open("bfile", O_RDONLY|O_CREAT, 0644)); #if 1 /* XXX: why was this disabled? */ RL(lseek(fd1, 0, SEEK_END)); #endif RL(kq = kqueue()); EV_SET(&event[0], fd1, EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); RL(dup2(fd2, fd1)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, file2); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c (revision 312126) @@ -1,88 +1,88 @@ -/* $NetBSD: t_pipe.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ +/* $NetBSD: t_pipe.c,v 1.2 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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_pipe.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); +__RCSID("$NetBSD: t_pipe.c,v 1.2 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include -#include "../../../h_macros.h" +#include "h_macros.h" ATF_TC(pipe); ATF_TC_HEAD(pipe, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_READ for pipes"); } ATF_TC_BODY(pipe, tc) { struct kevent event[1]; char buffer[128]; int fds[2]; int kq, n; RL(pipe(fds)); RL(kq = kqueue()); EV_SET(&event[0], fds[0], EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); /* make sure there is something in the pipe */ RL(write(fds[1], "foo", 3)); (void)printf("pipe: wrote 'foo' to pipe\n"); RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d flags: %#x, fflags: %#x, data: " #ifdef __FreeBSD__ "%" PRIdPTR "\n", n, event[0].flags, event[0].fflags, event[0].data); #else "%" PRId64 "\n", n, event[0].flags, event[0].fflags, event[0].data); #endif RL(n = read(fds[0], buffer, event[0].data)); buffer[n] = '\0'; (void)printf("pipe: read '%s'\n", buffer); (void)printf("pipe: successful end\n"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, pipe); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c (revision 312126) @@ -1,148 +1,148 @@ -/* $NetBSD: t_ttypty.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ +/* $NetBSD: t_ttypty.c,v 1.2 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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_ttypty.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); +__RCSID("$NetBSD: t_ttypty.c,v 1.2 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include #include -#include "../../../h_macros.h" +#include "h_macros.h" static void h_check(bool check_master) { char slavetty[1024]; char buffer[128]; struct kevent event[1]; pid_t child; int amaster, aslave, acurrent; int kq, n, status; #if 0 int fl; #endif struct pollfd pfd; struct termios tio; RL(openpty(&amaster, &aslave, slavetty, NULL, NULL)); (void)printf("tty: openpty master %d slave %d tty '%s'\n", amaster, aslave, slavetty); acurrent = check_master ? amaster : aslave; RL(child = fork()); if (child == 0) { sleep(1); (void)printf("tty: child writing 'f00\\n'\n"); (void)write(check_master ? aslave : amaster, "f00\n", 4); _exit(0); } /* switch ONLCR off, to not get confused by newline translation */ RL(tcgetattr(acurrent, &tio)); tio.c_oflag &= ~ONLCR; RL(tcsetattr(acurrent, TCSADRAIN, &tio)); pfd.fd = acurrent; pfd.events = POLLIN; (void)printf("tty: polling ...\n"); RL(poll(&pfd, 1, INFTIM)); (void)printf("tty: returned from poll - %d\n", pfd.revents); #if 0 fl = 1; if (ioctl(acurrent, TIOCPKT, &fl) < 0) err(1, "ioctl"); #endif RL(kq = kqueue()); EV_SET(&event[0], acurrent, EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d filt %d flags: %#x, fflags: %#x, " #ifdef __FreeBSD__ "data: %" PRIdPTR "\n", n, event[0].filter, event[0].flags, #else "data: %" PRId64 "\n", n, event[0].filter, event[0].flags, #endif event[0].fflags, event[0].data); ATF_REQUIRE_EQ(event[0].filter, EVFILT_READ); RL(n = read(acurrent, buffer, 128)); (void)printf("tty: read '%.*s' (n=%d)\n", n, buffer, n); (void)waitpid(child, &status, 0); (void)printf("tty: successful end\n"); } ATF_TC(master); ATF_TC_HEAD(master, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_READ for master tty"); } ATF_TC_BODY(master, tc) { h_check(true); } ATF_TC(slave); ATF_TC_HEAD(slave, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_READ for slave tty"); } ATF_TC_BODY(slave, tc) { h_check(false); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, master); ATF_TP_ADD_TC(tp, slave); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_ioctl.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_ioctl.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_ioctl.c (revision 312126) @@ -1,116 +1,116 @@ -/* $NetBSD: t_ioctl.c,v 1.2 2015/01/14 22:22:32 christos Exp $ */ +/* $NetBSD: t_ioctl.c,v 1.3 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn. * * 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_ioctl.c,v 1.2 2015/01/14 22:22:32 christos Exp $"); +__RCSID("$NetBSD: t_ioctl.c,v 1.3 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(kfilter_byfilter); ATF_TC_HEAD(kfilter_byfilter, tc) { atf_tc_set_md_var(tc, "descr", "Checks KFILTER_BYFILTER ioctl"); } ATF_TC_BODY(kfilter_byfilter, tc) { char buf[32]; struct kfilter_mapping km; int kq; uint32_t i; RL(kq = kqueue()); km.name = buf; km.len = sizeof(buf) - 1; for (i = 0; i < 7; ++i) { km.filter = i; RL(ioctl(kq, KFILTER_BYFILTER, &km)); (void)printf(" map %d -> %s\n", km.filter, km.name); } km.filter = 7; ATF_REQUIRE_EQ(ioctl(kq, KFILTER_BYFILTER, &km), -1); } ATF_TC(kfilter_byname); ATF_TC_HEAD(kfilter_byname, tc) { atf_tc_set_md_var(tc, "descr", "Checks KFILTER_BYNAME ioctl"); } ATF_TC_BODY(kfilter_byname, tc) { const char *tests[] = { "EVFILT_READ", "EVFILT_WRITE", "EVFILT_AIO", "EVFILT_VNODE", "EVFILT_PROC", "EVFILT_SIGNAL", "EVFILT_TIMER", NULL }; char buf[32]; struct kfilter_mapping km; const char **test; int kq; RL(kq = kqueue()); km.name = buf; for (test = &tests[0]; *test != NULL; ++test) { (void)strlcpy(buf, *test, sizeof(buf)); RL(ioctl(kq, KFILTER_BYNAME, &km)); (void)printf(" map %s -> %d\n", km.name, km.filter); } (void)strlcpy(buf, "NOTREG_FILTER", sizeof(buf)); ATF_REQUIRE_EQ(ioctl(kq, KFILTER_BYNAME, &km), -1); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, kfilter_byfilter); ATF_TP_ADD_TC(tp, kfilter_byname); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_proc1.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_proc1.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_proc1.c (revision 312126) @@ -1,159 +1,159 @@ -/* $NetBSD: t_proc1.c,v 1.2 2015/01/14 22:22:32 christos Exp $ */ +/* $NetBSD: t_proc1.c,v 1.3 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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_proc1.c,v 1.2 2015/01/14 22:22:32 christos Exp $"); +__RCSID("$NetBSD: t_proc1.c,v 1.3 2017/01/13 21:30:41 christos Exp $"); /* * this also used to trigger problem fixed in * rev. 1.1.1.1.2.13 of sys/kern/kern_event.c */ #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" static int child(void) { pid_t ch; int status; char *argv[] = { NULL, NULL }; char *envp[] = { NULL, NULL }; if ((argv[0] = strdup("true")) == NULL) err(EXIT_FAILURE, "strdup(\"true\")"); if ((envp[0] = strdup("FOO=BAZ")) == NULL) err(EXIT_FAILURE, "strdup(\"FOO=BAZ\")"); /* Ensure parent is ready */ (void)sleep(2); /* Do fork */ switch (ch = fork()) { case -1: return EXIT_FAILURE; /* NOTREACHED */ case 0: return EXIT_SUCCESS; /* NOTREACHED */ default: wait(&status); break; } /* Exec */ execve("/usr/bin/true", argv, envp); /* NOTREACHED */ return EXIT_FAILURE; } ATF_TC(proc1); ATF_TC_HEAD(proc1, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_PROC"); } ATF_TC_BODY(proc1, tc) { struct kevent event[1]; pid_t pid; int kq, status; u_int want; RL(kq = kqueue()); /* fork a child for doing the events */ RL(pid = fork()); if (pid == 0) { _exit(child()); /* NOTREACHED */ } (void)sleep(1); /* give child some time to come up */ event[0].ident = (uintptr_t)pid; event[0].filter = EVFILT_PROC; event[0].flags = EV_ADD | EV_ENABLE; event[0].fflags = NOTE_EXIT | NOTE_FORK | NOTE_EXEC; /* | NOTE_TRACK;*/ want = NOTE_EXIT | NOTE_FORK | NOTE_EXEC; RL(kevent(kq, event, 1, NULL, 0, NULL)); /* wait until we get all events we want */ while (want) { RL(kevent(kq, NULL, 0, event, 1, NULL)); printf("%ld:", (long)event[0].ident); if (event[0].fflags & NOTE_EXIT) { want &= ~NOTE_EXIT; printf(" NOTE_EXIT"); } if (event[0].fflags & NOTE_EXEC) { want &= ~NOTE_EXEC; printf(" NOTE_EXEC"); } if (event[0].fflags & NOTE_FORK) { want &= ~NOTE_FORK; printf(" NOTE_FORK"); } if (event[0].fflags & NOTE_CHILD) #ifdef __FreeBSD__ printf(" NOTE_CHILD, parent = %" PRIdPTR, event[0].data); #else printf(" NOTE_CHILD, parent = %" PRId64, event[0].data); #endif printf("\n"); } (void)waitpid(pid, &status, 0); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, proc1); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_proc2.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_proc2.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_proc2.c (revision 312126) @@ -1,142 +1,142 @@ -/* $NetBSD: t_proc2.c,v 1.2 2015/01/14 22:22:32 christos Exp $ */ +/* $NetBSD: t_proc2.c,v 1.3 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Peter Werner . * * 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_proc2.c,v 1.2 2015/01/14 22:22:32 christos Exp $"); +__RCSID("$NetBSD: t_proc2.c,v 1.3 2017/01/13 21:30:41 christos Exp $"); #ifdef __FreeBSD__ #include #endif #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" static void child_two(void) { _exit(EXIT_SUCCESS); } static void child_one(void) { pid_t pid; struct passwd *pwd; const char *nam = "nobody"; pwd = getpwnam(nam); if (pwd == NULL) err(EXIT_FAILURE, "getpwnam(\"%s\")", nam); if ((setuid(pwd->pw_uid)) == -1) err(EXIT_FAILURE, "setuid(%d)", pwd->pw_uid); pid = fork(); if (pid == -1) err(EXIT_FAILURE, "fork()"); if (pid == 0) child_two(); _exit(EXIT_SUCCESS); } ATF_TC(proc2); ATF_TC_HEAD(proc2, tc) { atf_tc_set_md_var(tc, "require.user", "root"); atf_tc_set_md_var(tc, "descr", "Checks EVFILT_PROC for NOTE_FORK|NOTE_TRACK error path problem " "fixed in rev. 1.1.1.1.2.17 of sys/kern/kern_event.c"); } ATF_TC_BODY(proc2, tc) { pid_t pid = 0; int kq, status; struct kevent ke; struct timespec timeout; RL(kq = kqueue()); timeout.tv_sec = 0; timeout.tv_nsec = 0; RL(pid = fork()); if (pid == 0) { (void)sleep(1); /* let parent set kevent */ child_one(); /* NOTREACHED */ } EV_SET(&ke, (uintptr_t)pid, EVFILT_PROC, EV_ADD, NOTE_FORK|NOTE_TRACK, 0, 0); RL(kevent(kq, &ke, 1, NULL, 0, &timeout)); (void)sleep(2); ke.ident = 0; ke.fflags = 0; ke.flags = EV_ENABLE; RL(kevent(kq, NULL, 0, &ke, 1, &timeout)); RL(close(kq)); RL(waitpid(pid, &status, 0)); ATF_REQUIRE(WIFEXITED(status)); ATF_REQUIRE_EQ(WEXITSTATUS(status), EXIT_SUCCESS); /* * we are expecting an error here as we should not have * been able to add a knote to child 2. */ ATF_REQUIRE(ke.fflags & NOTE_TRACKERR); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, proc2); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_proc3.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_proc3.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_proc3.c (revision 312126) @@ -1,102 +1,102 @@ -/* $NetBSD: t_proc3.c,v 1.2 2015/01/14 22:22:32 christos Exp $ */ +/* $NetBSD: t_proc3.c,v 1.3 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Joerg Sonnenberger. * * 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 -__RCSID("$NetBSD: t_proc3.c,v 1.2 2015/01/14 22:22:32 christos Exp $"); +__RCSID("$NetBSD: t_proc3.c,v 1.3 2017/01/13 21:30:41 christos Exp $"); #ifdef __FreeBSD__ #include #endif #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(proc3); ATF_TC_HEAD(proc3, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_PROC for NOTE_TRACK on self bug "); } ATF_TC_BODY(proc3, tc) { pid_t pid = 0; int kq, status; struct kevent ke; struct timespec timeout; RL(kq = kqueue()); EV_SET(&ke, (uintptr_t)getpid(), EVFILT_PROC, EV_ADD, NOTE_TRACK, 0, 0); RL(kevent(kq, &ke, 1, NULL, 0, NULL)); RL(pid = fork()); if (pid == 0) { _exit(EXIT_SUCCESS); /* NOTREACHED */ } RL(waitpid(pid, &status, 0)); ATF_REQUIRE(WIFEXITED(status)); ATF_REQUIRE_EQ(WEXITSTATUS(status), EXIT_SUCCESS); timeout.tv_sec = 0; timeout.tv_nsec = 0; ke.ident = 0; ke.fflags = 0; ke.flags = EV_ENABLE; RL(kevent(kq, NULL, 0, &ke, 1, &timeout)); RL(close(kq)); ATF_REQUIRE(ke.fflags & NOTE_CHILD); ATF_REQUIRE((ke.fflags & NOTE_TRACKERR) == 0); ATF_REQUIRE_EQ((pid_t)ke.ident, pid); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, proc3); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_sig.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_sig.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/t_sig.c (revision 312126) @@ -1,150 +1,150 @@ -/* $NetBSD: t_sig.c,v 1.2 2010/11/03 16:10:20 christos Exp $ */ +/* $NetBSD: t_sig.c,v 1.3 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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_sig.c,v 1.2 2010/11/03 16:10:20 christos Exp $"); +__RCSID("$NetBSD: t_sig.c,v 1.3 2017/01/13 21:30:41 christos Exp $"); #ifdef __FreeBSD__ #include #endif #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #define NSIGNALS 5 ATF_TC(sig); ATF_TC_HEAD(sig, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_SIGNAL"); } ATF_TC_BODY(sig, tc) { struct timespec timeout; #ifdef __NetBSD__ struct kfilter_mapping km; #endif struct kevent event[1]; #ifdef __NetBSD__ char namebuf[32]; #endif pid_t pid, child; int kq, n, num, status; pid = getpid(); (void)printf("my pid: %d\n", pid); /* fork a child to send signals */ RL(child = fork()); if (child == 0) { int i; (void)sleep(2); for(i = 0; i < NSIGNALS; ++i) { (void)kill(pid, SIGUSR1); (void)sleep(2); } _exit(0); /* NOTREACHED */ } RL(kq = kqueue()); #ifdef __NetBSD__ (void)strlcpy(namebuf, "EVFILT_SIGNAL", sizeof(namebuf)); km.name = namebuf; RL(ioctl(kq, KFILTER_BYNAME, &km)); (void)printf("got %d as filter number for `%s'.\n", km.filter, km.name); #endif /* ignore the signal to avoid taking it for real */ REQUIRE_LIBC(signal(SIGUSR1, SIG_IGN), SIG_ERR); event[0].ident = SIGUSR1; #ifdef __NetBSD__ event[0].filter = km.filter; #else event[0].filter = EVFILT_SIGNAL; #endif event[0].flags = EV_ADD | EV_ENABLE; RL(kevent(kq, event, 1, NULL, 0, NULL)); (void)sleep(1); timeout.tv_sec = 1; timeout.tv_nsec = 0; for (num = 0; num < NSIGNALS; num += n) { struct timeval then, now, diff; RL(gettimeofday(&then, NULL)); RL(n = kevent(kq, NULL, 0, event, 1, &timeout)); RL(gettimeofday(&now, NULL)); timersub(&now, &then, &diff); (void)printf("sig: kevent returned %d in %lld.%06ld\n", n, (long long)diff.tv_sec, (long)diff.tv_usec); if (n == 0) continue; #ifdef __FreeBSD__ (void)printf("sig: kevent flags: 0x%x, data: %" PRIdPTR " (# " #else (void)printf("sig: kevent flags: 0x%x, data: %" PRId64 " (# " #endif "times signal posted)\n", event[0].flags, event[0].data); } (void)waitpid(child, &status, 0); (void)printf("sig: finished successfully\n"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, sig); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/write/t_fifo.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/write/t_fifo.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/write/t_fifo.c (revision 312126) @@ -1,102 +1,102 @@ -/* $NetBSD: t_fifo.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $ */ +/* $NetBSD: t_fifo.c,v 1.4 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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_fifo.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $"); +__RCSID("$NetBSD: t_fifo.c,v 1.4 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include #include #include -#include "../../../h_macros.h" +#include "h_macros.h" #define FIFONAME "fifo" ATF_TC(fifo); ATF_TC_HEAD(fifo, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_WRITE for fifo"); } ATF_TC_BODY(fifo, tc) { char buffer[128]; struct kevent event[1]; pid_t child; int kq, n, fd, status; RL(mkfifo(FIFONAME, 0644)); RL(fd = open(FIFONAME, O_RDWR, 0644)); RL(kq = kqueue()); /* spawn child reader */ RL(child = fork()); if (child == 0) { int sz = read(fd, buffer, 128); if (sz > 0) (void)printf("fifo: child read '%.*s'\n", sz, buffer); _exit(sz <= 0); } EV_SET(&event[0], fd, EVFILT_WRITE, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); (void)memset(event, 0, sizeof(event)); RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d filt %d flags: %#x, fflags: %#x, " "data: %" PRId64 "\n", n, event[0].filter, event[0].flags, event[0].fflags, event[0].data); ATF_REQUIRE_EQ(event[0].filter, EVFILT_WRITE); RL(write(fd, "foo", 3)); (void)printf("fifo: wrote 'foo'\n"); RL(close(fd)); (void)waitpid(child, &status, 0); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fifo); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/write/t_pipe.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/write/t_pipe.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/write/t_pipe.c (revision 312126) @@ -1,147 +1,147 @@ -/* $NetBSD: t_pipe.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ +/* $NetBSD: t_pipe.c,v 1.2 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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_pipe.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); +__RCSID("$NetBSD: t_pipe.c,v 1.2 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include -#include "../../../h_macros.h" +#include "h_macros.h" ATF_TC(pipe1); ATF_TC_HEAD(pipe1, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_WRITE for pipes. This test used to trigger " "problem fixed in rev. 1.5.2.7 of sys/kern/sys_pipe.c"); } ATF_TC_BODY(pipe1, tc) { struct kevent event[1]; int fds[2]; int kq, n; RL(pipe(fds)); RL(kq = kqueue()); RL(close(fds[0])); EV_SET(&event[0], fds[1], EVFILT_WRITE, EV_ADD|EV_ENABLE, 0, 0, 0); ATF_REQUIRE_EQ_MSG((n = kevent(kq, event, 1, NULL, 0, NULL)), -1, "got: %d", n); ATF_REQUIRE_EQ_MSG(errno, EBADF, "got: %s", strerror(errno)); } ATF_TC(pipe2); ATF_TC_HEAD(pipe2, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_WRITE for pipes. This test used to trigger problem " "fixed in rev. 1.5.2.9 of sys/kern/sys_pipe.c"); } ATF_TC_BODY(pipe2, tc) { struct kevent event[1]; char buffer[128]; int fds[2]; int kq, n; int status; pid_t child; RL(pipe(fds)); RL(kq = kqueue()); EV_SET(&event[0], fds[1], EVFILT_WRITE, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); /* spawn child reader */ RL(child = fork()); if (child == 0) { int sz = read(fds[0], buffer, 128); if (sz > 0) (void)printf("pipe: child read '%.*s'\n", sz, buffer); exit(sz <= 0); } RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d flags: %#x, fflags: %#x, data: " "%" PRId64 "\n", n, event[0].flags, event[0].fflags, event[0].data); RL(n = write(fds[1], "foo", 3)); RL(close(fds[1])); (void)waitpid(child, &status, 0); } ATF_TC(pipe3); ATF_TC_HEAD(pipe3, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_WRITE for pipes. This test used to trigger problem " "fixed in rev. 1.5.2.10 of sys/kern/sys_pipe.c"); } ATF_TC_BODY(pipe3, tc) { struct kevent event[1]; int fds[2]; int kq; RL(pipe(fds)); RL(kq = kqueue()); EV_SET(&event[0], fds[1], EVFILT_WRITE, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); /* close 'read' end first, then 'write' */ RL(close(fds[0])); RL(close(fds[1])); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, pipe1); ATF_TP_ADD_TC(tp, pipe2); ATF_TP_ADD_TC(tp, pipe3); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/write/t_ttypty.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/write/t_ttypty.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/kqueue/write/t_ttypty.c (revision 312126) @@ -1,130 +1,130 @@ -/* $NetBSD: t_ttypty.c,v 1.1 2009/02/20 21:39:58 jmmv Exp $ */ +/* $NetBSD: t_ttypty.c,v 1.2 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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_ttypty.c,v 1.1 2009/02/20 21:39:58 jmmv Exp $"); +__RCSID("$NetBSD: t_ttypty.c,v 1.2 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include #include #include #include -#include "../../../h_macros.h" +#include "h_macros.h" static void h_check(bool check_master) { char slavetty[1024]; char buffer[128]; struct kevent event[1]; struct pollfd pfd; pid_t child; int status, kq, n; int amaster, aslave, acurrent; RL(openpty(&amaster, &aslave, slavetty, NULL, NULL)); (void)printf("tty: openpty master %d slave %d tty '%s'\n", amaster, aslave, slavetty); acurrent = check_master ? amaster : aslave; RL(child = fork()); if (child == 0) { (void)sleep(1); n = read(check_master ? aslave : amaster, buffer, 128); (void)printf("tty: child read '%.*s'\n", n, buffer); _exit(0); } pfd.fd = acurrent; pfd.events = POLLOUT; (void)printf("tty: polling ...\n"); RL(poll(&pfd, 1, INFTIM)); (void)printf("tty: returned from poll - %d\n", pfd.revents); RL(kq = kqueue()); EV_SET(&event[0], acurrent, EVFILT_WRITE, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d filt %d flags: %#x, fflags: %#x, data: " "%" PRId64 "\n", n, event[0].filter, event[0].flags, event[0].fflags, event[0].data); ATF_REQUIRE_EQ(event[0].filter, EVFILT_WRITE); RL(n = write(acurrent, "f00\n", 4)); (void)printf("tty: wrote 'f00\\n' (wrote %d characters)\n", n); (void)waitpid(child, &status, 0); (void)printf("tty: successful end\n"); } ATF_TC(master); ATF_TC_HEAD(master, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_WRITE for master tty"); } ATF_TC_BODY(master, tc) { h_check(true); } ATF_TC(slave); ATF_TC_HEAD(slave, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_WRITE for slave tty"); } ATF_TC_BODY(slave, tc) { h_check(false); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, master); ATF_TP_ADD_TC(tp, slave); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_extent.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_extent.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_extent.c (revision 312126) @@ -1,385 +1,385 @@ -/* $NetBSD: t_extent.c,v 1.4 2012/01/27 18:53:10 para Exp $ */ +/* $NetBSD: t_extent.c,v 1.5 2017/01/13 21:30:41 christos 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_extent.c,v 1.4 2012/01/27 18:53:10 para Exp $"); +__RCSID("$NetBSD: t_extent.c,v 1.5 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include -#include "../h_macros.h" +#include "h_macros.h" static int ret; static struct extent *ex; #define h_create(name, start, end, flags) \ ATF_REQUIRE((ex = extent_create(name, \ start, end, 0, 0, flags)) != NULL); #define h_alloc_region(start, size) \ ATF_REQUIRE_EQ_MSG(ret = extent_alloc_region(ex, \ start, size, 0), 0, "%s", strerror(ret)); #define h_free(start, size) \ ATF_REQUIRE_EQ_MSG(ret = extent_free(ex, \ start, size, 0), 0, "%s", strerror(ret)); static void h_alloc_subregion(u_long substart, u_long subend, u_long size, u_long alignment, u_long boundary, int expret, u_long expres) { u_long result; #define FAIL(fmt, ...) \ atf_tc_fail("extent_alloc_subregion1(ex, %#lx, %#lx, %#lx, %#lx, 0, " \ "%#lx, 0, &result): " fmt, substart, subend, size, alignment, \ boundary, ##__VA_ARGS__) ret = extent_alloc_subregion1(ex, substart, subend, size, alignment, 0, boundary, 0, &result); if (ret != expret) FAIL("%s", strerror(errno)); if (expret == 0 && result != expres) FAIL("result should be: %#lx, got: %#lx", expres, result); #undef FAIL } static void h_require(const char *name, u_long start, u_long end, int flags, const char *exp) { char buf[4096]; struct extent_region *rp; int n = 0; ATF_REQUIRE_STREQ_MSG(ex->ex_name, name, "expected: \"%s\", got: \"%s\"", name, ex->ex_name); ATF_REQUIRE_EQ_MSG(ex->ex_start, start, "expected: %#lx, got: %#lx", start, ex->ex_start); ATF_REQUIRE_EQ_MSG(ex->ex_end, end, "expected: %#lx, got: %#lx", end, ex->ex_end); ATF_REQUIRE_EQ_MSG(ex->ex_flags, flags, "expected: %#x, got: %#x", flags, ex->ex_flags); (void)memset(buf, 0, sizeof(buf)); LIST_FOREACH(rp, &ex->ex_regions, er_link) n += snprintf(buf + n, sizeof(buf) - n, "0x%lx - 0x%lx\n", rp->er_start, rp->er_end); if (strcmp(buf, exp) == 0) return; printf("Incorrect extent map\n"); printf("Expected:\n%s\n", exp); printf("Got:\n%s\n", buf); atf_tc_fail("incorrect extent map"); } ATF_TC(coalesce); ATF_TC_HEAD(coalesce, tc) { atf_tc_set_md_var(tc, "descr", "Checks coalescing of regions"); } ATF_TC_BODY(coalesce, tc) { h_create("test1", 0, 0x4f, 0); h_alloc_region(0x00, 0x10); h_alloc_region(0x20, 0x10); h_alloc_region(0x40, 0x10); h_alloc_region(0x10, 0x10); h_alloc_subregion(0, 0x4f, 0x10, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x30); h_require("test1", 0x00, 0x4f, 0x00, "0x0 - 0x4f\n"); extent_destroy(ex); } ATF_TC(subregion1); ATF_TC_HEAD(subregion1, tc) { atf_tc_set_md_var(tc, "descr", "Checks that subregions work (PR kern/7539)"); } ATF_TC_BODY(subregion1, tc) { h_create("test2", 0, 0x2f, EX_NOCOALESCE); h_alloc_region(0x00, 0x10); h_alloc_subregion(0x20, 0x30, 0x10, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x20); h_require("test2", 0x00, 0x2f, 0x2, "0x0 - 0xf\n" "0x20 - 0x2f\n"); extent_destroy(ex); } ATF_TC(subregion2); ATF_TC_HEAD(subregion2, tc) { atf_tc_set_md_var(tc, "descr", "Checks that subregion allocations don't overlap with existing " "ones (fixed in 1.25)"); } ATF_TC_BODY(subregion2, tc) { h_create("test3", 0, 0x3f, EX_NOCOALESCE); h_alloc_region(0x00, 0x20); h_alloc_region(0x30, 0x10); h_alloc_subregion(0x10, 0x3f, 0x10, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x20); h_require("test3", 0x00, 0x3f, 0x2, "0x0 - 0x1f\n" "0x20 - 0x2f\n" "0x30 - 0x3f\n"); extent_destroy(ex); } ATF_TC(bound1); ATF_TC_HEAD(bound1, tc) { atf_tc_set_md_var(tc, "descr", "Checks for overflow in boundary check, before an allocated region " "(fixed in 1.32)"); } ATF_TC_BODY(bound1, tc) { h_create("test4", 0xf0000000, 0xffffffff, 0); h_alloc_region(0xf1000000, 0x1); h_alloc_subregion(0xf0000000, 0xffffffff, 0x1, EX_NOALIGN, 0x20000000, 0, 0xf0000000); h_require("test4", 0xf0000000, 0xffffffff, 0x0, "0xf0000000 - 0xf0000000\n" "0xf1000000 - 0xf1000000\n"); extent_destroy(ex); } ATF_TC(bound2); ATF_TC_HEAD(bound2, tc) { atf_tc_set_md_var(tc, "descr", "Checks for overflow in boundary checks, before the subregion end " "(fixed in 1.32)"); } ATF_TC_BODY(bound2, tc) { h_create("test5", 0xf0000000, 0xffffffff, 0); h_alloc_subregion(0xf0000000, 0xffffffff, 0x1, EX_NOALIGN, 0x20000000, 0, 0xf0000000); h_require("test5", 0xf0000000, 0xffffffff, 0x0, "0xf0000000 - 0xf0000000\n"); extent_destroy(ex); } ATF_TC(bound3); ATF_TC_HEAD(bound3, tc) { atf_tc_set_md_var(tc, "descr", "Checks allocation beyond last boundary line: last two " "allocations should succeed without boundary \"fixups\""); } ATF_TC_BODY(bound3, tc) { h_create("test6", 0, 11, 0); h_alloc_subregion(0, 11, 8, EX_NOALIGN, 8, 0, 0); h_alloc_subregion(0, 11, 2, EX_NOALIGN, 8, 0, 0x8); h_alloc_subregion(0, 11, 2, EX_NOALIGN, 8, 0, 0xa); h_require("test6", 0x0, 0xb, 0x0, "0x0 - 0xb\n"); extent_destroy(ex); } ATF_TC(bound4); ATF_TC_HEAD(bound4, tc) { atf_tc_set_md_var(tc, "descr", "Checks allocation beyond last boundary line: last allocation " "should be bumped to the next boundary and exactly fit the " "remaining space"); } ATF_TC_BODY(bound4, tc) { h_create("test7", 0, 11, 0); h_alloc_subregion(0, 11, 7, EX_NOALIGN, 8, 0, 0); h_alloc_subregion(0, 11, 4, EX_NOALIGN, 8, 0, 8); h_require("test7", 0x0, 0xb, 0x0, "0x0 - 0x6\n" "0x8 - 0xb\n"); extent_destroy(ex); } ATF_TC(subregion3); ATF_TC_HEAD(subregion3, tc) { atf_tc_set_md_var(tc, "descr", "Checks that we don't allocate a region pasts the end of " "subregion (i.e., the second alloc_subregion should fail). " "subr_extent.c prior to rev. 1.43 allocated region starting " "from 0x10"); } ATF_TC_BODY(subregion3, tc) { h_create("test8", 0, 0x4f, EX_NOCOALESCE); h_alloc_region(0x30, 0x10); h_alloc_subregion(0, 0xf, 0x10, EX_NOALIGN, EX_NOBOUNDARY, 0, 0); h_alloc_subregion(0, 0xf, 0x10, EX_NOALIGN, EX_NOBOUNDARY, EAGAIN, 0); h_require("test8", 0x0, 0x4f, 0x2, "0x0 - 0xf\n" "0x30 - 0x3f\n"); extent_destroy(ex); } ATF_TC(bound5); ATF_TC_HEAD(bound5, tc) { atf_tc_set_md_var(tc, "descr", "When allocating a region with a boundary constraint, checks " "proper detection of overflaps once the candidate region has " "been aligned. subr_extent.c prior 1.45 could corrupt the extent " "map in this situation"); } ATF_TC_BODY(bound5, tc) { h_create("test9", 0, 0x4f, 0); h_alloc_subregion(0, 0x10, 4, EX_NOALIGN, 0, 0, 0); h_alloc_subregion(0xd, 0x20, 2, EX_NOALIGN, 0, 0, 0xd); h_alloc_subregion(0, 0x4f, 8, EX_NOALIGN, 8, 0, 0x10); h_require("test9", 0x0, 0x4f, 0x0, "0x0 - 0x3\n" "0xd - 0xe\n" "0x10 - 0x17\n"); extent_destroy(ex); } ATF_TC(free); ATF_TC_HEAD(free, tc) { atf_tc_set_md_var(tc, "descr", "Checks extent_free()"); } ATF_TC_BODY(free, tc) { h_create("test10", 0xc0002000, 0xffffe000, EX_BOUNDZERO); h_alloc_subregion(0xc0002000, 0xffffe000, 0x2000, 0x10000, 0x10000, 0, 0xc0010000); h_alloc_subregion(0xc0002000, 0xffffe000, 0x2000, 0x10000, 0x10000, 0, 0xc0020000); h_require("test10", 0xc0002000, 0xffffe000, 0x0, "0xc0010000 - 0xc0011fff\n" "0xc0020000 - 0xc0021fff\n"); h_free(0xc0020000, 0x2000); h_require("test10", 0xc0002000, 0xffffe000, 0x0, "0xc0010000 - 0xc0011fff\n"); h_alloc_subregion(0xc0002000, 0xffffe000, 0x10000, 0x10000, 0x10000, 0, 0xc0022000); h_require("test10", 0xc0002000, 0xffffe000, 0x0, "0xc0010000 - 0xc0011fff\n" "0xc0022000 - 0xc0031fff\n"); extent_destroy(ex); } ATF_TC(subregion4); ATF_TC_HEAD(subregion4, tc) { atf_tc_set_md_var(tc, "descr", "Checks for off-by-one bug which would cause a region at the end " "of the extent to be allocated multiple times (fixed in 1.51)"); } ATF_TC_BODY(subregion4, tc) { h_create("test11", 0x10, 0x20, EX_NOCOALESCE); h_alloc_subregion(0x10, 0x13, 0x4, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x10); h_alloc_subregion(0x1e, 0x1f, 0x2, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x1e); h_alloc_subregion(0x20, 0x20, 0x1, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x20); h_alloc_subregion(0x20, 0x20, 0x1, EX_NOALIGN, EX_NOBOUNDARY, EAGAIN, 0); h_alloc_subregion(0x10, 0x20, 0x1, EX_NOALIGN, EX_NOBOUNDARY, 0, 0x14); h_require("test11", 0x10, 0x20, 0x2, "0x10 - 0x13\n" "0x14 - 0x14\n" "0x1e - 0x1f\n" "0x20 - 0x20\n"); extent_destroy(ex); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, coalesce); ATF_TP_ADD_TC(tp, subregion1); ATF_TP_ADD_TC(tp, subregion2); ATF_TP_ADD_TC(tp, bound1); ATF_TP_ADD_TC(tp, bound2); ATF_TP_ADD_TC(tp, bound3); ATF_TP_ADD_TC(tp, bound4); ATF_TP_ADD_TC(tp, subregion3); ATF_TP_ADD_TC(tp, bound5); ATF_TP_ADD_TC(tp, free); ATF_TP_ADD_TC(tp, subregion4); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_filedesc.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_filedesc.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_filedesc.c (revision 312126) @@ -1,108 +1,108 @@ -/* $NetBSD: t_filedesc.c,v 1.5 2012/03/18 09:46:50 jruoho Exp $ */ +/* $NetBSD: t_filedesc.c,v 1.6 2017/01/13 21:30:41 christos 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 -__RCSID("$NetBSD: t_filedesc.c,v 1.5 2012/03/18 09:46:50 jruoho Exp $"); +__RCSID("$NetBSD: t_filedesc.c,v 1.6 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include #include -#include "../h_macros.h" +#include "h_macros.h" ATF_TC(getfilerace); ATF_TC_HEAD(getfilerace, tc) { atf_tc_set_md_var(tc, "descr", "race between multithreaded proc. " "fd_getfile() and fd_close() (PR kern/43694)"); } static int fd; static volatile bool quit; static void * wrkwrk(void *arg) { /* just something to cause fd_getfile() to be called */ while (!quit) rump_sys_write(fd, &fd, sizeof(fd)); return NULL; } /* for me, 1000 triggers extremely seldom, 10k sometimes, 100k almost always */ #define DEFAULT_ITERATIONS 10000 ATF_TC_BODY(getfilerace, tc) { pthread_t pt; int fd_wrk; int i, iters; /* * Want a multiprocessor virtual kernel. A multiprocessor host * probably helps too, but that's harder to do in software... */ setenv("RUMP_NCPU", "2", 1); rump_init(); fd = fd_wrk = rump_sys_open("/dev/null", O_RDWR, 0); if (fd == -1) atf_tc_fail_errno("cannot open /dev/null"); if (atf_tc_has_config_var(tc, "iters")) iters = atoi(atf_tc_get_config_var(tc, "iters")); else iters = DEFAULT_ITERATIONS; pthread_create(&pt, NULL, wrkwrk, NULL); for (i = 0; i < iters; i++) { rump_sys_close(fd_wrk); fd_wrk = rump_sys_open("/dev/null", O_RDWR, 0); assert(fd == fd_wrk); } quit = true; pthread_join(pt, NULL); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, getfilerace); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_lock.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_lock.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_lock.c (revision 312126) @@ -1,87 +1,87 @@ -/* $NetBSD: t_lock.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ +/* $NetBSD: t_lock.c,v 1.2 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2002, 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_lock.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); +__RCSID("$NetBSD: t_lock.c,v 1.2 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include -#include "../h_macros.h" +#include "h_macros.h" __cpu_simple_lock_t lk; volatile int handled = 0; static void handler(int sig) { handled = 1; __cpu_simple_unlock(&lk); } ATF_TC(lock); ATF_TC_HEAD(lock, tc) { atf_tc_set_md_var(tc, "timeout", "3"); atf_tc_set_md_var(tc, "descr", "Checks __cpu_simple_lock()/__cpu_simple_unlock()"); } ATF_TC_BODY(lock, tc) { struct itimerval itv; __cpu_simple_lock_init(&lk); REQUIRE_LIBC(signal(SIGVTALRM, handler), SIG_ERR); itv.it_interval.tv_sec = 0; itv.it_interval.tv_usec = 0; itv.it_value.tv_sec = 1; itv.it_value.tv_usec = 0; RL(setitimer(ITIMER_VIRTUAL, &itv, NULL)); __cpu_simple_lock(&lk); __cpu_simple_lock(&lk); ATF_REQUIRE(handled); __cpu_simple_unlock(&lk); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, lock); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_ptrace.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_ptrace.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_ptrace.c (revision 312126) @@ -1,208 +1,208 @@ -/* $NetBSD: t_ptrace.c,v 1.17 2016/11/13 22:59:31 kamil Exp $ */ +/* $NetBSD: t_ptrace.c,v 1.18 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2016 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 -__RCSID("$NetBSD: t_ptrace.c,v 1.17 2016/11/13 22:59:31 kamil Exp $"); +__RCSID("$NetBSD: t_ptrace.c,v 1.18 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include #include #include -#include "../h_macros.h" +#include "h_macros.h" /* * A child process cannot call atf functions and expect them to magically * work like in the parent. * The printf(3) messaging from a child will not work out of the box as well * without estabilishing a communication protocol with its parent. To not * overcomplicate the tests - do not log from a child and use err(3)/errx(3) * wrapped with FORKEE_ASSERT()/FORKEE_ASSERTX() as that is guaranteed to work. */ #define FORKEE_ASSERTX(x) \ do { \ int ret = (x); \ if (!ret) \ errx(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: %s", \ __FILE__, __LINE__, __func__, #x); \ } while (0) #define FORKEE_ASSERT(x) \ do { \ int ret = (x); \ if (!ret) \ err(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: %s", \ __FILE__, __LINE__, __func__, #x); \ } while (0) ATF_TC(attach_pid0); ATF_TC_HEAD(attach_pid0, tc) { atf_tc_set_md_var(tc, "descr", "Assert that a debugger cannot attach to PID 0"); } ATF_TC_BODY(attach_pid0, tc) { errno = 0; ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, 0, NULL, 0) == -1); } ATF_TC(attach_pid1); ATF_TC_HEAD(attach_pid1, tc) { atf_tc_set_md_var(tc, "descr", "Assert that a debugger cannot attach to PID 1 (as non-root)"); atf_tc_set_md_var(tc, "require.user", "unprivileged"); } ATF_TC_BODY(attach_pid1, tc) { ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, 1, NULL, 0) == -1); } ATF_TC(attach_pid1_securelevel); ATF_TC_HEAD(attach_pid1_securelevel, tc) { atf_tc_set_md_var(tc, "descr", "Assert that a debugger cannot attach to PID 1 with " "securelevel >= 1 (as root)"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(attach_pid1_securelevel, tc) { int level; size_t len = sizeof(level); ATF_REQUIRE(sysctlbyname("kern.securelevel", &level, &len, NULL, 0) != -1); if (level < 1) { atf_tc_skip("Test must be run with securelevel >= 1"); } ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, 1, NULL, 0) == -1); } ATF_TC(attach_self); ATF_TC_HEAD(attach_self, tc) { atf_tc_set_md_var(tc, "descr", "Assert that a debugger cannot attach to self (as it's nonsense)"); } ATF_TC_BODY(attach_self, tc) { ATF_REQUIRE_ERRNO(EINVAL, ptrace(PT_ATTACH, getpid(), NULL, 0) == -1); } ATF_TC(attach_chroot); ATF_TC_HEAD(attach_chroot, tc) { atf_tc_set_md_var(tc, "descr", "Assert that a debugger cannot trace another process unless the " "process's root directory is at or below the tracing process's " "root"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(attach_chroot, tc) { char buf[PATH_MAX]; pid_t child; int fds_toparent[2], fds_fromparent[2]; int rv; uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ (void)memset(buf, '\0', sizeof(buf)); ATF_REQUIRE(getcwd(buf, sizeof(buf)) != NULL); (void)strlcat(buf, "/dir", sizeof(buf)); ATF_REQUIRE(mkdir(buf, 0500) == 0); ATF_REQUIRE(chdir(buf) == 0); ATF_REQUIRE(pipe(fds_toparent) == 0); ATF_REQUIRE(pipe(fds_fromparent) == 0); child = atf_utils_fork(); if (child == 0) { FORKEE_ASSERT(close(fds_toparent[0]) == 0); FORKEE_ASSERT(close(fds_fromparent[1]) == 0); FORKEE_ASSERT(chroot(buf) == 0); rv = write(fds_toparent[1], &msg, sizeof(msg)); FORKEE_ASSERTX(rv == sizeof(msg)); ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, getppid(), NULL, 0) == -1); rv = read(fds_fromparent[0], &msg, sizeof(msg)); FORKEE_ASSERTX(rv == sizeof(msg)); _exit(0); } ATF_REQUIRE(close(fds_toparent[1]) == 0); ATF_REQUIRE(close(fds_fromparent[0]) == 0); printf("Waiting for chrooting of the child PID %d", child); rv = read(fds_toparent[0], &msg, sizeof(msg)); ATF_REQUIRE(rv == sizeof(msg)); printf("Child is ready, it will try to PT_ATTACH to parent\n"); rv = write(fds_fromparent[1], &msg, sizeof(msg)); ATF_REQUIRE(rv == sizeof(msg)); printf("fds_fromparent is no longer needed - close it\n"); ATF_REQUIRE(close(fds_fromparent[1]) == 0); printf("fds_toparent is no longer needed - close it\n"); ATF_REQUIRE(close(fds_toparent[0]) == 0); } ATF_TP_ADD_TCS(tp) { setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); ATF_TP_ADD_TC(tp, attach_pid0); ATF_TP_ADD_TC(tp, attach_pid1); ATF_TP_ADD_TC(tp, attach_pid1_securelevel); ATF_TP_ADD_TC(tp, attach_self); ATF_TP_ADD_TC(tp, attach_chroot); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_ptrace_wait.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_ptrace_wait.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_ptrace_wait.c (revision 312126) @@ -1,5082 +1,5384 @@ -/* $NetBSD: t_ptrace_wait.c,v 1.53 2017/01/10 05:08:24 kamil Exp $ */ +/* $NetBSD: t_ptrace_wait.c,v 1.58 2017/01/14 04:37:55 kamil Exp $ */ /*- * Copyright (c) 2016 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 -__RCSID("$NetBSD: t_ptrace_wait.c,v 1.53 2017/01/10 05:08:24 kamil Exp $"); +__RCSID("$NetBSD: t_ptrace_wait.c,v 1.58 2017/01/14 04:37:55 kamil Exp $"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../h_macros.h" +#include "h_macros.h" #include "t_ptrace_wait.h" #include "msg.h" #define PARENT_TO_CHILD(info, fds, msg) \ ATF_REQUIRE(msg_write_child(info " to child " # fds, &fds, &msg, sizeof(msg)) == 0) #define CHILD_FROM_PARENT(info, fds, msg) \ FORKEE_ASSERT(msg_read_parent(info " from parent " # fds, &fds, &msg, sizeof(msg)) == 0) #define CHILD_TO_PARENT(info, fds, msg) \ FORKEE_ASSERT(msg_write_parent(info " to parent " # fds, &fds, &msg, sizeof(msg)) == 0) #define PARENT_FROM_CHILD(info, fds, msg) \ ATF_REQUIRE(msg_read_child(info " from parent " # fds, &fds, &msg, sizeof(msg)) == 0) + ATF_TC(traceme1); ATF_TC_HEAD(traceme1, tc) { atf_tc_set_md_var(tc, "descr", "Verify SIGSTOP followed by _exit(2) in a child"); } ATF_TC_BODY(traceme1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(traceme2); ATF_TC_HEAD(traceme2, tc) { atf_tc_set_md_var(tc, "descr", "Verify SIGSTOP followed by _exit(2) in a child"); } static int traceme2_caught = 0; static void traceme2_sighandler(int sig) { FORKEE_ASSERT_EQ(sig, SIGINT); ++traceme2_caught; } ATF_TC_BODY(traceme2, tc) { const int exitval = 5; const int sigval = SIGSTOP, sigsent = SIGINT; pid_t child, wpid; struct sigaction sa; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); sa.sa_handler = traceme2_sighandler; sa.sa_flags = SA_SIGINFO; sigemptyset(&sa.sa_mask); FORKEE_ASSERT(sigaction(sigsent, &sa, NULL) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(traceme2_caught, 1); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before resuming the child process where it left off and with " "signal %s to be sent\n", strsignal(sigsent)); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the exited child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(traceme3); ATF_TC_HEAD(traceme3, tc) { atf_tc_set_md_var(tc, "descr", "Verify SIGSTOP followed by termination by a signal in a child"); } ATF_TC_BODY(traceme3, tc) { const int sigval = SIGSTOP, sigsent = SIGINT /* Without core-dump */; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); /* NOTREACHED */ FORKEE_ASSERTX(0 && "Child should be terminated by a signal from its parent"); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before resuming the child process where it left off and with " "signal %s to be sent\n", strsignal(sigsent)); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_signaled(status, sigsent, 0); printf("Before calling %s() for the exited child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(traceme4); ATF_TC_HEAD(traceme4, tc) { atf_tc_set_md_var(tc, "descr", "Verify SIGSTOP followed by SIGCONT and _exit(2) in a child"); } ATF_TC_BODY(traceme4, tc) { const int exitval = 5; const int sigval = SIGSTOP, sigsent = SIGCONT; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before raising %s from child\n", strsignal(sigsent)); FORKEE_ASSERT(raise(sigsent) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(),child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigsent); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the exited child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #if defined(TWAIT_HAVE_PID) ATF_TC(attach1); ATF_TC_HEAD(attach1, tc) { atf_tc_set_md_var(tc, "descr", "Assert that tracer sees process termination before the parent"); } ATF_TC_BODY(attach1, tc) { struct msg_fds parent_tracee, parent_tracer; const int exitval_tracee = 5; const int exitval_tracer = 10; pid_t tracee, tracer, wpid; uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Spawn tracee\n"); ATF_REQUIRE(msg_open(&parent_tracee) == 0); tracee = atf_utils_fork(); if (tracee == 0) { // Wait for parent to let us exit CHILD_FROM_PARENT("exit tracee", parent_tracee, msg); _exit(exitval_tracee); } printf("Spawn debugger\n"); ATF_REQUIRE(msg_open(&parent_tracer) == 0); tracer = atf_utils_fork(); if (tracer == 0) { printf("Before calling PT_ATTACH from tracee %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_stopped(status, SIGSTOP); /* Resume tracee with PT_CONTINUE */ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); /* Inform parent that tracer has attached to tracee */ CHILD_TO_PARENT("tracer ready", parent_tracer, msg); /* Wait for parent to tell use that tracee should have exited */ CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg); /* Wait for tracee and assert that it exited */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_exited(status, exitval_tracee); printf("Tracee %d exited with %d\n", tracee, exitval_tracee); printf("Before exiting of the tracer process\n"); _exit(exitval_tracer); } printf("Wait for the tracer to attach to the tracee\n"); PARENT_FROM_CHILD("tracer ready", parent_tracer, msg); printf("Resume the tracee and let it exit\n"); PARENT_TO_CHILD("exit tracee", parent_tracee, msg); printf("Detect that tracee is zombie\n"); await_zombie(tracee); printf("Assert that there is no status about tracee %d - " "Tracer must detect zombie first - calling %s()\n", tracee, TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); printf("Tell the tracer child should have exited\n"); PARENT_TO_CHILD("wait for tracee exit", parent_tracer, msg); printf("Wait for tracer to finish its job and exit - calling %s()\n", TWAIT_FNAME); printf("Wait from tracer child to complete waiting for tracee\n"); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0), tracer); validate_status_exited(status, exitval_tracer); printf("Wait for tracee to finish its job and exit - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), tracee); validate_status_exited(status, exitval_tracee); msg_close(&parent_tracer); msg_close(&parent_tracee); } #endif #if defined(TWAIT_HAVE_PID) ATF_TC(attach2); ATF_TC_HEAD(attach2, tc) { atf_tc_set_md_var(tc, "descr", "Assert that any tracer sees process termination before its " "parent"); } ATF_TC_BODY(attach2, tc) { struct msg_fds parent_tracer, parent_tracee; const int exitval_tracee = 5; const int exitval_tracer1 = 10, exitval_tracer2 = 20; pid_t tracee, tracer, wpid; uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Spawn tracee\n"); ATF_REQUIRE(msg_open(&parent_tracee) == 0); tracee = atf_utils_fork(); if (tracee == 0) { /* Wait for message from the parent */ CHILD_FROM_PARENT("Message 1", parent_tracee, msg); _exit(exitval_tracee); } printf("Spawn debugger\n"); ATF_REQUIRE(msg_open(&parent_tracer) == 0); tracer = atf_utils_fork(); if (tracer == 0) { /* Fork again and drop parent to reattach to PID 1 */ tracer = atf_utils_fork(); if (tracer != 0) _exit(exitval_tracer1); printf("Before calling PT_ATTACH from tracee %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_stopped(status, SIGSTOP); /* Resume tracee with PT_CONTINUE */ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); /* Inform parent that tracer has attached to tracee */ CHILD_TO_PARENT("Message 1", parent_tracer, msg); CHILD_FROM_PARENT("Message 2", parent_tracer, msg); /* Wait for tracee and assert that it exited */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_exited(status, exitval_tracee); printf("Before exiting of the tracer process\n"); _exit(exitval_tracer2); } printf("Wait for the tracer process (direct child) to exit calling " "%s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracer, &status, 0), tracer); validate_status_exited(status, exitval_tracer1); printf("Wait for the non-exited tracee process with %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, NULL, WNOHANG), 0); printf("Wait for the tracer to attach to the tracee\n"); PARENT_FROM_CHILD("Message 1", parent_tracer, msg); printf("Resume the tracee and let it exit\n"); PARENT_TO_CHILD("Message 1", parent_tracee, msg); printf("Detect that tracee is zombie\n"); await_zombie(tracee); printf("Assert that there is no status about tracee - " "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); printf("Resume the tracer and let it detect exited tracee\n"); PARENT_TO_CHILD("Message 2", parent_tracer, msg); printf("Wait for tracee to finish its job and exit - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), tracee); validate_status_exited(status, exitval_tracee); msg_close(&parent_tracer); msg_close(&parent_tracee); } #endif ATF_TC(attach3); ATF_TC_HEAD(attach3, tc) { atf_tc_set_md_var(tc, "descr", "Assert that tracer parent can PT_ATTACH to its child"); } ATF_TC_BODY(attach3, tc) { struct msg_fds parent_tracee; const int exitval_tracee = 5; pid_t tracee, wpid; uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Spawn tracee\n"); ATF_REQUIRE(msg_open(&parent_tracee) == 0); tracee = atf_utils_fork(); if (tracee == 0) { CHILD_FROM_PARENT("Message 1", parent_tracee, msg); printf("Parent should now attach to tracee\n"); CHILD_FROM_PARENT("Message 2", parent_tracee, msg); /* Wait for message from the parent */ _exit(exitval_tracee); } PARENT_TO_CHILD("Message 1", parent_tracee, msg); printf("Before calling PT_ATTACH for tracee %d\n", tracee); ATF_REQUIRE(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); printf("Wait for the stopped tracee process with %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); validate_status_stopped(status, SIGSTOP); printf("Resume tracee with PT_CONTINUE\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); printf("Let the tracee exit now\n"); PARENT_TO_CHILD("Message 2", parent_tracee, msg); printf("Wait for tracee to exit with %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); validate_status_exited(status, exitval_tracee); printf("Before calling %s() for tracee\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(tracee, &status, 0)); msg_close(&parent_tracee); } ATF_TC(attach4); ATF_TC_HEAD(attach4, tc) { atf_tc_set_md_var(tc, "descr", "Assert that tracer child can PT_ATTACH to its parent"); } ATF_TC_BODY(attach4, tc) { struct msg_fds parent_tracee; const int exitval_tracer = 5; pid_t tracer, wpid; uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Spawn tracer\n"); ATF_REQUIRE(msg_open(&parent_tracee) == 0); tracer = atf_utils_fork(); if (tracer == 0) { /* Wait for message from the parent */ CHILD_FROM_PARENT("Message 1", parent_tracee, msg); printf("Attach to parent PID %d with PT_ATTACH from child\n", getppid()); FORKEE_ASSERT(ptrace(PT_ATTACH, getppid(), NULL, 0) != -1); printf("Wait for the stopped parent process with %s()\n", TWAIT_FNAME); FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(getppid(), &status, 0), getppid()); forkee_status_stopped(status, SIGSTOP); printf("Resume parent with PT_DETACH\n"); FORKEE_ASSERT(ptrace(PT_DETACH, getppid(), (void *)1, 0) != -1); /* Tell parent we are ready */ CHILD_TO_PARENT("Message 1", parent_tracee, msg); _exit(exitval_tracer); } printf("Wait for the tracer to become ready\n"); PARENT_TO_CHILD("Message 1", parent_tracee, msg); printf("Allow the tracer to exit now\n"); PARENT_FROM_CHILD("Message 1", parent_tracee, msg); printf("Wait for tracer to exit with %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracer, &status, 0), tracer); validate_status_exited(status, exitval_tracer); printf("Before calling %s() for tracer\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(tracer, &status, 0)); msg_close(&parent_tracee); } #if defined(TWAIT_HAVE_PID) ATF_TC(attach5); ATF_TC_HEAD(attach5, tc) { atf_tc_set_md_var(tc, "descr", "Assert that tracer sees its parent when attached to tracer " "(check getppid(2))"); } ATF_TC_BODY(attach5, tc) { struct msg_fds parent_tracer, parent_tracee; const int exitval_tracee = 5; const int exitval_tracer = 10; pid_t parent, tracee, tracer, wpid; uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Spawn tracee\n"); ATF_REQUIRE(msg_open(&parent_tracer) == 0); ATF_REQUIRE(msg_open(&parent_tracee) == 0); tracee = atf_utils_fork(); if (tracee == 0) { parent = getppid(); /* Emit message to the parent */ CHILD_TO_PARENT("tracee ready", parent_tracee, msg); CHILD_FROM_PARENT("exit tracee", parent_tracee, msg); FORKEE_ASSERT_EQ(parent, getppid()); _exit(exitval_tracee); } printf("Wait for child to record its parent identifier (pid)\n"); PARENT_FROM_CHILD("tracee ready", parent_tracee, msg); printf("Spawn debugger\n"); tracer = atf_utils_fork(); if (tracer == 0) { /* No IPC to communicate with the child */ printf("Before calling PT_ATTACH from tracee %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_stopped(status, SIGSTOP); /* Resume tracee with PT_CONTINUE */ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); /* Inform parent that tracer has attached to tracee */ CHILD_TO_PARENT("tracer ready", parent_tracer, msg); /* Wait for parent to tell use that tracee should have exited */ CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg); /* Wait for tracee and assert that it exited */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_exited(status, exitval_tracee); printf("Before exiting of the tracer process\n"); _exit(exitval_tracer); } printf("Wait for the tracer to attach to the tracee\n"); PARENT_FROM_CHILD("tracer ready", parent_tracer, msg); printf("Resume the tracee and let it exit\n"); PARENT_TO_CHILD("exit tracee", parent_tracee, msg); printf("Detect that tracee is zombie\n"); await_zombie(tracee); printf("Assert that there is no status about tracee - " "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); printf("Tell the tracer child should have exited\n"); PARENT_TO_CHILD("wait for tracee exit", parent_tracer, msg); printf("Wait from tracer child to complete waiting for tracee\n"); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0), tracer); validate_status_exited(status, exitval_tracer); printf("Wait for tracee to finish its job and exit - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), tracee); validate_status_exited(status, exitval_tracee); msg_close(&parent_tracer); msg_close(&parent_tracee); } #endif #if defined(TWAIT_HAVE_PID) ATF_TC(attach6); ATF_TC_HEAD(attach6, tc) { atf_tc_set_md_var(tc, "descr", "Assert that tracer sees its parent when attached to tracer " "(check sysctl(7) and struct kinfo_proc2)"); } ATF_TC_BODY(attach6, tc) { struct msg_fds parent_tracee, parent_tracer; const int exitval_tracee = 5; const int exitval_tracer = 10; pid_t parent, tracee, tracer, wpid; uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ #if defined(TWAIT_HAVE_STATUS) int status; #endif int name[CTL_MAXNAME]; struct kinfo_proc2 kp; size_t len = sizeof(kp); unsigned int namelen; printf("Spawn tracee\n"); ATF_REQUIRE(msg_open(&parent_tracee) == 0); ATF_REQUIRE(msg_open(&parent_tracer) == 0); tracee = atf_utils_fork(); if (tracee == 0) { parent = getppid(); /* Emit message to the parent */ CHILD_TO_PARENT("Message 1", parent_tracee, msg); CHILD_FROM_PARENT("Message 2", parent_tracee, msg); namelen = 0; name[namelen++] = CTL_KERN; name[namelen++] = KERN_PROC2; name[namelen++] = KERN_PROC_PID; name[namelen++] = getpid(); name[namelen++] = len; name[namelen++] = 1; FORKEE_ASSERT(sysctl(name, namelen, &kp, &len, NULL, 0) == 0); FORKEE_ASSERT_EQ(parent, kp.p_ppid); _exit(exitval_tracee); } printf("Wait for child to record its parent identifier (pid)\n"); PARENT_FROM_CHILD("Message 1", parent_tracee, msg); printf("Spawn debugger\n"); tracer = atf_utils_fork(); if (tracer == 0) { /* No IPC to communicate with the child */ printf("Before calling PT_ATTACH from tracee %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_stopped(status, SIGSTOP); /* Resume tracee with PT_CONTINUE */ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); /* Inform parent that tracer has attached to tracee */ CHILD_TO_PARENT("Message 1", parent_tracer, msg); CHILD_FROM_PARENT("Message 2", parent_tracer, msg); /* Wait for tracee and assert that it exited */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_exited(status, exitval_tracee); printf("Before exiting of the tracer process\n"); _exit(exitval_tracer); } printf("Wait for the tracer to attach to the tracee\n"); PARENT_FROM_CHILD("Message 1", parent_tracer, msg); printf("Resume the tracee and let it exit\n"); PARENT_TO_CHILD("Message 1", parent_tracee, msg); printf("Detect that tracee is zombie\n"); await_zombie(tracee); printf("Assert that there is no status about tracee - " "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); printf("Resume the tracer and let it detect exited tracee\n"); PARENT_TO_CHILD("Message 2", parent_tracer, msg); printf("Wait for tracer to finish its job and exit - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0), tracer); validate_status_exited(status, exitval_tracer); printf("Wait for tracee to finish its job and exit - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), tracee); validate_status_exited(status, exitval_tracee); msg_close(&parent_tracee); msg_close(&parent_tracer); } #endif #if defined(TWAIT_HAVE_PID) ATF_TC(attach7); ATF_TC_HEAD(attach7, tc) { atf_tc_set_md_var(tc, "descr", "Assert that tracer sees its parent when attached to tracer " "(check /proc/curproc/status 3rd column)"); } ATF_TC_BODY(attach7, tc) { struct msg_fds parent_tracee, parent_tracer; int rv; const int exitval_tracee = 5; const int exitval_tracer = 10; pid_t parent, tracee, tracer, wpid; uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ #if defined(TWAIT_HAVE_STATUS) int status; #endif FILE *fp; struct stat st; const char *fname = "/proc/curproc/status"; char s_executable[MAXPATHLEN]; int s_pid, s_ppid; /* * Format: * EXECUTABLE PID PPID ... */ ATF_REQUIRE((rv = stat(fname, &st)) == 0 || (errno == ENOENT)); if (rv != 0) { atf_tc_skip("/proc/curproc/status not found"); } printf("Spawn tracee\n"); ATF_REQUIRE(msg_open(&parent_tracee) == 0); ATF_REQUIRE(msg_open(&parent_tracer) == 0); tracee = atf_utils_fork(); if (tracee == 0) { parent = getppid(); // Wait for parent to let us exit CHILD_TO_PARENT("tracee ready", parent_tracee, msg); CHILD_FROM_PARENT("tracee exit", parent_tracee, msg); FORKEE_ASSERT((fp = fopen(fname, "r")) != NULL); fscanf(fp, "%s %d %d", s_executable, &s_pid, &s_ppid); FORKEE_ASSERT(fclose(fp) == 0); FORKEE_ASSERT_EQ(parent, s_ppid); _exit(exitval_tracee); } printf("Wait for child to record its parent identifier (pid)\n"); PARENT_FROM_CHILD("tracee ready", parent_tracee, msg); printf("Spawn debugger\n"); tracer = atf_utils_fork(); if (tracer == 0) { printf("Before calling PT_ATTACH from tracee %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_stopped(status, SIGSTOP); /* Resume tracee with PT_CONTINUE */ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); /* Inform parent that tracer has attached to tracee */ CHILD_TO_PARENT("tracer ready", parent_tracer, msg); /* Wait for parent to tell use that tracee should have exited */ CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg); /* Wait for tracee and assert that it exited */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_exited(status, exitval_tracee); printf("Before exiting of the tracer process\n"); _exit(exitval_tracer); } printf("Wait for the tracer to attach to the tracee\n"); PARENT_FROM_CHILD("tracer ready", parent_tracer, msg); printf("Resume the tracee and let it exit\n"); PARENT_TO_CHILD("tracee exit", parent_tracee, msg); printf("Detect that tracee is zombie\n"); await_zombie(tracee); printf("Assert that there is no status about tracee - " "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); printf("Resume the tracer and let it detect exited tracee\n"); PARENT_TO_CHILD("Message 2", parent_tracer, msg); printf("Wait for tracer to finish its job and exit - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0), tracer); validate_status_exited(status, exitval_tracer); printf("Wait for tracee to finish its job and exit - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), tracee); validate_status_exited(status, exitval_tracee); msg_close(&parent_tracee); msg_close(&parent_tracer); } #endif ATF_TC(eventmask1); ATF_TC_HEAD(eventmask1, tc) { atf_tc_set_md_var(tc, "descr", "Verify that empty EVENT_MASK is preserved"); } ATF_TC_BODY(eventmask1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif ptrace_event_t set_event, get_event; const int len = sizeof(ptrace_event_t); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); set_event.pe_set_event = 0; ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1); ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1); ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(eventmask2); ATF_TC_HEAD(eventmask2, tc) { atf_tc_set_md_var(tc, "descr", "Verify that PTRACE_FORK in EVENT_MASK is preserved"); } ATF_TC_BODY(eventmask2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif ptrace_event_t set_event, get_event; const int len = sizeof(ptrace_event_t); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); set_event.pe_set_event = PTRACE_FORK; ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1); ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1); ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } +ATF_TC(eventmask3); +ATF_TC_HEAD(eventmask3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that PTRACE_VFORK in EVENT_MASK is preserved"); +} + +ATF_TC_BODY(eventmask3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + ptrace_event_t set_event, get_event; + const int len = sizeof(ptrace_event_t); + + atf_tc_expect_fail("PR kern/51630"); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + set_event.pe_set_event = PTRACE_VFORK; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1); + ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1); + ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(eventmask4); +ATF_TC_HEAD(eventmask4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that PTRACE_VFORK_DONE in EVENT_MASK is preserved"); +} + +ATF_TC_BODY(eventmask4, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + ptrace_event_t set_event, get_event; + const int len = sizeof(ptrace_event_t); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + set_event.pe_set_event = PTRACE_VFORK_DONE; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1); + ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1); + ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + #if defined(TWAIT_HAVE_PID) ATF_TC(fork1); ATF_TC_HEAD(fork1, tc) { atf_tc_set_md_var(tc, "descr", "Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK " "set to PTRACE_FORK"); } ATF_TC_BODY(fork1, tc) { const int exitval = 5; const int exitval2 = 15; const int sigval = SIGSTOP; pid_t child, child2, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif ptrace_state_t state; const int slen = sizeof(state); ptrace_event_t event; const int elen = sizeof(event); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT((child2 = fork()) != 1); if (child2 == 0) _exit(exitval2); FORKEE_REQUIRE_SUCCESS (wpid = TWAIT_GENERIC(child2, &status, 0), child2); forkee_status_exited(status, exitval2); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Enable PTRACE_FORK in EVENT_MASK for the child %d\n", child); event.pe_set_event = PTRACE_FORK; ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGTRAP); ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1); ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK); child2 = state.pe_other_pid; printf("Reported PTRACE_FORK event with forkee %d\n", child2); printf("Before calling %s() for the forkee %d of the child %d\n", TWAIT_FNAME, child2, child); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), child2); validate_status_stopped(status, SIGTRAP); ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1); ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK); ATF_REQUIRE_EQ(state.pe_other_pid, child); printf("Before resuming the forkee process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the forkee - expected exited\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), child2); validate_status_exited(status, exitval2); printf("Before calling %s() for the forkee - expected no process\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child2, &status, 0)); printf("Before calling %s() for the child - expected stopped " "SIGCHLD\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGCHLD); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child - expected exited\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child - expected no process\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif ATF_TC(fork2); ATF_TC_HEAD(fork2, tc) { atf_tc_set_md_var(tc, "descr", "Verify that fork(2) is not intercepted by ptrace(2) with empty " "EVENT_MASK"); } ATF_TC_BODY(fork2, tc) { const int exitval = 5; const int exitval2 = 15; const int sigval = SIGSTOP; pid_t child, child2, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif ptrace_event_t event; const int elen = sizeof(event); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT((child2 = fork()) != 1); if (child2 == 0) _exit(exitval2); FORKEE_REQUIRE_SUCCESS (wpid = TWAIT_GENERIC(child2, &status, 0), child2); forkee_status_exited(status, exitval2); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Set empty EVENT_MASK for the child %d\n", child); event.pe_set_event = 0; ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child - expected stopped " "SIGCHLD\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGCHLD); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child - expected exited\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child - expected no process\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #if defined(TWAIT_HAVE_PID) ATF_TC(vfork1); ATF_TC_HEAD(vfork1, tc) { atf_tc_set_md_var(tc, "descr", "Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK " "set to PTRACE_VFORK"); } ATF_TC_BODY(vfork1, tc) { const int exitval = 5; const int exitval2 = 15; const int sigval = SIGSTOP; pid_t child, child2, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif ptrace_state_t state; const int slen = sizeof(state); ptrace_event_t event; const int elen = sizeof(event); - /* - * ptrace(2) command PT_SET_EVENT_MASK: option PTRACE_VFORK unsupported - */ -#ifndef PTRACE_VFORK -#define PTRACE_VFORK 0 -#endif atf_tc_expect_fail("PR kern/51630"); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT((child2 = vfork()) != 1); if (child2 == 0) _exit(exitval2); FORKEE_REQUIRE_SUCCESS (wpid = TWAIT_GENERIC(child2, &status, 0), child2); forkee_status_exited(status, exitval2); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Enable PTRACE_VFORK in EVENT_MASK for the child %d\n", child); event.pe_set_event = PTRACE_VFORK; ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGTRAP); ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1); ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK); child2 = state.pe_other_pid; printf("Reported PTRACE_VFORK event with forkee %d\n", child2); printf("Before calling %s() for the forkee %d of the child %d\n", TWAIT_FNAME, child2, child); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), child2); validate_status_stopped(status, SIGTRAP); ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1); ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK); ATF_REQUIRE_EQ(state.pe_other_pid, child); printf("Before resuming the forkee process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the forkee - expected exited\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), child2); validate_status_exited(status, exitval2); printf("Before calling %s() for the forkee - expected no process\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child2, &status, 0)); printf("Before calling %s() for the child - expected stopped " "SIGCHLD\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGCHLD); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child - expected exited\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child - expected no process\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif ATF_TC(vfork2); ATF_TC_HEAD(vfork2, tc) { atf_tc_set_md_var(tc, "descr", "Verify that vfork(2) is not intercepted by ptrace(2) with empty " "EVENT_MASK"); } ATF_TC_BODY(vfork2, tc) { const int exitval = 5; const int exitval2 = 15; const int sigval = SIGSTOP; pid_t child, child2, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif ptrace_event_t event; const int elen = sizeof(event); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT((child2 = vfork()) != 1); if (child2 == 0) _exit(exitval2); FORKEE_REQUIRE_SUCCESS (wpid = TWAIT_GENERIC(child2, &status, 0), child2); forkee_status_exited(status, exitval2); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Set empty EVENT_MASK for the child %d\n", child); event.pe_set_event = 0; ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child - expected stopped " "SIGCHLD\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGCHLD); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child - expected exited\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child - expected no process\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } +ATF_TC(vforkdone1); +ATF_TC_HEAD(vforkdone1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK " + "set to PTRACE_VFORK_DONE"); +} + +ATF_TC_BODY(vforkdone1, tc) +{ + const int exitval = 5; + const int exitval2 = 15; + const int sigval = SIGSTOP; + pid_t child, child2, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + ptrace_state_t state; + const int slen = sizeof(state); + ptrace_event_t event; + const int elen = sizeof(event); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT((child2 = vfork()) != 1); + + if (child2 == 0) + _exit(exitval2); + + FORKEE_REQUIRE_SUCCESS + (wpid = TWAIT_GENERIC(child2, &status, 0), child2); + + forkee_status_exited(status, exitval2); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Enable PTRACE_VFORK in EVENT_MASK for the child %d\n", child); + event.pe_set_event = PTRACE_VFORK_DONE; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1); + ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK_DONE); + + child2 = state.pe_other_pid; + printf("Reported PTRACE_VFORK_DONE event with forkee %d\n", child2); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child - expected stopped " + "SIGCHLD\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGCHLD); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child - expected exited\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child - expected no process\n", + TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(vforkdone2); +ATF_TC_HEAD(vforkdone2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK " + "set to PTRACE_FORK | PTRACE_VFORK_DONE"); +} + +ATF_TC_BODY(vforkdone2, tc) +{ + const int exitval = 5; + const int exitval2 = 15; + const int sigval = SIGSTOP; + pid_t child, child2, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + ptrace_state_t state; + const int slen = sizeof(state); + ptrace_event_t event; + const int elen = sizeof(event); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT((child2 = vfork()) != 1); + + if (child2 == 0) + _exit(exitval2); + + FORKEE_REQUIRE_SUCCESS + (wpid = TWAIT_GENERIC(child2, &status, 0), child2); + + forkee_status_exited(status, exitval2); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Enable PTRACE_VFORK in EVENT_MASK for the child %d\n", child); + event.pe_set_event = PTRACE_FORK | PTRACE_VFORK_DONE; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1); + ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK_DONE); + + child2 = state.pe_other_pid; + printf("Reported PTRACE_VFORK_DONE event with forkee %d\n", child2); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child - expected stopped " + "SIGCHLD\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGCHLD); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child - expected exited\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child - expected no process\n", + TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + ATF_TC(io_read_d1); ATF_TC_HEAD(io_read_d1, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_READ_D and len = sizeof(uint8_t)"); } ATF_TC_BODY(io_read_d1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint8_t lookup_me = 0; const uint8_t magic = 0xab; struct ptrace_io_desc io = { .piod_op = PIOD_READ_D, .piod_offs = &lookup_me, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me = magic; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me, magic, "got value %" PRIx8 " != expected %" PRIx8, lookup_me, magic); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_read_d2); ATF_TC_HEAD(io_read_d2, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_READ_D and len = sizeof(uint16_t)"); } ATF_TC_BODY(io_read_d2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint16_t lookup_me = 0; const uint16_t magic = 0x1234; struct ptrace_io_desc io = { .piod_op = PIOD_READ_D, .piod_offs = &lookup_me, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me = magic; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me, magic, "got value %" PRIx16 " != expected %" PRIx16, lookup_me, magic); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_read_d3); ATF_TC_HEAD(io_read_d3, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_READ_D and len = sizeof(uint32_t)"); } ATF_TC_BODY(io_read_d3, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint32_t lookup_me = 0; const uint32_t magic = 0x1234abcd; struct ptrace_io_desc io = { .piod_op = PIOD_READ_D, .piod_offs = &lookup_me, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me = magic; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me, magic, "got value %" PRIx32 " != expected %" PRIx32, lookup_me, magic); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_read_d4); ATF_TC_HEAD(io_read_d4, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_READ_D and len = sizeof(uint64_t)"); } ATF_TC_BODY(io_read_d4, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint64_t lookup_me = 0; const uint64_t magic = 0x1234abcd9876dcfa; struct ptrace_io_desc io = { .piod_op = PIOD_READ_D, .piod_offs = &lookup_me, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me = magic; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me, magic, "got value %" PRIx64 " != expected %" PRIx64, lookup_me, magic); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_write_d1); ATF_TC_HEAD(io_write_d1, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint8_t)"); } ATF_TC_BODY(io_write_d1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint8_t lookup_me = 0; const uint8_t magic = 0xab; struct ptrace_io_desc io = { .piod_op = PIOD_WRITE_D, .piod_offs = &lookup_me, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me, magic); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); lookup_me = magic; printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_write_d2); ATF_TC_HEAD(io_write_d2, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint16_t)"); } ATF_TC_BODY(io_write_d2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint16_t lookup_me = 0; const uint16_t magic = 0xab12; struct ptrace_io_desc io = { .piod_op = PIOD_WRITE_D, .piod_offs = &lookup_me, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me, magic); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); lookup_me = magic; printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_write_d3); ATF_TC_HEAD(io_write_d3, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint32_t)"); } ATF_TC_BODY(io_write_d3, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint32_t lookup_me = 0; const uint32_t magic = 0xab127643; struct ptrace_io_desc io = { .piod_op = PIOD_WRITE_D, .piod_offs = &lookup_me, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me, magic); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); lookup_me = magic; printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_write_d4); ATF_TC_HEAD(io_write_d4, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint64_t)"); } ATF_TC_BODY(io_write_d4, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint64_t lookup_me = 0; const uint64_t magic = 0xab12764376490123; struct ptrace_io_desc io = { .piod_op = PIOD_WRITE_D, .piod_offs = &lookup_me, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me, magic); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); lookup_me = magic; printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(read_d1); ATF_TC_HEAD(read_d1, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_READ_D called once"); } ATF_TC_BODY(read_d1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me = 0; const int magic = (int)random(); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me = magic; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read new lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me = ptrace(PT_READ_D, child, &lookup_me, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me, magic, "got value %#x != expected %#x", lookup_me, magic); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(read_d2); ATF_TC_HEAD(read_d2, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_READ_D called twice"); } ATF_TC_BODY(read_d2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me1 = 0; int lookup_me2 = 0; const int magic1 = (int)random(); const int magic2 = (int)random(); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me1 = magic1; lookup_me2 = magic2; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, "got value %#x != expected %#x", lookup_me1, magic1); printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, "got value %#x != expected %#x", lookup_me2, magic2); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(read_d3); ATF_TC_HEAD(read_d3, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_READ_D called three times"); } ATF_TC_BODY(read_d3, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me1 = 0; int lookup_me2 = 0; int lookup_me3 = 0; const int magic1 = (int)random(); const int magic2 = (int)random(); const int magic3 = (int)random(); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me1 = magic1; lookup_me2 = magic2; lookup_me3 = magic3; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, "got value %#x != expected %#x", lookup_me1, magic1); printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, "got value %#x != expected %#x", lookup_me2, magic2); printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me3 = ptrace(PT_READ_D, child, &lookup_me3, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me3, magic3, "got value %#x != expected %#x", lookup_me3, magic3); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(read_d4); ATF_TC_HEAD(read_d4, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_READ_D called four times"); } ATF_TC_BODY(read_d4, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me1 = 0; int lookup_me2 = 0; int lookup_me3 = 0; int lookup_me4 = 0; const int magic1 = (int)random(); const int magic2 = (int)random(); const int magic3 = (int)random(); const int magic4 = (int)random(); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me1 = magic1; lookup_me2 = magic2; lookup_me3 = magic3; lookup_me4 = magic4; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, "got value %#x != expected %#x", lookup_me1, magic1); printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, "got value %#x != expected %#x", lookup_me2, magic2); printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me3 = ptrace(PT_READ_D, child, &lookup_me3, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me3, magic3, "got value %#x != expected %#x", lookup_me3, magic3); printf("Read new lookup_me4 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me4 = ptrace(PT_READ_D, child, &lookup_me4, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me4, magic4, "got value %#x != expected %#x", lookup_me4, magic4); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(write_d1); ATF_TC_HEAD(write_d1, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_WRITE_D called once"); } ATF_TC_BODY(write_d1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me = 0; const int magic = (int)random(); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me, magic); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me, magic) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(write_d2); ATF_TC_HEAD(write_d2, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_WRITE_D called twice"); } ATF_TC_BODY(write_d2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me1 = 0; int lookup_me2 = 0; const int magic1 = (int)random(); const int magic2 = (int)random(); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me1, magic1); FORKEE_ASSERT_EQ(lookup_me2, magic2); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1); printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(write_d3); ATF_TC_HEAD(write_d3, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_WRITE_D called three times"); } ATF_TC_BODY(write_d3, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me1 = 0; int lookup_me2 = 0; int lookup_me3 = 0; const int magic1 = (int)random(); const int magic2 = (int)random(); const int magic3 = (int)random(); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me1, magic1); FORKEE_ASSERT_EQ(lookup_me2, magic2); FORKEE_ASSERT_EQ(lookup_me3, magic3); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1); printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1); printf("Write new lookup_me3 to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me3, magic3) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(write_d4); ATF_TC_HEAD(write_d4, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_WRITE_D called four times"); } ATF_TC_BODY(write_d4, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me1 = 0; int lookup_me2 = 0; int lookup_me3 = 0; int lookup_me4 = 0; const int magic1 = (int)random(); const int magic2 = (int)random(); const int magic3 = (int)random(); const int magic4 = (int)random(); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me1, magic1); FORKEE_ASSERT_EQ(lookup_me2, magic2); FORKEE_ASSERT_EQ(lookup_me3, magic3); FORKEE_ASSERT_EQ(lookup_me4, magic4); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1); printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1); printf("Write new lookup_me3 to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me3, magic3) != -1); printf("Write new lookup_me4 to tracee (PID=%d) from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me4, magic4) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_read_d_write_d_handshake1); ATF_TC_HEAD(io_read_d_write_d_handshake1, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_READ_D and PIOD_WRITE_D handshake"); } ATF_TC_BODY(io_read_d_write_d_handshake1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint8_t lookup_me_fromtracee = 0; const uint8_t magic_fromtracee = (uint8_t)random(); uint8_t lookup_me_totracee = 0; const uint8_t magic_totracee = (uint8_t)random(); struct ptrace_io_desc io_fromtracee = { .piod_op = PIOD_READ_D, .piod_offs = &lookup_me_fromtracee, .piod_addr = &lookup_me_fromtracee, .piod_len = sizeof(lookup_me_fromtracee) }; struct ptrace_io_desc io_totracee = { .piod_op = PIOD_WRITE_D, .piod_offs = &lookup_me_totracee, .piod_addr = &lookup_me_totracee, .piod_len = sizeof(lookup_me_totracee) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me_fromtracee = magic_fromtracee; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read lookup_me_fromtracee PID=%d by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io_fromtracee, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee, "got value %" PRIx8 " != expected %" PRIx8, lookup_me_fromtracee, magic_fromtracee); lookup_me_totracee = magic_totracee; printf("Write lookup_me_totracee to PID=%d by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io_totracee, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me_totracee, magic_totracee, "got value %" PRIx8 " != expected %" PRIx8, lookup_me_totracee, magic_totracee); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_read_d_write_d_handshake2); ATF_TC_HEAD(io_read_d_write_d_handshake2, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_WRITE_D and PIOD_READ_D handshake"); } ATF_TC_BODY(io_read_d_write_d_handshake2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint8_t lookup_me_fromtracee = 0; const uint8_t magic_fromtracee = (uint8_t)random(); uint8_t lookup_me_totracee = 0; const uint8_t magic_totracee = (uint8_t)random(); struct ptrace_io_desc io_fromtracee = { .piod_op = PIOD_READ_D, .piod_offs = &lookup_me_fromtracee, .piod_addr = &lookup_me_fromtracee, .piod_len = sizeof(lookup_me_fromtracee) }; struct ptrace_io_desc io_totracee = { .piod_op = PIOD_WRITE_D, .piod_offs = &lookup_me_totracee, .piod_addr = &lookup_me_totracee, .piod_len = sizeof(lookup_me_totracee) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me_fromtracee = magic_fromtracee; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); lookup_me_totracee = magic_totracee; printf("Write lookup_me_totracee to PID=%d by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io_totracee, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me_totracee, magic_totracee, "got value %" PRIx8 " != expected %" PRIx8, lookup_me_totracee, magic_totracee); printf("Read lookup_me_fromtracee PID=%d by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io_fromtracee, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee, "got value %" PRIx8 " != expected %" PRIx8, lookup_me_fromtracee, magic_fromtracee); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(read_d_write_d_handshake1); ATF_TC_HEAD(read_d_write_d_handshake1, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_READ_D with PT_WRITE_D handshake"); } ATF_TC_BODY(read_d_write_d_handshake1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me_fromtracee = 0; const int magic_fromtracee = (int)random(); int lookup_me_totracee = 0; const int magic_totracee = (int)random(); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me_fromtracee = magic_fromtracee; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read new lookup_me_fromtracee PID=%d by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me_fromtracee = ptrace(PT_READ_D, child, &lookup_me_fromtracee, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee, "got value %#x != expected %#x", lookup_me_fromtracee, magic_fromtracee); printf("Write new lookup_me_totracee to PID=%d from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE (ptrace(PT_WRITE_D, child, &lookup_me_totracee, magic_totracee) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(read_d_write_d_handshake2); ATF_TC_HEAD(read_d_write_d_handshake2, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_WRITE_D with PT_READ_D handshake"); } ATF_TC_BODY(read_d_write_d_handshake2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me_fromtracee = 0; const int magic_fromtracee = (int)random(); int lookup_me_totracee = 0; const int magic_totracee = (int)random(); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); lookup_me_fromtracee = magic_fromtracee; printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Write new lookup_me_totracee to PID=%d from tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE (ptrace(PT_WRITE_D, child, &lookup_me_totracee, magic_totracee) != -1); printf("Read new lookup_me_fromtracee PID=%d by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me_fromtracee = ptrace(PT_READ_D, child, &lookup_me_fromtracee, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee, "got value %#x != expected %#x", lookup_me_fromtracee, magic_fromtracee); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } /* These dummy functions are used to be copied with ptrace(2) calls */ static int __used dummy_fn1(int a, int b, int c, int d) { a *= 1; b += 2; c -= 3; d /= 4; return a + b * c - d; } static int __used dummy_fn2(int a, int b, int c, int d) { a *= 4; b += 3; c -= 2; d /= 1; return a + b * c - d; } static int __used dummy_fn3(int a, int b, int c, int d) { a *= 10; b += 20; c -= 30; d /= 40; return a + b * c - d; } static int __used dummy_fn4(int a, int b, int c, int d) { a *= 40; b += 30; c -= 20; d /= 10; return a + b * c - d; } ATF_TC(io_read_i1); ATF_TC_HEAD(io_read_i1, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_READ_I and len = sizeof(uint8_t)"); } ATF_TC_BODY(io_read_i1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint8_t lookup_me = 0; uint8_t magic; memcpy(&magic, dummy_fn1, sizeof(magic)); struct ptrace_io_desc io = { .piod_op = PIOD_READ_I, .piod_offs = dummy_fn1, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me, magic, "got value %" PRIx8 " != expected %" PRIx8, lookup_me, magic); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_read_i2); ATF_TC_HEAD(io_read_i2, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_READ_I and len = sizeof(uint16_t)"); } ATF_TC_BODY(io_read_i2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint16_t lookup_me = 0; uint16_t magic; memcpy(&magic, dummy_fn1, sizeof(magic)); struct ptrace_io_desc io = { .piod_op = PIOD_READ_I, .piod_offs = dummy_fn1, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me, magic, "got value %" PRIx16 " != expected %" PRIx16, lookup_me, magic); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_read_i3); ATF_TC_HEAD(io_read_i3, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_READ_I and len = sizeof(uint32_t)"); } ATF_TC_BODY(io_read_i3, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint32_t lookup_me = 0; uint32_t magic; memcpy(&magic, dummy_fn1, sizeof(magic)); struct ptrace_io_desc io = { .piod_op = PIOD_READ_I, .piod_offs = dummy_fn1, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me, magic, "got value %" PRIx32 " != expected %" PRIx32, lookup_me, magic); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(io_read_i4); ATF_TC_HEAD(io_read_i4, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_IO with PIOD_READ_I and len = sizeof(uint64_t)"); } ATF_TC_BODY(io_read_i4, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; uint64_t lookup_me = 0; uint64_t magic; memcpy(&magic, dummy_fn1, sizeof(magic)); struct ptrace_io_desc io = { .piod_op = PIOD_READ_I, .piod_offs = dummy_fn1, .piod_addr = &lookup_me, .piod_len = sizeof(lookup_me) }; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); ATF_REQUIRE_EQ_MSG(lookup_me, magic, "got value %" PRIx64 " != expected %" PRIx64, lookup_me, magic); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(read_i1); ATF_TC_HEAD(read_i1, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_READ_I called once"); } ATF_TC_BODY(read_i1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me = 0; int magic; memcpy(&magic, dummy_fn1, sizeof(magic)); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read new lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me = ptrace(PT_READ_I, child, dummy_fn1, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me, magic, "got value %#x != expected %#x", lookup_me, magic); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(read_i2); ATF_TC_HEAD(read_i2, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_READ_I called twice"); } ATF_TC_BODY(read_i2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me1 = 0; int lookup_me2 = 0; int magic1; int magic2; memcpy(&magic1, dummy_fn1, sizeof(magic1)); memcpy(&magic2, dummy_fn2, sizeof(magic2)); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, "got value %#x != expected %#x", lookup_me1, magic1); printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, "got value %#x != expected %#x", lookup_me2, magic2); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(read_i3); ATF_TC_HEAD(read_i3, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_READ_I called three times"); } ATF_TC_BODY(read_i3, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me1 = 0; int lookup_me2 = 0; int lookup_me3 = 0; int magic1; int magic2; int magic3; memcpy(&magic1, dummy_fn1, sizeof(magic1)); memcpy(&magic2, dummy_fn2, sizeof(magic2)); memcpy(&magic3, dummy_fn3, sizeof(magic3)); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, "got value %#x != expected %#x", lookup_me1, magic1); printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, "got value %#x != expected %#x", lookup_me2, magic2); printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me3 = ptrace(PT_READ_I, child, dummy_fn3, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me3, magic3, "got value %#x != expected %#x", lookup_me3, magic3); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(read_i4); ATF_TC_HEAD(read_i4, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_READ_I called four times"); } ATF_TC_BODY(read_i4, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; int lookup_me1 = 0; int lookup_me2 = 0; int lookup_me3 = 0; int lookup_me4 = 0; int magic1; int magic2; int magic3; int magic4; memcpy(&magic1, dummy_fn1, sizeof(magic1)); memcpy(&magic2, dummy_fn2, sizeof(magic2)); memcpy(&magic3, dummy_fn3, sizeof(magic3)); memcpy(&magic4, dummy_fn4, sizeof(magic4)); #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, "got value %#x != expected %#x", lookup_me1, magic1); printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, "got value %#x != expected %#x", lookup_me2, magic2); printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me3 = ptrace(PT_READ_I, child, dummy_fn3, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me3, magic3, "got value %#x != expected %#x", lookup_me3, magic3); printf("Read new lookup_me4 from tracee (PID=%d) by tracer (PID=%d)\n", child, getpid()); errno = 0; lookup_me4 = ptrace(PT_READ_I, child, dummy_fn4, 0); ATF_REQUIRE_EQ(errno, 0); ATF_REQUIRE_EQ_MSG(lookup_me4, magic4, "got value %#x != expected %#x", lookup_me4, magic4); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #if defined(HAVE_GPREGS) ATF_TC(regs1); ATF_TC_HEAD(regs1, tc) { atf_tc_set_md_var(tc, "descr", "Verify plain PT_GETREGS call without further steps"); } ATF_TC_BODY(regs1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct reg r; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Call GETREGS for the child process\n"); ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif #if defined(HAVE_GPREGS) ATF_TC(regs2); ATF_TC_HEAD(regs2, tc) { atf_tc_set_md_var(tc, "descr", "Verify plain PT_GETREGS call and retrieve PC"); } ATF_TC_BODY(regs2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct reg r; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Call GETREGS for the child process\n"); ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); printf("Retrieved PC=%" PRIxREGISTER "\n", PTRACE_REG_PC(&r)); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif #if defined(HAVE_GPREGS) ATF_TC(regs3); ATF_TC_HEAD(regs3, tc) { atf_tc_set_md_var(tc, "descr", "Verify plain PT_GETREGS call and retrieve SP"); } ATF_TC_BODY(regs3, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct reg r; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Call GETREGS for the child process\n"); ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); printf("Retrieved SP=%" PRIxREGISTER "\n", PTRACE_REG_SP(&r)); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif #if defined(HAVE_GPREGS) ATF_TC(regs4); ATF_TC_HEAD(regs4, tc) { atf_tc_set_md_var(tc, "descr", "Verify plain PT_GETREGS call and retrieve INTRV"); } ATF_TC_BODY(regs4, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct reg r; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Call GETREGS for the child process\n"); ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); printf("Retrieved INTRV=%" PRIxREGISTER "\n", PTRACE_REG_INTRV(&r)); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif #if defined(HAVE_GPREGS) ATF_TC(regs5); ATF_TC_HEAD(regs5, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_GETREGS and PT_SETREGS calls without changing regs"); } ATF_TC_BODY(regs5, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct reg r; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Call GETREGS for the child process\n"); ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); printf("Call SETREGS for the child process (without changed regs)\n"); ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif #if defined(HAVE_FPREGS) ATF_TC(fpregs1); ATF_TC_HEAD(fpregs1, tc) { atf_tc_set_md_var(tc, "descr", "Verify plain PT_GETFPREGS call without further steps"); } ATF_TC_BODY(fpregs1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct fpreg r; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Call GETFPREGS for the child process\n"); ATF_REQUIRE(ptrace(PT_GETFPREGS, child, &r, 0) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif #if defined(HAVE_FPREGS) ATF_TC(fpregs2); ATF_TC_HEAD(fpregs2, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_GETFPREGS and PT_SETFPREGS calls without changing " "regs"); } ATF_TC_BODY(fpregs2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct fpreg r; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Call GETFPREGS for the child process\n"); ATF_REQUIRE(ptrace(PT_GETFPREGS, child, &r, 0) != -1); printf("Call SETFPREGS for the child (without changed regs)\n"); ATF_REQUIRE(ptrace(PT_SETFPREGS, child, &r, 0) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif #if defined(PT_STEP) ATF_TC(step1); ATF_TC_HEAD(step1, tc) { atf_tc_set_md_var(tc, "descr", "Verify single PT_STEP call"); } ATF_TC_BODY(step1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif int happy; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); happy = check_happy(100); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(happy, check_happy(100)); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before resuming the child process where it left off and " "without signal to be sent (use PT_STEP)\n"); ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGTRAP); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif #if defined(PT_STEP) ATF_TC(step2); ATF_TC_HEAD(step2, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_STEP called twice"); } ATF_TC_BODY(step2, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif int happy; int N = 2; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); happy = check_happy(999); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(happy, check_happy(999)); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); while (N --> 0) { printf("Before resuming the child process where it left off " "and without signal to be sent (use PT_STEP)\n"); ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGTRAP); } printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif #if defined(PT_STEP) ATF_TC(step3); ATF_TC_HEAD(step3, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_STEP called three times"); } ATF_TC_BODY(step3, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif int happy; int N = 3; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); happy = check_happy(999); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(happy, check_happy(999)); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); while (N --> 0) { printf("Before resuming the child process where it left off " "and without signal to be sent (use PT_STEP)\n"); ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGTRAP); } printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif #if defined(PT_STEP) ATF_TC(step4); ATF_TC_HEAD(step4, tc) { atf_tc_set_md_var(tc, "descr", "Verify PT_STEP called four times"); } ATF_TC_BODY(step4, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif int happy; int N = 4; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); happy = check_happy(999); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(happy, check_happy(999)); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); while (N --> 0) { printf("Before resuming the child process where it left off " "and without signal to be sent (use PT_STEP)\n"); ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGTRAP); } printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif ATF_TC(kill1); ATF_TC_HEAD(kill1, tc) { atf_tc_set_md_var(tc, "descr", "Verify that PT_CONTINUE with SIGKILL terminates child"); } ATF_TC_BODY(kill1, tc) { const int sigval = SIGSTOP, sigsent = SIGKILL; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); /* NOTREACHED */ FORKEE_ASSERTX(0 && "Child should be terminated by a signal from its parent"); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_signaled(status, sigsent, 0); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(kill2); ATF_TC_HEAD(kill2, tc) { atf_tc_set_md_var(tc, "descr", "Verify that PT_KILL terminates child"); } ATF_TC_BODY(kill2, tc) { const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); /* NOTREACHED */ FORKEE_ASSERTX(0 && "Child should be terminated by a signal from its parent"); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_KILL, child, (void*)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_signaled(status, SIGKILL, 0); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(lwpinfo1); ATF_TC_HEAD(lwpinfo1, tc) { atf_tc_set_md_var(tc, "descr", "Verify basic LWPINFO call for single thread (PT_TRACE_ME)"); } ATF_TC_BODY(lwpinfo1, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct ptrace_lwpinfo info = {0, 0}; printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before calling ptrace(2) with PT_LWPINFO for child\n"); ATF_REQUIRE(ptrace(PT_LWPINFO, child, &info, sizeof(info)) != -1); printf("Assert that there exists a thread\n"); ATF_REQUIRE(info.pl_lwpid > 0); printf("Assert that lwp thread %d received event PL_EVENT_SIGNAL\n", info.pl_lwpid); ATF_REQUIRE_EQ_MSG(info.pl_event, PL_EVENT_SIGNAL, "Received event %d != expected event %d", info.pl_event, PL_EVENT_SIGNAL); printf("Before calling ptrace(2) with PT_LWPINFO for child\n"); ATF_REQUIRE(ptrace(PT_LWPINFO, child, &info, sizeof(info)) != -1); printf("Assert that there are no more lwp threads in child\n"); ATF_REQUIRE_EQ(info.pl_lwpid, 0); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #if defined(TWAIT_HAVE_PID) ATF_TC(lwpinfo2); ATF_TC_HEAD(lwpinfo2, tc) { atf_tc_set_md_var(tc, "descr", "Verify basic LWPINFO call for single thread (PT_ATTACH from " "tracer)"); } ATF_TC_BODY(lwpinfo2, tc) { struct msg_fds parent_tracee, parent_tracer; const int exitval_tracee = 5; const int exitval_tracer = 10; pid_t tracee, tracer, wpid; uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ #if defined(TWAIT_HAVE_STATUS) int status; #endif struct ptrace_lwpinfo info = {0, 0}; printf("Spawn tracee\n"); ATF_REQUIRE(msg_open(&parent_tracee) == 0); ATF_REQUIRE(msg_open(&parent_tracer) == 0); tracee = atf_utils_fork(); if (tracee == 0) { /* Wait for message from the parent */ CHILD_TO_PARENT("tracee ready", parent_tracee, msg); CHILD_FROM_PARENT("tracee exit", parent_tracee, msg); _exit(exitval_tracee); } PARENT_FROM_CHILD("tracee ready", parent_tracee, msg); printf("Spawn debugger\n"); tracer = atf_utils_fork(); if (tracer == 0) { /* No IPC to communicate with the child */ printf("Before calling PT_ATTACH from tracee %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_stopped(status, SIGSTOP); printf("Before calling ptrace(2) with PT_LWPINFO for child\n"); FORKEE_ASSERT(ptrace(PT_LWPINFO, tracee, &info, sizeof(info)) != -1); printf("Assert that there exists a thread\n"); FORKEE_ASSERTX(info.pl_lwpid > 0); printf("Assert that lwp thread %d received event " "PL_EVENT_SIGNAL\n", info.pl_lwpid); FORKEE_ASSERT_EQ(info.pl_event, PL_EVENT_SIGNAL); printf("Before calling ptrace(2) with PT_LWPINFO for child\n"); FORKEE_ASSERT(ptrace(PT_LWPINFO, tracee, &info, sizeof(info)) != -1); printf("Assert that there are no more lwp threads in child\n"); FORKEE_ASSERTX(info.pl_lwpid == 0); /* Resume tracee with PT_CONTINUE */ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); /* Inform parent that tracer has attached to tracee */ CHILD_TO_PARENT("tracer ready", parent_tracer, msg); /* Wait for parent */ CHILD_FROM_PARENT("tracer wait", parent_tracer, msg); /* Wait for tracee and assert that it exited */ FORKEE_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); forkee_status_exited(status, exitval_tracee); printf("Before exiting of the tracer process\n"); _exit(exitval_tracer); } printf("Wait for the tracer to attach to the tracee\n"); PARENT_FROM_CHILD("tracer ready", parent_tracer, msg); printf("Resume the tracee and let it exit\n"); PARENT_TO_CHILD("tracee exit", parent_tracee, msg); printf("Detect that tracee is zombie\n"); await_zombie(tracee); printf("Assert that there is no status about tracee - " "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS( wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); printf("Resume the tracer and let it detect exited tracee\n"); PARENT_TO_CHILD("tracer wait", parent_tracer, msg); printf("Wait for tracer to finish its job and exit - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0), tracer); validate_status_exited(status, exitval_tracer); printf("Wait for tracee to finish its job and exit - calling %s()\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), tracee); validate_status_exited(status, exitval_tracee); msg_close(&parent_tracer); msg_close(&parent_tracee); } #endif ATF_TC(siginfo1); ATF_TC_HEAD(siginfo1, tc) { atf_tc_set_md_var(tc, "descr", "Verify basic PT_GET_SIGINFO call for SIGTRAP from tracee"); } ATF_TC_BODY(siginfo1, tc) { const int exitval = 5; const int sigval = SIGTRAP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct ptrace_siginfo info; memset(&info, 0, sizeof(info)); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Signal traced to lwpid=%d\n", info.psi_lwpid); printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n", info.psi_siginfo.si_signo, info.psi_siginfo.si_code, info.psi_siginfo.si_errno); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(siginfo2); ATF_TC_HEAD(siginfo2, tc) { atf_tc_set_md_var(tc, "descr", "Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls without " "modification of SIGINT from tracee"); } static int siginfo2_caught = 0; static void siginfo2_sighandler(int sig) { FORKEE_ASSERT_EQ(sig, SIGINT); ++siginfo2_caught; } ATF_TC_BODY(siginfo2, tc) { const int exitval = 5; const int sigval = SIGINT; pid_t child, wpid; struct sigaction sa; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct ptrace_siginfo info; memset(&info, 0, sizeof(info)); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); sa.sa_handler = siginfo2_sighandler; sa.sa_flags = SA_SIGINFO; sigemptyset(&sa.sa_mask); FORKEE_ASSERT(sigaction(sigval, &sa, NULL) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(siginfo2_caught, 1); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Signal traced to lwpid=%d\n", info.psi_lwpid); printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n", info.psi_siginfo.si_signo, info.psi_siginfo.si_code, info.psi_siginfo.si_errno); printf("Before calling ptrace(2) with PT_SET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_SET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigval) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(siginfo3); ATF_TC_HEAD(siginfo3, tc) { atf_tc_set_md_var(tc, "descr", "Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls with " "setting signal to new value"); } static int siginfo3_caught = 0; static void siginfo3_sigaction(int sig, siginfo_t *info, void *ctx) { FORKEE_ASSERT_EQ(sig, SIGTRAP); FORKEE_ASSERT_EQ(info->si_signo, SIGTRAP); FORKEE_ASSERT_EQ(info->si_code, TRAP_BRKPT); ++siginfo3_caught; } ATF_TC_BODY(siginfo3, tc) { const int exitval = 5; const int sigval = SIGINT; const int sigfaked = SIGTRAP; const int sicodefaked = TRAP_BRKPT; pid_t child, wpid; struct sigaction sa; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct ptrace_siginfo info; memset(&info, 0, sizeof(info)); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); sa.sa_sigaction = siginfo3_sigaction; sa.sa_flags = SA_SIGINFO; sigemptyset(&sa.sa_mask); FORKEE_ASSERT(sigaction(sigfaked, &sa, NULL) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(siginfo3_caught, 1); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Signal traced to lwpid=%d\n", info.psi_lwpid); printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n", info.psi_siginfo.si_signo, info.psi_siginfo.si_code, info.psi_siginfo.si_errno); printf("Before setting new faked signal to signo=%d si_code=%d\n", sigfaked, sicodefaked); info.psi_siginfo.si_signo = sigfaked; info.psi_siginfo.si_code = sicodefaked; printf("Before calling ptrace(2) with PT_SET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_SET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Before checking siginfo_t\n"); ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigfaked); ATF_REQUIRE_EQ(info.psi_siginfo.si_code, sicodefaked); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigfaked) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } ATF_TC(siginfo4); ATF_TC_HEAD(siginfo4, tc) { atf_tc_set_md_var(tc, "descr", "Detect SIGTRAP TRAP_EXEC from tracee"); } ATF_TC_BODY(siginfo4, tc) { const int sigval = SIGTRAP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif struct ptrace_siginfo info; memset(&info, 0, sizeof(info)); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before calling execve(2) from child\n"); execlp("/bin/echo", "/bin/echo", NULL); FORKEE_ASSERT(0 && "Not reached"); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Signal traced to lwpid=%d\n", info.psi_lwpid); printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n", info.psi_siginfo.si_signo, info.psi_siginfo.si_code, info.psi_siginfo.si_errno); ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval); ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_EXEC); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #if defined(TWAIT_HAVE_PID) ATF_TC(siginfo5); ATF_TC_HEAD(siginfo5, tc) { atf_tc_set_md_var(tc, "descr", "Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK " "set to PTRACE_FORK and reports correct signal information"); } ATF_TC_BODY(siginfo5, tc) { const int exitval = 5; const int exitval2 = 15; const int sigval = SIGSTOP; pid_t child, child2, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif ptrace_state_t state; const int slen = sizeof(state); ptrace_event_t event; const int elen = sizeof(event); struct ptrace_siginfo info; memset(&info, 0, sizeof(info)); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT((child2 = fork()) != 1); if (child2 == 0) _exit(exitval2); FORKEE_REQUIRE_SUCCESS (wpid = TWAIT_GENERIC(child2, &status, 0), child2); forkee_status_exited(status, exitval2); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Before checking siginfo_t\n"); ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval); ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP); printf("Enable PTRACE_FORK in EVENT_MASK for the child %d\n", child); event.pe_set_event = PTRACE_FORK; ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGTRAP); printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Before checking siginfo_t\n"); ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_CHLD); ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1); ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK); child2 = state.pe_other_pid; printf("Reported PTRACE_FORK event with forkee %d\n", child2); printf("Before calling %s() for the forkee %d of the child %d\n", TWAIT_FNAME, child2, child); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), child2); validate_status_stopped(status, SIGTRAP); printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Before checking siginfo_t\n"); ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_CHLD); ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1); ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK); ATF_REQUIRE_EQ(state.pe_other_pid, child); printf("Before resuming the forkee process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the forkee - expected exited\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), child2); validate_status_exited(status, exitval2); printf("Before calling %s() for the forkee - expected no process\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child2, &status, 0)); printf("Before calling %s() for the child - expected stopped " "SIGCHLD\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGCHLD); printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Before checking siginfo_t\n"); ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGCHLD); ATF_REQUIRE_EQ(info.psi_siginfo.si_code, CLD_EXITED); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child - expected exited\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child - expected no process\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif #if defined(PT_STEP) ATF_TC(siginfo6); ATF_TC_HEAD(siginfo6, tc) { atf_tc_set_md_var(tc, "descr", "Verify single PT_STEP call with signal information check"); } ATF_TC_BODY(siginfo6, tc) { const int exitval = 5; const int sigval = SIGSTOP; pid_t child, wpid; #if defined(TWAIT_HAVE_STATUS) int status; #endif int happy; struct ptrace_siginfo info; memset(&info, 0, sizeof(info)); printf("Before forking process PID=%d\n", getpid()); ATF_REQUIRE((child = fork()) != -1); if (child == 0) { printf("Before calling PT_TRACE_ME from child %d\n", getpid()); FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); happy = check_happy(100); printf("Before raising %s from child\n", strsignal(sigval)); FORKEE_ASSERT(raise(sigval) == 0); FORKEE_ASSERT_EQ(happy, check_happy(100)); printf("Before exiting of the child process\n"); _exit(exitval); } printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, sigval); printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Before checking siginfo_t\n"); ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval); ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP); printf("Before resuming the child process where it left off and " "without signal to be sent (use PT_STEP)\n"); ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_stopped(status, SIGTRAP); printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); printf("Before checking siginfo_t\n"); ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_TRACE); printf("Before resuming the child process where it left off and " "without signal to be sent\n"); ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); validate_status_exited(status, exitval); printf("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); } #endif ATF_TP_ADD_TCS(tp) { setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); ATF_TP_ADD_TC(tp, traceme1); ATF_TP_ADD_TC(tp, traceme2); ATF_TP_ADD_TC(tp, traceme3); ATF_TP_ADD_TC(tp, traceme4); ATF_TP_ADD_TC_HAVE_PID(tp, attach1); ATF_TP_ADD_TC_HAVE_PID(tp, attach2); ATF_TP_ADD_TC(tp, attach3); ATF_TP_ADD_TC(tp, attach4); ATF_TP_ADD_TC_HAVE_PID(tp, attach5); ATF_TP_ADD_TC_HAVE_PID(tp, attach6); ATF_TP_ADD_TC_HAVE_PID(tp, attach7); ATF_TP_ADD_TC(tp, eventmask1); ATF_TP_ADD_TC(tp, eventmask2); + ATF_TP_ADD_TC(tp, eventmask3); + ATF_TP_ADD_TC(tp, eventmask4); ATF_TP_ADD_TC_HAVE_PID(tp, fork1); ATF_TP_ADD_TC(tp, fork2); ATF_TP_ADD_TC_HAVE_PID(tp, vfork1); ATF_TP_ADD_TC(tp, vfork2); + + ATF_TP_ADD_TC(tp, vforkdone1); + ATF_TP_ADD_TC(tp, vforkdone2); ATF_TP_ADD_TC(tp, io_read_d1); ATF_TP_ADD_TC(tp, io_read_d2); ATF_TP_ADD_TC(tp, io_read_d3); ATF_TP_ADD_TC(tp, io_read_d4); ATF_TP_ADD_TC(tp, io_write_d1); ATF_TP_ADD_TC(tp, io_write_d2); ATF_TP_ADD_TC(tp, io_write_d3); ATF_TP_ADD_TC(tp, io_write_d4); ATF_TP_ADD_TC(tp, read_d1); ATF_TP_ADD_TC(tp, read_d2); ATF_TP_ADD_TC(tp, read_d3); ATF_TP_ADD_TC(tp, read_d4); ATF_TP_ADD_TC(tp, write_d1); ATF_TP_ADD_TC(tp, write_d2); ATF_TP_ADD_TC(tp, write_d3); ATF_TP_ADD_TC(tp, write_d4); ATF_TP_ADD_TC(tp, io_read_d_write_d_handshake1); ATF_TP_ADD_TC(tp, io_read_d_write_d_handshake2); ATF_TP_ADD_TC(tp, read_d_write_d_handshake1); ATF_TP_ADD_TC(tp, read_d_write_d_handshake2); ATF_TP_ADD_TC(tp, io_read_i1); ATF_TP_ADD_TC(tp, io_read_i2); ATF_TP_ADD_TC(tp, io_read_i3); ATF_TP_ADD_TC(tp, io_read_i4); ATF_TP_ADD_TC(tp, read_i1); ATF_TP_ADD_TC(tp, read_i2); ATF_TP_ADD_TC(tp, read_i3); ATF_TP_ADD_TC(tp, read_i4); ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs1); ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs2); ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs3); ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs4); ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs5); ATF_TP_ADD_TC_HAVE_FPREGS(tp, fpregs1); ATF_TP_ADD_TC_HAVE_FPREGS(tp, fpregs2); ATF_TP_ADD_TC_PT_STEP(tp, step1); ATF_TP_ADD_TC_PT_STEP(tp, step2); ATF_TP_ADD_TC_PT_STEP(tp, step3); ATF_TP_ADD_TC_PT_STEP(tp, step4); ATF_TP_ADD_TC(tp, kill1); ATF_TP_ADD_TC(tp, kill2); ATF_TP_ADD_TC(tp, lwpinfo1); ATF_TP_ADD_TC_HAVE_PID(tp, lwpinfo2); ATF_TP_ADD_TC(tp, siginfo1); ATF_TP_ADD_TC(tp, siginfo2); ATF_TP_ADD_TC(tp, siginfo3); ATF_TP_ADD_TC(tp, siginfo4); ATF_TP_ADD_TC_HAVE_PID(tp, siginfo5); ATF_TP_ADD_TC_PT_STEP(tp, siginfo6); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_pty.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_pty.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_pty.c (revision 312126) @@ -1,351 +1,351 @@ -/* $Id: t_pty.c,v 1.1 2011/09/24 15:53:01 christos Exp $ */ +/* $Id: t_pty.c,v 1.2 2017/01/13 21:30:41 christos Exp $ */ /* * Allocates a pty(4) device, and sends the specified number of packets of the * specified length though it, while a child reader process reads and reports * results. * * Written by Matthew Mondor */ #include -__RCSID("$NetBSD: t_pty.c,v 1.1 2011/09/24 15:53:01 christos Exp $"); +__RCSID("$NetBSD: t_pty.c,v 1.2 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #ifdef __linux__ #define _XOPEN_SOURCE #define __USE_XOPEN #endif #include #include #include #include #include #include #include #include #ifdef STANDALONE static __dead void usage(const char *); static void parse_args(int, char **); #else #include -#include "../h_macros.h" +#include "h_macros.h" #endif static int pty_open(void); static int tty_open(const char *); static void fd_nonblock(int); static pid_t child_spawn(const char *); static void run(void); static size_t buffer_size = 4096; static size_t packets = 2; static uint8_t *dbuf; static int verbose; static int qsize; static void run(void) { size_t i; int pty; int status; pid_t child; if ((dbuf = calloc(1, buffer_size)) == NULL) err(EXIT_FAILURE, "malloc(%zu)", buffer_size); if (verbose) (void)printf( "parent: started; opening PTY and spawning child\n"); pty = pty_open(); child = child_spawn(ptsname(pty)); if (verbose) (void)printf("parent: sleeping to make sure child is ready\n"); (void)sleep(1); for (i = 0; i < buffer_size; i++) dbuf[i] = i & 0xff; if (verbose) (void)printf("parent: writing\n"); for (i = 0; i < packets; i++) { ssize_t size; if (verbose) (void)printf( "parent: attempting to write %zu bytes to PTY\n", buffer_size); if ((size = write(pty, dbuf, buffer_size)) == -1) { err(EXIT_FAILURE, "parent: write()"); break; } if (verbose) (void)printf("parent: wrote %zd bytes to PTY\n", size); } if (verbose) (void)printf("parent: waiting for child to exit\n"); if (waitpid(child, &status, 0) == -1) err(EXIT_FAILURE, "waitpid"); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) errx(EXIT_FAILURE, "child failed"); if (verbose) (void)printf("parent: closing PTY\n"); (void)close(pty); if (verbose) (void)printf("parent: exiting\n"); } static void condition(int fd) { struct termios tios; if (qsize) { int opt = qsize; if (ioctl(fd, TIOCSQSIZE, &opt) == -1) err(EXIT_FAILURE, "Couldn't set tty(4) buffer size"); if (ioctl(fd, TIOCGQSIZE, &opt) == -1) err(EXIT_FAILURE, "Couldn't get tty(4) buffer size"); if (opt != qsize) errx(EXIT_FAILURE, "Wrong qsize %d != %d\n", qsize, opt); } if (tcgetattr(fd, &tios) == -1) err(EXIT_FAILURE, "tcgetattr()"); cfmakeraw(&tios); cfsetspeed(&tios, B921600); if (tcsetattr(fd, TCSANOW, &tios) == -1) err(EXIT_FAILURE, "tcsetattr()"); } static int pty_open(void) { int fd; if ((fd = posix_openpt(O_RDWR)) == -1) err(EXIT_FAILURE, "Couldn't pty(4) device"); condition(fd); if (grantpt(fd) == -1) err(EXIT_FAILURE, "Couldn't grant permissions on tty(4) device"); condition(fd); if (unlockpt(fd) == -1) err(EXIT_FAILURE, "unlockpt()"); return fd; } static int tty_open(const char *ttydev) { int fd; if ((fd = open(ttydev, O_RDWR, 0)) == -1) err(EXIT_FAILURE, "Couldn't open tty(4) device"); #ifdef USE_PPP_DISCIPLINE { int opt = PPPDISC; if (ioctl(fd, TIOCSETD, &opt) == -1) err(EXIT_FAILURE, "Couldn't set tty(4) discipline to PPP"); } #endif condition(fd); return fd; } static void fd_nonblock(int fd) { int opt; if ((opt = fcntl(fd, F_GETFL, NULL)) == -1) err(EXIT_FAILURE, "fcntl()"); if (fcntl(fd, F_SETFL, opt | O_NONBLOCK) == -1) err(EXIT_FAILURE, "fcntl()"); } static pid_t child_spawn(const char *ttydev) { pid_t pid; int tty; struct pollfd pfd; size_t total = 0; if ((pid = fork()) == -1) err(EXIT_FAILURE, "fork()"); (void)setsid(); if (pid != 0) return pid; if (verbose) (void)printf("child: started; open \"%s\"\n", ttydev); tty = tty_open(ttydev); fd_nonblock(tty); if (verbose) (void)printf("child: TTY open, starting read loop\n"); pfd.fd = tty; pfd.events = POLLIN; pfd.revents = 0; for (;;) { int ret; ssize_t size; if (verbose) (void)printf("child: polling\n"); if ((ret = poll(&pfd, 1, 2000)) == -1) err(EXIT_FAILURE, "child: poll()"); if (ret == 0) break; if ((pfd.revents & POLLERR) != 0) break; if ((pfd.revents & POLLIN) != 0) { for (;;) { if (verbose) (void)printf( "child: attempting to read %zu" " bytes\n", buffer_size); if ((size = read(tty, dbuf, buffer_size)) == -1) { if (errno == EAGAIN) break; err(EXIT_FAILURE, "child: read()"); } if (qsize && size < qsize && (size_t)size < buffer_size) errx(EXIT_FAILURE, "read returned %zd " "less than the queue size %d", size, qsize); if (verbose) (void)printf( "child: read %zd bytes from TTY\n", size); if (size == 0) goto end; total += size; } } } end: if (verbose) (void)printf("child: closing TTY %zu\n", total); (void)close(tty); if (verbose) (void)printf("child: exiting\n"); if (total != buffer_size * packets) errx(EXIT_FAILURE, "Lost data %zu != %zu\n", total, buffer_size * packets); exit(EXIT_SUCCESS); } #ifdef STANDALONE static void usage(const char *msg) { if (msg != NULL) (void) fprintf(stderr, "\n%s\n\n", msg); (void)fprintf(stderr, "Usage: %s [-v] [-q ] [-s ] [-n ]\n", getprogname()); exit(EXIT_FAILURE); } static void parse_args(int argc, char **argv) { int ch; while ((ch = getopt(argc, argv, "n:q:s:v")) != -1) { switch (ch) { case 'n': packets = (size_t)atoi(optarg); break; case 'q': qsize = atoi(optarg); break; case 's': buffer_size = (size_t)atoi(optarg); break; case 'v': verbose++; break; default: usage(NULL); break; } } if (buffer_size < 0 || buffer_size > 65536) usage("-s must be between 0 and 65536"); if (packets < 1 || packets > 100) usage("-p must be between 1 and 100"); } int main(int argc, char **argv) { parse_args(argc, argv); run(); exit(EXIT_SUCCESS); } #else ATF_TC(pty_no_queue); ATF_TC_HEAD(pty_no_queue, tc) { atf_tc_set_md_var(tc, "descr", "Checks that writing to pty " "does not lose data with the default queue size of 1024"); } ATF_TC_BODY(pty_no_queue, tc) { qsize = 0; run(); } ATF_TC(pty_queue); ATF_TC_HEAD(pty_queue, tc) { atf_tc_set_md_var(tc, "descr", "Checks that writing to pty " "does not lose data with the a queue size of 4096"); } ATF_TC_BODY(pty_queue, tc) { qsize = 4096; run(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, pty_no_queue); ATF_TP_ADD_TC(tp, pty_queue); return atf_no_error(); } #endif Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_rnd.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_rnd.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/kernel/t_rnd.c (revision 312126) @@ -1,114 +1,114 @@ -/* $NetBSD: t_rnd.c,v 1.9 2016/05/22 04:34:44 riastradh Exp $ */ +/* $NetBSD: t_rnd.c,v 1.10 2017/01/13 21:30:41 christos Exp $ */ /* * Copyright (c) 2009 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 -__RCSID("$NetBSD: t_rnd.c,v 1.9 2016/05/22 04:34:44 riastradh Exp $"); +__RCSID("$NetBSD: t_rnd.c,v 1.10 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include -#include "../h_macros.h" +#include "h_macros.h" ATF_TC(RNDADDDATA); ATF_TC_HEAD(RNDADDDATA, tc) { atf_tc_set_md_var(tc, "descr", "Checks ioctl(RNDADDDATA) (PR kern/42020)"); } /* Adapted from example provided by Juho Salminen in the noted PR. */ ATF_TC_BODY(RNDADDDATA, tc) { rnddata_t rd; int fd; rump_init(); fd = rump_sys_open("/dev/random", O_RDWR, 0); if (fd == -1) atf_tc_fail_errno("cannot open /dev/random"); rd.entropy = 1; rd.len = 1; if (rump_sys_ioctl(fd, RNDADDDATA, &rd) == -1) atf_tc_fail_errno("RNDADDDATA"); } ATF_TC(RNDADDDATA2); ATF_TC_HEAD(RNDADDDATA2, tc) { atf_tc_set_md_var(tc, "descr", "checks ioctl(RNDADDDATA) deals with " "garbage len field"); } ATF_TC_BODY(RNDADDDATA2, tc) { rnddata_t rd; int fd; rump_init(); fd = rump_sys_open("/dev/random", O_RDWR, 0); if (fd == -1) atf_tc_fail_errno("cannot open /dev/random"); rd.entropy = 1; rd.len = -1; ATF_REQUIRE_ERRNO(EINVAL, rump_sys_ioctl(fd, RNDADDDATA, &rd) == -1); } ATF_TC(read_random); ATF_TC_HEAD(read_random, tc) { atf_tc_set_md_var(tc, "descr", "does reading /dev/random return " "within reasonable time"); atf_tc_set_md_var(tc, "timeout", "10"); } ATF_TC_BODY(read_random, tc) { char buf[128]; int fd; rump_init(); RL(fd = rump_sys_open("/dev/random", O_RDONLY)); RL(rump_sys_read(fd, buf, sizeof(buf))); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, RNDADDDATA); ATF_TP_ADD_TC(tp, RNDADDDATA2); ATF_TP_ADD_TC(tp, read_random); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/gen/exect/t_exect.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/gen/exect/t_exect.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/gen/exect/t_exect.c (revision 312126) @@ -0,0 +1,90 @@ +/* $NetBSD: t_exect.c,v 1.6 2016/12/12 10:34:55 joerg Exp $ */ + +/*- + * Copyright (c) 2014 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 + +ATF_TC(t_exect_null); + +ATF_TC_HEAD(t_exect_null, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Tests an empty exect(2) executing"); +} + +static volatile sig_atomic_t caught = 0; + +static void +sigtrap_handler(int sig, siginfo_t *info, void *ctx) +{ + ATF_REQUIRE_EQ(sig, SIGTRAP); + ATF_REQUIRE_EQ(info->si_code, TRAP_TRACE); + + ++caught; +} + +ATF_TC_BODY(t_exect_null, tc) +{ + struct sigaction act; + + /* + * Currently exect(3) is misdesigned -- see PR port-amd64/51700 and it + * needs to be redone from scratch. + * + * This test affects amd64 releng machines causing tests to hang or + * fail. As there is little point to test interface that is still not, + * designed and implemented and is breaking tests - skip it + * unconditionally for all ports. + */ + /* Prevent static analysis from requiring t_exec_null to be __dead. */ + if (!caught) + atf_tc_skip("exect(3) misdesigned and hangs - PR port-amd64/51700"); + + ATF_REQUIRE(sigemptyset(&act.sa_mask) == 0); + act.sa_sigaction = sigtrap_handler; + act.sa_flags = SA_SIGINFO; + + ATF_REQUIRE(sigaction(SIGTRAP, &act, 0) == 0); + + ATF_REQUIRE_ERRNO(EFAULT, exect(NULL, NULL, NULL) == -1); + + ATF_REQUIRE_EQ_MSG(caught, 1, "expected caught (1) != received (%d)", + (int)caught); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, t_exect_null); + + return atf_no_error(); +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/gen/exect/t_exect.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/gen/t_glob.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/gen/t_glob.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/gen/t_glob.c (revision 312126) @@ -1,289 +1,288 @@ -/* $NetBSD: t_glob.c,v 1.3 2013/01/02 11:28:48 martin Exp $ */ +/* $NetBSD: t_glob.c,v 1.4 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Christos Zoulas * * 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 COPYRIGHT HOLDERS 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 * COPYRIGHT HOLDERS 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 -__RCSID("$NetBSD: t_glob.c,v 1.3 2013/01/02 11:28:48 martin Exp $"); +__RCSID("$NetBSD: t_glob.c,v 1.4 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include #include #include -#ifdef __FreeBSD__ #include "h_macros.h" + +#ifdef __FreeBSD__ #define __gl_stat_t struct stat #define _S_IFDIR S_IFDIR -#else -#include "../../../h_macros.h" #endif #ifdef DEBUG #define DPRINTF(a) printf a #else #define DPRINTF(a) #endif struct gl_file { const char *name; int dir; }; static struct gl_file a[] = { { "1", 0 }, { "b", 1 }, { "3", 0 }, { "4", 0 }, }; static struct gl_file b[] = { { "x", 0 }, { "y", 0 }, { "z", 0 }, { "w", 0 }, }; struct gl_dir { const char *name; /* directory name */ const struct gl_file *dir; size_t len, pos; }; static struct gl_dir d[] = { { "a", a, __arraycount(a), 0 }, { "a/b", b, __arraycount(b), 0 }, }; #ifndef __FreeBSD__ static const char *glob_star[] = { "a/1", "a/3", "a/4", "a/b", "a/b/w", "a/b/x", "a/b/y", "a/b/z", }; #endif static const char *glob_star_not[] = { "a/1", "a/3", "a/4", "a/b", }; static void trim(char *buf, size_t len, const char *name) { char *path = buf, *epath = buf + len; while (path < epath && (*path++ = *name++) != '\0') continue; path--; while (path > buf && *--path == '/') *path = '\0'; } static void * gl_opendir(const char *dir) { size_t i; char buf[MAXPATHLEN]; trim(buf, sizeof(buf), dir); for (i = 0; i < __arraycount(d); i++) if (strcmp(buf, d[i].name) == 0) { DPRINTF(("opendir %s %zu\n", buf, i)); return &d[i]; } errno = ENOENT; return NULL; } static struct dirent * gl_readdir(void *v) { static struct dirent dir; struct gl_dir *dd = v; if (dd->pos < dd->len) { const struct gl_file *f = &dd->dir[dd->pos++]; strcpy(dir.d_name, f->name); dir.d_namlen = strlen(f->name); dir.d_ino = dd->pos; dir.d_type = f->dir ? DT_DIR : DT_REG; DPRINTF(("readdir %s %d\n", dir.d_name, dir.d_type)); #ifdef __FreeBSD__ dir.d_reclen = -1; /* Does not have _DIRENT_RECLEN */ #else dir.d_reclen = _DIRENT_RECLEN(&dir, dir.d_namlen); #endif return &dir; } return NULL; } static int gl_stat(const char *name , __gl_stat_t *st) { char buf[MAXPATHLEN]; trim(buf, sizeof(buf), name); memset(st, 0, sizeof(*st)); if (strcmp(buf, "a") == 0 || strcmp(buf, "a/b") == 0) { st->st_mode |= _S_IFDIR; return 0; } if (buf[0] == 'a' && buf[1] == '/') { struct gl_file *f; size_t offs, count; if (buf[2] == 'b' && buf[3] == '/') { offs = 4; count = __arraycount(b); f = b; } else { offs = 2; count = __arraycount(a); f = a; } for (size_t i = 0; i < count; i++) if (strcmp(f[i].name, buf + offs) == 0) return 0; } DPRINTF(("stat %s %d\n", buf, st->st_mode)); errno = ENOENT; return -1; } static int gl_lstat(const char *name , __gl_stat_t *st) { return gl_stat(name, st); } static void gl_closedir(void *v) { struct gl_dir *dd = v; dd->pos = 0; DPRINTF(("closedir %p\n", dd)); } static void run(const char *p, int flags, const char **res, size_t len) { glob_t gl; size_t i; memset(&gl, 0, sizeof(gl)); gl.gl_opendir = gl_opendir; gl.gl_readdir = gl_readdir; gl.gl_closedir = gl_closedir; gl.gl_stat = gl_stat; gl.gl_lstat = gl_lstat; RZ(glob(p, GLOB_ALTDIRFUNC | flags, NULL, &gl)); for (i = 0; i < gl.gl_pathc; i++) DPRINTF(("%s\n", gl.gl_pathv[i])); ATF_CHECK(len == gl.gl_pathc); for (i = 0; i < gl.gl_pathc; i++) ATF_CHECK_STREQ(gl.gl_pathv[i], res[i]); globfree(&gl); } #ifndef __FreeBSD__ ATF_TC(glob_star); ATF_TC_HEAD(glob_star, tc) { atf_tc_set_md_var(tc, "descr", "Test glob(3) ** with GLOB_STAR"); } ATF_TC_BODY(glob_star, tc) { run("a/**", GLOB_STAR, glob_star, __arraycount(glob_star)); } #endif ATF_TC(glob_star_not); ATF_TC_HEAD(glob_star_not, tc) { atf_tc_set_md_var(tc, "descr", "Test glob(3) ** without GLOB_STAR"); } ATF_TC_BODY(glob_star_not, tc) { run("a/**", 0, glob_star_not, __arraycount(glob_star_not)); } #if 0 ATF_TC(glob_nocheck); ATF_TC_HEAD(glob_nocheck, tc) { atf_tc_set_md_var(tc, "descr", "Test glob(3) pattern with backslash and GLOB_NOCHECK"); } ATF_TC_BODY(glob_nocheck, tc) { static const char pattern[] = { 'f', 'o', 'o', '\\', ';', 'b', 'a', 'r', '\0' }; static const char *glob_nocheck[] = { pattern }; run(pattern, GLOB_NOCHECK, glob_nocheck, __arraycount(glob_nocheck)); } #endif ATF_TP_ADD_TCS(tp) { #ifndef __FreeBSD__ ATF_TP_ADD_TC(tp, glob_star); #endif ATF_TP_ADD_TC(tp, glob_star_not); /* * Remove this test for now - the GLOB_NOCHECK return value has been * re-defined to return a modified pattern in revision 1.33 of glob.c * * ATF_TP_ADD_TC(tp, glob_nocheck); */ return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/regex/debug.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/regex/debug.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/regex/debug.c (revision 312126) @@ -1,278 +1,275 @@ -/* $NetBSD: debug.c,v 1.2 2011/10/10 04:32:41 christos Exp $ */ +/* $NetBSD: debug.c,v 1.3 2017/01/14 00:50:56 christos Exp $ */ /*- * Copyright (c) 1993 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 - -#include -#ifdef __FreeBSD__ #include #include -#endif /* Don't sort these! */ #include "utils.h" #include "regex2.h" #include "test_regex.h" #ifdef __NetBSD__ static void s_print(struct re_guts *, FILE *); static char *regchar(int); /* * regprint - print a regexp for debugging */ void regprint(regex_t *r, FILE *d) { struct re_guts *g = r->re_g; int c; int last; int nincat[NC]; fprintf(d, "%ld states, %zu categories", (long)g->nstates, g->ncategories); fprintf(d, ", first %ld last %ld", (long)g->firststate, (long)g->laststate); if (g->iflags&USEBOL) fprintf(d, ", USEBOL"); if (g->iflags&USEEOL) fprintf(d, ", USEEOL"); if (g->iflags&BAD) fprintf(d, ", BAD"); if (g->nsub > 0) fprintf(d, ", nsub=%ld", (long)g->nsub); if (g->must != NULL) fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen, g->must); if (g->backrefs) fprintf(d, ", backrefs"); if (g->nplus > 0) fprintf(d, ", nplus %ld", (long)g->nplus); fprintf(d, "\n"); s_print(g, d); for (size_t i = 0; i < g->ncategories; i++) { nincat[i] = 0; for (c = CHAR_MIN; c <= CHAR_MAX; c++) if (g->categories[c] == i) nincat[i]++; } fprintf(d, "cc0#%d", nincat[0]); for (size_t i = 1; i < g->ncategories; i++) if (nincat[i] == 1) { for (c = CHAR_MIN; c <= CHAR_MAX; c++) if (g->categories[c] == i) break; fprintf(d, ", %zu=%s", i, regchar(c)); } fprintf(d, "\n"); for (size_t i = 1; i < g->ncategories; i++) if (nincat[i] != 1) { fprintf(d, "cc%zu\t", i); last = -1; for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */ if (c <= CHAR_MAX && g->categories[c] == i) { if (last < 0) { fprintf(d, "%s", regchar(c)); last = c; } } else { if (last >= 0) { if (last != c-1) fprintf(d, "-%s", regchar(c-1)); last = -1; } } fprintf(d, "\n"); } } /* * s_print - print the strip for debugging */ static void s_print(struct re_guts *g, FILE *d) { sop *s; cset *cs; int done = 0; sop opnd; int col = 0; ssize_t last; sopno offset = 2; # define GAP() { if (offset % 5 == 0) { \ if (col > 40) { \ fprintf(d, "\n\t"); \ col = 0; \ } else { \ fprintf(d, " "); \ col++; \ } \ } else \ col++; \ offset++; \ } if (OP(g->strip[0]) != OEND) fprintf(d, "missing initial OEND!\n"); for (s = &g->strip[1]; !done; s++) { opnd = OPND(*s); switch (OP(*s)) { case OEND: fprintf(d, "\n"); done = 1; break; case OCHAR: if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd) != NULL) fprintf(d, "\\%c", (char)opnd); else fprintf(d, "%s", regchar((char)opnd)); break; case OBOL: fprintf(d, "^"); break; case OEOL: fprintf(d, "$"); break; case OBOW: fprintf(d, "\\{"); break; case OEOW: fprintf(d, "\\}"); break; case OANY: fprintf(d, "."); break; case OANYOF: fprintf(d, "[(%ld)", (long)opnd); cs = &g->sets[opnd]; last = -1; for (size_t i = 0; i < g->csetsize+1; i++) /* +1 flushes */ if (CHIN(cs, i) && i < g->csetsize) { if (last < 0) { fprintf(d, "%s", regchar(i)); last = i; } } else { if (last >= 0) { if (last != (ssize_t)i - 1) fprintf(d, "-%s", regchar(i - 1)); last = -1; } } fprintf(d, "]"); break; case OBACK_: fprintf(d, "(\\<%ld>", (long)opnd); break; case O_BACK: fprintf(d, "<%ld>\\)", (long)opnd); break; case OPLUS_: fprintf(d, "(+"); if (OP(*(s+opnd)) != O_PLUS) fprintf(d, "<%ld>", (long)opnd); break; case O_PLUS: if (OP(*(s-opnd)) != OPLUS_) fprintf(d, "<%ld>", (long)opnd); fprintf(d, "+)"); break; case OQUEST_: fprintf(d, "(?"); if (OP(*(s+opnd)) != O_QUEST) fprintf(d, "<%ld>", (long)opnd); break; case O_QUEST: if (OP(*(s-opnd)) != OQUEST_) fprintf(d, "<%ld>", (long)opnd); fprintf(d, "?)"); break; case OLPAREN: fprintf(d, "((<%ld>", (long)opnd); break; case ORPAREN: fprintf(d, "<%ld>))", (long)opnd); break; case OCH_: fprintf(d, "<"); if (OP(*(s+opnd)) != OOR2) fprintf(d, "<%ld>", (long)opnd); break; case OOR1: if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_) fprintf(d, "<%ld>", (long)opnd); fprintf(d, "|"); break; case OOR2: fprintf(d, "|"); if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH) fprintf(d, "<%ld>", (long)opnd); break; case O_CH: if (OP(*(s-opnd)) != OOR1) fprintf(d, "<%ld>", (long)opnd); fprintf(d, ">"); break; default: fprintf(d, "!%d(%d)!", OP(*s), opnd); break; } if (!done) GAP(); } } /* * regchar - make a character printable */ static char * /* -> representation */ regchar(int ch) { static char buf[10]; if (isprint(ch) || ch == ' ') sprintf(buf, "%c", ch); else sprintf(buf, "\\%o", ch); return(buf); } #else void regprint(regex_t *r, FILE *d) { } #endif Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c (revision 312126) @@ -1,224 +1,214 @@ -/* $NetBSD: t_exhaust.c,v 1.7 2011/11/16 18:37:31 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.8 2017/01/14 00:50:56 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Christos Zoulas. * * 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 by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * 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 -__RCSID("$NetBSD: t_exhaust.c,v 1.7 2011/11/16 18:37:31 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.8 2017/01/14 00:50:56 christos Exp $"); -#include +#include +#include +#include #include -#include +#include #include -#include -#include -#ifdef __FreeBSD__ -#include -#endif +#include #ifndef REGEX_MAXSIZE #define REGEX_MAXSIZE 9999 #endif static char * mkstr(const char *str, size_t len) { size_t slen = strlen(str); char *p = malloc(slen * len + 1); ATF_REQUIRE(p != NULL); for (size_t i = 0; i < len; i++) strcpy(&p[i * slen], str); return p; } static char * concat(const char *d, const char *s) { size_t dlen = strlen(d); size_t slen = strlen(s); char *p = malloc(dlen + slen + 1); ATF_REQUIRE(p != NULL); strcpy(p, d); strcpy(p + dlen, s); return p; } static char * p0(size_t len) { char *d, *s1, *s2; s1 = mkstr("\\(", len); s2 = concat(s1, ")"); free(s1); d = concat("(", s2); free(s2); return d; } static char * p1(size_t len) { char *d, *s1, *s2, *s3; s1 = mkstr("\\(", 60); s2 = mkstr("(.*)", len); s3 = concat(s1, s2); free(s2); free(s1); s1 = concat(s3, ")"); free(s3); d = concat("(", s1); free(s1); return d; } static char * ps(const char *m, const char *s, size_t len) { char *d, *s1, *s2, *s3; s1 = mkstr(m, len); s2 = mkstr(s, len); s3 = concat(s1, s2); free(s2); free(s1); d = concat("(.?)", s3); free(s3); return d; } static char * p2(size_t len) { return ps("((.*){0,255}", ")", len); } static char * p3(size_t len) { return ps("(.\\{0,}", ")", len); } static char * p4(size_t len) { return ps("((.*){1,255}", ")", len); } static char * p5(size_t len) { return ps("(", "){1,100}", len); } static char * p6(size_t len) { char *d, *s1, *s2; s1 = mkstr("(?:(.*)|", len); s2 = concat(s1, "(.*)"); free(s1); s1 = mkstr(")", len); d = concat(s2, s1); free(s1); free(s2); return d; } static const struct { char *(*pattern)(size_t); int type; } tests[] = { { p0, REG_EXTENDED }, { p1, REG_EXTENDED }, { p2, REG_EXTENDED }, { p3, REG_EXTENDED }, { p4, REG_EXTENDED }, { p5, REG_EXTENDED }, { p6, REG_BASIC }, }; ATF_TC(regcomp_too_big); ATF_TC_HEAD(regcomp_too_big, tc) { atf_tc_set_md_var(tc, "descr", "Check that large patterns don't" " crash, but return a proper error code"); // libtre needs it. atf_tc_set_md_var(tc, "timeout", "600"); -#ifdef __FreeBSD__ atf_tc_set_md_var(tc, "require.memory", "64M"); -#else - atf_tc_set_md_var(tc, "require.memory", "120M"); -#endif } ATF_TC_BODY(regcomp_too_big, tc) { regex_t re; -#ifdef __FreeBSD__ struct rlimit limit; -#endif int e; -#ifdef __FreeBSD__ limit.rlim_cur = limit.rlim_max = 64 * 1024 * 1024; ATF_REQUIRE(setrlimit(RLIMIT_VMEM, &limit) != -1); -#endif for (size_t i = 0; i < __arraycount(tests); i++) { char *d = (*tests[i].pattern)(REGEX_MAXSIZE); e = regcomp(&re, d, tests[i].type); if (e) { char ebuf[1024]; (void)regerror(e, &re, ebuf, sizeof(ebuf)); ATF_REQUIRE_MSG(e == REG_ESPACE, "regcomp returned %d (%s) for pattern %zu [%s]", e, ebuf, i, d); free(d); continue; } free(d); (void)regexec(&re, "aaaaaaaaaaa", 0, NULL, 0); regfree(&re); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, regcomp_too_big); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c (revision 312126) @@ -1,639 +1,635 @@ -/* $NetBSD: t_regex_att.c,v 1.1 2012/08/24 20:24:40 jmmv Exp $ */ +/* $NetBSD: t_regex_att.c,v 1.2 2017/01/14 00:50:56 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Christos Zoulas. * * 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 by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * 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 -__RCSID("$NetBSD: t_regex_att.c,v 1.1 2012/08/24 20:24:40 jmmv Exp $"); +__RCSID("$NetBSD: t_regex_att.c,v 1.2 2017/01/14 00:50:56 christos Exp $"); #include #include #include #include #include #include #include #include #ifdef __FreeBSD__ #include #endif static const char sep[] = "\r\n\t"; static const char delim[3] = "\\\\\0"; static void fail(const char *pattern, const char *input, size_t lineno) { fprintf(stderr, "skipping failed test at line %zu (pattern=%s, input=%s)\n", lineno, pattern, input); } static int bug(const char *pattern, const char *input, size_t lineno) { static const struct { const char *p; const char *i; } b[] = { #if defined(REGEX_SPENCER) /* * The default libc implementation by Henry Spencer */ { "a[-]?c", "ac" }, // basic.dat { "(a*)*", "a" }, // categorization.dat { "(aba|a*b)*", "ababa" }, // categorization.dat { "\\(a\\(b\\)*\\)*\\2", "abab" }, // categorization.dat { "(a*)*", "aaaaaa" }, // nullsubexpression.dat { "(a*)*", "aaaaaax" }, // nullsubexpression.dat { "(a*)+", "a" }, // nullsubexpression.dat { "(a*)+", "aaaaaa" }, // nullsubexpression.dat { "(a*)+", "aaaaaax" }, // nullsubexpression.dat { "([a]*)*", "a" }, // nullsubexpression.dat { "([a]*)*", "aaaaaa" }, // nullsubexpression.dat { "([a]*)*", "aaaaaax" }, // nullsubexpression.dat { "([a]*)+", "a" }, // nullsubexpression.dat { "([a]*)+", "aaaaaa" }, // nullsubexpression.dat { "([a]*)+", "aaaaaax" }, // nullsubexpression.dat { "([^b]*)*", "a" }, // nullsubexpression.dat { "([^b]*)*", "aaaaaa" }, // nullsubexpression.dat { "([^b]*)*", "aaaaaab" }, // nullsubexpression.dat { "([ab]*)*", "a" }, // nullsubexpression.dat { "([ab]*)*", "aaaaaa" }, // nullsubexpression.dat { "([ab]*)*", "ababab" }, // nullsubexpression.dat { "([ab]*)*", "bababa" }, // nullsubexpression.dat { "([ab]*)*", "b" }, // nullsubexpression.dat { "([ab]*)*", "bbbbbb" }, // nullsubexpression.dat { "([ab]*)*", "aaaabcde" }, // nullsubexpression.dat { "([^a]*)*", "b" }, // nullsubexpression.dat { "([^a]*)*", "bbbbbb" }, // nullsubexpression.dat { "([^ab]*)*", "ccccxx" }, // nullsubexpression.dat { "\\(a*\\)*\\(x\\)", "ax" }, // nullsubexpression.dat { "\\(a*\\)*\\(x\\)", "axa" }, // nullsubexpression.dat { "\\(a*\\)*\\(x\\)\\(\\1\\)", "x" }, // nullsubexpression.dat /* crash! */ { "\\(a*\\)*\\(x\\)\\(\\1\\)", "ax" }, // nullsubexpression.dat /* crash! */ { "\\(a*\\)*\\(x\\)\\(\\1\\)\\(x\\)", "axxa" }, // "" { "(a*)*(x)", "ax" }, // nullsubexpression.dat { "(a*)*(x)", "axa" }, // nullsubexpression.dat { "(a*)+(x)", "ax" }, // nullsubexpression.dat { "(a*)+(x)", "axa" }, // nullsubexpression.dat { "((a|ab)(c|bcd))(d*)", "abcd" }, // forcedassoc.dat { "((a|ab)(bcd|c))(d*)", "abcd" }, // forcedassoc.dat { "((ab|a)(c|bcd))(d*)", "abcd" }, // forcedassoc.dat { "((ab|a)(bcd|c))(d*)", "abcd" }, // forcedassoc.dat { "((a*)(b|abc))(c*)", "abc" }, // forcedassoc.dat { "((a*)(abc|b))(c*)", "abc" }, // forcedassoc.dat { "((..)|(.)){2}", "aaa" }, // repetition.dat { "((..)|(.)){3}", "aaa" }, // repetition.dat { "((..)|(.)){3}", "aaaa" }, // repetition.dat { "((..)|(.)){3}", "aaaaa" }, // repetition.dat { "X(.?){0,}Y", "X1234567Y" }, // repetition.dat { "X(.?){1,}Y", "X1234567Y" }, // repetition.dat { "X(.?){2,}Y", "X1234567Y" }, // repetition.dat { "X(.?){3,}Y", "X1234567Y" }, // repetition.dat { "X(.?){4,}Y", "X1234567Y" }, // repetition.dat { "X(.?){5,}Y", "X1234567Y" }, // repetition.dat { "X(.?){6,}Y", "X1234567Y" }, // repetition.dat { "X(.?){7,}Y", "X1234567Y" }, // repetition.dat { "X(.?){0,8}Y", "X1234567Y" }, // repetition.dat { "X(.?){1,8}Y", "X1234567Y" }, // repetition.dat { "X(.?){2,8}Y", "X1234567Y" }, // repetition.dat { "X(.?){3,8}Y", "X1234567Y" }, // repetition.dat { "X(.?){4,8}Y", "X1234567Y" }, // repetition.dat { "X(.?){5,8}Y", "X1234567Y" }, // repetition.dat { "X(.?){6,8}Y", "X1234567Y" }, // repetition.dat { "X(.?){7,8}Y", "X1234567Y" }, // repetition.dat { "(a|ab|c|bcd){0,}(d*)", "ababcd" }, // repetition.dat { "(a|ab|c|bcd){1,}(d*)", "ababcd" }, // repetition.dat { "(a|ab|c|bcd){2,}(d*)", "ababcd" }, // repetition.dat { "(a|ab|c|bcd){3,}(d*)", "ababcd" }, // repetition.dat { "(a|ab|c|bcd){1,10}(d*)", "ababcd" }, // repetition.dat { "(a|ab|c|bcd){2,10}(d*)", "ababcd" }, // repetition.dat { "(a|ab|c|bcd){3,10}(d*)", "ababcd" }, // repetition.dat { "(a|ab|c|bcd)*(d*)", "ababcd" }, // repetition.dat { "(a|ab|c|bcd)+(d*)", "ababcd" }, // repetition.dat { "(ab|a|c|bcd){0,}(d*)", "ababcd" }, // repetition.dat { "(ab|a|c|bcd){1,}(d*)", "ababcd" }, // repetition.dat { "(ab|a|c|bcd){2,}(d*)", "ababcd" }, // repetition.dat { "(ab|a|c|bcd){3,}(d*)", "ababcd" }, // repetition.dat { "(ab|a|c|bcd){1,10}(d*)", "ababcd" }, // repetition.dat { "(ab|a|c|bcd){2,10}(d*)", "ababcd" }, // repetition.dat { "(ab|a|c|bcd){3,10}(d*)", "ababcd" }, // repetition.dat { "(ab|a|c|bcd)*(d*)", "ababcd" }, // repetition.dat { "(ab|a|c|bcd)+(d*)", "ababcd" }, // repetition.dat #elif defined(REGEX_TRE) { "a[-]?c", "ac" }, // basic.dat { "a\\(b\\)*\\1", "a" }, // categorization.dat { "a\\(b\\)*\\1", "abab" }, // categorization.dat { "\\(a\\(b\\)*\\)*\\2", "abab" }, // categorization.dat { "\\(a*\\)*\\(x\\)\\(\\1\\)", "ax" }, // categorization.dat { "\\(a*\\)*\\(x\\)\\(\\1\\)\\(x\\)", "axxa" }, // "" { "((..)|(.))*", "aa" }, // repetition.dat { "((..)|(.))*", "aaa" }, // repetition.dat { "((..)|(.))*", "aaaaa" }, // repetition.dat { "X(.?){7,}Y", "X1234567Y" }, // repetition.dat #else { "", "" } #endif }; for (size_t i = 0; i < __arraycount(b); i++) { if (strcmp(pattern, b[i].p) == 0 && strcmp(input, b[i].i) == 0) { fail(pattern, input, lineno); return 1; } } return 0; } #ifdef REGEX_SPENCER #define HAVE_BRACES 1 #define HAVE_MINIMAL 0 #endif #ifndef HAVE_BRACES #define HAVE_BRACES 1 #endif #ifndef HAVE_MINIMAL #define HAVE_MINIMAL 1 #endif static int optional(const char *s) { static const struct{ const char *n; int v; } nv[]= { { "[[]] not supported", HAVE_BRACES }, { "no *? +? mimimal match ops", HAVE_MINIMAL }, }; for (size_t i = 0; i < __arraycount(nv); i++) if (strcmp(nv[i].n, s) == 0) { if (nv[i].v) return 0; fprintf(stderr, "skipping unsupported [%s] tests\n", s); return 1; } ATF_REQUIRE_MSG(0, "Unknown feature: %s", s); return 0; } static int unsupported(const char *s) { static const char *we[] = { #if defined(REGEX_SPENCER) "ASSOCIATIVITY=left", // have right associativity "SUBEXPRESSION=precedence", // have grouping subexpression "REPEAT_LONGEST=last", // have first repeat longest "BUG=alternation-order", // don't have it "BUG=first-match", // don't have it "BUG=nomatch-match", // don't have it "BUG=repeat-any", // don't have it "BUG=range-null", // don't have it "BUG=repeat-null-unknown", // don't have it "BUG=repeat-null", // don't have it "BUG=repeat-artifact", // don't have it "BUG=subexpression-first", // don't have it #elif defined(REGEX_TRE) "ASSOCIATIVITY=right", // have left associativity "SUBEXPRESSION=grouping", // have precedence subexpression "REPEAT_LONGEST=first", // have last repeat longest "LENGTH=first", // have last length "BUG=alternation-order", // don't have it "BUG=first-match", // don't have it "BUG=range-null", // don't have it "BUG=repeat-null", // don't have it "BUG=repeat-artifact", // don't have it "BUG=subexpression-first", // don't have it "BUG=repeat-short", // don't have it #endif }; if (s == NULL) return 0; while (*s == '#' || isspace((unsigned char)*s)) s++; for (size_t i = 0; i < __arraycount(we); i++) if (strcmp(we[i], s) == 0) return 1; return 0; } static void geterror(const char *s, int *comp, int *exec) { static const struct { const char *n; int v; int ce; } nv[] = { #define COMP 1 #define EXEC 2 { "OK", 0, COMP|EXEC }, #define _DO(a, b) { # a, REG_ ## a, b }, _DO(NOMATCH, EXEC) _DO(BADPAT, COMP) _DO(ECOLLATE, COMP) _DO(ECTYPE, COMP) _DO(EESCAPE, COMP) _DO(ESUBREG, COMP) _DO(EBRACK, COMP) _DO(EPAREN, COMP) _DO(EBRACE, COMP) _DO(BADBR, COMP) _DO(ERANGE, COMP) _DO(ESPACE, EXEC) _DO(BADRPT, COMP) _DO(EMPTY, COMP) _DO(ASSERT, COMP) _DO(INVARG, COMP) _DO(ENOSYS, COMP) #undef _DO }; *comp = 0; *exec = 0; for (size_t i = 0; i < __arraycount(nv); i++) if (strcmp(s, nv[i].n) == 0) { if (nv[i].ce & COMP) *comp = nv[i].v; if (nv[i].ce & EXEC) *exec = nv[i].v; return; } ATF_REQUIRE_MSG(0, "Unknown error %s", s); return; } static int getflags(char *s) { int flags = 0; for (;; s++) switch (*s) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': *s = '\0'; break; case '\0': return flags; case 'B': case 'E': case 'F': case 'L': break; case 'i': flags |= REG_ICASE; *s = '\0'; break; case '$': *s = '\0'; break; case 'n': *s = '\0'; break; default: ATF_REQUIRE_MSG(0, "Unknown char %c", *s); break; } } static size_t getmatches(const char *s) { size_t i; char *q; for (i = 0; (q = strchr(s, '(')) != NULL; i++, s = q + 1) continue; ATF_REQUIRE_MSG(i != 0, "No parentheses found"); return i; } static void checkcomment(const char *s, size_t lineno) { if (s && strstr(s, "BUG") != NULL) fprintf(stderr, "Expected %s at line %zu\n", s, lineno); } static void checkmatches(const char *matches, size_t nm, const regmatch_t *pm, size_t lineno) { if (nm == 0) return; char *res; size_t len = strlen(matches) + 1, off = 0; ATF_REQUIRE((res = strdup(matches)) != NULL); for (size_t i = 0; i < nm; i++) { int l; if (pm[i].rm_so == -1 && pm[i].rm_eo == -1) l = snprintf(res + off, len - off, "(?,?)"); else l = snprintf(res + off, len - off, "(%lld,%lld)", (long long)pm[i].rm_so, (long long)pm[i].rm_eo); ATF_REQUIRE_MSG((size_t) l < len - off, "String too long %s" " cur=%d, max=%zu", res, l, len - off); off += l; } -#ifdef __FreeBSD__ ATF_CHECK_STREQ_MSG(res, matches, " at line %zu", lineno); -#else - ATF_REQUIRE_STREQ_MSG(res, matches, " at line %zu", lineno); -#endif free(res); } static void att_test(const struct atf_tc *tc, const char *data_name) { regex_t re; char *line, *lastpattern = NULL, data_path[MAXPATHLEN]; size_t len, lineno = 0; int skipping = 0; FILE *input_file; snprintf(data_path, sizeof(data_path), "%s/data/%s.dat", atf_tc_get_config_var(tc, "srcdir"), data_name); input_file = fopen(data_path, "r"); if (input_file == NULL) atf_tc_fail("Failed to open input file %s", data_path); for (; (line = fparseln(input_file, &len, &lineno, delim, 0)) != NULL; free(line)) { char *name, *pattern, *input, *matches, *comment; regmatch_t *pm; size_t nm; #ifdef DEBUG fprintf(stderr, "[%s]\n", line); #endif if ((name = strtok(line, sep)) == NULL) continue; /* * We check these early so that we skip the lines quickly * in order to do more strict testing on the other arguments * The same characters are also tested in the switch below */ if (*name == '}') { skipping = 0; continue; } if (skipping) continue; if (*name == ';' || *name == '#' || strcmp(name, "NOTE") == 0) continue; if (*name == ':') { /* Skip ":HA#???:" prefix */ while (*++name && *name != ':') continue; if (*name) name++; } ATF_REQUIRE_MSG((pattern = strtok(NULL, sep)) != NULL, "Missing pattern at line %zu", lineno); ATF_REQUIRE_MSG((input = strtok(NULL, sep)) != NULL, "Missing input at line %zu", lineno); if (strchr(name, '$')) { ATF_REQUIRE(strunvis(pattern, pattern) != -1); ATF_REQUIRE(strunvis(input, input) != -1); } if (strcmp(input, "NULL") == 0) *input = '\0'; if (strcmp(pattern, "SAME") == 0) { ATF_REQUIRE(lastpattern != NULL); pattern = lastpattern; } else { free(lastpattern); ATF_REQUIRE((lastpattern = strdup(pattern)) != NULL); } ATF_REQUIRE_MSG((matches = strtok(NULL, sep)) != NULL, "Missing matches at line %zu", lineno); comment = strtok(NULL, sep); switch (*name) { case '{': /* Begin optional implementation */ if (optional(comment)) { skipping++; continue; } name++; /* We have it, so ignore */ break; case '}': /* End optional implementation */ skipping = 0; continue; case '?': /* Optional */ case '|': /* Alternative */ if (unsupported(comment)) continue; name++; /* We have it, so ignore */ break; case '#': /* Comment */ case ';': /* Skip */ continue; default: break; } /* XXX: Our bug */ if (bug(pattern, input, lineno)) continue; int comp, exec; if (*matches != '(') { geterror(matches, &comp, &exec); pm = NULL; nm = 0; } else { comp = exec = 0; nm = getmatches(matches); ATF_REQUIRE((pm = calloc(nm, sizeof(*pm))) != NULL); } int iflags = getflags(name); for (; *name; name++) { int flags; switch (*name) { case 'B': flags = REG_BASIC; break; case 'E': flags = REG_EXTENDED; break; case 'L': flags = REG_NOSPEC; break; default: ATF_REQUIRE_MSG(0, "Bad name %c", *name); continue; } int c = regcomp(&re, pattern, flags | iflags); ATF_REQUIRE_MSG(c == comp, "regcomp returned %d for pattern %s at line %zu", c, pattern, lineno); if (c) continue; int e = regexec(&re, input, nm, pm, 0); ATF_REQUIRE_MSG(e == exec, "Expected error %d," " got %d at line %zu", exec, e, lineno); checkmatches(matches, nm, pm, lineno); checkcomment(comment, lineno); regfree(&re); } free(pm); } fclose(input_file); } ATF_TC(basic); ATF_TC_HEAD(basic, tc) { atf_tc_set_md_var(tc, "descr", "Tests basic functionality"); } ATF_TC_BODY(basic, tc) { att_test(tc, "basic"); } ATF_TC(categorization); ATF_TC_HEAD(categorization, tc) { atf_tc_set_md_var(tc, "descr", "Tests implementation categorization"); } ATF_TC_BODY(categorization, tc) { att_test(tc, "categorization"); } ATF_TC(nullsubexpr); ATF_TC_HEAD(nullsubexpr, tc) { atf_tc_set_md_var(tc, "descr", "Tests (...)*"); } ATF_TC_BODY(nullsubexpr, tc) { att_test(tc, "nullsubexpr"); } ATF_TC(leftassoc); ATF_TC_HEAD(leftassoc, tc) { atf_tc_set_md_var(tc, "descr", "Tests left-associative " "implementations"); } ATF_TC_BODY(leftassoc, tc) { #if SKIP_LEFTASSOC /* jmmv: I converted the original shell-based tests to C and they * disabled this test in a very unconventional way without giving * any explation. Mark as broken here, but I don't know why. */ atf_tc_expect_fail("Reason for breakage unknown"); #endif #ifdef __FreeBSD__ atf_tc_expect_fail("The expected and matched groups are mismatched on FreeBSD"); #endif att_test(tc, "leftassoc"); } ATF_TC(rightassoc); ATF_TC_HEAD(rightassoc, tc) { atf_tc_set_md_var(tc, "descr", "Tests right-associative " "implementations"); } ATF_TC_BODY(rightassoc, tc) { #if SKIP_RIGHTASSOC /* jmmv: I converted the original shell-based tests to C and they * disabled this test in a very unconventional way without giving * any explation. Mark as broken here, but I don't know why. */ atf_tc_expect_fail("Reason for breakage unknown"); #endif att_test(tc, "rightassoc"); } ATF_TC(forcedassoc); ATF_TC_HEAD(forcedassoc, tc) { atf_tc_set_md_var(tc, "descr", "Tests subexpression grouping to " "force association"); } ATF_TC_BODY(forcedassoc, tc) { att_test(tc, "forcedassoc"); } ATF_TC(repetition); ATF_TC_HEAD(repetition, tc) { atf_tc_set_md_var(tc, "descr", "Tests implicit vs. explicit " "repetition"); } ATF_TC_BODY(repetition, tc) { att_test(tc, "repetition"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, basic); ATF_TP_ADD_TC(tp, categorization); ATF_TP_ADD_TC(tp, nullsubexpr); ATF_TP_ADD_TC(tp, leftassoc); ATF_TP_ADD_TC(tp, rightassoc); ATF_TP_ADD_TC(tp, forcedassoc); ATF_TP_ADD_TC(tp, repetition); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_clock_gettime.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_clock_gettime.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_clock_gettime.c (revision 312126) @@ -1,220 +1,212 @@ -/* $NetBSD: t_clock_gettime.c,v 1.1 2011/10/15 06:42:16 jruoho Exp $ */ +/* $NetBSD: t_clock_gettime.c,v 1.3 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Frank Kardel. * * 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) 2006 Frank Kardel * 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_clock_gettime.c,v 1.1 2011/10/15 06:42:16 jruoho Exp $"); +__RCSID("$NetBSD: t_clock_gettime.c,v 1.3 2017/01/13 21:30:41 christos Exp $"); #include #include -#ifdef __NetBSD__ -#include -#endif - #include #include +#include #include +#include #include #include #include #include -#ifdef __NetBSD__ -#include "../../../h_macros.h" -#else -#include -#include #include "h_macros.h" -#endif #define MINPOSDIFF 15000000 /* 15 ms for now */ #define TIMEOUT 5 #define TC_HARDWARE "kern.timecounter.hardware" #define TC_CHOICE "kern.timecounter.choice" static void check_timecounter(void) { struct timespec tsa, tsb, tsl, res; long long mindiff = INTMAX_MAX; time_t endlimit; #define CL(x) \ do { \ if ((x) != -1) \ break; \ atf_tc_fail_nonfatal("%s: %s", #x, strerror(errno)); \ return; \ } while (0) CL(clock_gettime(CLOCK_REALTIME, &tsa)); tsl = tsa; CL(time(&endlimit)); endlimit += TIMEOUT + 1; while ((time_t)tsa.tv_sec < endlimit) { long long diff; CL(clock_gettime(CLOCK_REALTIME, &tsb)); diff = 1000000000LL * (tsb.tv_sec - tsa.tv_sec) + tsb.tv_nsec - tsa.tv_nsec; if (diff > 0 && mindiff > diff) mindiff = diff; if (diff < 0 || diff > MINPOSDIFF) { long long elapsed; (void)printf("%stime TSA: 0x%jx.%08jx, TSB: 0x%jx.%08jx, " "diff = %lld nsec, ", (diff < 0) ? "BAD " : "", (uintmax_t)tsa.tv_sec, (uintmax_t)tsa.tv_nsec, (uintmax_t)tsb.tv_sec, (uintmax_t)tsb.tv_nsec, diff); elapsed = 1000000000LL * (tsb.tv_sec - tsl.tv_sec) + tsb.tv_nsec - tsl.tv_nsec; (void)printf("%lld nsec\n", elapsed); tsl = tsb; ATF_CHECK(diff >= 0); if (diff < 0) return; } tsa.tv_sec = tsb.tv_sec; tsa.tv_nsec = tsb.tv_nsec; } if (clock_getres(CLOCK_REALTIME, &res) == 0) { long long r = res.tv_sec * 1000000000 + res.tv_nsec; (void)printf("Claimed resolution: %lld nsec (%f Hz) or " "better\n", r, 1.0 / r * 1e9); (void)printf("Observed minimum non zero delta: %lld " "nsec\n", mindiff); } #undef CL } ATF_TC(clock_gettime_real); ATF_TC_HEAD(clock_gettime_real, tc) { atf_tc_set_md_var(tc, "require.user", "root"); atf_tc_set_md_var(tc, "descr", "Checks the monotonicity of the CLOCK_REALTIME implementation"); atf_tc_set_md_var(tc, "timeout", "300"); } ATF_TC_BODY(clock_gettime_real, tc) { char name[128], cbuf[512], ctrbuf[10240]; size_t cbufsiz = sizeof(cbuf); size_t ctrbufsiz = sizeof(ctrbuf); const char *p; char *save; int quality, n; if (sysctlbyname(TC_HARDWARE, cbuf, &cbufsiz, NULL, 0) != 0) { (void)printf("\nChecking legacy time implementation " "for %d seconds\n", TIMEOUT); check_timecounter(); return; /* NOTREACHED */ } (void)printf("%s = %s\n", TC_HARDWARE, cbuf); REQUIRE_LIBC(save = strdup(cbuf), NULL); RL(sysctlbyname(TC_CHOICE, ctrbuf, &ctrbufsiz, NULL, 0)); (void)printf("%s = %s\n", TC_CHOICE, ctrbuf); for (p = ctrbuf, n = 0; sscanf(p, "%127[^(](q=%d, f=%*u Hz)%*[ ]%n", name, &quality, &n) == 2; p += n) { struct timespec ts; int ret; if (quality < 0) continue; (void)printf("\nChecking %s for %d seconds\n", name, TIMEOUT); CHECK_LIBC(ret = sysctlbyname(TC_HARDWARE, NULL, 0, name, strlen(name)), -1); if (ret == -1) continue; /* wait a bit to select new counter in clockinterrupt */ ts.tv_sec = 0; ts.tv_nsec = 100000000; (void)nanosleep(&ts, NULL); check_timecounter(); } RL(sysctlbyname(TC_HARDWARE, NULL, 0, save, strlen(save))); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, clock_gettime_real); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_connect.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_connect.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_connect.c (revision 312126) @@ -1,140 +1,137 @@ -/* $NetBSD: t_connect.c,v 1.2 2015/04/05 23:17:41 rtr Exp $ */ +/* $NetBSD: t_connect.c,v 1.3 2017/01/13 20:09:48 christos Exp $ */ /* * Copyright (c) 2007, 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 #include #include #include #include #include #include #include #ifdef __FreeBSD__ #include #endif ATF_TC(connect_low_port); ATF_TC_HEAD(connect_low_port, tc) { atf_tc_set_md_var(tc, "descr", "Checks that low-port allocation " "works"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(connect_low_port, tc) { struct sockaddr_in sin, sinlist; int sd, val, slist; socklen_t slen; slist = socket(AF_INET, SOCK_STREAM, 0); sd = socket(AF_INET, SOCK_STREAM, 0); -#ifdef __FreeBSD__ ATF_REQUIRE(sd > 0); ATF_REQUIRE(slist > 0); -#endif /* bind listening socket */ memset(&sinlist, 0, sizeof(sinlist)); sinlist.sin_family = AF_INET; sinlist.sin_port = htons(31522); sinlist.sin_addr.s_addr = inet_addr("127.0.0.1"); ATF_REQUIRE_EQ(bind(slist, (struct sockaddr *)&sinlist, sizeof(sinlist)), 0); ATF_REQUIRE_EQ(listen(slist, 1), 0); val = IP_PORTRANGE_LOW; if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, &val, sizeof(val)) == -1) atf_tc_fail("setsockopt failed: %s", strerror(errno)); memset(&sin, 0, sizeof(sin)); sin.sin_port = htons(31522); sin.sin_addr.s_addr = inet_addr("127.0.0.1"); sin.sin_family = AF_INET; if (connect(sd, (struct sockaddr *)&sin, sizeof(sin)) == -1) { int serrno = errno; atf_tc_fail("connect failed: %s%s", strerror(serrno), serrno != EACCES ? "" : " (see http://mail-index.netbsd.org/" "source-changes/2007/12/16/0011.html)"); } slen = sizeof(sin); ATF_REQUIRE_EQ(getsockname(sd, (struct sockaddr *)&sin, &slen), 0); ATF_REQUIRE_EQ(slen, sizeof(sin)); ATF_REQUIRE(ntohs(sin.sin_port) <= IPPORT_RESERVEDMAX); close(sd); -#ifdef __FreeBSD__ close(slist); -#endif } ATF_TC(connect_foreign_family); ATF_TC_HEAD(connect_foreign_family, tc) { atf_tc_set_md_var(tc, "descr", "Checks that connecting a socket " "with a different address family fails"); } ATF_TC_BODY(connect_foreign_family, tc) { struct sockaddr_in addr; /* addr.sin_family = AF_UNSPEC = 0 */ memset(&addr, 0, sizeof(addr)); /* * it is not necessary to initialize sin_{addr,port} since * those structure members shall not be accessed if connect * fails correctly. */ int sock = socket(AF_LOCAL, SOCK_STREAM, 0); ATF_REQUIRE(sock != -1); ATF_REQUIRE(-1 == connect(sock, (struct sockaddr *)&addr, sizeof(addr))); ATF_REQUIRE(EAFNOSUPPORT == errno); close(sock); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, connect_low_port); ATF_TP_ADD_TC(tp, connect_foreign_family); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_dup.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_dup.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_dup.c (revision 312126) @@ -1,405 +1,406 @@ -/* $NetBSD: t_dup.c,v 1.8 2012/03/18 07:00:51 jruoho Exp $ */ +/* $NetBSD: t_dup.c,v 1.9 2017/01/13 20:31:53 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_dup.c,v 1.8 2012/03/18 07:00:51 jruoho Exp $"); +__RCSID("$NetBSD: t_dup.c,v 1.9 2017/01/13 20:31:53 christos Exp $"); #include #include #include #include #include #include #include +#include #include #include #include #include #include #ifdef __FreeBSD__ #include #endif static char path[] = "dup"; #ifdef __NetBSD__ static void check_mode(bool, bool, bool); #endif static void check_mode(bool _dup, bool _dup2, bool _dup3) { int mode[3] = { O_RDONLY, O_WRONLY, O_RDWR }; int perm[5] = { 0700, 0400, 0600, 0444, 0666 }; struct stat st, st1; int fd, fd1, fd2; size_t i, j; /* * Check that a duplicated descriptor * retains the mode of the original file. */ for (i = 0; i < __arraycount(mode); i++) { for (j = 0; j < __arraycount(perm); j++) { fd1 = open(path, mode[i] | O_CREAT, perm[j]); fd2 = open("/etc/passwd", O_RDONLY); ATF_REQUIRE(fd1 >= 0); ATF_REQUIRE(fd2 >= 0); if (_dup != false) fd = dup(fd1); else if (_dup2 != false) fd = dup2(fd1, fd2); else if (_dup3 != false) fd = dup3(fd1, fd2, O_CLOEXEC); else { fd = -1; } ATF_REQUIRE(fd >= 0); (void)memset(&st, 0, sizeof(struct stat)); (void)memset(&st1, 0, sizeof(struct stat)); ATF_REQUIRE(fstat(fd, &st) == 0); ATF_REQUIRE(fstat(fd1, &st1) == 0); if (st.st_mode != st1.st_mode) atf_tc_fail("invalid mode"); (void)close(fd); (void)close(fd1); (void)close(fd2); (void)unlink(path); } } } ATF_TC(dup2_basic); ATF_TC_HEAD(dup2_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of dup2(2)"); } ATF_TC_BODY(dup2_basic, tc) { int fd, fd1, fd2; fd1 = open("/etc/passwd", O_RDONLY); fd2 = open("/etc/passwd", O_RDONLY); ATF_REQUIRE(fd1 >= 0); ATF_REQUIRE(fd2 >= 0); fd = dup2(fd1, fd2); ATF_REQUIRE(fd >= 0); if (fd != fd2) atf_tc_fail("invalid descriptor"); (void)close(fd); (void)close(fd1); ATF_REQUIRE(close(fd2) != 0); } ATF_TC(dup2_err); ATF_TC_HEAD(dup2_err, tc) { atf_tc_set_md_var(tc, "descr", "Test error conditions of dup2(2)"); } ATF_TC_BODY(dup2_err, tc) { int fd; fd = open("/etc/passwd", O_RDONLY); ATF_REQUIRE(fd >= 0); errno = 0; ATF_REQUIRE_ERRNO(EBADF, dup2(-1, -1) == -1); errno = 0; ATF_REQUIRE_ERRNO(EBADF, dup2(fd, -1) == -1); errno = 0; ATF_REQUIRE_ERRNO(EBADF, dup2(-1, fd) == -1); /* * Note that this should not fail with EINVAL. */ ATF_REQUIRE(dup2(fd, fd) != -1); (void)close(fd); } ATF_TC(dup2_max); ATF_TC_HEAD(dup2_max, tc) { atf_tc_set_md_var(tc, "descr", "Test dup2(2) against limits"); } ATF_TC_BODY(dup2_max, tc) { struct rlimit res; (void)memset(&res, 0, sizeof(struct rlimit)); (void)getrlimit(RLIMIT_NOFILE, &res); errno = 0; ATF_REQUIRE_ERRNO(EBADF, dup2(STDERR_FILENO, res.rlim_cur + 1) == -1); } ATF_TC_WITH_CLEANUP(dup2_mode); ATF_TC_HEAD(dup2_mode, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of dup2(2)"); } ATF_TC_BODY(dup2_mode, tc) { check_mode(false, true, false); } ATF_TC_CLEANUP(dup2_mode, tc) { (void)unlink(path); } ATF_TC(dup3_err); ATF_TC_HEAD(dup3_err, tc) { atf_tc_set_md_var(tc, "descr", "Test error conditions of dup3(2) (PR lib/45148)"); } ATF_TC_BODY(dup3_err, tc) { int fd; fd = open("/etc/passwd", O_RDONLY); ATF_REQUIRE(fd >= 0); errno = 0; #if defined(__FreeBSD__) || defined(__linux__) /* * FreeBSD and linux return EINVAL, because... * * [EINVAL] The oldd argument is equal to the newd argument. */ ATF_REQUIRE(dup3(fd, fd, O_CLOEXEC) == -1); #else ATF_REQUIRE(dup3(fd, fd, O_CLOEXEC) != -1); #endif errno = 0; #if defined(__FreeBSD__) || defined(__linux__) ATF_REQUIRE_ERRNO(EINVAL, dup3(-1, -1, O_CLOEXEC) == -1); ATF_REQUIRE_ERRNO(EBADF, dup3(fd, -1, O_CLOEXEC) == -1); #else ATF_REQUIRE_ERRNO(EBADF, dup3(-1, -1, O_CLOEXEC) == -1); #endif errno = 0; ATF_REQUIRE_ERRNO(EBADF, dup3(fd, -1, O_CLOEXEC) == -1); errno = 0; ATF_REQUIRE_ERRNO(EBADF, dup3(-1, fd, O_CLOEXEC) == -1); errno = 0; ATF_REQUIRE_ERRNO(EINVAL, dup3(fd, 1, O_NOFOLLOW) == -1); (void)close(fd); } ATF_TC(dup3_max); ATF_TC_HEAD(dup3_max, tc) { atf_tc_set_md_var(tc, "descr", "Test dup3(2) against limits"); } ATF_TC_BODY(dup3_max, tc) { struct rlimit res; (void)memset(&res, 0, sizeof(struct rlimit)); (void)getrlimit(RLIMIT_NOFILE, &res); errno = 0; ATF_REQUIRE_ERRNO(EBADF, dup3(STDERR_FILENO, res.rlim_cur + 1, O_CLOEXEC) == -1); } ATF_TC_WITH_CLEANUP(dup3_mode); ATF_TC_HEAD(dup3_mode, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of dup3(2)"); } ATF_TC_BODY(dup3_mode, tc) { check_mode(false, false, true); } ATF_TC_CLEANUP(dup3_mode, tc) { (void)unlink(path); } ATF_TC(dup_err); ATF_TC_HEAD(dup_err, tc) { atf_tc_set_md_var(tc, "descr", "Test error conditions of dup(2)"); } ATF_TC_BODY(dup_err, tc) { errno = 0; ATF_REQUIRE_ERRNO(EBADF, dup(-1) == -1); } ATF_TC_WITH_CLEANUP(dup_max); ATF_TC_HEAD(dup_max, tc) { atf_tc_set_md_var(tc, "descr", "Test dup(2) against limits"); } ATF_TC_BODY(dup_max, tc) { struct rlimit res; int *buf, fd, sta; size_t i, n; pid_t pid; pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { /* * Open a temporary file until the * maximum number of open files is * reached. Ater that dup(2) family * should fail with EMFILE. */ (void)closefrom(0); (void)memset(&res, 0, sizeof(struct rlimit)); n = 10; res.rlim_cur = res.rlim_max = n; if (setrlimit(RLIMIT_NOFILE, &res) != 0) _exit(EX_OSERR); buf = calloc(n, sizeof(int)); if (buf == NULL) _exit(EX_OSERR); buf[0] = mkstemp(path); if (buf[0] < 0) _exit(EX_OSERR); for (i = 1; i < n; i++) { buf[i] = open(path, O_RDONLY); if (buf[i] < 0) _exit(EX_OSERR); } errno = 0; fd = dup(buf[0]); if (fd != -1 || errno != EMFILE) _exit(EX_DATAERR); _exit(EXIT_SUCCESS); } (void)wait(&sta); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) { if (WEXITSTATUS(sta) == EX_OSERR) atf_tc_fail("system call error"); if (WEXITSTATUS(sta) == EX_DATAERR) atf_tc_fail("dup(2) dupped more than RLIMIT_NOFILE"); atf_tc_fail("unknown error"); } (void)unlink(path); } ATF_TC_CLEANUP(dup_max, tc) { (void)unlink(path); } ATF_TC_WITH_CLEANUP(dup_mode); ATF_TC_HEAD(dup_mode, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of dup(2)"); } ATF_TC_BODY(dup_mode, tc) { check_mode(true, false, false); } ATF_TC_CLEANUP(dup_mode, tc) { (void)unlink(path); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, dup2_basic); ATF_TP_ADD_TC(tp, dup2_err); ATF_TP_ADD_TC(tp, dup2_max); ATF_TP_ADD_TC(tp, dup2_mode); ATF_TP_ADD_TC(tp, dup3_err); ATF_TP_ADD_TC(tp, dup3_max); ATF_TP_ADD_TC(tp, dup3_mode); ATF_TP_ADD_TC(tp, dup_err); ATF_TP_ADD_TC(tp, dup_max); ATF_TP_ADD_TC(tp, dup_mode); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c (revision 312126) @@ -1,216 +1,212 @@ -/* $NetBSD: t_getrusage.c,v 1.4 2016/08/05 15:01:39 scole Exp $ */ +/* $NetBSD: t_getrusage.c,v 1.5 2017/01/13 20:31:06 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_getrusage.c,v 1.4 2016/08/05 15:01:39 scole Exp $"); +__RCSID("$NetBSD: t_getrusage.c,v 1.5 2017/01/13 20:31:06 christos Exp $"); #include #include #include #include #include #include #include #include static void work(void); static void sighandler(int); static const size_t maxiter = 2000; static void -#ifdef __FreeBSD__ sighandler(int signo __unused) -#else -sighandler(int signo) -#endif { /* Nothing. */ } #ifdef __FreeBSD__ #define asm __asm #endif static void work(void) { size_t n = UINT16_MAX * 10; while (n > 0) { #ifdef __or1k__ asm volatile("l.nop"); /* Do something. */ #elif defined(__ia64__) asm volatile("nop 0"); /* Do something. */ #else asm volatile("nop"); /* Do something. */ #endif n--; } } ATF_TC(getrusage_err); ATF_TC_HEAD(getrusage_err, tc) { atf_tc_set_md_var(tc, "descr", "Test error conditions"); } ATF_TC_BODY(getrusage_err, tc) { struct rusage ru; errno = 0; ATF_REQUIRE(getrusage(INT_MAX, &ru) != 0); ATF_REQUIRE(errno == EINVAL); errno = 0; ATF_REQUIRE(getrusage(RUSAGE_SELF, (void *)0) != 0); ATF_REQUIRE(errno == EFAULT); } ATF_TC(getrusage_sig); ATF_TC_HEAD(getrusage_sig, tc) { atf_tc_set_md_var(tc, "descr", "Test signal count with getrusage(2)"); } ATF_TC_BODY(getrusage_sig, tc) { struct rusage ru; const long n = 5; int i; /* * Test that signals are recorded. */ ATF_REQUIRE(signal(SIGUSR1, sighandler) != SIG_ERR); for (i = 0; i < n; i++) ATF_REQUIRE(raise(SIGUSR1) == 0); (void)memset(&ru, 0, sizeof(struct rusage)); ATF_REQUIRE(getrusage(RUSAGE_SELF, &ru) == 0); if (n != ru.ru_nsignals) atf_tc_fail("getrusage(2) did not record signals"); } ATF_TC(getrusage_utime_back); ATF_TC_HEAD(getrusage_utime_back, tc) { atf_tc_set_md_var(tc, "descr", "Test bogus values from getrusage(2)"); } ATF_TC_BODY(getrusage_utime_back, tc) { struct rusage ru1, ru2; size_t i; /* * Test that two consecutive calls are sane. */ #ifdef __NetBSD__ atf_tc_expect_fail("PR kern/30115"); #endif for (i = 0; i < maxiter; i++) { (void)memset(&ru1, 0, sizeof(struct rusage)); (void)memset(&ru2, 0, sizeof(struct rusage)); work(); ATF_REQUIRE(getrusage(RUSAGE_SELF, &ru1) == 0); work(); ATF_REQUIRE(getrusage(RUSAGE_SELF, &ru2) == 0); if (timercmp(&ru2.ru_utime, &ru1.ru_utime, <) != 0) atf_tc_fail("user time went backwards"); } #ifdef __NetBSD__ atf_tc_fail("anticipated error did not occur"); #endif } ATF_TC(getrusage_utime_zero); ATF_TC_HEAD(getrusage_utime_zero, tc) { atf_tc_set_md_var(tc, "descr", "Test zero utime from getrusage(2)"); } ATF_TC_BODY(getrusage_utime_zero, tc) { struct rusage ru; size_t i; #ifdef __FreeBSD__ atf_tc_skip("this testcase passes/fails sporadically on FreeBSD/i386 " "@ r273153 (at least)"); #endif /* * Test that getrusage(2) does not return * zero user time for the calling process. * * See also (duplicate) PR port-amd64/41734. */ atf_tc_expect_fail("PR kern/30115"); for (i = 0; i < maxiter; i++) { work(); (void)memset(&ru, 0, sizeof(struct rusage)); ATF_REQUIRE(getrusage(RUSAGE_SELF, &ru) == 0); if (ru.ru_utime.tv_sec == 0 && ru.ru_utime.tv_usec == 0) atf_tc_fail("zero user time from getrusage(2)"); } atf_tc_fail("anticipated error did not occur"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, getrusage_err); ATF_TP_ADD_TC(tp, getrusage_sig); ATF_TP_ADD_TC(tp, getrusage_utime_back); ATF_TP_ADD_TC(tp, getrusage_utime_zero); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_link.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_link.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_link.c (revision 312126) @@ -1,233 +1,234 @@ -/* $NetBSD: t_link.c,v 1.2 2014/04/21 14:39:36 martin Exp $ */ +/* $NetBSD: t_link.c,v 1.3 2017/01/13 20:42:36 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_link.c,v 1.2 2014/04/21 14:39:36 martin Exp $"); +__RCSID("$NetBSD: t_link.c,v 1.3 2017/01/13 20:42:36 christos Exp $"); #include #include #include #include #include +#include #include #include #include #ifdef __FreeBSD__ #include #endif static const char *getpath(void); static char path[] = "link"; static const char *pathl; static const char * getpath(void) { static char buf[LINE_MAX]; (void)memset(buf, '\0', sizeof(buf)); if (getcwd(buf, sizeof(buf)) == NULL) return NULL; (void)strlcat(buf, path, sizeof(buf)); (void)strlcat(buf, ".link", sizeof(buf)); return buf; } ATF_TC_WITH_CLEANUP(link_count); ATF_TC_HEAD(link_count, tc) { atf_tc_set_md_var(tc, "descr", "link(2) counts are incremented?"); } ATF_TC_BODY(link_count, tc) { struct stat sa, sb; int fd; (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); pathl = getpath(); fd = open(path, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); ATF_REQUIRE(pathl != NULL); ATF_REQUIRE(stat(path, &sa) == 0); ATF_REQUIRE(link(path, pathl) == 0); ATF_REQUIRE(stat(path, &sb) == 0); if (sa.st_nlink != sb.st_nlink - 1) atf_tc_fail("incorrect link(2) count"); ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(unlink(path) == 0); ATF_REQUIRE(unlink(pathl) == 0); } ATF_TC_CLEANUP(link_count, tc) { (void)unlink(path); (void)unlink(pathl); } ATF_TC_WITH_CLEANUP(link_err); ATF_TC_HEAD(link_err, tc) { atf_tc_set_md_var(tc, "descr", "Test error conditions of link(2)"); } ATF_TC_BODY(link_err, tc) { char buf[MAXPATHLEN + 1]; int fd; (void)memset(buf, 'x', sizeof(buf)); pathl = getpath(); fd = open(path, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); ATF_REQUIRE(pathl != NULL); errno = 0; ATF_REQUIRE(link(path, pathl) == 0); ATF_REQUIRE_ERRNO(EEXIST, link(path, pathl) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENAMETOOLONG, link(buf, "xxx") == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOENT, link(path, "/d/c/b/a") == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOENT, link("/a/b/c/d", path) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOENT, link("/a/b/c/d", "/d/c/b/a") == -1); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, link(path, (const char *)-1) == -1); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, link((const char *)-1, "xxx") == -1); ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(unlink(path) == 0); ATF_REQUIRE(unlink(pathl) == 0); } ATF_TC_CLEANUP(link_err, tc) { (void)unlink(path); (void)unlink(pathl); } ATF_TC(link_perm); ATF_TC_HEAD(link_perm, tc) { atf_tc_set_md_var(tc, "descr", "Test permissions with link(2)"); atf_tc_set_md_var(tc, "require.user", "unprivileged"); } ATF_TC_BODY(link_perm, tc) { int rv; errno = 0; rv = link("/root", "/root.link"); ATF_REQUIRE_MSG(rv == -1 && (errno == EACCES || errno == EPERM), "link to a directory did not fail with EPERM or EACCESS; link() " "returned %d, errno %d", rv, errno); errno = 0; ATF_REQUIRE_ERRNO(EACCES, link("/root/.profile", "/root/.profile.link") == -1); } ATF_TC_WITH_CLEANUP(link_stat); ATF_TC_HEAD(link_stat, tc) { atf_tc_set_md_var(tc, "descr", "Check stat(2) of a linked file"); } ATF_TC_BODY(link_stat, tc) { struct stat sa, sb; int fd; (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); pathl = getpath(); fd = open(path, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); ATF_REQUIRE(pathl != NULL); ATF_REQUIRE(link(path, pathl) == 0); ATF_REQUIRE(stat(path, &sa) == 0); ATF_REQUIRE(lstat(pathl, &sb) == 0); if (sa.st_uid != sb.st_uid) atf_tc_fail("unequal UIDs"); if (sa.st_mode != sb.st_mode) atf_tc_fail("unequal modes"); if (sa.st_ino != sb.st_ino) atf_tc_fail("unequal inodes"); ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(unlink(path) == 0); ATF_REQUIRE(unlink(pathl) == 0); } ATF_TC_CLEANUP(link_stat, tc) { (void)unlink(path); (void)unlink(pathl); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, link_count); ATF_TP_ADD_TC(tp, link_err); ATF_TP_ADD_TC(tp, link_perm); ATF_TP_ADD_TC(tp, link_stat); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_listen.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_listen.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_listen.c (revision 312126) @@ -1,141 +1,140 @@ -/* $NetBSD: t_listen.c,v 1.4 2012/03/18 07:00:52 jruoho Exp $ */ +/* $NetBSD: t_listen.c,v 1.5 2017/01/13 20:41:50 christos Exp $ */ /* * Copyright (c) 2007 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 #include #include #ifdef __FreeBSD__ #include #endif static const char *path = "listen"; ATF_TC_WITH_CLEANUP(listen_err); ATF_TC_HEAD(listen_err, tc) { atf_tc_set_md_var(tc, "descr", "Checks errors from listen(2) (PR standards/46150)"); } ATF_TC_BODY(listen_err, tc) { static const size_t siz = sizeof(struct sockaddr_in); struct sockaddr_in sina, sinb; int fda, fdb, fdc; (void)memset(&sina, 0, sizeof(struct sockaddr_in)); (void)memset(&sinb, 0, sizeof(struct sockaddr_in)); sina.sin_family = AF_INET; sina.sin_port = htons(31522); sina.sin_addr.s_addr = inet_addr("127.0.0.1"); sinb.sin_family = AF_INET; sinb.sin_port = htons(31522); sinb.sin_addr.s_addr = inet_addr("127.0.0.1"); fda = socket(AF_INET, SOCK_STREAM, 0); fdb = socket(AF_INET, SOCK_STREAM, 0); fdc = open("listen", O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fda >= 0 && fdb >= 0 && fdc >= 0); ATF_REQUIRE_ERRNO(ENOTSOCK, listen(fdc, 1) == -1); (void)close(fdc); (void)unlink(path); ATF_REQUIRE(bind(fda, (struct sockaddr *)&sina, siz) == 0); ATF_REQUIRE(listen(fda, 1) == 0); /* * According to IEEE Std 1003.1-2008: if the socket is * already connected, the call should fail with EINVAL. */ ATF_REQUIRE(connect(fdb, (struct sockaddr *)&sinb, siz) == 0); ATF_REQUIRE_ERRNO(EINVAL, listen(fdb, 1) == -1); (void)close(fda); (void)close(fdb); ATF_REQUIRE_ERRNO(EBADF, connect(fdb, (struct sockaddr *)&sinb, siz) == -1); } ATF_TC_CLEANUP(listen_err, tc) { (void)unlink(path); } ATF_TC(listen_low_port); ATF_TC_HEAD(listen_low_port, tc) { atf_tc_set_md_var(tc, "descr", "Does low-port allocation work?"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(listen_low_port, tc) { int sd, val; sd = socket(AF_INET, SOCK_STREAM, 0); -#ifdef __FreeBSD__ ATF_REQUIRE_MSG(sd != -1, "socket failed: %s", strerror(errno)); -#endif val = IP_PORTRANGE_LOW; if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, &val, sizeof(val)) == -1) atf_tc_fail("setsockopt failed: %s", strerror(errno)); if (listen(sd, 5) == -1) { int serrno = errno; atf_tc_fail("listen failed: %s%s", strerror(serrno), serrno != EACCES ? "" : " (see http://mail-index.netbsd.org/" "source-changes/2007/12/16/0011.html)"); } close(sd); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, listen_err); ATF_TP_ADD_TC(tp, listen_low_port); return 0; } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_mmap.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_mmap.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_mmap.c (revision 312126) @@ -1,605 +1,601 @@ -/* $NetBSD: t_mmap.c,v 1.10 2017/01/10 22:36:29 christos Exp $ */ +/* $NetBSD: t_mmap.c,v 1.11 2017/01/13 20:43:11 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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)2004 YAMAMOTO Takashi, * 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. */ #include -__RCSID("$NetBSD: t_mmap.c,v 1.10 2017/01/10 22:36:29 christos Exp $"); +__RCSID("$NetBSD: t_mmap.c,v 1.11 2017/01/13 20:43:11 christos Exp $"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __NetBSD__ #include #endif #ifdef __FreeBSD__ #include #include #endif static long page = 0; static char path[] = "mmap"; static void map_check(void *, int); static void map_sighandler(int); static void testloan(void *, void *, char, int); #define BUFSIZE (32 * 1024) /* enough size to trigger sosend_loan */ static void map_check(void *map, int flag) { if (flag != 0) { ATF_REQUIRE(map == MAP_FAILED); return; } ATF_REQUIRE(map != MAP_FAILED); ATF_REQUIRE(munmap(map, page) == 0); } void testloan(void *vp, void *vp2, char pat, int docheck) { char buf[BUFSIZE]; char backup[BUFSIZE]; ssize_t nwritten; ssize_t nread; int fds[2]; int val; val = BUFSIZE; if (docheck != 0) (void)memcpy(backup, vp, BUFSIZE); if (socketpair(AF_LOCAL, SOCK_STREAM, PF_UNSPEC, fds) != 0) atf_tc_fail("socketpair() failed"); val = BUFSIZE; if (setsockopt(fds[1], SOL_SOCKET, SO_RCVBUF, &val, sizeof(val)) != 0) atf_tc_fail("setsockopt() failed, SO_RCVBUF"); val = BUFSIZE; if (setsockopt(fds[0], SOL_SOCKET, SO_SNDBUF, &val, sizeof(val)) != 0) atf_tc_fail("setsockopt() failed, SO_SNDBUF"); if (fcntl(fds[0], F_SETFL, O_NONBLOCK) != 0) atf_tc_fail("fcntl() failed"); nwritten = write(fds[0], (char *)vp + page, BUFSIZE - page); if (nwritten == -1) atf_tc_fail("write() failed"); /* Break loan. */ (void)memset(vp2, pat, BUFSIZE); nread = read(fds[1], buf + page, BUFSIZE - page); if (nread == -1) atf_tc_fail("read() failed"); if (nread != nwritten) atf_tc_fail("too short read"); if (docheck != 0 && memcmp(backup, buf + page, nread) != 0) atf_tc_fail("data mismatch"); ATF_REQUIRE(close(fds[0]) == 0); ATF_REQUIRE(close(fds[1]) == 0); } static void map_sighandler(int signo) { _exit(signo); } #ifdef __NetBSD__ ATF_TC(mmap_block); ATF_TC_HEAD(mmap_block, tc) { atf_tc_set_md_var(tc, "descr", "Test mmap(2) with a block device"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(mmap_block, tc) { static const int mib[] = { CTL_HW, HW_DISKNAMES }; static const unsigned int miblen = __arraycount(mib); char *map, *dk, *drives, dev[PATH_MAX]; size_t len; int fd = -1; atf_tc_skip("The test case causes a panic (PR kern/38889, kern/46592)"); ATF_REQUIRE(sysctl(mib, miblen, NULL, &len, NULL, 0) == 0); drives = malloc(len); ATF_REQUIRE(drives != NULL); ATF_REQUIRE(sysctl(mib, miblen, drives, &len, NULL, 0) == 0); for (dk = strtok(drives, " "); dk != NULL; dk = strtok(NULL, " ")) { sprintf(dev, _PATH_DEV "%s%c", dk, 'a'+RAW_PART); fprintf(stderr, "trying: %s\n", dev); if ((fd = open(dev, O_RDONLY)) >= 0) { (void)fprintf(stderr, "using %s\n", dev); break; } } free(drives); if (fd < 0) atf_tc_skip("failed to find suitable block device"); map = mmap(NULL, 4096, PROT_READ, MAP_FILE, fd, 0); ATF_REQUIRE(map != MAP_FAILED); (void)fprintf(stderr, "first byte %x\n", *map); ATF_REQUIRE(close(fd) == 0); (void)fprintf(stderr, "first byte %x\n", *map); ATF_REQUIRE(munmap(map, 4096) == 0); } #endif ATF_TC(mmap_err); ATF_TC_HEAD(mmap_err, tc) { atf_tc_set_md_var(tc, "descr", "Test error conditions of mmap(2)"); } ATF_TC_BODY(mmap_err, tc) { size_t addr = SIZE_MAX; void *map; errno = 0; map = mmap(NULL, 3, PROT_READ, MAP_FILE|MAP_PRIVATE, -1, 0); ATF_REQUIRE(map == MAP_FAILED); ATF_REQUIRE(errno == EBADF); errno = 0; map = mmap(&addr, page, PROT_READ, MAP_FIXED|MAP_PRIVATE, -1, 0); ATF_REQUIRE(map == MAP_FAILED); ATF_REQUIRE(errno == EINVAL); errno = 0; map = mmap(NULL, page, PROT_READ, MAP_ANON|MAP_PRIVATE, INT_MAX, 0); ATF_REQUIRE(map == MAP_FAILED); ATF_REQUIRE(errno == EINVAL); } ATF_TC_WITH_CLEANUP(mmap_loan); ATF_TC_HEAD(mmap_loan, tc) { atf_tc_set_md_var(tc, "descr", "Test uvm page loanout with mmap(2)"); } ATF_TC_BODY(mmap_loan, tc) { char buf[BUFSIZE]; char *vp, *vp2; int fd; fd = open(path, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); (void)memset(buf, 'x', sizeof(buf)); (void)write(fd, buf, sizeof(buf)); vp = mmap(NULL, BUFSIZE, PROT_READ | PROT_WRITE, MAP_FILE | MAP_PRIVATE, fd, 0); ATF_REQUIRE(vp != MAP_FAILED); vp2 = vp; testloan(vp, vp2, 'A', 0); testloan(vp, vp2, 'B', 1); ATF_REQUIRE(munmap(vp, BUFSIZE) == 0); vp = mmap(NULL, BUFSIZE, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0); vp2 = mmap(NULL, BUFSIZE, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0); ATF_REQUIRE(vp != MAP_FAILED); ATF_REQUIRE(vp2 != MAP_FAILED); testloan(vp, vp2, 'E', 1); ATF_REQUIRE(munmap(vp, BUFSIZE) == 0); ATF_REQUIRE(munmap(vp2, BUFSIZE) == 0); } ATF_TC_CLEANUP(mmap_loan, tc) { (void)unlink(path); } ATF_TC_WITH_CLEANUP(mmap_prot_1); ATF_TC_HEAD(mmap_prot_1, tc) { atf_tc_set_md_var(tc, "descr", "Test mmap(2) protections, #1"); } ATF_TC_BODY(mmap_prot_1, tc) { void *map; int fd; /* * Open a file write-only and try to * map it read-only. This should fail. */ fd = open(path, O_WRONLY | O_CREAT, 0700); if (fd < 0) return; ATF_REQUIRE(write(fd, "XXX", 3) == 3); map = mmap(NULL, 3, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0); map_check(map, 1); map = mmap(NULL, 3, PROT_WRITE, MAP_FILE|MAP_PRIVATE, fd, 0); map_check(map, 0); ATF_REQUIRE(close(fd) == 0); } ATF_TC_CLEANUP(mmap_prot_1, tc) { (void)unlink(path); } ATF_TC(mmap_prot_2); ATF_TC_HEAD(mmap_prot_2, tc) { atf_tc_set_md_var(tc, "descr", "Test mmap(2) protections, #2"); } ATF_TC_BODY(mmap_prot_2, tc) { char buf[2]; void *map; pid_t pid; int sta; /* * Make a PROT_NONE mapping and try to access it. * If we catch a SIGSEGV, all works as expected. */ map = mmap(NULL, page, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0); ATF_REQUIRE(map != MAP_FAILED); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { ATF_REQUIRE(signal(SIGSEGV, map_sighandler) != SIG_ERR); ATF_REQUIRE(strlcpy(buf, map, sizeof(buf)) != 0); } (void)wait(&sta); ATF_REQUIRE(WIFEXITED(sta) != 0); ATF_REQUIRE(WEXITSTATUS(sta) == SIGSEGV); ATF_REQUIRE(munmap(map, page) == 0); } ATF_TC_WITH_CLEANUP(mmap_prot_3); ATF_TC_HEAD(mmap_prot_3, tc) { atf_tc_set_md_var(tc, "descr", "Test mmap(2) protections, #3"); } ATF_TC_BODY(mmap_prot_3, tc) { char buf[2]; int fd, sta; void *map; pid_t pid; /* * Open a file, change the permissions * to read-only, and try to map it as * PROT_NONE. This should succeed, but * the access should generate SIGSEGV. */ fd = open(path, O_RDWR | O_CREAT, 0700); if (fd < 0) #ifdef __FreeBSD__ atf_tc_skip("opening %s failed; skipping testcase: %s", path, strerror(errno)); #else return; #endif ATF_REQUIRE(write(fd, "XXX", 3) == 3); ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(chmod(path, 0444) == 0); fd = open(path, O_RDONLY); ATF_REQUIRE(fd != -1); map = mmap(NULL, 3, PROT_NONE, MAP_FILE | MAP_SHARED, fd, 0); ATF_REQUIRE(map != MAP_FAILED); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { ATF_REQUIRE(signal(SIGSEGV, map_sighandler) != SIG_ERR); ATF_REQUIRE(strlcpy(buf, map, sizeof(buf)) != 0); } (void)wait(&sta); ATF_REQUIRE(WIFEXITED(sta) != 0); ATF_REQUIRE(WEXITSTATUS(sta) == SIGSEGV); ATF_REQUIRE(munmap(map, 3) == 0); #ifdef __FreeBSD__ (void)close(fd); #endif } ATF_TC_CLEANUP(mmap_prot_3, tc) { (void)unlink(path); } ATF_TC_WITH_CLEANUP(mmap_truncate); ATF_TC_HEAD(mmap_truncate, tc) { atf_tc_set_md_var(tc, "descr", "Test mmap(2) and ftruncate(2)"); } ATF_TC_BODY(mmap_truncate, tc) { char *map; long i; int fd; fd = open(path, O_RDWR | O_CREAT, 0700); if (fd < 0) return; /* * See that ftruncate(2) works * while the file is mapped. */ ATF_REQUIRE(ftruncate(fd, page) == 0); map = mmap(NULL, page, PROT_READ | PROT_WRITE, MAP_FILE|MAP_PRIVATE, fd, 0); ATF_REQUIRE(map != MAP_FAILED); for (i = 0; i < page; i++) map[i] = 'x'; ATF_REQUIRE(ftruncate(fd, 0) == 0); ATF_REQUIRE(ftruncate(fd, page / 8) == 0); ATF_REQUIRE(ftruncate(fd, page / 4) == 0); ATF_REQUIRE(ftruncate(fd, page / 2) == 0); ATF_REQUIRE(ftruncate(fd, page / 12) == 0); ATF_REQUIRE(ftruncate(fd, page / 64) == 0); -#ifdef __FreeBSD__ (void)munmap(map, page); -#endif ATF_REQUIRE(close(fd) == 0); } ATF_TC_CLEANUP(mmap_truncate, tc) { (void)unlink(path); } ATF_TC_WITH_CLEANUP(mmap_truncate_signal); ATF_TC_HEAD(mmap_truncate_signal, tc) { atf_tc_set_md_var(tc, "descr", "Test mmap(2) ftruncate(2) causing signal"); } ATF_TC_BODY(mmap_truncate_signal, tc) { char *map; long i; int fd, sta; pid_t pid; #ifdef __FreeBSD__ atf_tc_expect_fail("testcase fails with SIGSEGV on FreeBSD; bug # 211924"); #endif fd = open(path, O_RDWR | O_CREAT, 0700); if (fd < 0) return; ATF_REQUIRE(write(fd, "foo\n", 5) == 5); map = mmap(NULL, page, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0); ATF_REQUIRE(map != MAP_FAILED); sta = 0; for (i = 0; i < 5; i++) sta += map[i]; ATF_REQUIRE(sta == 334); ATF_REQUIRE(ftruncate(fd, 0) == 0); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { ATF_REQUIRE(signal(SIGBUS, map_sighandler) != SIG_ERR); ATF_REQUIRE(signal(SIGSEGV, map_sighandler) != SIG_ERR); sta = 0; for (i = 0; i < page; i++) sta += map[i]; /* child never will get this far, but the compiler will not know, so better use the values calculated to prevent the access to be optimized out */ ATF_REQUIRE(i == 0); ATF_REQUIRE(sta == 0); -#ifdef __FreeBSD__ (void)munmap(map, page); (void)close(fd); -#endif return; } (void)wait(&sta); ATF_REQUIRE(WIFEXITED(sta) != 0); if (WEXITSTATUS(sta) == SIGSEGV) atf_tc_fail("child process got SIGSEGV instead of SIGBUS"); ATF_REQUIRE(WEXITSTATUS(sta) == SIGBUS); ATF_REQUIRE(munmap(map, page) == 0); ATF_REQUIRE(close(fd) == 0); } ATF_TC_CLEANUP(mmap_truncate_signal, tc) { (void)unlink(path); } ATF_TC(mmap_va0); ATF_TC_HEAD(mmap_va0, tc) { atf_tc_set_md_var(tc, "descr", "Test mmap(2) and vm.user_va0_disable"); } ATF_TC_BODY(mmap_va0, tc) { int flags = MAP_ANON | MAP_FIXED | MAP_PRIVATE; size_t len = sizeof(int); void *map; int val; /* * Make an anonymous fixed mapping at zero address. If the address * is restricted as noted in security(7), the syscall should fail. */ #ifdef __FreeBSD__ if (sysctlbyname("security.bsd.map_at_zero", &val, &len, NULL, 0) != 0) atf_tc_fail("failed to read security.bsd.map_at_zero"); val = !val; /* 1 == enable map at zero */ #endif #ifdef __NetBSD__ if (sysctlbyname("vm.user_va0_disable", &val, &len, NULL, 0) != 0) atf_tc_fail("failed to read vm.user_va0_disable"); #endif map = mmap(NULL, page, PROT_EXEC, flags, -1, 0); map_check(map, val); map = mmap(NULL, page, PROT_READ, flags, -1, 0); map_check(map, val); map = mmap(NULL, page, PROT_WRITE, flags, -1, 0); map_check(map, val); map = mmap(NULL, page, PROT_READ|PROT_WRITE, flags, -1, 0); map_check(map, val); map = mmap(NULL, page, PROT_EXEC|PROT_READ|PROT_WRITE, flags, -1, 0); map_check(map, val); } ATF_TP_ADD_TCS(tp) { page = sysconf(_SC_PAGESIZE); ATF_REQUIRE(page >= 0); #ifdef __NetBSD__ ATF_TP_ADD_TC(tp, mmap_block); #endif ATF_TP_ADD_TC(tp, mmap_err); ATF_TP_ADD_TC(tp, mmap_loan); ATF_TP_ADD_TC(tp, mmap_prot_1); ATF_TP_ADD_TC(tp, mmap_prot_2); ATF_TP_ADD_TC(tp, mmap_prot_3); ATF_TP_ADD_TC(tp, mmap_truncate); ATF_TP_ADD_TC(tp, mmap_truncate_signal); ATF_TP_ADD_TC(tp, mmap_va0); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c (revision 312126) @@ -1,362 +1,363 @@ -/* $NetBSD: t_msgctl.c,v 1.4 2014/02/27 00:59:50 joerg Exp $ */ +/* $NetBSD: t_msgctl.c,v 1.5 2017/01/13 20:44:45 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_msgctl.c,v 1.4 2014/02/27 00:59:50 joerg Exp $"); +__RCSID("$NetBSD: t_msgctl.c,v 1.5 2017/01/13 20:44:45 christos Exp $"); #include #include #include #include #include #include +#include #include #include #include #include #include #include #include #ifdef __FreeBSD__ #include #endif #define MSG_KEY 12345689 #define MSG_MTYPE_1 0x41 struct msg { long mtype; char buf[3]; }; static void clean(void); static void clean(void) { int id; if ((id = msgget(MSG_KEY, 0)) != -1) (void)msgctl(id, IPC_RMID, 0); } ATF_TC_WITH_CLEANUP(msgctl_err); ATF_TC_HEAD(msgctl_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from msgctl(2)"); } ATF_TC_BODY(msgctl_err, tc) { const int cmd[] = { IPC_STAT, IPC_SET, IPC_RMID }; struct msqid_ds msgds; size_t i; int id; (void)memset(&msgds, 0, sizeof(struct msqid_ds)); id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); errno = 0; ATF_REQUIRE_ERRNO(EINVAL, msgctl(id, INT_MAX, &msgds) == -1); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, msgctl(id, IPC_STAT, (void *)-1) == -1); for (i = 0; i < __arraycount(cmd); i++) { errno = 0; ATF_REQUIRE_ERRNO(EINVAL, msgctl(-1, cmd[i], &msgds) == -1); } ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgctl_err, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgctl_perm); ATF_TC_HEAD(msgctl_perm, tc) { atf_tc_set_md_var(tc, "descr", "Test permissions with msgctl(2)"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(msgctl_perm, tc) { struct msqid_ds msgds; struct passwd *pw; pid_t pid; int sta; int id; (void)memset(&msgds, 0, sizeof(struct msqid_ds)); pw = getpwnam("nobody"); id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); ATF_REQUIRE(pw != NULL); ATF_REQUIRE(msgctl(id, IPC_STAT, &msgds) == 0); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { if (setuid(pw->pw_uid) != 0) _exit(EX_OSERR); msgds.msg_perm.uid = getuid(); msgds.msg_perm.gid = getgid(); errno = 0; if (msgctl(id, IPC_SET, &msgds) == 0) _exit(EXIT_FAILURE); if (errno != EPERM) _exit(EXIT_FAILURE); (void)memset(&msgds, 0, sizeof(struct msqid_ds)); if (msgctl(id, IPC_STAT, &msgds) != 0) _exit(EX_OSERR); msgds.msg_qbytes = 1; if (msgctl(id, IPC_SET, &msgds) == 0) _exit(EXIT_FAILURE); if (errno != EPERM) _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); } (void)wait(&sta); if (WIFEXITED(sta) == 0) { if (WEXITSTATUS(sta) == EX_OSERR) atf_tc_fail("system call failed"); if (WEXITSTATUS(sta) == EXIT_FAILURE) atf_tc_fail("UID %u manipulated root's " "message queue", pw->pw_uid); } ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgctl_perm, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgctl_pid); ATF_TC_HEAD(msgctl_pid, tc) { atf_tc_set_md_var(tc, "descr", "Test that PIDs are updated"); } ATF_TC_BODY(msgctl_pid, tc) { struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; struct msqid_ds msgds; int id, sta; pid_t pid; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { (void)msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT); _exit(EXIT_SUCCESS); } (void)sleep(1); (void)wait(&sta); (void)memset(&msgds, 0, sizeof(struct msqid_ds)); ATF_REQUIRE(msgctl(id, IPC_STAT, &msgds) == 0); if (pid != msgds.msg_lspid) atf_tc_fail("the PID of last msgsnd(2) was not updated"); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { (void)msgrcv(id, &msg, sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT); _exit(EXIT_SUCCESS); } (void)sleep(1); (void)wait(&sta); (void)memset(&msgds, 0, sizeof(struct msqid_ds)); ATF_REQUIRE(msgctl(id, IPC_STAT, &msgds) == 0); if (pid != msgds.msg_lrpid) atf_tc_fail("the PID of last msgrcv(2) was not updated"); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgctl_pid, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgctl_set); ATF_TC_HEAD(msgctl_set, tc) { atf_tc_set_md_var(tc, "descr", "Test msgctl(2) with IPC_SET"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(msgctl_set, tc) { struct msqid_ds msgds; struct passwd *pw; int id; (void)memset(&msgds, 0, sizeof(struct msqid_ds)); pw = getpwnam("nobody"); id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); ATF_REQUIRE(pw != NULL); ATF_REQUIRE(msgctl(id, IPC_STAT, &msgds) == 0); msgds.msg_perm.uid = pw->pw_uid; if (msgctl(id, IPC_SET, &msgds) != 0) atf_tc_fail("root failed to change the UID of message queue"); msgds.msg_perm.uid = getuid(); msgds.msg_perm.gid = pw->pw_gid; if (msgctl(id, IPC_SET, &msgds) != 0) atf_tc_fail("root failed to change the GID of message queue"); /* * Note: setting the qbytes to zero fails even as root. */ msgds.msg_qbytes = 1; msgds.msg_perm.gid = getgid(); if (msgctl(id, IPC_SET, &msgds) != 0) atf_tc_fail("root failed to change qbytes of message queue"); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgctl_set, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgctl_time); ATF_TC_HEAD(msgctl_time, tc) { atf_tc_set_md_var(tc, "descr", "Test that access times are updated"); } ATF_TC_BODY(msgctl_time, tc) { struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; struct msqid_ds msgds; time_t t; int id; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); t = time(NULL); (void)memset(&msgds, 0, sizeof(struct msqid_ds)); (void)msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT); (void)msgctl(id, IPC_STAT, &msgds); if (llabs(t - msgds.msg_stime) > 1) atf_tc_fail("time of last msgsnd(2) was not updated"); if (msgds.msg_rtime != 0) atf_tc_fail("time of last msgrcv(2) was updated incorrectly"); t = time(NULL); (void)memset(&msgds, 0, sizeof(struct msqid_ds)); (void)msgrcv(id, &msg, sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT); (void)msgctl(id, IPC_STAT, &msgds); if (llabs(t - msgds.msg_rtime) > 1) atf_tc_fail("time of last msgrcv(2) was not updated"); /* * Note: this is non-zero even after the memset(3). */ if (msgds.msg_stime == 0) atf_tc_fail("time of last msgsnd(2) was updated incorrectly"); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgctl_time, tc) { clean(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, msgctl_err); ATF_TP_ADD_TC(tp, msgctl_perm); ATF_TP_ADD_TC(tp, msgctl_pid); ATF_TP_ADD_TC(tp, msgctl_set); ATF_TP_ADD_TC(tp, msgctl_time); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_msgrcv.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_msgrcv.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_msgrcv.c (revision 312126) @@ -1,346 +1,347 @@ -/* $NetBSD: t_msgrcv.c,v 1.3 2013/07/24 11:44:10 skrll Exp $ */ +/* $NetBSD: t_msgrcv.c,v 1.4 2017/01/13 20:44:45 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_msgrcv.c,v 1.3 2013/07/24 11:44:10 skrll Exp $"); +__RCSID("$NetBSD: t_msgrcv.c,v 1.4 2017/01/13 20:44:45 christos Exp $"); #include #include #include #include #include #include +#include #include #include #include #include #include #include #include #include #ifdef __FreeBSD__ #include #endif #define MSG_KEY 1234 #define MSG_MTYPE_1 0x41 #define MSG_MTYPE_2 0x42 #define MSG_MTYPE_3 0x43 #define MSG_LEN 3 struct msg { long mtype; char buf[MSG_LEN]; }; static void clean(void); static void clean(void) { int id; if ((id = msgget(MSG_KEY, 0)) != -1) (void)msgctl(id, IPC_RMID, 0); } ATF_TC_WITH_CLEANUP(msgrcv_basic); ATF_TC_HEAD(msgrcv_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of msgrcv(2)"); } ATF_TC_BODY(msgrcv_basic, tc) { struct msg msg1 = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; struct msg msg2 = { MSG_MTYPE_1, { 'x', 'y', 'z' } }; int id; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); (void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT); (void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT); ATF_CHECK(msg1.buf[0] == msg2.buf[0]); ATF_CHECK(msg1.buf[1] == msg2.buf[1]); ATF_CHECK(msg1.buf[2] == msg2.buf[2]); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgrcv_basic, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgrcv_block); ATF_TC_HEAD(msgrcv_block, tc) { atf_tc_set_md_var(tc, "descr", "Test that msgrcv(2) blocks"); } ATF_TC_BODY(msgrcv_block, tc) { struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; int id, sta; pid_t pid; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { if (msgrcv(id, &msg, MSG_LEN, MSG_MTYPE_1, 0) < 0) _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); } /* * Below msgsnd(2) should unblock the child, * and hence kill(2) should fail with ESRCH. */ (void)sleep(1); (void)msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT); (void)sleep(1); (void)kill(pid, SIGKILL); (void)wait(&sta); if (WIFEXITED(sta) == 0 || WIFSIGNALED(sta) != 0) atf_tc_fail("msgrcv(2) did not block"); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgrcv_block, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgrcv_err); ATF_TC_HEAD(msgrcv_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from msgrcv(2)"); } ATF_TC_BODY(msgrcv_err, tc) { struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; int id, r = 0; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); errno = 0; ATF_REQUIRE_ERRNO(ENOMSG, msgrcv(id, &msg, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1); ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, msgrcv(id, (void *)-1, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1); errno = 0; ATF_REQUIRE_ERRNO(EINVAL, msgrcv(-1, &msg, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1); errno = 0; ATF_REQUIRE_ERRNO(EINVAL, msgrcv(-1, &msg, SSIZE_MAX, MSG_MTYPE_1, IPC_NOWAIT) == -1); ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0); errno = 0; ATF_REQUIRE_ERRNO(E2BIG, msgrcv(id, &r, MSG_LEN - 1, MSG_MTYPE_1, IPC_NOWAIT) == -1); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgrcv_err, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgrcv_mtype); ATF_TC_HEAD(msgrcv_mtype, tc) { atf_tc_set_md_var(tc, "descr", "Test message types with msgrcv(2)"); } ATF_TC_BODY(msgrcv_mtype, tc) { struct msg msg1 = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; struct msg msg2 = { MSG_MTYPE_3, { 'x', 'y', 'z' } }; int id; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); (void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT); (void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_2, IPC_NOWAIT); ATF_CHECK(msg1.buf[0] != msg2.buf[0]); /* Different mtype. */ ATF_CHECK(msg1.buf[1] != msg2.buf[1]); ATF_CHECK(msg1.buf[2] != msg2.buf[2]); (void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT); ATF_CHECK(msg1.buf[0] == msg2.buf[0]); /* Same mtype. */ ATF_CHECK(msg1.buf[1] == msg2.buf[1]); ATF_CHECK(msg1.buf[2] == msg2.buf[2]); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgrcv_mtype, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgrcv_nonblock); ATF_TC_HEAD(msgrcv_nonblock, tc) { atf_tc_set_md_var(tc, "descr", "Test msgrcv(2) with IPC_NOWAIT"); atf_tc_set_md_var(tc, "timeout", "10"); } ATF_TC_BODY(msgrcv_nonblock, tc) { struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; const ssize_t n = 10; int id, sta; ssize_t i; pid_t pid; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); for (i = 0; i < n; i++) { ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0); } pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { while (i != 0) { if (msgrcv(id, &msg, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1) _exit(EXIT_FAILURE); i--; } _exit(EXIT_SUCCESS); } (void)sleep(2); (void)kill(pid, SIGKILL); (void)wait(&sta); if (WIFSIGNALED(sta) != 0 || WTERMSIG(sta) == SIGKILL) atf_tc_fail("msgrcv(2) blocked with IPC_NOWAIT"); if (WIFEXITED(sta) == 0 && WEXITSTATUS(sta) != EXIT_SUCCESS) atf_tc_fail("msgrcv(2) failed"); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgrcv_nonblock, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgrcv_truncate); ATF_TC_HEAD(msgrcv_truncate, tc) { atf_tc_set_md_var(tc, "descr", "Test msgrcv(2) with MSG_NOERROR"); } ATF_TC_BODY(msgrcv_truncate, tc) { #define MSG_SMALLLEN 2 struct msgsmall { long mtype; char buf[MSG_SMALLLEN]; }; struct msg msg1 = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; struct msgsmall msg2 = { MSG_MTYPE_1, { 'x', 'y' } }; int id; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); (void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT); (void)msgrcv(id, &msg2, MSG_SMALLLEN, MSG_MTYPE_1, IPC_NOWAIT | MSG_NOERROR); ATF_CHECK(msg1.buf[0] == msg2.buf[0]); ATF_CHECK(msg1.buf[1] == msg2.buf[1]); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgrcv_truncate, tc) { clean(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, msgrcv_basic); ATF_TP_ADD_TC(tp, msgrcv_block); ATF_TP_ADD_TC(tp, msgrcv_err); ATF_TP_ADD_TC(tp, msgrcv_mtype); ATF_TP_ADD_TC(tp, msgrcv_nonblock); ATF_TP_ADD_TC(tp, msgrcv_truncate); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c (revision 312126) @@ -1,342 +1,343 @@ -/* $NetBSD: t_msgsnd.c,v 1.2 2011/11/05 08:47:54 jruoho Exp $ */ +/* $NetBSD: t_msgsnd.c,v 1.3 2017/01/13 20:44:45 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_msgsnd.c,v 1.2 2011/11/05 08:47:54 jruoho Exp $"); +__RCSID("$NetBSD: t_msgsnd.c,v 1.3 2017/01/13 20:44:45 christos Exp $"); #include #include #include #include #include #include +#include #include #include #include #include #include #include #include #include #ifdef __FreeBSD__ #include #endif #define MSG_KEY 1234 #define MSG_MTYPE_1 0x41 #define MSG_MTYPE_2 0x42 #define MSG_MTYPE_3 0x43 struct msg { long mtype; char buf[3]; }; static void clean(void); static void clean(void) { int id; if ((id = msgget(MSG_KEY, 0)) != -1) (void)msgctl(id, IPC_RMID, 0); } ATF_TC_WITH_CLEANUP(msgsnd_block); ATF_TC_HEAD(msgsnd_block, tc) { atf_tc_set_md_var(tc, "descr", "Test that msgsnd(2) blocks"); atf_tc_set_md_var(tc, "timeout", "10"); } ATF_TC_BODY(msgsnd_block, tc) { struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; int id, sta; pid_t pid; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { /* * Enqueue messages until some limit (e.g. the maximum * number of messages in the queue or the maximum number * of bytes in the queue) is reached. After this the call * should block when the IPC_NOWAIT is not set. */ for (;;) { if (msgsnd(id, &msg, sizeof(struct msg), 0) < 0) _exit(EXIT_FAILURE); } } (void)sleep(2); (void)kill(pid, SIGKILL); (void)wait(&sta); if (WIFEXITED(sta) != 0 || WIFSIGNALED(sta) == 0) atf_tc_fail("msgsnd(2) did not block"); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgsnd_block, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgsnd_count); ATF_TC_HEAD(msgsnd_count, tc) { atf_tc_set_md_var(tc, "descr", "Test that msgsnd(2) increments the amount of " "message in the queue, as given by msgctl(2)"); atf_tc_set_md_var(tc, "timeout", "10"); } ATF_TC_BODY(msgsnd_count, tc) { struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; struct msqid_ds ds; size_t i = 0; int id, rv; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); for (;;) { errno = 0; rv = msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT); if (rv == 0) { i++; continue; } if (rv == -1 && errno == EAGAIN) break; atf_tc_fail("failed to enqueue a message"); } (void)memset(&ds, 0, sizeof(struct msqid_ds)); (void)msgctl(id, IPC_STAT, &ds); if (ds.msg_qnum != i) atf_tc_fail("incorrect message count"); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgsnd_count, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgsnd_err); ATF_TC_HEAD(msgsnd_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from msgsnd(2)"); } ATF_TC_BODY(msgsnd_err, tc) { struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; int id; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, msgsnd(id, (void *)-1, sizeof(struct msg), IPC_NOWAIT) == -1); errno = 0; ATF_REQUIRE_ERRNO(EINVAL, msgsnd(-1, &msg, sizeof(struct msg), IPC_NOWAIT) == -1); errno = 0; ATF_REQUIRE_ERRNO(EINVAL, msgsnd(-1, &msg, SSIZE_MAX, IPC_NOWAIT) == -1); errno = 0; msg.mtype = 0; ATF_REQUIRE_ERRNO(EINVAL, msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT) == -1); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgsnd_err, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgsnd_nonblock); ATF_TC_HEAD(msgsnd_nonblock, tc) { atf_tc_set_md_var(tc, "descr", "Test msgsnd(2) with IPC_NOWAIT"); atf_tc_set_md_var(tc, "timeout", "10"); } ATF_TC_BODY(msgsnd_nonblock, tc) { struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; int id, rv, sta; pid_t pid; id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { for (;;) { errno = 0; rv = msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT); if (rv == -1 && errno == EAGAIN) _exit(EXIT_SUCCESS); } } (void)sleep(2); (void)kill(pid, SIGKILL); (void)wait(&sta); if (WIFEXITED(sta) == 0 || WIFSIGNALED(sta) != 0) atf_tc_fail("msgsnd(2) blocked with IPC_NOWAIT"); ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgsnd_nonblock, tc) { clean(); } ATF_TC_WITH_CLEANUP(msgsnd_perm); ATF_TC_HEAD(msgsnd_perm, tc) { atf_tc_set_md_var(tc, "descr", "Test permissions with msgsnd(2)"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(msgsnd_perm, tc) { struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } }; struct passwd *pw; int id, sta; pid_t pid; uid_t uid; pw = getpwnam("nobody"); id = msgget(MSG_KEY, IPC_CREAT | 0600); ATF_REQUIRE(id != -1); ATF_REQUIRE(pw != NULL); uid = pw->pw_uid; ATF_REQUIRE(uid != 0); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { /* * Try to enqueue a message to the queue * created by root as RW for owner only. */ if (setuid(uid) != 0) _exit(EX_OSERR); id = msgget(MSG_KEY, 0); if (id == -1) _exit(EX_OSERR); errno = 0; if (msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT) == 0) _exit(EXIT_FAILURE); if (errno != EACCES) _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); } (void)wait(&sta); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) { if (errno == EX_OSERR) atf_tc_fail("system call failed"); atf_tc_fail("UID %u enqueued message to root's queue", uid); } ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } ATF_TC_CLEANUP(msgsnd_perm, tc) { clean(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, msgsnd_block); ATF_TP_ADD_TC(tp, msgsnd_count); ATF_TP_ADD_TC(tp, msgsnd_err); ATF_TP_ADD_TC(tp, msgsnd_nonblock); ATF_TP_ADD_TC(tp, msgsnd_perm); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c (revision 312126) @@ -1,191 +1,187 @@ -/* $NetBSD: t_nanosleep.c,v 1.3 2013/03/31 16:47:16 christos Exp $ */ +/* $NetBSD: t_nanosleep.c,v 1.4 2017/01/13 21:15:14 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_nanosleep.c,v 1.3 2013/03/31 16:47:16 christos Exp $"); +__RCSID("$NetBSD: t_nanosleep.c,v 1.4 2017/01/13 21:15:14 christos Exp $"); #include #include #include #include #include #include #include #include #include #include #include static void -#ifdef __FreeBSD__ handler(int signo __unused) -#else -handler(int signo) -#endif { /* Nothing. */ } ATF_TC(nanosleep_basic); ATF_TC_HEAD(nanosleep_basic, tc) { atf_tc_set_md_var(tc, "descr", "Test that nanosleep(2) works"); } ATF_TC_BODY(nanosleep_basic, tc) { static const size_t maxiter = 10; struct timespec ts1, ts2, tsn; size_t i; for (i = 1; i < maxiter; i++) { tsn.tv_sec = 0; tsn.tv_nsec = i; (void)memset(&ts1, 0, sizeof(struct timespec)); (void)memset(&ts2, 0, sizeof(struct timespec)); ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC, &ts1) == 0); ATF_REQUIRE(nanosleep(&tsn, NULL) == 0); ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC, &ts2) == 0); /* * Verify that we slept at least one nanosecond. */ if (timespeccmp(&ts2, &ts1, <=) != 0) { (void)fprintf(stderr, "sleep time:: sec %llu, nsec %lu\n\t\t" "ts1: sec %llu, nsec %lu\n\t\t" "ts2: sec %llu, nsec %lu\n", (unsigned long long)tsn.tv_sec, tsn.tv_nsec, (unsigned long long)ts1.tv_sec, ts1.tv_nsec, (unsigned long long)ts2.tv_sec, ts2.tv_nsec); atf_tc_fail_nonfatal("inaccuracies in sleep time " "(resolution = %lu nsec)", tsn.tv_nsec); } } } ATF_TC(nanosleep_err); ATF_TC_HEAD(nanosleep_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from nanosleep(2) (PR bin/14558)"); } ATF_TC_BODY(nanosleep_err, tc) { struct timespec ts; ts.tv_sec = 1; ts.tv_nsec = -1; errno = 0; ATF_REQUIRE_ERRNO(EINVAL, nanosleep(&ts, NULL) == -1); ts.tv_sec = 1; ts.tv_nsec = 1000000000; errno = 0; ATF_REQUIRE_ERRNO(EINVAL, nanosleep(&ts, NULL) == -1); ts.tv_sec = -1; ts.tv_nsec = 0; errno = 0; ATF_REQUIRE_ERRNO(0, nanosleep(&ts, NULL) == 0); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, nanosleep((void *)-1, NULL) == -1); } ATF_TC(nanosleep_sig); ATF_TC_HEAD(nanosleep_sig, tc) { atf_tc_set_md_var(tc, "descr", "Test signal for nanosleep(2)"); } ATF_TC_BODY(nanosleep_sig, tc) { struct timespec tsn, tsr; pid_t pid; int sta; /* * Test that a signal interrupts nanosleep(2). * * (In which case the return value should be -1 and the * second parameter should contain the unslept time.) */ pid = fork(); ATF_REQUIRE(pid >= 0); ATF_REQUIRE(signal(SIGINT, handler) == 0); if (pid == 0) { tsn.tv_sec = 10; tsn.tv_nsec = 0; tsr.tv_sec = 0; tsr.tv_nsec = 0; errno = 0; if (nanosleep(&tsn, &tsr) != -1) _exit(EXIT_FAILURE); if (errno != EINTR) _exit(EXIT_FAILURE); if (tsr.tv_sec == 0 && tsr.tv_nsec == 0) _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); } (void)sleep(1); (void)kill(pid, SIGINT); (void)wait(&sta); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) atf_tc_fail("signal did not interrupt nanosleep(2)"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, nanosleep_basic); ATF_TP_ADD_TC(tp, nanosleep_err); ATF_TP_ADD_TC(tp, nanosleep_sig); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_pipe.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_pipe.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_pipe.c (revision 312126) @@ -1,166 +1,164 @@ -/* $NetBSD: t_pipe.c,v 1.3 2011/10/31 15:41:31 christos Exp $ */ +/* $NetBSD: t_pipe.c,v 1.5 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2001, 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_pipe.c,v 1.3 2011/10/31 15:41:31 christos Exp $"); +__RCSID("$NetBSD: t_pipe.c,v 1.5 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include #include #include #include #include -#include "../../../h_macros.h" +#include "h_macros.h" static pid_t pid; static int nsiginfo = 0; /* * This is used for both parent and child. Handle parent's SIGALRM, * the childs SIGINFO doesn't need anything. */ static void sighand(int sig) { if (sig == SIGALRM) { kill(pid, SIGINFO); } if (sig == SIGINFO) { nsiginfo++; } } ATF_TC(pipe_restart); ATF_TC_HEAD(pipe_restart, tc) { atf_tc_set_md_var(tc, "descr", "Checks that writing to pipe " "works correctly after being interrupted and restarted " "(kern/14087)"); } ATF_TC_BODY(pipe_restart, tc) { int pp[2], st; ssize_t sz, todo, done; char *f; sigset_t asigset, osigset, emptysigset; /* Initialise signal masks */ RL(sigemptyset(&emptysigset)); RL(sigemptyset(&asigset)); RL(sigaddset(&asigset, SIGINFO)); /* Register signal handlers for both read and writer */ REQUIRE_LIBC(signal(SIGINFO, sighand), SIG_ERR); REQUIRE_LIBC(signal(SIGALRM, sighand), SIG_ERR); todo = 2 * 1024 * 1024; REQUIRE_LIBC(f = malloc(todo), NULL); RL(pipe(pp)); RL(pid = fork()); if (pid == 0) { /* child */ RL(close(pp[1])); /* Do inital write. This should succeed, make * the other side do partial write and wait for us to pick * rest up. */ RL(done = read(pp[0], f, 128 * 1024)); /* Wait until parent is alarmed and awakens us */ RL(sigprocmask(SIG_BLOCK, &asigset, &osigset)); while (nsiginfo == 0) { if (sigsuspend(&emptysigset) != -1 || errno != EINTR) atf_tc_fail("sigsuspend(&emptysigset): %s", strerror(errno)); } RL(sigprocmask(SIG_SETMASK, &osigset, NULL)); /* Read all what parent wants to give us */ while((sz = read(pp[0], f, 1024 * 1024)) > 0) done += sz; /* * Exit with 1 if number of bytes read doesn't match * number of expected bytes */ printf("Read: %#zx\n", (size_t)done); printf("Expected: %#zx\n", (size_t)todo); exit(done != todo); /* NOTREACHED */ } else { RL(close(pp[0])); /* * Arrange for alarm after two seconds. Since we have * handler setup for SIGARLM, the write(2) call should * be restarted internally by kernel. */ (void)alarm(2); /* We write exactly 'todo' bytes. The very first write(2) * should partially succeed, block and eventually * be restarted by kernel */ while(todo > 0 && ((sz = write(pp[1], f, todo)) > 0)) todo -= sz; /* Close the pipe, so that child would stop reading */ RL(close(pp[1])); /* And pickup child's exit status */ RL(waitpid(pid, &st, 0)); ATF_REQUIRE_EQ(WEXITSTATUS(st), 0); } -#ifdef __FreeBSD__ free(f); -#endif } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, pipe_restart); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c (revision 312126) @@ -1,210 +1,207 @@ -/* $NetBSD: t_pipe2.c,v 1.8 2012/05/16 13:54:28 jruoho Exp $ */ +/* $NetBSD: t_pipe2.c,v 1.9 2017/01/13 21:19:45 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Christos Zoulas. * * 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 by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * 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 -__RCSID("$NetBSD: t_pipe2.c,v 1.8 2012/05/16 13:54:28 jruoho Exp $"); +__RCSID("$NetBSD: t_pipe2.c,v 1.9 2017/01/13 21:19:45 christos Exp $"); #include #include #include #include #include #include static void run(int flags) { int fd[2], i; while ((i = open("/", O_RDONLY)) < 3) ATF_REQUIRE(i != -1); #ifdef __FreeBSD__ closefrom(3); #else - ATF_REQUIRE(fcntl(3, F_CLOSEM) != -1); + ATF_REQUIRE_MSG(closefrom(3) != -1, "closefrom failed: %s", + strerror(errno)); #endif ATF_REQUIRE(pipe2(fd, flags) == 0); ATF_REQUIRE(fd[0] == 3); ATF_REQUIRE(fd[1] == 4); if (flags & O_CLOEXEC) { ATF_REQUIRE((fcntl(fd[0], F_GETFD) & FD_CLOEXEC) != 0); ATF_REQUIRE((fcntl(fd[1], F_GETFD) & FD_CLOEXEC) != 0); } else { ATF_REQUIRE((fcntl(fd[0], F_GETFD) & FD_CLOEXEC) == 0); ATF_REQUIRE((fcntl(fd[1], F_GETFD) & FD_CLOEXEC) == 0); } if (flags & O_NONBLOCK) { ATF_REQUIRE((fcntl(fd[0], F_GETFL) & O_NONBLOCK) != 0); ATF_REQUIRE((fcntl(fd[1], F_GETFL) & O_NONBLOCK) != 0); } else { ATF_REQUIRE((fcntl(fd[0], F_GETFL) & O_NONBLOCK) == 0); ATF_REQUIRE((fcntl(fd[1], F_GETFL) & O_NONBLOCK) == 0); } #ifndef __FreeBSD__ if (flags & O_NOSIGPIPE) { ATF_REQUIRE(fcntl(fd[0], F_GETNOSIGPIPE) != 0); ATF_REQUIRE(fcntl(fd[1], F_GETNOSIGPIPE) != 0); } else { ATF_REQUIRE(fcntl(fd[0], F_GETNOSIGPIPE) == 0); ATF_REQUIRE(fcntl(fd[1], F_GETNOSIGPIPE) == 0); } #endif ATF_REQUIRE(close(fd[0]) != -1); ATF_REQUIRE(close(fd[1]) != -1); } ATF_TC(pipe2_basic); ATF_TC_HEAD(pipe2_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of pipe2(2)"); } ATF_TC_BODY(pipe2_basic, tc) { run(0); } ATF_TC(pipe2_consume); ATF_TC_HEAD(pipe2_consume, tc) { atf_tc_set_md_var(tc, "descr", "Test that consuming file descriptors " "with pipe2(2) does not crash the system (PR kern/46457)"); } ATF_TC_BODY(pipe2_consume, tc) { struct rlimit rl; int err, filedes[2]; -#ifdef __FreeBSD__ int old; +#ifdef __FreeBSD__ closefrom(4); #else - err = fcntl(4, F_CLOSEM); - ATF_REQUIRE(err == 0); + ATF_REQUIRE_MSG(closefrom(4) != -1, "closefrom failed: %s", + strerror(errno)); #endif err = getrlimit(RLIMIT_NOFILE, &rl); ATF_REQUIRE(err == 0); /* * The heart of this test is to run against the number of open * file descriptor limit in the middle of a pipe2() call - i.e. * before the call only a single descriptor may be openend. */ -#ifdef __FreeBSD__ old = rl.rlim_cur; -#endif rl.rlim_cur = 4; err = setrlimit(RLIMIT_NOFILE, &rl); ATF_REQUIRE(err == 0); err = pipe2(filedes, O_CLOEXEC); ATF_REQUIRE(err == -1); -#ifdef __FreeBSD__ rl.rlim_cur = old; err = setrlimit(RLIMIT_NOFILE, &rl); -#endif } ATF_TC(pipe2_nonblock); ATF_TC_HEAD(pipe2_nonblock, tc) { atf_tc_set_md_var(tc, "descr", "A non-blocking test of pipe2(2)"); } ATF_TC_BODY(pipe2_nonblock, tc) { run(O_NONBLOCK); } ATF_TC(pipe2_cloexec); ATF_TC_HEAD(pipe2_cloexec, tc) { atf_tc_set_md_var(tc, "descr", "A close-on-exec test of pipe2(2)"); } ATF_TC_BODY(pipe2_cloexec, tc) { run(O_CLOEXEC); } #ifdef __NetBSD__ ATF_TC(pipe2_nosigpipe); ATF_TC_HEAD(pipe2_nosigpipe, tc) { atf_tc_set_md_var(tc, "descr", "A no sigpipe test of pipe2(2)"); } ATF_TC_BODY(pipe2_nosigpipe, tc) { run(O_NOSIGPIPE); } #endif ATF_TC(pipe2_einval); ATF_TC_HEAD(pipe2_einval, tc) { atf_tc_set_md_var(tc, "descr", "A error check of pipe2(2)"); } ATF_TC_BODY(pipe2_einval, tc) { int fd[2]; ATF_REQUIRE_ERRNO(EINVAL, pipe2(fd, O_ASYNC) == -1); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, pipe2_basic); ATF_TP_ADD_TC(tp, pipe2_consume); ATF_TP_ADD_TC(tp, pipe2_nonblock); ATF_TP_ADD_TC(tp, pipe2_cloexec); #ifdef __NetBSD__ ATF_TP_ADD_TC(tp, pipe2_nosigpipe); #endif ATF_TP_ADD_TC(tp, pipe2_einval); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_posix_fadvise.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_posix_fadvise.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_posix_fadvise.c (revision 312126) @@ -1,165 +1,165 @@ -/* $NetBSD: t_posix_fadvise.c,v 1.1 2011/10/15 06:10:26 jruoho Exp $ */ +/* $NetBSD: t_posix_fadvise.c,v 1.2 2017/01/13 21:30:41 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by YAMAMOTO Takashi. * * 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)2005 YAMAMOTO Takashi, * 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. */ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_posix_fadvise.c,v 1.1 2011/10/15 06:10:26 jruoho Exp $"); +__RCSID("$NetBSD: t_posix_fadvise.c,v 1.2 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include -#include "../../../h_macros.h" +#include "h_macros.h" #include #include ATF_TC(posix_fadvise); ATF_TC_HEAD(posix_fadvise, tc) { atf_tc_set_md_var(tc, "descr", "Checks posix_fadvise(2)"); } ATF_TC(posix_fadvise_reg); ATF_TC_HEAD(posix_fadvise_reg, tc) { atf_tc_set_md_var(tc, "descr", "Checks posix_fadvise(2) " "for regular files"); } ATF_TC_BODY(posix_fadvise, tc) { int fd; int pipe_fds[2]; int badfd = 10; int ret; RL(fd = open("/dev/null", O_RDWR)); (void)close(badfd); RL(pipe(pipe_fds)); /* * it's hard to check if posix_fadvise is working properly. * only check return values here. */ /* posix_fadvise shouldn't affect errno. */ #define CE(x, exp) \ do { \ int save = errno; \ errno = 999; \ ATF_CHECK_EQ_MSG(ret = (x), exp, "got: %d", ret); \ ATF_CHECK_EQ_MSG(errno, 999, "got: %s", strerror(errno)); \ errno = save; \ } while (0); CE(posix_fadvise(fd, 0, 0, -1), EINVAL); CE(posix_fadvise(pipe_fds[0], 0, 0, POSIX_FADV_NORMAL), ESPIPE); CE(posix_fadvise(badfd, 0, 0, POSIX_FADV_NORMAL), EBADF); CE(posix_fadvise(fd, 0, 0, POSIX_FADV_NORMAL), 0); CE(posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL), 0); CE(posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM), 0); CE(posix_fadvise(fd, 0, 0, POSIX_FADV_WILLNEED), 0); CE(posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED), 0); CE(posix_fadvise(fd, 0, 0, POSIX_FADV_NOREUSE), 0); } ATF_TC_BODY(posix_fadvise_reg, tc) { int rfd, ret; rump_init(); RL(rfd = rump_sys_open("/a_file", O_CREAT, 0666)); CE(rump_sys_posix_fadvise(rfd, 0, 0, POSIX_FADV_NORMAL), 0); CE(rump_sys_posix_fadvise(rfd, 0, 0, POSIX_FADV_SEQUENTIAL), 0); CE(rump_sys_posix_fadvise(rfd, 0, 0, POSIX_FADV_RANDOM), 0); CE(rump_sys_posix_fadvise(rfd, 0, 0, POSIX_FADV_WILLNEED), 0); CE(rump_sys_posix_fadvise(rfd, 0, 0, POSIX_FADV_NOREUSE), 0); CE(rump_sys_posix_fadvise(rfd, INT64_MAX-getpagesize(), getpagesize(), POSIX_FADV_NORMAL), 0); CE(rump_sys_posix_fadvise(rfd, INT64_MAX-getpagesize(), getpagesize(), POSIX_FADV_SEQUENTIAL), 0); CE(rump_sys_posix_fadvise(rfd, INT64_MAX-getpagesize(), getpagesize(), POSIX_FADV_RANDOM), 0); CE(rump_sys_posix_fadvise(rfd, INT64_MAX-getpagesize(), getpagesize(), POSIX_FADV_WILLNEED), 0); CE(rump_sys_posix_fadvise(rfd, INT64_MAX-getpagesize(), getpagesize(), POSIX_FADV_NOREUSE), 0); //atf_tc_expect_signal(-1, "http://mail-index.netbsd.org/source-changes-d/2010/11/11/msg002508.html"); CE(rump_sys_posix_fadvise(rfd, INT64_MAX-getpagesize(), getpagesize(), POSIX_FADV_DONTNEED), 0); CE(rump_sys_posix_fadvise(rfd, 0, 0, POSIX_FADV_DONTNEED), 0); #undef CE } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, posix_fadvise); ATF_TP_ADD_TC(tp, posix_fadvise_reg); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_revoke.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_revoke.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_revoke.c (revision 312126) @@ -1,198 +1,196 @@ -/* $NetBSD: t_revoke.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $ */ +/* $NetBSD: t_revoke.c,v 1.2 2017/01/13 21:15:57 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_revoke.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $"); +__RCSID("$NetBSD: t_revoke.c,v 1.2 2017/01/13 21:15:57 christos Exp $"); #include #include #include #include #include #include #include #include #include #include static const char path[] = "revoke"; ATF_TC_WITH_CLEANUP(revoke_basic); ATF_TC_HEAD(revoke_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of revoke(2)"); } ATF_TC_BODY(revoke_basic, tc) { struct rlimit res; char tmp[10]; size_t i, n; int *buf; #ifdef __FreeBSD__ atf_tc_skip("revoke(2) is only implemented for devfs(5)."); #endif (void)memset(&res, 0, sizeof(struct rlimit)); (void)getrlimit(RLIMIT_NOFILE, &res); if ((n = res.rlim_cur / 10) == 0) n = 10; buf = calloc(n, sizeof(int)); ATF_REQUIRE(buf != NULL); buf[0] = open(path, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(buf[0] >= 0); for (i = 1; i < n; i++) { buf[i] = open(path, O_RDWR); ATF_REQUIRE(buf[i] >= 0); } ATF_REQUIRE(revoke(path) == 0); for (i = 0; i < n; i++) { ATF_REQUIRE(read(buf[i], tmp, sizeof(tmp)) == -1); (void)close(buf[i]); } free(buf); (void)unlink(path); } ATF_TC_CLEANUP(revoke_basic, tc) { (void)unlink(path); } ATF_TC(revoke_err); ATF_TC_HEAD(revoke_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from revoke(2)"); atf_tc_set_md_var(tc, "require.user", "unprivileged"); } ATF_TC_BODY(revoke_err, tc) { char buf[1024 + 1]; /* XXX: From the manual page... */ (void)memset(buf, 'x', sizeof(buf)); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, revoke((char *)-1) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENAMETOOLONG, revoke(buf) == -1); #ifdef __FreeBSD__ atf_tc_skip("revoke(2) is only implemented for devfs(5)."); #endif errno = 0; ATF_REQUIRE_ERRNO(EPERM, revoke("/etc/passwd") == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOENT, revoke("/etc/xxx/yyy") == -1); } ATF_TC_WITH_CLEANUP(revoke_perm); ATF_TC_HEAD(revoke_perm, tc) { atf_tc_set_md_var(tc, "descr", "Test permissions revoke(2)"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(revoke_perm, tc) { struct passwd *pw; int fd, sta; pid_t pid; #ifdef __FreeBSD__ atf_tc_skip("revoke(2) is only implemented for devfs(5)."); #endif pw = getpwnam("nobody"); fd = open(path, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); ATF_REQUIRE(pw != NULL); ATF_REQUIRE(revoke(path) == 0); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { if (setuid(pw->pw_uid) != 0) _exit(EXIT_FAILURE); errno = 0; if (revoke(path) == 0) _exit(EXIT_FAILURE); if (errno != EACCES) _exit(EXIT_FAILURE); if (close(fd) != 0) _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); } (void)wait(&sta); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) atf_tc_fail("revoke(2) did not obey permissions"); -#ifdef __FreeBSD__ (void)close(fd); -#endif ATF_REQUIRE(unlink(path) == 0); } ATF_TC_CLEANUP(revoke_perm, tc) { (void)unlink(path); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, revoke_basic); ATF_TP_ADD_TC(tp, revoke_err); ATF_TP_ADD_TC(tp, revoke_perm); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_select.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_select.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_select.c (revision 312126) @@ -1,229 +1,217 @@ -/* $NetBSD: t_select.c,v 1.3 2012/03/18 07:00:52 jruoho Exp $ */ +/* $NetBSD: t_select.c,v 1.4 2017/01/13 21:18:33 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundatiom * by Christos Zoulas. * * 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 #include #include #include #include #include #include static sig_atomic_t keep_going = 1; static void -#ifdef __FreeBSD__ sig_handler(int signum __unused) -#else -sig_handler(int signum) -#endif { keep_going = 0; } static void -#ifdef __FreeBSD__ sigchld(int signum __unused) -#else -sigchld(int signum) -#endif { } static char xtoa(uint8_t n) { static const char xarray[] = "0123456789abcdef"; assert(n < sizeof(xarray)); return xarray[n]; } static const char * prmask(const sigset_t *m, char *buf, size_t len) { size_t j = 2; assert(len >= 3 + sizeof(*m)); buf[0] = '0'; buf[1] = 'x'; #define N(p, a) (((p) >> ((a) * 4)) & 0xf) for (size_t i = __arraycount(m->__bits); i > 0; i--) { uint32_t p = m->__bits[i - 1]; for (size_t k = sizeof(p); k > 0; k--) buf[j++] = xtoa(N(p, k - 1)); } buf[j] = '\0'; return buf; } -static void +static __dead void child(const struct timespec *ts) { struct sigaction sa; sigset_t set, oset, nset; char obuf[sizeof(oset) + 3], nbuf[sizeof(nset) + 3]; int fd; memset(&sa, 0, sizeof(sa)); sa.sa_handler = sig_handler; if ((fd = open("/dev/null", O_RDONLY)) == -1) err(1, "open"); if (sigaction(SIGTERM, &sa, NULL) == -1) err(1, "sigaction"); sigfillset(&set); if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) err(1, "sigprocmask"); if (sigprocmask(SIG_BLOCK, NULL, &oset) == -1) err(1, "sigprocmask"); sigemptyset(&set); for (;;) { fd_set rset; FD_ZERO(&rset); FD_SET(fd, &rset); if (pselect(1, &rset, NULL, NULL, ts, &set) == -1) { if(errno == EINTR) { if (!keep_going) break; } } if (ts) break; } if (sigprocmask(SIG_BLOCK, NULL, &nset) == -1) err(1, "sigprocmask"); if (memcmp(&oset, &nset, sizeof(oset)) != 0) atf_tc_fail("pselect() masks don't match " "after timeout %s != %s", prmask(&nset, nbuf, sizeof(nbuf)), prmask(&oset, obuf, sizeof(obuf))); -#ifdef __FreeBSD__ _exit(0); -#endif } ATF_TC(pselect_sigmask); ATF_TC_HEAD(pselect_sigmask, tc) { atf_tc_set_md_var(tc, "descr", "Checks pselect's temporary mask " "setting when a signal is received (PR lib/43625)"); } ATF_TC_BODY(pselect_sigmask, tc) { pid_t pid; int status; signal(SIGCHLD, sigchld); switch (pid = fork()) { case 0: child(NULL); -#ifdef __FreeBSD__ - break; -#endif + /*NOTREACHED*/ case -1: err(1, "fork"); default: sleep(1); if (kill(pid, SIGTERM) == -1) err(1, "kill"); sleep(1); switch (waitpid(pid, &status, WNOHANG)) { case -1: err(1, "wait"); case 0: if (kill(pid, SIGKILL) == -1) err(1, "kill"); atf_tc_fail("pselect() did not receive signal"); break; default: break; } } } ATF_TC(pselect_timeout); ATF_TC_HEAD(pselect_timeout, tc) { atf_tc_set_md_var(tc, "descr", "Checks pselect's temporary mask " "setting when a timeout occurs"); } ATF_TC_BODY(pselect_timeout, tc) { pid_t pid; int status; static const struct timespec zero = { 0, 0 }; signal(SIGCHLD, sigchld); switch (pid = fork()) { case 0: child(&zero); break; case -1: err(1, "fork"); default: sleep(1); switch (waitpid(pid, &status, WNOHANG)) { case -1: err(1, "wait"); case 0: if (kill(pid, SIGKILL) == -1) err(1, "kill"); atf_tc_fail("pselect() did not receive signal"); break; default: break; } } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, pselect_sigmask); ATF_TP_ADD_TC(tp, pselect_timeout); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c (revision 312126) @@ -1,581 +1,579 @@ -/* $NetBSD: t_setrlimit.c,v 1.5 2016/07/13 09:53:16 njoly Exp $ */ +/* $NetBSD: t_setrlimit.c,v 1.6 2017/01/13 21:16:38 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_setrlimit.c,v 1.5 2016/07/13 09:53:16 njoly Exp $"); +__RCSID("$NetBSD: t_setrlimit.c,v 1.6 2017/01/13 21:16:38 christos Exp $"); #include #include #include #include #include #include #include #ifdef __NetBSD__ #include #endif #include #include #include #include #include #include #include #ifdef __FreeBSD__ void set_vm_max_wired(int); void restore_vm_max_wired(void); #endif static void sighandler(int); static const char path[] = "setrlimit"; static const int rlimit[] = { RLIMIT_AS, RLIMIT_CORE, RLIMIT_CPU, RLIMIT_DATA, RLIMIT_FSIZE, RLIMIT_MEMLOCK, RLIMIT_NOFILE, RLIMIT_NPROC, RLIMIT_RSS, RLIMIT_SBSIZE, RLIMIT_STACK }; ATF_TC(setrlimit_basic); ATF_TC_HEAD(setrlimit_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic soft limit test"); } ATF_TC_BODY(setrlimit_basic, tc) { struct rlimit res; int *buf, lim; size_t i; buf = calloc(__arraycount(rlimit), sizeof(int)); if (buf == NULL) atf_tc_fail("initialization failed"); for (i = lim = 0; i < __arraycount(rlimit); i++) { (void)memset(&res, 0, sizeof(struct rlimit)); if (getrlimit(rlimit[i], &res) != 0) continue; if (res.rlim_cur == RLIM_INFINITY || res.rlim_cur == 0) continue; if (res.rlim_cur == res.rlim_max) /* An unprivileged run. */ continue; buf[i] = res.rlim_cur; res.rlim_cur = res.rlim_cur - 1; if (setrlimit(rlimit[i], &res) != 0) { lim = rlimit[i]; goto out; } } out: for (i = 0; i < __arraycount(rlimit); i++) { (void)memset(&res, 0, sizeof(struct rlimit)); if (buf[i] == 0) continue; if (getrlimit(rlimit[i], &res) != 0) continue; res.rlim_cur = buf[i]; (void)setrlimit(rlimit[i], &res); } if (lim != 0) atf_tc_fail("failed to set limit (%d)", lim); -#ifdef __FreeBSD__ free(buf); -#endif } ATF_TC(setrlimit_current); ATF_TC_HEAD(setrlimit_current, tc) { atf_tc_set_md_var(tc, "descr", "setrlimit(3) with current limits"); } ATF_TC_BODY(setrlimit_current, tc) { struct rlimit res; size_t i; for (i = 0; i < __arraycount(rlimit); i++) { (void)memset(&res, 0, sizeof(struct rlimit)); ATF_REQUIRE(getrlimit(rlimit[i], &res) == 0); ATF_REQUIRE(setrlimit(rlimit[i], &res) == 0); } } ATF_TC(setrlimit_err); ATF_TC_HEAD(setrlimit_err, tc) { atf_tc_set_md_var(tc, "descr", "Test error conditions"); } ATF_TC_BODY(setrlimit_err, tc) { struct rlimit res; size_t i; for (i = 0; i < __arraycount(rlimit); i++) { errno = 0; ATF_REQUIRE(getrlimit(rlimit[i], (void *)0) != 0); ATF_REQUIRE(errno == EFAULT); } errno = 0; ATF_REQUIRE(getrlimit(INT_MAX, &res) != 0); ATF_REQUIRE(errno == EINVAL); } ATF_TC_WITH_CLEANUP(setrlimit_fsize); ATF_TC_HEAD(setrlimit_fsize, tc) { atf_tc_set_md_var(tc, "descr", "Test setrlimit(2), RLIMIT_FSIZE"); } ATF_TC_BODY(setrlimit_fsize, tc) { struct rlimit res; int fd, sta; pid_t pid; fd = open(path, O_RDWR | O_CREAT, 0700); if (fd < 0) atf_tc_fail("initialization failed"); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { res.rlim_cur = 2; res.rlim_max = 2; if (setrlimit(RLIMIT_FSIZE, &res) != 0) _exit(EXIT_FAILURE); if (signal(SIGXFSZ, sighandler) == SIG_ERR) _exit(EXIT_FAILURE); /* * The third call should generate a SIGXFSZ. */ (void)write(fd, "X", 1); (void)write(fd, "X", 1); (void)write(fd, "X", 1); _exit(EXIT_FAILURE); } (void)close(fd); (void)wait(&sta); (void)unlink(path); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) atf_tc_fail("RLIMIT_FSIZE not enforced"); } ATF_TC_CLEANUP(setrlimit_fsize, tc) { (void)unlink(path); } static void sighandler(int signo) { if (signo != SIGXFSZ) _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); } #ifdef __FreeBSD__ ATF_TC_WITH_CLEANUP(setrlimit_memlock); #else ATF_TC(setrlimit_memlock); #endif ATF_TC_HEAD(setrlimit_memlock, tc) { atf_tc_set_md_var(tc, "descr", "Test setrlimit(2), RLIMIT_MEMLOCK"); #ifdef __FreeBSD__ atf_tc_set_md_var(tc, "require.config", "allow_sysctl_side_effects"); atf_tc_set_md_var(tc, "require.user", "root"); #endif } ATF_TC_BODY(setrlimit_memlock, tc) { struct rlimit res; void *buf; long page; pid_t pid; int sta; #ifdef __FreeBSD__ /* Set max_wired really really high to avoid EAGAIN */ set_vm_max_wired(INT_MAX); #endif page = sysconf(_SC_PAGESIZE); ATF_REQUIRE(page >= 0); buf = malloc(page); pid = fork(); if (buf == NULL || pid < 0) atf_tc_fail("initialization failed"); if (pid == 0) { /* * Try to lock a page while * RLIMIT_MEMLOCK is zero. */ if (mlock(buf, page) != 0) _exit(EXIT_FAILURE); if (munlock(buf, page) != 0) _exit(EXIT_FAILURE); res.rlim_cur = 0; res.rlim_max = 0; if (setrlimit(RLIMIT_MEMLOCK, &res) != 0) _exit(EXIT_FAILURE); if (mlock(buf, page) != 0) _exit(EXIT_SUCCESS); (void)munlock(buf, page); _exit(EXIT_FAILURE); } free(buf); (void)wait(&sta); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) atf_tc_fail("RLIMIT_MEMLOCK not enforced"); } #ifdef __FreeBSD__ ATF_TC_CLEANUP(setrlimit_memlock, tc) { restore_vm_max_wired(); } #endif ATF_TC(setrlimit_nofile_1); ATF_TC_HEAD(setrlimit_nofile_1, tc) { atf_tc_set_md_var(tc, "descr", "Test setrlimit(2), RLIMIT_NOFILE, #1"); } ATF_TC_BODY(setrlimit_nofile_1, tc) { struct rlimit res; int fd, i, rv, sta; pid_t pid; res.rlim_cur = 0; res.rlim_max = 0; pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { /* * Close all descriptors, set RLIMIT_NOFILE * to zero, and try to open a random file. * This should fail with EMFILE. */ for (i = 0; i < 1024; i++) (void)close(i); rv = setrlimit(RLIMIT_NOFILE, &res); if (rv != 0) _exit(EXIT_FAILURE); errno = 0; fd = open("/etc/passwd", O_RDONLY); if (fd >= 0 || errno != EMFILE) _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); } (void)wait(&sta); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) atf_tc_fail("RLIMIT_NOFILE not enforced"); } ATF_TC(setrlimit_nofile_2); ATF_TC_HEAD(setrlimit_nofile_2, tc) { atf_tc_set_md_var(tc, "descr", "Test setrlimit(2), RLIMIT_NOFILE, #2"); } ATF_TC_BODY(setrlimit_nofile_2, tc) { static const rlim_t lim = 12; struct rlimit res; int fd, i, rv, sta; pid_t pid; /* * See that an arbitrary limit on * open files is being enforced. */ res.rlim_cur = lim; res.rlim_max = lim; pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { for (i = 0; i < 1024; i++) (void)close(i); rv = setrlimit(RLIMIT_NOFILE, &res); if (rv != 0) _exit(EXIT_FAILURE); for (i = 0; i < (int)lim; i++) { fd = open("/etc/passwd", O_RDONLY); if (fd < 0) _exit(EXIT_FAILURE); } /* * After the limit has been reached, * EMFILE should again follow. */ fd = open("/etc/passwd", O_RDONLY); if (fd >= 0 || errno != EMFILE) _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); } (void)wait(&sta); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) atf_tc_fail("RLIMIT_NOFILE not enforced"); } ATF_TC(setrlimit_nproc); ATF_TC_HEAD(setrlimit_nproc, tc) { atf_tc_set_md_var(tc, "descr", "Test setrlimit(2), RLIMIT_NPROC"); atf_tc_set_md_var(tc, "require.user", "unprivileged"); } ATF_TC_BODY(setrlimit_nproc, tc) { struct rlimit res; pid_t pid, cpid; int sta; pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { /* * Set RLIMIT_NPROC to zero and try to fork. */ res.rlim_cur = 0; res.rlim_max = 0; if (setrlimit(RLIMIT_NPROC, &res) != 0) _exit(EXIT_FAILURE); cpid = fork(); if (cpid < 0) _exit(EXIT_SUCCESS); _exit(EXIT_FAILURE); } (void)waitpid(pid, &sta, 0); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) atf_tc_fail("RLIMIT_NPROC not enforced"); } #ifdef __NetBSD__ ATF_TC(setrlimit_nthr); ATF_TC_HEAD(setrlimit_nthr, tc) { atf_tc_set_md_var(tc, "descr", "Test setrlimit(2), RLIMIT_NTHR"); atf_tc_set_md_var(tc, "require.user", "unprivileged"); } static void func(lwpid_t *id) { printf("thread %d\n", *id); fflush(stdout); _lwp_exit(); } ATF_TC_BODY(setrlimit_nthr, tc) { struct rlimit res; lwpid_t lwpid; ucontext_t c; /* * Set RLIMIT_NTHR to zero and try to create a thread. */ res.rlim_cur = 0; res.rlim_max = 0; ATF_REQUIRE(setrlimit(RLIMIT_NTHR, &res) == 0); ATF_REQUIRE(getcontext(&c) == 0); c.uc_link = NULL; sigemptyset(&c.uc_sigmask); c.uc_stack.ss_flags = 0; c.uc_stack.ss_size = 4096; ATF_REQUIRE((c.uc_stack.ss_sp = malloc(c.uc_stack.ss_size)) != NULL); makecontext(&c, func, 1, &lwpid); ATF_CHECK_ERRNO(EAGAIN, _lwp_create(&c, 0, &lwpid) == -1); } #endif ATF_TC(setrlimit_perm); ATF_TC_HEAD(setrlimit_perm, tc) { atf_tc_set_md_var(tc, "descr", "Test setrlimit(2) for EPERM"); atf_tc_set_md_var(tc, "require.user", "unprivileged"); } ATF_TC_BODY(setrlimit_perm, tc) { struct rlimit res; size_t i; /* * Try to raise the maximum limits as an user. */ for (i = 0; i < __arraycount(rlimit); i++) { ATF_REQUIRE(getrlimit(rlimit[i], &res) == 0); #ifdef __FreeBSD__ if (res.rlim_max == INT64_MAX) /* Overflow. */ #else if (res.rlim_max == UINT64_MAX) /* Overflow. */ #endif continue; errno = 0; res.rlim_max = res.rlim_max + 1; ATF_CHECK_ERRNO(EPERM, setrlimit(rlimit[i], &res) != 0); } } ATF_TC(setrlimit_stack); ATF_TC_HEAD(setrlimit_stack, tc) { atf_tc_set_md_var(tc, "descr", "Test setrlimit(2), RLIMIT_STACK"); atf_tc_set_md_var(tc, "require.user", "unprivileged"); } ATF_TC_BODY(setrlimit_stack, tc) { struct rlimit res; /* Ensure soft limit is not bigger than hard limit */ res.rlim_cur = res.rlim_max = 4192256; ATF_REQUIRE(setrlimit(RLIMIT_STACK, &res) == 0); ATF_REQUIRE(getrlimit(RLIMIT_STACK, &res) == 0); ATF_CHECK(res.rlim_cur <= res.rlim_max); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, setrlimit_basic); ATF_TP_ADD_TC(tp, setrlimit_current); ATF_TP_ADD_TC(tp, setrlimit_err); ATF_TP_ADD_TC(tp, setrlimit_fsize); ATF_TP_ADD_TC(tp, setrlimit_memlock); ATF_TP_ADD_TC(tp, setrlimit_nofile_1); ATF_TP_ADD_TC(tp, setrlimit_nofile_2); ATF_TP_ADD_TC(tp, setrlimit_nproc); ATF_TP_ADD_TC(tp, setrlimit_perm); #ifdef __NetBSD__ ATF_TP_ADD_TC(tp, setrlimit_nthr); #endif ATF_TP_ADD_TC(tp, setrlimit_stack); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c (revision 312126) @@ -1,165 +1,153 @@ -/* $NetBSD: t_sigaction.c,v 1.3 2014/11/04 00:20:19 justin Exp $ */ +/* $NetBSD: t_sigaction.c,v 1.5 2017/01/13 21:30:41 christos 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 __COPYRIGHT("@(#) Copyright (c) 2010\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_sigaction.c,v 1.3 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_sigaction.c,v 1.5 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include -#ifdef __NetBSD__ -#include "../../../h_macros.h" -#else #include "h_macros.h" -#endif static bool handler_called = false; static void -#ifdef __FreeBSD__ handler(int signo __unused) -#else -handler(int signo) -#endif { handler_called = true; } static void sa_resethand_child(const int flags) { struct sigaction sa; sa.sa_flags = flags; sa.sa_handler = &handler; sigemptyset(&sa.sa_mask); sigaction(SIGUSR1, &sa, NULL); kill(getpid(), SIGUSR1); exit(handler_called ? EXIT_SUCCESS : EXIT_FAILURE); } static void wait_and_check_child(const pid_t pid, const char *fail_message) { int status; (void)waitpid(pid, &status, 0); if (WIFEXITED(status)) ATF_CHECK_EQ(EXIT_SUCCESS, WEXITSTATUS(status)); else atf_tc_fail("%s; raw exit status was %d", fail_message, status); } static void -#ifdef __FreeBSD__ catch(int sig __unused) -#else -catch(int sig) -#endif { return; } ATF_TC(sigaction_basic); ATF_TC_HEAD(sigaction_basic, tc) { atf_tc_set_md_var(tc, "descr", "Checks for correct I&D cache" "synchronization after copying out the trampoline code."); } ATF_TC_BODY(sigaction_basic, tc) { static struct sigaction sa; sa.sa_handler = catch; sigaction(SIGUSR1, &sa, 0); kill(getpid(), SIGUSR1); atf_tc_pass(); } ATF_TC(sigaction_noflags); ATF_TC_HEAD(sigaction_noflags, tc) { atf_tc_set_md_var(tc, "descr", "Checks programming a signal with " "sigaction(2) but without any flags"); } ATF_TC_BODY(sigaction_noflags, tc) { const pid_t pid = fork(); if (pid == -1) atf_tc_fail_errno("fork(2) failed"); else if (pid == 0) sa_resethand_child(0); else wait_and_check_child(pid, "Child process did not exit cleanly;" " it failed to process the signal"); } ATF_TC(sigaction_resethand); ATF_TC_HEAD(sigaction_resethand, tc) { atf_tc_set_md_var(tc, "descr", "Checks that SA_RESETHAND works"); } ATF_TC_BODY(sigaction_resethand, tc) { const pid_t pid = fork(); if (pid == -1) atf_tc_fail_errno("fork(2) failed"); else if (pid == 0) sa_resethand_child(SA_RESETHAND); else { wait_and_check_child(pid, "Child process did not exit cleanly;" " it either failed to process the signal or SA_RESETHAND" " is broken"); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, sigaction_basic); ATF_TP_ADD_TC(tp, sigaction_noflags); ATF_TP_ADD_TC(tp, sigaction_resethand); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c (revision 312126) @@ -1,260 +1,247 @@ -/* $NetBSD: t_sigqueue.c,v 1.6 2016/08/04 06:43:43 christos Exp $ */ +/* $NetBSD: t_sigqueue.c,v 1.7 2017/01/13 20:44:10 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Christos Zoulas. * * 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 -__RCSID("$NetBSD: t_sigqueue.c,v 1.6 2016/08/04 06:43:43 christos Exp $"); +__RCSID("$NetBSD: t_sigqueue.c,v 1.7 2017/01/13 20:44:10 christos Exp $"); #include +#include #include #include +#include #include #include #include #ifdef __FreeBSD__ #include #include #endif static void handler(int, siginfo_t *, void *); #define VALUE (int)0xc001dad1 static int value; static void -#ifdef __FreeBSD__ -handler(int signo __unused, siginfo_t *info __unused, void *data __unused) -#else -handler(int signo, siginfo_t *info, void *data) -#endif +handler(int signo __unused, siginfo_t *info, void *data __unused) { value = info->si_value.sival_int; kill(0, SIGINFO); } ATF_TC(sigqueue_basic); ATF_TC_HEAD(sigqueue_basic, tc) { atf_tc_set_md_var(tc, "descr", "Checks sigqueue(3) sigval delivery"); } ATF_TC_BODY(sigqueue_basic, tc) { struct sigaction sa; union sigval sv; sa.sa_sigaction = handler; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO; if (sigaction(SIGUSR1, &sa, NULL) != 0) atf_tc_fail("sigaction failed"); sv.sival_int = VALUE; #ifdef __FreeBSD__ /* * From kern_sig.c: * Specification says sigqueue can only send signal to single process. */ if (sigqueue(getpid(), SIGUSR1, sv) != 0) #else if (sigqueue(0, SIGUSR1, sv) != 0) #endif atf_tc_fail("sigqueue failed"); sched_yield(); ATF_REQUIRE_EQ(sv.sival_int, value); } ATF_TC(sigqueue_err); ATF_TC_HEAD(sigqueue_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from sigqueue(3)"); } ATF_TC_BODY(sigqueue_err, tc) { static union sigval sv; errno = 0; ATF_REQUIRE_ERRNO(EINVAL, sigqueue(getpid(), -1, sv) == -1); } static int signals[] = { SIGINT, SIGRTMIN + 1, SIGINT, SIGRTMIN + 0, SIGRTMIN + 2, SIGQUIT, SIGRTMIN + 1 }; #ifdef __arraycount #define CNT __arraycount(signals) #else #define CNT (sizeof(signals) / sizeof(signals[0])) #endif static sig_atomic_t count = 0; static int delivered[CNT]; static void -myhandler(int signo, siginfo_t *info, void *context) +myhandler(int signo, siginfo_t *info, void *context __unused) { delivered[count++] = signo; -#ifdef __FreeBSD__ printf("Signal #%zu: signo: %d\n", (size_t)count, signo); -#endif } static int asc(const void *a, const void *b) { const int *ia = a, *ib = b; return *ib - *ia; } /* * given a array of signals to be delivered in tosend of size len * place in ordered the signals to be delivered in delivery order * and return the number of signals that should be delivered */ static size_t sigorder(int *ordered, const int *tosend, size_t len) { memcpy(ordered, tosend, len * sizeof(*tosend)); qsort(ordered, len, sizeof(*ordered), asc); if (len == 1) return len; #ifdef __FreeBSD__ /* * Don't dedupe signal numbers (bug 212173) * * Per kib's comment.. * * " * OTOH, FreeBSD behaviour is to treat all signals as realtime while * there is no mem shortage and siginfo can be allocated. In * particular, signals < SIGRTMIN are not collapsed when queued more * than once. * " */ return len; #else size_t i, j; for (i = 0, j = 0; i < len - 1; i++) { if (ordered[i] >= SIGRTMIN) continue; if (j == 0) j = i + 1; while (ordered[i] == ordered[j] && j < len) j++; if (j == len) break; ordered[i + 1] = ordered[j]; } return i + 1; #endif } ATF_TC(sigqueue_rt); ATF_TC_HEAD(sigqueue_rt, tc) { atf_tc_set_md_var(tc, "descr", "Test queuing of real-time signals"); } ATF_TC_BODY(sigqueue_rt, tc) { pid_t pid; union sigval val; struct sigaction act; int ordered[CNT]; struct sigaction oact[CNT]; size_t ndelivered; ndelivered = sigorder(ordered, signals, CNT); act.sa_flags = SA_SIGINFO; act.sa_sigaction = myhandler; sigemptyset(&act.sa_mask); for (size_t i = 0; i < ndelivered; i++) ATF_REQUIRE(sigaction(ordered[i], &act, &oact[i]) != -1); val.sival_int = 0; pid = getpid(); sigset_t mask, orig; sigemptyset(&mask); for (size_t i = 0; i < CNT; i++) -#ifdef __FreeBSD__ if (sigaddset(&mask, signals[i]) == -1) warn("sigaddset"); -#else - sigaddset(&mask, signals[i]); -#endif + ATF_REQUIRE(sigprocmask(SIG_BLOCK, &mask, &orig) != -1); for (size_t i = 0; i < CNT; i++) ATF_REQUIRE(sigqueue(pid, signals[i], val) != -1); ATF_REQUIRE(sigprocmask(SIG_UNBLOCK, &mask, &orig) != -1); sleep(1); -#ifdef __FreeBSD__ ATF_CHECK_MSG((size_t)count == ndelivered, "count %zu != ndelivered %zu", (size_t)count, ndelivered); -#else - ATF_REQUIRE_MSG((size_t)count == ndelivered, - "count %zu != ndelivered %zu", (size_t)count, ndelivered); -#endif + for (size_t i = 0; i < ndelivered; i++) ATF_REQUIRE_MSG(ordered[i] == delivered[i], "%zu: ordered %d != delivered %d", i, ordered[i], delivered[i]); -#ifdef __FreeBSD__ - if (count > ndelivered) - for (size_t i = ndelivered; i < count; i++) + if ((size_t)count > ndelivered) + for (size_t i = ndelivered; i < (size_t)count; i++) printf("Undelivered signal #%zu: %d\n", i, ordered[i]); -#endif for (size_t i = 0; i < ndelivered; i++) ATF_REQUIRE(sigaction(signals[i], &oact[i], NULL) != -1); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, sigqueue_basic); ATF_TP_ADD_TC(tp, sigqueue_err); ATF_TP_ADD_TC(tp, sigqueue_rt); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c (revision 312126) @@ -1,141 +1,141 @@ -/* $NetBSD: t_socketpair.c,v 1.1 2011/11/05 18:19:02 jruoho Exp $ */ +/* $NetBSD: t_socketpair.c,v 1.2 2017/01/13 20:04:52 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Christos Zoulas. * * 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 by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * 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 -__RCSID("$NetBSD: t_socketpair.c,v 1.1 2011/11/05 18:19:02 jruoho Exp $"); +__RCSID("$NetBSD: t_socketpair.c,v 1.2 2017/01/13 20:04:52 christos Exp $"); #include #include #include #include #include #include #include static void connected(int fd) { struct sockaddr_un addr; socklen_t len = (socklen_t)sizeof(addr); ATF_REQUIRE(getpeername(fd, (struct sockaddr*)(void *)&addr, &len) == 0); } static void run(int flags) { int fd[2], i; while ((i = open("/", O_RDONLY)) < 3) ATF_REQUIRE(i != -1); #ifdef __FreeBSD__ closefrom(3); #else - ATF_REQUIRE(fcntl(3, F_CLOSEM) != -1); + ATF_REQUIRE(closefrom(3) != -1); #endif ATF_REQUIRE(socketpair(AF_UNIX, SOCK_DGRAM | flags, 0, fd) == 0); ATF_REQUIRE(fd[0] == 3); ATF_REQUIRE(fd[1] == 4); connected(fd[0]); connected(fd[1]); if (flags & SOCK_CLOEXEC) { ATF_REQUIRE((fcntl(fd[0], F_GETFD) & FD_CLOEXEC) != 0); ATF_REQUIRE((fcntl(fd[1], F_GETFD) & FD_CLOEXEC) != 0); } else { ATF_REQUIRE((fcntl(fd[0], F_GETFD) & FD_CLOEXEC) == 0); ATF_REQUIRE((fcntl(fd[1], F_GETFD) & FD_CLOEXEC) == 0); } if (flags & SOCK_NONBLOCK) { ATF_REQUIRE((fcntl(fd[0], F_GETFL) & O_NONBLOCK) != 0); ATF_REQUIRE((fcntl(fd[1], F_GETFL) & O_NONBLOCK) != 0); } else { ATF_REQUIRE((fcntl(fd[0], F_GETFL) & O_NONBLOCK) == 0); ATF_REQUIRE((fcntl(fd[1], F_GETFL) & O_NONBLOCK) == 0); } ATF_REQUIRE(close(fd[0]) != -1); ATF_REQUIRE(close(fd[1]) != -1); } ATF_TC(socketpair_basic); ATF_TC_HEAD(socketpair_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of socketpair(2)"); } ATF_TC_BODY(socketpair_basic, tc) { run(0); } ATF_TC(socketpair_nonblock); ATF_TC_HEAD(socketpair_nonblock, tc) { atf_tc_set_md_var(tc, "descr", "A non-blocking test of socketpair(2)"); } ATF_TC_BODY(socketpair_nonblock, tc) { run(SOCK_NONBLOCK); } ATF_TC(socketpair_cloexec); ATF_TC_HEAD(socketpair_cloexec, tc) { atf_tc_set_md_var(tc, "descr", "A close-on-exec of socketpair(2)"); } ATF_TC_BODY(socketpair_cloexec, tc) { run(SOCK_CLOEXEC); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, socketpair_basic); ATF_TP_ADD_TC(tp, socketpair_nonblock); ATF_TP_ADD_TC(tp, socketpair_cloexec); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_stat.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_stat.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_stat.c (revision 312126) @@ -1,424 +1,426 @@ -/* $NetBSD: t_stat.c,v 1.4 2012/03/17 08:37:08 jruoho Exp $ */ +/* $NetBSD: t_stat.c,v 1.5 2017/01/13 20:06:50 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_stat.c,v 1.4 2012/03/17 08:37:08 jruoho Exp $"); +__RCSID("$NetBSD: t_stat.c,v 1.5 2017/01/13 20:06:50 christos Exp $"); #include #include #include #include +#include #include #include #include #include #include #include #include #include #ifdef __FreeBSD__ #include #endif static const char *path = "stat"; ATF_TC_WITH_CLEANUP(stat_chflags); ATF_TC_HEAD(stat_chflags, tc) { atf_tc_set_md_var(tc, "descr", "Test chflags(2) with stat(2)"); } ATF_TC_BODY(stat_chflags, tc) { struct stat sa, sb; int fd; (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); fd = open(path, O_RDONLY | O_CREAT); ATF_REQUIRE(fd != -1); ATF_REQUIRE(stat(path, &sa) == 0); ATF_REQUIRE(chflags(path, UF_NODUMP) == 0); ATF_REQUIRE(stat(path, &sb) == 0); if (sa.st_flags == sb.st_flags) atf_tc_fail("stat(2) did not detect chflags(2)"); ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(unlink(path) == 0); } ATF_TC_CLEANUP(stat_chflags, tc) { (void)unlink(path); } ATF_TC(stat_dir); ATF_TC_HEAD(stat_dir, tc) { atf_tc_set_md_var(tc, "descr", "Test stat(2) with directories"); } ATF_TC_BODY(stat_dir, tc) { const short depth = 2; struct stat sa, sb; char *argv[2]; FTSENT *ftse; FTS *fts; int ops; argv[1] = NULL; argv[0] = __UNCONST("/"); ops = FTS_NOCHDIR; ops |= FTS_PHYSICAL; fts = fts_open(argv, ops, NULL); ATF_REQUIRE(fts != NULL); while ((ftse = fts_read(fts)) != NULL) { if (ftse->fts_level < 1) continue; if (ftse->fts_level > depth) { (void)fts_set(fts, ftse, FTS_SKIP); continue; } switch(ftse->fts_info) { case FTS_DP: (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); ATF_REQUIRE(stat(ftse->fts_parent->fts_path,&sa) == 0); ATF_REQUIRE(chdir(ftse->fts_path) == 0); ATF_REQUIRE(stat(".", &sb) == 0); /* * The previous two stat(2) calls * should be for the same directory. */ if (sa.st_dev != sb.st_dev || sa.st_ino != sb.st_ino) atf_tc_fail("inconsistent stat(2)"); /* * Check that fts(3)'s stat(2) * call equals the manual one. */ if (sb.st_ino != ftse->fts_statp->st_ino) atf_tc_fail("stat(2) and fts(3) differ"); break; default: break; } } (void)fts_close(fts); } ATF_TC(stat_err); ATF_TC_HEAD(stat_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from the stat(2) family"); } ATF_TC_BODY(stat_err, tc) { char buf[NAME_MAX + 1]; struct stat st; (void)memset(buf, 'x', sizeof(buf)); errno = 0; ATF_REQUIRE_ERRNO(EBADF, fstat(-1, &st) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENAMETOOLONG, stat(buf, &st) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENAMETOOLONG, lstat(buf, &st) == -1); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, stat((void *)-1, &st) == -1); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, lstat((void *)-1, &st) == -1); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, stat("/etc/passwd", (void *)-1) == -1); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, lstat("/etc/passwd", (void *)-1) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOENT, stat("/a/b/c/d/e/f/g/h/i/j/k", &st) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOENT, lstat("/a/b/c/d/e/f/g/h/i/j/k", &st) == -1); } ATF_TC_WITH_CLEANUP(stat_mtime); ATF_TC_HEAD(stat_mtime, tc) { atf_tc_set_md_var(tc, "descr", "Test modification times with stat(2)"); } ATF_TC_BODY(stat_mtime, tc) { struct stat sa, sb; int fd[3]; size_t i; for (i = 0; i < __arraycount(fd); i++) { (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); fd[i] = open(path, O_WRONLY | O_CREAT); ATF_REQUIRE(fd[i] != -1); ATF_REQUIRE(write(fd[i], "X", 1) == 1); ATF_REQUIRE(stat(path, &sa) == 0); (void)sleep(1); ATF_REQUIRE(write(fd[i], "X", 1) == 1); ATF_REQUIRE(stat(path, &sb) == 0); ATF_REQUIRE(close(fd[i]) == 0); ATF_REQUIRE(unlink(path) == 0); if (sa.st_mtime == sb.st_mtime) atf_tc_fail("mtimes did not change"); } } ATF_TC_CLEANUP(stat_mtime, tc) { (void)unlink(path); } ATF_TC_WITH_CLEANUP(stat_perm); ATF_TC_HEAD(stat_perm, tc) { atf_tc_set_md_var(tc, "descr", "Test permissions with stat(2)"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(stat_perm, tc) { struct stat sa, sb; gid_t gid; uid_t uid; int fd; (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); uid = getuid(); gid = getgid(); fd = open(path, O_RDONLY | O_CREAT); ATF_REQUIRE(fd != -1); ATF_REQUIRE(fstat(fd, &sa) == 0); ATF_REQUIRE(stat(path, &sb) == 0); if (gid != sa.st_gid || sa.st_gid != sb.st_gid) atf_tc_fail("invalid GID"); if (uid != sa.st_uid || sa.st_uid != sb.st_uid) atf_tc_fail("invalid UID"); ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(unlink(path) == 0); } ATF_TC_CLEANUP(stat_perm, tc) { (void)unlink(path); } ATF_TC_WITH_CLEANUP(stat_size); ATF_TC_HEAD(stat_size, tc) { atf_tc_set_md_var(tc, "descr", "Test file sizes with stat(2)"); } ATF_TC_BODY(stat_size, tc) { struct stat sa, sb, sc; const size_t n = 10; size_t i; int fd; fd = open(path, O_WRONLY | O_CREAT); ATF_REQUIRE(fd >= 0); for (i = 0; i < n; i++) { (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); (void)memset(&sc, 0, sizeof(struct stat)); ATF_REQUIRE(fstat(fd, &sa) == 0); ATF_REQUIRE(write(fd, "X", 1) == 1); ATF_REQUIRE(fstat(fd, &sb) == 0); ATF_REQUIRE(stat(path, &sc) == 0); if (sa.st_size + 1 != sb.st_size) atf_tc_fail("invalid file size"); if (sb.st_size != sc.st_size) atf_tc_fail("stat(2) and fstat(2) mismatch"); } ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(unlink(path) == 0); } ATF_TC_CLEANUP(stat_size, tc) { (void)unlink(path); } ATF_TC(stat_socket); ATF_TC_HEAD(stat_socket, tc) { atf_tc_set_md_var(tc, "descr", "Test fstat(2) with " "a socket (PR kern/46077)"); } ATF_TC_BODY(stat_socket, tc) { struct sockaddr_in addr; struct stat st; uint32_t iaddr; int fd, flags; (void)memset(&st, 0, sizeof(struct stat)); (void)memset(&addr, 0, sizeof(struct sockaddr_in)); fd = socket(AF_INET, SOCK_STREAM, 0); ATF_REQUIRE(fd >= 0); flags = fcntl(fd, F_GETFL); ATF_REQUIRE(flags != -1); ATF_REQUIRE(fcntl(fd, F_SETFL, flags | O_NONBLOCK) != -1); ATF_REQUIRE(inet_pton(AF_INET, "127.0.0.1", &iaddr) == 1); addr.sin_port = htons(42); addr.sin_family = AF_INET; addr.sin_addr.s_addr = iaddr; errno = 0; ATF_REQUIRE_ERRNO(EINPROGRESS, connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) == -1); errno = 0; if (fstat(fd, &st) != 0 || errno != 0) atf_tc_fail("fstat(2) failed for a EINPROGRESS socket"); (void)close(fd); } ATF_TC_WITH_CLEANUP(stat_symlink); ATF_TC_HEAD(stat_symlink, tc) { atf_tc_set_md_var(tc, "descr", "Test symbolic links with stat(2)"); } ATF_TC_BODY(stat_symlink, tc) { const char *pathlink = "pathlink"; struct stat sa, sb; int fd; (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); fd = open(path, O_WRONLY | O_CREAT); ATF_REQUIRE(fd >= 0); ATF_REQUIRE(symlink(path, pathlink) == 0); ATF_REQUIRE(stat(pathlink, &sa) == 0); ATF_REQUIRE(lstat(pathlink, &sb) == 0); if (S_ISLNK(sa.st_mode) != 0) atf_tc_fail("stat(2) detected symbolic link"); if (S_ISLNK(sb.st_mode) == 0) atf_tc_fail("lstat(2) did not detect symbolic link"); if (sa.st_mode == sb.st_mode) atf_tc_fail("inconsistencies between stat(2) and lstat(2)"); + (void)close(fd); ATF_REQUIRE(unlink(path) == 0); ATF_REQUIRE(unlink(pathlink) == 0); #ifdef __FreeBSD__ (void)close(fd); #endif } ATF_TC_CLEANUP(stat_symlink, tc) { (void)unlink(path); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, stat_chflags); ATF_TP_ADD_TC(tp, stat_dir); ATF_TP_ADD_TC(tp, stat_err); ATF_TP_ADD_TC(tp, stat_mtime); ATF_TP_ADD_TC(tp, stat_perm); ATF_TP_ADD_TC(tp, stat_size); ATF_TP_ADD_TC(tp, stat_socket); ATF_TP_ADD_TC(tp, stat_symlink); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_truncate.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_truncate.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_truncate.c (revision 312126) @@ -1,188 +1,183 @@ -/* $NetBSD: t_truncate.c,v 1.2 2011/08/18 19:48:03 dholland Exp $ */ +/* $NetBSD: t_truncate.c,v 1.3 2017/01/13 20:03:51 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_truncate.c,v 1.2 2011/08/18 19:48:03 dholland Exp $"); +__RCSID("$NetBSD: t_truncate.c,v 1.3 2017/01/13 20:03:51 christos Exp $"); #include #include #include #include +#include #include #include #include #ifdef __FreeBSD__ #include #endif static const char path[] = "truncate"; static const size_t sizes[] = { 8, 16, 512, 1024, 2048, 4094, 3000, 30 }; ATF_TC_WITH_CLEANUP(ftruncate_basic); ATF_TC_HEAD(ftruncate_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of ftruncate(2)"); } ATF_TC_BODY(ftruncate_basic, tc) { struct stat st; size_t i; int fd; fd = open(path, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); for (i = 0; i < __arraycount(sizes); i++) { (void)memset(&st, 0, sizeof(struct stat)); ATF_REQUIRE(ftruncate(fd, sizes[i]) == 0); ATF_REQUIRE(fstat(fd, &st) == 0); (void)fprintf(stderr, "truncating to %zu bytes\n", sizes[i]); if (sizes[i] != (size_t)st.st_size) atf_tc_fail("ftruncate(2) did not truncate"); } (void)close(fd); (void)unlink(path); } ATF_TC_CLEANUP(ftruncate_basic, tc) { (void)unlink(path); } ATF_TC(ftruncate_err); ATF_TC_HEAD(ftruncate_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from ftruncate(2)"); atf_tc_set_md_var(tc, "require.user", "unprivileged"); } ATF_TC_BODY(ftruncate_err, tc) { int fd; fd = open("/etc/passwd", O_RDONLY, 0400); ATF_REQUIRE(fd >= 0); errno = 0; ATF_REQUIRE_ERRNO(EBADF, ftruncate(-1, 999) == -1); errno = 0; ATF_REQUIRE_ERRNO(EINVAL, ftruncate(fd, 999) == -1); (void)close(fd); } ATF_TC_WITH_CLEANUP(truncate_basic); ATF_TC_HEAD(truncate_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of truncate(2)"); } ATF_TC_BODY(truncate_basic, tc) { struct stat st; size_t i; int fd; fd = open(path, O_RDWR | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); for (i = 0; i < __arraycount(sizes); i++) { (void)memset(&st, 0, sizeof(struct stat)); ATF_REQUIRE(truncate(path, sizes[i]) == 0); ATF_REQUIRE(fstat(fd, &st) == 0); (void)fprintf(stderr, "truncating to %zu bytes\n", sizes[i]); if (sizes[i] != (size_t)st.st_size) atf_tc_fail("truncate(2) did not truncate"); } (void)close(fd); (void)unlink(path); } ATF_TC_CLEANUP(truncate_basic, tc) { (void)unlink(path); } ATF_TC(truncate_err); ATF_TC_HEAD(truncate_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from truncate(2)"); atf_tc_set_md_var(tc, "require.user", "unprivileged"); } ATF_TC_BODY(truncate_err, tc) { -#ifndef __NetBSD__ char buf[PATH_MAX]; -#endif errno = 0; ATF_REQUIRE_ERRNO(EFAULT, truncate((void *)-1, 999) == -1); errno = 0; ATF_REQUIRE_ERRNO(EISDIR, truncate("/etc", 999) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOENT, truncate("/a/b/c/d/e/f/g", 999) == -1); errno = 0; -#ifdef __NetBSD__ - ATF_REQUIRE_ERRNO(EACCES, truncate("/usr/bin/fpr", 999) == -1); -#else snprintf(buf, sizeof(buf), "%s/truncate_test.root_owned", atf_tc_get_config_var(tc, "srcdir")); ATF_REQUIRE_ERRNO(EACCES, truncate(buf, 999) == -1); -#endif } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, ftruncate_basic); ATF_TP_ADD_TC(tp, ftruncate_err); ATF_TP_ADD_TC(tp, truncate_basic); ATF_TP_ADD_TC(tp, truncate_err); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_umask.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_umask.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_umask.c (revision 312126) @@ -1,208 +1,206 @@ -/* $NetBSD: t_umask.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $ */ +/* $NetBSD: t_umask.c,v 1.2 2017/01/13 19:34:19 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_umask.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $"); +__RCSID("$NetBSD: t_umask.c,v 1.2 2017/01/13 19:34:19 christos Exp $"); #include #include #include #include #include #include #include static const char path[] = "umask"; static const mode_t mask[] = { S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR, S_IRWXG, S_IRGRP, S_IWGRP, S_IXGRP, S_IRWXO, S_IROTH, S_IWOTH, S_IXOTH }; ATF_TC_WITH_CLEANUP(umask_fork); ATF_TC_HEAD(umask_fork, tc) { atf_tc_set_md_var(tc, "descr", "Check that umask(2) is inherited"); } ATF_TC_BODY(umask_fork, tc) { mode_t mode; pid_t pid; size_t i; int sta; for (i = 0; i < __arraycount(mask) - 1; i++) { (void)umask(mask[i] | mask[i + 1]); pid = fork(); if (pid < 0) continue; if (pid == 0) { mode = umask(mask[i]); if (mode != (mask[i] | mask[i + 1])) _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); } (void)wait(&sta); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) goto fail; } return; fail: (void)umask(S_IWGRP | S_IWOTH); atf_tc_fail("umask(2) was not inherited"); } ATF_TC_CLEANUP(umask_fork, tc) { (void)umask(S_IWGRP | S_IWOTH); } ATF_TC_WITH_CLEANUP(umask_open); ATF_TC_HEAD(umask_open, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of open(2) and umask(2)"); } ATF_TC_BODY(umask_open, tc) { const char *str = NULL; struct stat st; size_t i; int fd; for (i = 0; i < __arraycount(mask); i++) { (void)umask(mask[i]); fd = open(path, O_RDWR | O_CREAT, 0777); if (fd < 0) continue; -#ifdef __FreeBSD__ (void)close(fd); -#endif (void)memset(&st, 0, sizeof(struct stat)); if (stat(path, &st) != 0) { str = "failed to stat(2)"; goto out; } if ((st.st_mode & mask[i]) != 0) { str = "invalid umask(2)"; goto out; } if (unlink(path) != 0) { str = "failed to unlink(2)"; goto out; } } out: (void)umask(S_IWGRP | S_IWOTH); if (str != NULL) atf_tc_fail("%s", str); } ATF_TC_CLEANUP(umask_open, tc) { (void)umask(S_IWGRP | S_IWOTH); (void)unlink(path); } ATF_TC_WITH_CLEANUP(umask_previous); ATF_TC_HEAD(umask_previous, tc) { atf_tc_set_md_var(tc, "descr", "Test the return value from umask(2)"); } ATF_TC_BODY(umask_previous, tc) { mode_t mode; size_t i; for (i = 0; i < __arraycount(mask); i++) { mode = umask(mask[i]); mode = umask(mask[i]); if (mode != mask[i]) goto fail; } return; fail: (void)umask(S_IWGRP | S_IWOTH); atf_tc_fail("umask(2) did not return the previous mask"); } ATF_TC_CLEANUP(umask_previous, tc) { (void)umask(S_IWGRP | S_IWOTH); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, umask_fork); ATF_TP_ADD_TC(tp, umask_open); ATF_TP_ADD_TC(tp, umask_previous); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_unlink.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_unlink.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_unlink.c (revision 312126) @@ -1,169 +1,165 @@ -/* $NetBSD: t_unlink.c,v 1.2 2014/04/21 18:05:17 martin Exp $ */ +/* $NetBSD: t_unlink.c,v 1.3 2017/01/13 19:33:03 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_unlink.c,v 1.2 2014/04/21 18:05:17 martin Exp $"); +__RCSID("$NetBSD: t_unlink.c,v 1.3 2017/01/13 19:33:03 christos Exp $"); #include #include #include #include #include #include #include static char path[] = "unlink"; ATF_TC_WITH_CLEANUP(unlink_basic); ATF_TC_HEAD(unlink_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of unlink(2)"); } ATF_TC_BODY(unlink_basic, tc) { const size_t n = 512; size_t i; int fd; for (i = 0; i < n; i++) { fd = open(path, O_RDWR | O_CREAT, 0666); ATF_REQUIRE(fd != -1); ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(unlink(path) == 0); errno = 0; ATF_REQUIRE_ERRNO(ENOENT, open(path, O_RDONLY) == -1); } } ATF_TC_CLEANUP(unlink_basic, tc) { (void)unlink(path); } ATF_TC_WITH_CLEANUP(unlink_err); ATF_TC_HEAD(unlink_err, tc) { atf_tc_set_md_var(tc, "descr", "Test error conditions of unlink(2)"); } ATF_TC_BODY(unlink_err, tc) { char buf[PATH_MAX + 1]; (void)memset(buf, 'x', sizeof(buf)); errno = 0; #ifdef __FreeBSD__ ATF_REQUIRE_ERRNO(EISDIR, unlink("/") == -1); #else ATF_REQUIRE_ERRNO(EBUSY, unlink("/") == -1); #endif errno = 0; ATF_REQUIRE_ERRNO(ENAMETOOLONG, unlink(buf) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOENT, unlink("/a/b/c/d/e/f/g/h/i/j/k/l/m") == -1); } ATF_TC_CLEANUP(unlink_err, tc) { (void)unlink(path); } ATF_TC_WITH_CLEANUP(unlink_fifo); ATF_TC_HEAD(unlink_fifo, tc) { atf_tc_set_md_var(tc, "descr", "Test unlink(2) for a FIFO"); } ATF_TC_BODY(unlink_fifo, tc) { -#ifdef __FreeBSD__ int fd; ATF_REQUIRE_MSG((fd = mkfifo(path, 0666)) == 0, "mkfifo failed: %s", strerror(errno)); (void)close(fd); -#else - ATF_REQUIRE(mkfifo(path, 0666) == 0); -#endif ATF_REQUIRE(unlink(path) == 0); errno = 0; ATF_REQUIRE_ERRNO(ENOENT, open(path, O_RDONLY) == -1); } ATF_TC_CLEANUP(unlink_fifo, tc) { (void)unlink(path); } ATF_TC_WITH_CLEANUP(unlink_perm); ATF_TC_HEAD(unlink_perm, tc) { atf_tc_set_md_var(tc, "descr", "Test permissions with unlink(2)"); atf_tc_set_md_var(tc, "require.user", "unprivileged"); } ATF_TC_BODY(unlink_perm, tc) { int rv; errno = 0; rv = unlink("/etc"); ATF_REQUIRE_MSG(rv == -1 && (errno == EACCES || errno == EPERM), "unlinking a directory did not fail with EPERM or EACCESS; " "unlink() returned %d, errno %d", rv, errno); errno = 0; ATF_REQUIRE_ERRNO(EACCES, unlink("/root/.profile") == -1); } ATF_TC_CLEANUP(unlink_perm, tc) { (void)unlink(path); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, unlink_basic); ATF_TP_ADD_TC(tp, unlink_err); ATF_TP_ADD_TC(tp, unlink_fifo); ATF_TP_ADD_TC(tp, unlink_perm); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_wait.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_wait.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_wait.c (revision 312126) @@ -1,323 +1,324 @@ -/* $NetBSD: t_wait.c,v 1.7 2016/11/06 15:04:14 kamil Exp $ */ +/* $NetBSD: t_wait.c,v 1.8 2017/01/13 19:28:55 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Christos Zoulas. * * 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 -__RCSID("$NetBSD: t_wait.c,v 1.7 2016/11/06 15:04:14 kamil Exp $"); +__RCSID("$NetBSD: t_wait.c,v 1.8 2017/01/13 19:28:55 christos Exp $"); #include #include -#include #include +#include #include #include #include +#include #include #include #include #ifdef __FreeBSD__ #define wrusage __wrusage #endif ATF_TC(wait6_invalid); ATF_TC_HEAD(wait6_invalid, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait6(2) returns EINVAL with 0 options"); } ATF_TC_BODY(wait6_invalid, tc) { siginfo_t si; struct wrusage wru; int st; ATF_REQUIRE(wait6(P_ALL, 0, &st, 0, &wru, &si) == -1 && errno == EINVAL); } ATF_TC(wait6_exited); ATF_TC_HEAD(wait6_exited, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait6(2) handled exiting process and code"); } ATF_TC_BODY(wait6_exited, tc) { siginfo_t si; struct wrusage wru; int st; pid_t pid; switch (pid = fork()) { case -1: ATF_REQUIRE(pid > 0); case 0: exit(0x5a5a5a5a); /*NOTREACHED*/ default: ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); ATF_REQUIRE(WIFEXITED(st) && WEXITSTATUS(st) == 0x5a); ATF_REQUIRE(si.si_status = 0x5a5a5a5a); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); ATF_REQUIRE(si.si_code == CLD_EXITED); #ifdef __NetBSD__ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime, (uintmax_t)si.si_utime); #endif break; } } ATF_TC(wait6_terminated); ATF_TC_HEAD(wait6_terminated, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait6(2) handled terminated process and code"); } ATF_TC_BODY(wait6_terminated, tc) { siginfo_t si; struct wrusage wru; int st; pid_t pid; switch (pid = fork()) { case 0: sleep(100); /*FALLTHROUGH*/ case -1: ATF_REQUIRE(pid > 0); default: ATF_REQUIRE(kill(pid, SIGTERM) == 0); ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); ATF_REQUIRE(WIFSIGNALED(st) && WTERMSIG(st) == SIGTERM); ATF_REQUIRE(si.si_status == SIGTERM); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); ATF_REQUIRE(si.si_code == CLD_KILLED); #ifdef __NetBSD__ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime, (uintmax_t)si.si_utime); #endif break; } } ATF_TC(wait6_coredumped); ATF_TC_HEAD(wait6_coredumped, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait6(2) handled coredumped process and code"); } ATF_TC_BODY(wait6_coredumped, tc) { siginfo_t si; struct wrusage wru; int st; pid_t pid; static const struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY }; switch (pid = fork()) { case 0: ATF_REQUIRE(setrlimit(RLIMIT_CORE, &rl) == 0); *(char *)8 = 0; /*FALLTHROUGH*/ case -1: ATF_REQUIRE(pid > 0); default: ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); ATF_REQUIRE(WIFSIGNALED(st) && WTERMSIG(st) == SIGSEGV && WCOREDUMP(st)); ATF_REQUIRE(si.si_status == SIGSEGV); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); ATF_REQUIRE(si.si_code == CLD_DUMPED); #ifdef __NetBSD__ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime, (uintmax_t)si.si_utime); #endif break; } } ATF_TC(wait6_stop_and_go); ATF_TC_HEAD(wait6_stop_and_go, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait6(2) handled stopped/continued process and code"); } ATF_TC_BODY(wait6_stop_and_go, tc) { siginfo_t si; struct wrusage wru; int st; pid_t pid; static const struct rlimit rl = { 0, 0 }; ATF_REQUIRE(setrlimit(RLIMIT_CORE, &rl) == 0); switch (pid = fork()) { case 0: sleep(100); /*FALLTHROUGH*/ case -1: ATF_REQUIRE(pid > 0); default: ATF_REQUIRE(kill(pid, SIGSTOP) == 0); ATF_REQUIRE(wait6(P_PID, pid, &st, WSTOPPED, &wru, &si) == pid); ATF_REQUIRE(!WIFEXITED(st)); ATF_REQUIRE(!WIFSIGNALED(st)); ATF_REQUIRE(WIFSTOPPED(st) && WSTOPSIG(st) == SIGSTOP); ATF_REQUIRE(!WIFCONTINUED(st)); ATF_REQUIRE(si.si_status == SIGSTOP); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); ATF_REQUIRE(si.si_code == CLD_STOPPED); #ifdef __NetBSD__ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime, (uintmax_t)si.si_utime); #endif ATF_REQUIRE(kill(pid, SIGCONT) == 0); ATF_REQUIRE(wait6(P_PID, pid, &st, WCONTINUED, &wru, &si) == pid); ATF_REQUIRE(!WIFEXITED(st)); ATF_REQUIRE(!WIFSIGNALED(st)); ATF_REQUIRE(WIFCONTINUED(st)); ATF_REQUIRE(!WIFSTOPPED(st)); ATF_REQUIRE(si.si_status == SIGCONT); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); ATF_REQUIRE(si.si_code == CLD_CONTINUED); #ifdef __NetBSD__ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime, (uintmax_t)si.si_utime); #endif ATF_REQUIRE(kill(pid, SIGQUIT) == 0); ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); ATF_REQUIRE(!WIFEXITED(st)); ATF_REQUIRE(WIFSIGNALED(st) && WTERMSIG(st) == SIGQUIT); ATF_REQUIRE(!WIFSTOPPED(st)); ATF_REQUIRE(!WIFCONTINUED(st)); ATF_REQUIRE(si.si_status == SIGQUIT); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); ATF_REQUIRE(si.si_code == CLD_KILLED); #ifdef __NetBSD__ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime, (uintmax_t)si.si_utime); #endif break; } } ATF_TC(wait6_stopgo_loop); ATF_TC_HEAD(wait6_stopgo_loop, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait6(2) handled stopped/continued process loop"); } ATF_TC_BODY(wait6_stopgo_loop, tc) { siginfo_t si; struct wrusage wru; int st; pid_t pid; static const struct rlimit rl = { 0, 0 }; size_t N = 100; ATF_REQUIRE(setrlimit(RLIMIT_CORE, &rl) == 0); switch (pid = fork()) { case 0: sleep(100); /*FALLTHROUGH*/ case -1: ATF_REQUIRE(pid > 0); } printf("Before loop of SIGSTOP/SIGCONT sequence %zu times\n", N); while (N --> 0) { ATF_REQUIRE(kill(pid, SIGSTOP) == 0); ATF_REQUIRE(wait6(P_PID, pid, &st, WSTOPPED, &wru, &si) == pid); ATF_REQUIRE(!WIFEXITED(st)); ATF_REQUIRE(!WIFSIGNALED(st)); ATF_REQUIRE(WIFSTOPPED(st) && WSTOPSIG(st) == SIGSTOP); ATF_REQUIRE(!WIFCONTINUED(st)); ATF_REQUIRE(si.si_status == SIGSTOP); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); ATF_REQUIRE(si.si_code == CLD_STOPPED); ATF_REQUIRE(kill(pid, SIGCONT) == 0); ATF_REQUIRE(wait6(P_PID, pid, &st, WCONTINUED, &wru, &si) == pid); ATF_REQUIRE(!WIFEXITED(st)); ATF_REQUIRE(!WIFSIGNALED(st)); ATF_REQUIRE(WIFCONTINUED(st)); ATF_REQUIRE(!WIFSTOPPED(st)); ATF_REQUIRE(si.si_status == SIGCONT); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); ATF_REQUIRE(si.si_code == CLD_CONTINUED); } ATF_REQUIRE(kill(pid, SIGQUIT) == 0); ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); ATF_REQUIRE(!WIFEXITED(st)); ATF_REQUIRE(WIFSIGNALED(st) && WTERMSIG(st) == SIGQUIT); ATF_REQUIRE(!WIFSTOPPED(st)); ATF_REQUIRE(!WIFCONTINUED(st)); ATF_REQUIRE(si.si_status == SIGQUIT); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); ATF_REQUIRE(si.si_code == CLD_KILLED); #ifdef __NetBSD__ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime, (uintmax_t)si.si_utime); #endif } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, wait6_invalid); ATF_TP_ADD_TC(tp, wait6_exited); ATF_TP_ADD_TC(tp, wait6_terminated); ATF_TP_ADD_TC(tp, wait6_coredumped); ATF_TP_ADD_TC(tp, wait6_stop_and_go); ATF_TP_ADD_TC(tp, wait6_stopgo_loop); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_write.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_write.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_write.c (revision 312126) @@ -1,236 +1,226 @@ -/* $NetBSD: t_write.c,v 1.2 2011/10/19 16:19:30 jruoho Exp $ */ +/* $NetBSD: t_write.c,v 1.3 2017/01/13 19:27:23 christos Exp $ */ /*- * Copyright (c) 2001, 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_write.c,v 1.2 2011/10/19 16:19:30 jruoho Exp $"); +__RCSID("$NetBSD: t_write.c,v 1.3 2017/01/13 19:27:23 christos Exp $"); #include -#ifdef __NetBSD__ -#include -#endif #include #include #include #include +#include #include #include #include #include -#ifdef __FreeBSD__ -#include -#endif - static void sighandler(int); static bool fail = false; static const char *path = "write"; static void -#ifdef __FreeBSD__ sighandler(int signo __unused) -#else -sighandler(int signo) -#endif { fail = false; } ATF_TC_WITH_CLEANUP(write_err); ATF_TC_HEAD(write_err, tc) { atf_tc_set_md_var(tc, "descr", "Checks errors from write(2)"); } ATF_TC_BODY(write_err, tc) { char rbuf[3] = { 'a', 'b', 'c' }; char wbuf[3] = { 'x', 'y', 'z' }; int fd; errno = 0; ATF_REQUIRE_ERRNO(EBADF, write(-1, wbuf, sizeof(wbuf)) == -1); fd = open(path, O_RDWR | O_CREAT); if (fd >= 0) { errno = 0; ATF_REQUIRE_ERRNO(0, write(fd, wbuf, 3) == 3); errno = 0; ATF_REQUIRE_ERRNO(EINVAL, write(fd, wbuf, SIZE_MAX) == -1); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, write(fd, (void *)-1, 1) == -1); /* * Check that the above bogus write(2) * calls did not corrupt the file. */ ATF_REQUIRE(lseek(fd, 0, SEEK_SET) == 0); ATF_REQUIRE(read(fd, rbuf, 3) == 3); ATF_REQUIRE(memcmp(rbuf, wbuf, 3) == 0); (void)close(fd); (void)unlink(path); } } ATF_TC_CLEANUP(write_err, tc) { (void)unlink(path); } ATF_TC(write_pipe); ATF_TC_HEAD(write_pipe, tc) { atf_tc_set_md_var(tc, "descr", "Checks for EPIPE from write(2)"); } ATF_TC_BODY(write_pipe, tc) { int fds[2]; ATF_REQUIRE(pipe(fds) == 0); ATF_REQUIRE(signal(SIGPIPE, sighandler) == 0); ATF_REQUIRE(write(fds[1], "x", 1) != -1); ATF_REQUIRE(close(fds[0]) == 0); errno = 0; fail = true; if (write(fds[1], "x", 1) != -1 || errno != EPIPE) atf_tc_fail_nonfatal("expected EPIPE but write(2) succeeded"); ATF_REQUIRE(close(fds[1]) == 0); if (fail != false) atf_tc_fail_nonfatal("SIGPIPE was not raised"); } ATF_TC_WITH_CLEANUP(write_pos); ATF_TC_HEAD(write_pos, tc) { atf_tc_set_md_var(tc, "descr", "Checks that write(2) " "updates the file position"); } ATF_TC_BODY(write_pos, tc) { const size_t n = 123; size_t i; int fd; fd = open(path, O_RDWR | O_CREAT); ATF_REQUIRE(fd >= 0); for (i = 0; i < n; i++) { ATF_REQUIRE(write(fd, "x", 1) == 1); ATF_REQUIRE(lseek(fd, 0, SEEK_CUR) == (off_t)(i + 1)); } ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(unlink(path) == 0); } ATF_TC_CLEANUP(write_pos, tc) { (void)unlink(path); } ATF_TC_WITH_CLEANUP(write_ret); ATF_TC_HEAD(write_ret, tc) { atf_tc_set_md_var(tc, "descr", "Checks return values from write(2)"); } ATF_TC_BODY(write_ret, tc) { const size_t n = 99; char buf[123]; size_t i, j; int fd; fd = open(path, O_WRONLY | O_CREAT); ATF_REQUIRE(fd >= 0); (void)memset(buf, 'x', sizeof(buf)); for (i = j = 0; i < n; i++) j += write(fd, buf, sizeof(buf)); if (j != n * 123) atf_tc_fail("inconsistent return values from write(2)"); (void)close(fd); (void)unlink(path); } ATF_TC_CLEANUP(write_ret, tc) { (void)unlink(path); } ATF_TC(writev_iovmax); ATF_TC_HEAD(writev_iovmax, tc) { atf_tc_set_md_var(tc, "timeout", "10"); atf_tc_set_md_var(tc, "descr", "Checks that file descriptor is properly FILE_UNUSE()d " "when iovcnt is greater than IOV_MAX"); } ATF_TC_BODY(writev_iovmax, tc) { ssize_t retval; (void)printf("Calling writev(2, NULL, IOV_MAX + 1)...\n"); errno = 0; retval = writev(2, NULL, IOV_MAX + 1); ATF_REQUIRE_EQ_MSG(retval, -1, "got: %zd", retval); ATF_REQUIRE_EQ_MSG(errno, EINVAL, "got: %s", strerror(errno)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, write_err); ATF_TP_ADD_TC(tp, write_pipe); ATF_TP_ADD_TC(tp, write_pos); ATF_TP_ADD_TC(tp, write_ret); ATF_TP_ADD_TC(tp, writev_iovmax); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libm/t_ilogb.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libm/t_ilogb.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libm/t_ilogb.c (revision 312126) @@ -1,130 +1,133 @@ -/* $NetBSD: t_ilogb.c,v 1.6 2016/08/26 08:01:55 christos Exp $ */ +/* $NetBSD: t_ilogb.c,v 1.7 2017/01/13 19:23:40 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Maya Rashish. * * 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 +__RCSID("$NetBSD: t_ilogb.c,v 1.7 2017/01/13 19:23:40 christos Exp $"); #ifdef __FreeBSD__ #include #endif #include #include +#include #include #ifndef __HAVE_FENV -# define ATF_CHECK_RAISED_INVALID -# define ATF_CHECK_RAISED_NOTHING +# define ATF_CHECK_RAISED_INVALID +# define ATF_CHECK_RAISED_NOTHING #else # define ATF_CHECK_RAISED_INVALID do { \ int r = fetestexcept(FE_ALL_EXCEPT); \ ATF_CHECK_MSG(r == FE_INVALID, "r=%#x != %#x\n", r, FE_INVALID); \ (void)feclearexcept(FE_ALL_EXCEPT); \ } while (/*CONSTCOND*/0) # define ATF_CHECK_RAISED_NOTHING do { \ int r = fetestexcept(FE_ALL_EXCEPT); \ ATF_CHECK_MSG(r == 0, "r=%#x != 0\n", r); \ (void)feclearexcept(FE_ALL_EXCEPT); \ } while (/*CONSTCOND*/0) #endif ATF_TC(ilogb); ATF_TC_HEAD(ilogb, tc) { atf_tc_set_md_var(tc, "descr","Check ilogb family"); } ATF_TC_BODY(ilogb, tc) { ATF_CHECK(ilogbf(0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; #ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; #endif ATF_CHECK(ilogbf(-0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(-0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; #ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(-0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; #endif ATF_CHECK(ilogbf(INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; #ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; #endif ATF_CHECK(ilogbf(-INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(-INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; #ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(-INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; #endif ATF_CHECK(ilogbf(1024) == 10); ATF_CHECK_RAISED_NOTHING; ATF_CHECK(ilogb(1024) == 10); ATF_CHECK_RAISED_NOTHING; #ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(1024) == 10); ATF_CHECK_RAISED_NOTHING; #endif #ifndef __vax__ ATF_CHECK(ilogbf(NAN) == FP_ILOGBNAN); ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(NAN) == FP_ILOGBNAN); ATF_CHECK_RAISED_INVALID; #ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(NAN) == FP_ILOGBNAN); ATF_CHECK_RAISED_INVALID; #endif #endif } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, ilogb); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libm/t_scalbn.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libm/t_scalbn.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libm/t_scalbn.c (revision 312126) @@ -1,532 +1,526 @@ -/* $NetBSD: t_scalbn.c,v 1.11 2014/03/03 10:39:08 martin Exp $ */ +/* $NetBSD: t_scalbn.c,v 1.14 2017/01/13 21:09:12 agc Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_scalbn.c,v 1.11 2014/03/03 10:39:08 martin Exp $"); +__RCSID("$NetBSD: t_scalbn.c,v 1.14 2017/01/13 21:09:12 agc Exp $"); #include #include #include #include #include static const int exps[] = { 0, 1, -1, 100, -100 }; /* tests here do not require specific precision, so we just use double */ struct testcase { int exp; double inval; double result; int error; }; struct testcase test_vals[] = { { 0, 1.00085, 1.00085, 0 }, { 0, 0.99755, 0.99755, 0 }, { 0, -1.00085, -1.00085, 0 }, { 0, -0.99755, -0.99755, 0 }, { 1, 1.00085, 2.0* 1.00085, 0 }, { 1, 0.99755, 2.0* 0.99755, 0 }, { 1, -1.00085, 2.0* -1.00085, 0 }, { 1, -0.99755, 2.0* -0.99755, 0 }, /* * We could add more corner test cases here, but we would have to * add some ifdefs for the exact format and use a reliable * generator program - bail for now and only do trivial stuff above. */ }; /* * scalbn(3) */ ATF_TC(scalbn_val); ATF_TC_HEAD(scalbn_val, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbn() for a few values"); } ATF_TC_BODY(scalbn_val, tc) { const struct testcase *tests = test_vals; const size_t tcnt = __arraycount(test_vals); size_t i; double rv; for (i = 0; i < tcnt; i++) { -#ifdef __FreeBSD__ errno = 0; -#endif rv = scalbn(tests[i].inval, tests[i].exp); ATF_CHECK_EQ_MSG(errno, tests[i].error, "test %zu: errno %d instead of %d", i, errno, tests[i].error); ATF_CHECK_MSG(fabs(rv-tests[i].result)<2.0*DBL_EPSILON, "test %zu: return value %g instead of %g (difference %g)", i, rv, tests[i].result, tests[i].result-rv); } } ATF_TC(scalbn_nan); ATF_TC_HEAD(scalbn_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbn(NaN, n) == NaN"); } ATF_TC_BODY(scalbn_nan, tc) { const double x = 0.0L / 0.0L; double y; size_t i; ATF_REQUIRE(isnan(x) != 0); for (i = 0; i < __arraycount(exps); i++) { y = scalbn(x, exps[i]); ATF_CHECK(isnan(y) != 0); } } ATF_TC(scalbn_inf_neg); ATF_TC_HEAD(scalbn_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbn(-Inf, n) == -Inf"); } ATF_TC_BODY(scalbn_inf_neg, tc) { const double x = -1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(scalbn(x, exps[i]) == x); } ATF_TC(scalbn_inf_pos); ATF_TC_HEAD(scalbn_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbn(+Inf, n) == +Inf"); } ATF_TC_BODY(scalbn_inf_pos, tc) { const double x = 1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(scalbn(x, exps[i]) == x); } ATF_TC(scalbn_ldexp); ATF_TC_HEAD(scalbn_ldexp, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbn(x, n) == ldexp(x, n)"); } ATF_TC_BODY(scalbn_ldexp, tc) { #if FLT_RADIX == 2 const double x = 2.91288191221812821; double y; size_t i; for (i = 0; i < __arraycount(exps); i++) { y = scalbn(x, exps[i]); ATF_CHECK_MSG(y == ldexp(x, exps[i]), "test %zu: exponent=%d, " "y=%g, expected %g (diff: %g)", i, exps[i], y, ldexp(x, exps[i]), y - ldexp(x, exps[i])); } #endif } ATF_TC(scalbn_zero_neg); ATF_TC_HEAD(scalbn_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbn(-0.0, n) == -0.0"); } ATF_TC_BODY(scalbn_zero_neg, tc) { const double x = -0.0L; double y; size_t i; ATF_REQUIRE(signbit(x) != 0); for (i = 0; i < __arraycount(exps); i++) { y = scalbn(x, exps[i]); ATF_CHECK(x == y); ATF_CHECK(signbit(y) != 0); } } ATF_TC(scalbn_zero_pos); ATF_TC_HEAD(scalbn_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbn(+0.0, n) == +0.0"); } ATF_TC_BODY(scalbn_zero_pos, tc) { const double x = 0.0L; double y; size_t i; ATF_REQUIRE(signbit(x) == 0); for (i = 0; i < __arraycount(exps); i++) { y = scalbn(x, exps[i]); ATF_CHECK(x == y); ATF_CHECK(signbit(y) == 0); } } /* * scalbnf(3) */ ATF_TC(scalbnf_val); ATF_TC_HEAD(scalbnf_val, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnf() for a few values"); } ATF_TC_BODY(scalbnf_val, tc) { const struct testcase *tests = test_vals; const size_t tcnt = __arraycount(test_vals); size_t i; double rv; for (i = 0; i < tcnt; i++) { -#ifdef __FreeBSD__ errno = 0; -#endif rv = scalbnf(tests[i].inval, tests[i].exp); ATF_CHECK_EQ_MSG(errno, tests[i].error, "test %zu: errno %d instead of %d", i, errno, tests[i].error); ATF_CHECK_MSG(fabs(rv-tests[i].result)<2.0*FLT_EPSILON, "test %zu: return value %g instead of %g (difference %g)", i, rv, tests[i].result, tests[i].result-rv); } } ATF_TC(scalbnf_nan); ATF_TC_HEAD(scalbnf_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnf(NaN, n) == NaN"); } ATF_TC_BODY(scalbnf_nan, tc) { const float x = 0.0L / 0.0L; float y; size_t i; ATF_REQUIRE(isnan(x) != 0); for (i = 0; i < __arraycount(exps); i++) { y = scalbnf(x, exps[i]); ATF_CHECK(isnan(y) != 0); } } ATF_TC(scalbnf_inf_neg); ATF_TC_HEAD(scalbnf_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnf(-Inf, n) == -Inf"); } ATF_TC_BODY(scalbnf_inf_neg, tc) { const float x = -1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(scalbnf(x, exps[i]) == x); } ATF_TC(scalbnf_inf_pos); ATF_TC_HEAD(scalbnf_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnf(+Inf, n) == +Inf"); } ATF_TC_BODY(scalbnf_inf_pos, tc) { const float x = 1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(scalbnf(x, exps[i]) == x); } ATF_TC(scalbnf_ldexpf); ATF_TC_HEAD(scalbnf_ldexpf, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnf(x, n) == ldexpf(x, n)"); } ATF_TC_BODY(scalbnf_ldexpf, tc) { #if FLT_RADIX == 2 const float x = 2.91288191221812821; float y; size_t i; for (i = 0; i < __arraycount(exps); i++) { y = scalbnf(x, exps[i]); ATF_CHECK_MSG(y == ldexpf(x, exps[i]), "test %zu: exponent=%d, y=%g ldexpf returns %g (diff: %g)", i, exps[i], y, ldexpf(x, exps[i]), y-ldexpf(x, exps[i])); } #endif } ATF_TC(scalbnf_zero_neg); ATF_TC_HEAD(scalbnf_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnf(-0.0, n) == -0.0"); } ATF_TC_BODY(scalbnf_zero_neg, tc) { const float x = -0.0L; float y; size_t i; ATF_REQUIRE(signbit(x) != 0); for (i = 0; i < __arraycount(exps); i++) { y = scalbnf(x, exps[i]); ATF_CHECK(x == y); ATF_CHECK(signbit(y) != 0); } } ATF_TC(scalbnf_zero_pos); ATF_TC_HEAD(scalbnf_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnf(+0.0, n) == +0.0"); } ATF_TC_BODY(scalbnf_zero_pos, tc) { const float x = 0.0L; float y; size_t i; ATF_REQUIRE(signbit(x) == 0); for (i = 0; i < __arraycount(exps); i++) { y = scalbnf(x, exps[i]); ATF_CHECK(x == y); ATF_CHECK(signbit(y) == 0); } } /* * scalbnl(3) */ ATF_TC(scalbnl_val); ATF_TC_HEAD(scalbnl_val, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnl() for a few values"); } ATF_TC_BODY(scalbnl_val, tc) { #ifndef __HAVE_LONG_DOUBLE atf_tc_skip("Requires long double support"); #else const struct testcase *tests = test_vals; const size_t tcnt = __arraycount(test_vals); size_t i; long double rv; for (i = 0; i < tcnt; i++) { -#ifdef __FreeBSD__ errno = 0; -#endif rv = scalbnl(tests[i].inval, tests[i].exp); ATF_CHECK_EQ_MSG(errno, tests[i].error, "test %zu: errno %d instead of %d", i, errno, tests[i].error); ATF_CHECK_MSG(fabsl(rv-(long double)tests[i].result)<2.0*LDBL_EPSILON, "test %zu: return value %Lg instead of %Lg (difference %Lg)", i, rv, (long double)tests[i].result, (long double)tests[i].result-rv); } #endif } ATF_TC(scalbnl_nan); ATF_TC_HEAD(scalbnl_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnl(NaN, n) == NaN"); } ATF_TC_BODY(scalbnl_nan, tc) { #ifndef __HAVE_LONG_DOUBLE atf_tc_skip("Requires long double support"); #else const long double x = 0.0L / 0.0L; long double y; size_t i; if (isnan(x) == 0) { atf_tc_expect_fail("PR lib/45362"); atf_tc_fail("(0.0L / 0.0L) != NaN"); } for (i = 0; i < __arraycount(exps); i++) { y = scalbnl(x, exps[i]); ATF_CHECK(isnan(y) != 0); } #endif } ATF_TC(scalbnl_inf_neg); ATF_TC_HEAD(scalbnl_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnl(-Inf, n) == -Inf"); } ATF_TC_BODY(scalbnl_inf_neg, tc) { #ifndef __HAVE_LONG_DOUBLE atf_tc_skip("Requires long double support"); #else const long double x = -1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(scalbnl(x, exps[i]) == x); #endif } ATF_TC(scalbnl_inf_pos); ATF_TC_HEAD(scalbnl_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnl(+Inf, n) == +Inf"); } ATF_TC_BODY(scalbnl_inf_pos, tc) { #ifndef __HAVE_LONG_DOUBLE atf_tc_skip("Requires long double support"); #else const long double x = 1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(scalbnl(x, exps[i]) == x); #endif } ATF_TC(scalbnl_zero_neg); ATF_TC_HEAD(scalbnl_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnl(-0.0, n) == -0.0"); } ATF_TC_BODY(scalbnl_zero_neg, tc) { #ifndef __HAVE_LONG_DOUBLE atf_tc_skip("Requires long double support"); #else const long double x = -0.0L; long double y; size_t i; ATF_REQUIRE(signbit(x) != 0); for (i = 0; i < __arraycount(exps); i++) { y = scalbnl(x, exps[i]); ATF_CHECK(x == y); ATF_CHECK(signbit(y) != 0); } #endif } ATF_TC(scalbnl_zero_pos); ATF_TC_HEAD(scalbnl_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test scalbnl(+0.0, n) == +0.0"); } ATF_TC_BODY(scalbnl_zero_pos, tc) { #ifndef __HAVE_LONG_DOUBLE atf_tc_skip("Requires long double support"); #else const long double x = 0.0L; long double y; size_t i; ATF_REQUIRE(signbit(x) == 0); for (i = 0; i < __arraycount(exps); i++) { y = scalbnl(x, exps[i]); ATF_CHECK(x == y); ATF_CHECK(signbit(y) == 0); } #endif } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, scalbn_val); ATF_TP_ADD_TC(tp, scalbn_nan); ATF_TP_ADD_TC(tp, scalbn_inf_neg); ATF_TP_ADD_TC(tp, scalbn_inf_pos); ATF_TP_ADD_TC(tp, scalbn_ldexp); ATF_TP_ADD_TC(tp, scalbn_zero_neg); ATF_TP_ADD_TC(tp, scalbn_zero_pos); ATF_TP_ADD_TC(tp, scalbnf_val); ATF_TP_ADD_TC(tp, scalbnf_nan); ATF_TP_ADD_TC(tp, scalbnf_inf_neg); ATF_TP_ADD_TC(tp, scalbnf_inf_pos); ATF_TP_ADD_TC(tp, scalbnf_ldexpf); ATF_TP_ADD_TC(tp, scalbnf_zero_neg); ATF_TP_ADD_TC(tp, scalbnf_zero_pos); ATF_TP_ADD_TC(tp, scalbnl_val); ATF_TP_ADD_TC(tp, scalbnl_nan); ATF_TP_ADD_TC(tp, scalbnl_inf_neg); ATF_TP_ADD_TC(tp, scalbnl_inf_pos); /* ATF_TP_ADD_TC(tp, scalbnl_ldexp); */ ATF_TP_ADD_TC(tp, scalbnl_zero_neg); ATF_TP_ADD_TC(tp, scalbnl_zero_pos); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libposix/t_rename.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libposix/t_rename.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libposix/t_rename.c (revision 312126) @@ -1,89 +1,89 @@ -/* $NetBSD: t_rename.c,v 1.2 2011/05/16 00:03:36 christos Exp $ */ +/* $NetBSD: t_rename.c,v 1.3 2017/01/13 21:30:41 christos Exp $ */ /* * Copyright (c) 2001, 2008, 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. */ #define _NETBSD_SOURCE /* strlcat/random */ #include __COPYRIGHT("@(#) Copyright (c) 2008, 2010\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_rename.c,v 1.2 2011/05/16 00:03:36 christos Exp $"); +__RCSID("$NetBSD: t_rename.c,v 1.3 2017/01/13 21:30:41 christos Exp $"); #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(rename); ATF_TC_HEAD(rename, tc) { atf_tc_set_md_var(tc, "descr", "Checks rename(2)"); } ATF_TC_BODY(rename, tc) { struct stat sb; REQUIRE_LIBC(open("t1", O_CREAT | O_TRUNC | O_WRONLY, 0600), -1); REQUIRE_LIBC(link("t1", "t2"), -1); /* Check if rename to same name works as expected */ REQUIRE_LIBC(rename("t1", "t1"), -1); /* Rename removed file? */ REQUIRE_LIBC(stat("t1", &sb), -1); REQUIRE_LIBC(rename("t1", "t2"), -1); #if BSD_RENAME /* check if rename of hardlinked file works the BSD way */ ATF_REQUIRE_MSG(stat("t1", &sb) != 0, "BSD rename should remove file t1"); ATF_REQUIRE_EQ(errno, ENOENT); #else /* check if rename of hardlinked file works as the standard says */ REQUIRE_LIBC(stat("t1", &sb), -1); #endif /* check if we get the expected error */ /* this also exercises icky shared libraries goo */ ATF_REQUIRE_MSG(rename("no/such/file/or/dir", "no/such/file/or/dir") != 0, "No error renaming nonexistent file"); ATF_REQUIRE_EQ(errno, ENOENT); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, rename); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/h_common.h =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/h_common.h (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/h_common.h (revision 312126) @@ -0,0 +1,128 @@ +/* $NetBSD: h_common.h,v 1.2 2016/11/19 02:30:54 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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. + */ + + +#ifndef H_COMMON_H +#define H_COMMON_H + +#include +#include +#include +#include + +#include + +#define PTHREAD_REQUIRE(x) \ + do { \ + int ret = (x); \ + ATF_REQUIRE_MSG(ret == 0, "%s: %s", #x, strerror(ret)); \ + } while (0) + +#define PTHREAD_REQUIRE_STATUS(x, v) \ + do { \ + int ret = (x); \ + ATF_REQUIRE_MSG(ret == (v), "%s: %s", #x, strerror(ret)); \ + } while (0) + +static int __used +dummy_proc_read(void *arg, caddr_t addr, void *buf, size_t size) +{ + return TD_ERR_ERR; +} + +static int __used +dummy_proc_write(void *arg, caddr_t addr, void *buf, size_t size) +{ + return TD_ERR_ERR; +} + +static int __used +dummy_proc_lookup(void *arg, const char *sym, caddr_t *addr) +{ + return TD_ERR_ERR; +} + +static int __used +dummy_proc_regsize(void *arg, int regset, size_t *size) +{ + return TD_ERR_ERR; +} + +static int __used +dummy_proc_getregs(void *arg, int regset, int lwp, void *buf) +{ + return TD_ERR_ERR; +} + +static int __used +dummy_proc_setregs(void *arg, int regset, int lwp, void *buf) +{ + return TD_ERR_ERR; +} + +/* Minimalistic basic implementation */ + +static int __used +basic_proc_read(void *arg, caddr_t addr, void *buf, size_t size) +{ + memcpy(buf, addr, size); + + return TD_ERR_OK; +} + +static int __used +basic_proc_write(void *arg, caddr_t addr, void *buf, size_t size) +{ + memcpy(addr, buf, size); + + return TD_ERR_OK; +} + +static int __used +basic_proc_lookup(void *arg, const char *sym, caddr_t *addr) +{ + void *handle; + void *symbol; + + ATF_REQUIRE_MSG((handle = dlopen(NULL, RTLD_LOCAL | RTLD_LAZY)) + != NULL, "dlopen(3) failed: %s", dlerror()); + + symbol = dlsym(handle, sym); + + ATF_REQUIRE_MSG(dlclose(handle) == 0, "dlclose(3) failed: %s", + dlerror()); + + if (!symbol) + return TD_ERR_NOSYM; + + *addr = (caddr_t)(uintptr_t)symbol; + + return TD_ERR_OK; +} + +#endif // H_COMMON_H Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/h_common.h ___________________________________________________________________ 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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/t_dummy.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/t_dummy.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/t_dummy.c (revision 312126) @@ -0,0 +1,131 @@ +/* $NetBSD: t_dummy.c,v 1.6 2016/11/19 15:13:46 kamil Exp $ */ + +/*- + * Copyright (c) 2016 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 +__RCSID("$NetBSD: t_dummy.c,v 1.6 2016/11/19 15:13:46 kamil Exp $"); + +#include "h_common.h" +#include +#include + +#include + + +ATF_TC(dummy1); +ATF_TC_HEAD(dummy1, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that dummy lookup functions stop td_open() with failure"); +} + +ATF_TC_BODY(dummy1, tc) +{ + + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta; + + dummy_callbacks.proc_read = dummy_proc_read; + dummy_callbacks.proc_write = dummy_proc_write; + dummy_callbacks.proc_lookup = dummy_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_ERR); +} + +ATF_TC(dummy2); +ATF_TC_HEAD(dummy2, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that td_open() for basic proc_{read,write,lookup} works"); +} + +ATF_TC_BODY(dummy2, tc) +{ + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta; + + dummy_callbacks.proc_read = basic_proc_read; + dummy_callbacks.proc_write = basic_proc_write; + dummy_callbacks.proc_lookup = basic_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + printf("Calling td_open(3)\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK); + + printf("Calling td_close(3)\n"); + ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK); +} + +ATF_TC(dummy3); +ATF_TC_HEAD(dummy3, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that calling twice td_open() for the same process fails"); +} + +ATF_TC_BODY(dummy3, tc) +{ + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta1; + td_proc_t *main_ta2; + + dummy_callbacks.proc_read = basic_proc_read; + dummy_callbacks.proc_write = basic_proc_write; + dummy_callbacks.proc_lookup = basic_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + printf("Calling td_open(3) for the first time - expecting success\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta1) == TD_ERR_OK); + + printf("Calling td_open(3) for the first time - expecting in-use\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta2) == + TD_ERR_INUSE); + + printf("Calling td_close(3) for the first successful call\n"); + ATF_REQUIRE(td_close(main_ta1) == TD_ERR_OK); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, dummy1); + ATF_TP_ADD_TC(tp, dummy2); + ATF_TP_ADD_TC(tp, dummy3); + + return atf_no_error(); +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/t_dummy.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/t_threads.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/t_threads.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/t_threads.c (revision 312126) @@ -0,0 +1,719 @@ +/* $NetBSD: t_threads.c,v 1.9 2017/01/13 05:18:22 christos Exp $ */ + +/*- + * Copyright (c) 2016 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 +__RCSID("$NetBSD: t_threads.c,v 1.9 2017/01/13 05:18:22 christos Exp $"); + +#include +#include +#include +#include +#include +#include + +#include + +#include "h_common.h" + +#define MAX_THREADS (size_t)10 + +ATF_TC(threads1); +ATF_TC_HEAD(threads1, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that td_thr_iter() call without extra logic works"); +} + +static volatile int exiting1; + +static void * +busyFunction1(void *arg) +{ + + while (exiting1 == 0) + usleep(50000); + + return NULL; +} + +static int +iterateThreads1(td_thread_t *thread, void *arg) +{ + + return TD_ERR_OK; +} + +ATF_TC_BODY(threads1, tc) +{ + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta; + size_t i; + pthread_t threads[MAX_THREADS]; + + dummy_callbacks.proc_read = basic_proc_read; + dummy_callbacks.proc_write = basic_proc_write; + dummy_callbacks.proc_lookup = basic_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + for (i = 0; i < MAX_THREADS; i++) { + printf("Creating thread %zu\n", i); + PTHREAD_REQUIRE + (pthread_create(&threads[i], NULL, busyFunction1, NULL)); + } + + printf("Calling td_open(3)\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK); + + ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads1, NULL) == TD_ERR_OK); + + exiting1 = 1; + + printf("Calling td_close(3)\n"); + ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK); +} + +ATF_TC(threads2); +ATF_TC_HEAD(threads2, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that td_thr_iter() call is executed for each thread once"); +} + +static volatile int exiting2; + +static void * +busyFunction2(void *arg) +{ + + while (exiting2 == 0) + usleep(50000); + + return NULL; +} + +static int +iterateThreads2(td_thread_t *thread, void *arg) +{ + int *counter = (int *)arg; + + ++(*counter); + + return TD_ERR_OK; +} + +ATF_TC_BODY(threads2, tc) +{ + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta; + size_t i; + pthread_t threads[MAX_THREADS]; + int count = 0; + + dummy_callbacks.proc_read = basic_proc_read; + dummy_callbacks.proc_write = basic_proc_write; + dummy_callbacks.proc_lookup = basic_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + + for (i = 0; i < MAX_THREADS; i++) { + printf("Creating thread %zu\n", i); + PTHREAD_REQUIRE + (pthread_create(&threads[i], NULL, busyFunction2, NULL)); + } + + printf("Calling td_open(3)\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK); + + ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads2, &count) == TD_ERR_OK); + + exiting2 = 1; + + printf("Calling td_close(3)\n"); + ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK); + + ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1, + "counted threads (%d) != expected threads (%zu)", + count, MAX_THREADS + 1); +} + +ATF_TC(threads3); +ATF_TC_HEAD(threads3, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that for each td_thr_iter() call td_thr_info() is valid"); +} + +static volatile int exiting3; + +static void * +busyFunction3(void *arg) +{ + + while (exiting3 == 0) + usleep(50000); + + return NULL; +} + +static int +iterateThreads3(td_thread_t *thread, void *arg) +{ + int *counter = (int *)arg; + td_thread_info_t info; + + ATF_REQUIRE(td_thr_info(thread, &info) == TD_ERR_OK); + + ++(*counter); + + return TD_ERR_OK; +} + +ATF_TC_BODY(threads3, tc) +{ + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta; + size_t i; + pthread_t threads[MAX_THREADS]; + int count = 0; + + dummy_callbacks.proc_read = basic_proc_read; + dummy_callbacks.proc_write = basic_proc_write; + dummy_callbacks.proc_lookup = basic_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + + for (i = 0; i < MAX_THREADS; i++) { + printf("Creating thread %zu\n", i); + PTHREAD_REQUIRE + (pthread_create(&threads[i], NULL, busyFunction3, NULL)); + } + + printf("Calling td_open(3)\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK); + + ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads3, &count) == TD_ERR_OK); + + exiting3 = 1; + + printf("Calling td_close(3)\n"); + ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK); + + ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1, + "counted threads (%d) != expected threads (%zu)", + count, MAX_THREADS + 1); +} + +ATF_TC(threads4); +ATF_TC_HEAD(threads4, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that for each td_thr_iter() call td_thr_getname() is " + "valid"); +} + +static volatile int exiting4; + +static void * +busyFunction4(void *arg) +{ + + while (exiting4 == 0) + usleep(50000); + + return NULL; +} + +static int +iterateThreads4(td_thread_t *thread, void *arg) +{ + int *counter = (int *)arg; + char name[PTHREAD_MAX_NAMELEN_NP]; + + ATF_REQUIRE(td_thr_getname(thread, name, sizeof(name)) == TD_ERR_OK); + + printf("Thread name: %s\n", name); + + ++(*counter); + + return TD_ERR_OK; +} + +ATF_TC_BODY(threads4, tc) +{ + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta; + size_t i; + pthread_t threads[MAX_THREADS]; + int count = 0; + + dummy_callbacks.proc_read = basic_proc_read; + dummy_callbacks.proc_write = basic_proc_write; + dummy_callbacks.proc_lookup = basic_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + for (i = 0; i < MAX_THREADS; i++) { + printf("Creating thread %zu\n", i); + PTHREAD_REQUIRE + (pthread_create(&threads[i], NULL, busyFunction4, NULL)); + } + + for (i = 0; i < MAX_THREADS; i++) { + PTHREAD_REQUIRE + (pthread_setname_np(threads[i], "test_%d", (void*)i)); + } + + printf("Calling td_open(3)\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK); + + ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads4, &count) == TD_ERR_OK); + + exiting4 = 1; + + printf("Calling td_close(3)\n"); + ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK); + + ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1, + "counted threads (%d) != expected threads (%zu)", + count, MAX_THREADS + 1); +} + +ATF_TC(threads5); +ATF_TC_HEAD(threads5, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that td_thr_getname() handles shorter buffer parameter " + "and the result is properly truncated"); +} + +static volatile int exiting5; + +static void * +busyFunction5(void *arg) +{ + + while (exiting5 == 0) + usleep(50000); + + return NULL; +} + +static int +iterateThreads5(td_thread_t *thread, void *arg) +{ + int *counter = (int *)arg; + /* Arbitrarily short string buffer */ + char name[3]; + + ATF_REQUIRE(td_thr_getname(thread, name, sizeof(name)) == TD_ERR_OK); + + printf("Thread name: %s\n", name); + + /* strlen(3) does not count including a '\0' character */ + ATF_REQUIRE(strlen(name) < sizeof(name)); + + ++(*counter); + + return TD_ERR_OK; +} + +ATF_TC_BODY(threads5, tc) +{ + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta; + size_t i; + pthread_t threads[MAX_THREADS]; + int count = 0; + + dummy_callbacks.proc_read = basic_proc_read; + dummy_callbacks.proc_write = basic_proc_write; + dummy_callbacks.proc_lookup = basic_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + for (i = 0; i < MAX_THREADS; i++) { + printf("Creating thread %zu\n", i); + PTHREAD_REQUIRE + (pthread_create(&threads[i], NULL, busyFunction5, NULL)); + } + + for (i = 0; i < MAX_THREADS; i++) { + PTHREAD_REQUIRE + (pthread_setname_np(threads[i], "test_%d", (void*)i)); + } + + printf("Calling td_open(3)\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK); + + ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads5, &count) == TD_ERR_OK); + + exiting5 = 1; + + printf("Calling td_close(3)\n"); + ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK); + + ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1, + "counted threads (%d) != expected threads (%zu)", + count, MAX_THREADS + 1); +} + +ATF_TC(threads6); +ATF_TC_HEAD(threads6, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that pthread_t can be translated with td_map_pth2thr() " + "to td_thread_t -- and assert earlier that td_thr_iter() call is " + "valid"); +} + +static volatile int exiting6; + +static void * +busyFunction6(void *arg) +{ + + while (exiting6 == 0) + usleep(50000); + + return NULL; +} + +static int +iterateThreads6(td_thread_t *thread, void *arg) +{ + int *counter = (int *)arg; + + ++(*counter); + + return TD_ERR_OK; +} + +ATF_TC_BODY(threads6, tc) +{ + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta; + size_t i; + pthread_t threads[MAX_THREADS]; + int count = 0; + + dummy_callbacks.proc_read = basic_proc_read; + dummy_callbacks.proc_write = basic_proc_write; + dummy_callbacks.proc_lookup = basic_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + for (i = 0; i < MAX_THREADS; i++) { + printf("Creating thread %zu\n", i); + PTHREAD_REQUIRE + (pthread_create(&threads[i], NULL, busyFunction6, NULL)); + } + + printf("Calling td_open(3)\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK); + + ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads6, &count) == TD_ERR_OK); + + for (i = 0; i < MAX_THREADS; i++) { + td_thread_t *td_thread; + ATF_REQUIRE(td_map_pth2thr(main_ta, threads[i], &td_thread) + == TD_ERR_OK); + } + + exiting6 = 1; + + printf("Calling td_close(3)\n"); + ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK); + + ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1, + "counted threads (%d) != expected threads (%zu)", + count, MAX_THREADS + 1); +} + +ATF_TC(threads7); +ATF_TC_HEAD(threads7, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that pthread_t can be translated with td_map_pth2thr() " + "to td_thread_t -- and assert later that td_thr_iter() call is " + "valid"); +} + +static volatile int exiting7; + +static void * +busyFunction7(void *arg) +{ + + while (exiting7 == 0) + usleep(50000); + + return NULL; +} + +static int +iterateThreads7(td_thread_t *thread, void *arg) +{ + int *counter = (int *)arg; + + ++(*counter); + + return TD_ERR_OK; +} + +ATF_TC_BODY(threads7, tc) +{ + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta; + size_t i; + pthread_t threads[MAX_THREADS]; + int count = 0; + + dummy_callbacks.proc_read = basic_proc_read; + dummy_callbacks.proc_write = basic_proc_write; + dummy_callbacks.proc_lookup = basic_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + for (i = 0; i < MAX_THREADS; i++) { + printf("Creating thread %zu\n", i); + PTHREAD_REQUIRE + (pthread_create(&threads[i], NULL, busyFunction7, NULL)); + } + + printf("Calling td_open(3)\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK); + + for (i = 0; i < MAX_THREADS; i++) { + td_thread_t *td_thread; + ATF_REQUIRE(td_map_pth2thr(main_ta, threads[i], &td_thread) + == TD_ERR_OK); + } + + ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads7, &count) == TD_ERR_OK); + + exiting7 = 1; + + printf("Calling td_close(3)\n"); + ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK); + + ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1, + "counted threads (%d) != expected threads (%zu)", + count, MAX_THREADS + 1); +} + +ATF_TC(threads8); +ATF_TC_HEAD(threads8, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that pthread_t can be translated with td_map_pth2thr() " + "to td_thread_t -- compare thread's name of pthread_t and " + "td_thread_t"); +} + +static volatile int exiting8; + +static void * +busyFunction8(void *arg) +{ + + while (exiting8 == 0) + usleep(50000); + + return NULL; +} + +static int +iterateThreads8(td_thread_t *thread, void *arg) +{ + int *counter = (int *)arg; + + ++(*counter); + + return TD_ERR_OK; +} + +ATF_TC_BODY(threads8, tc) +{ + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta; + size_t i; + pthread_t threads[MAX_THREADS]; + int count = 0; + + dummy_callbacks.proc_read = basic_proc_read; + dummy_callbacks.proc_write = basic_proc_write; + dummy_callbacks.proc_lookup = basic_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + for (i = 0; i < MAX_THREADS; i++) { + printf("Creating thread %zu\n", i); + PTHREAD_REQUIRE + (pthread_create(&threads[i], NULL, busyFunction8, NULL)); + } + + printf("Calling td_open(3)\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK); + + ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads8, &count) == TD_ERR_OK); + + for (i = 0; i < MAX_THREADS; i++) { + td_thread_t *td_thread; + char td_threadname[PTHREAD_MAX_NAMELEN_NP]; + char pth_threadname[PTHREAD_MAX_NAMELEN_NP]; + ATF_REQUIRE(td_map_pth2thr(main_ta, threads[i], &td_thread) + == TD_ERR_OK); + ATF_REQUIRE(td_thr_getname(td_thread, td_threadname, + sizeof(td_threadname)) == TD_ERR_OK); + PTHREAD_REQUIRE(pthread_getname_np(threads[i], pth_threadname, + sizeof(pth_threadname))); + ATF_REQUIRE(strcmp(td_threadname, pth_threadname) == 0); + } + + exiting8 = 1; + + printf("Calling td_close(3)\n"); + ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK); + + ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1, + "counted threads (%d) != expected threads (%zu)", + count, MAX_THREADS + 1); +} + +ATF_TC(threads9); +ATF_TC_HEAD(threads9, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Asserts that pthread_t can be translated with td_map_pth2thr() " + "to td_thread_t -- assert that thread is in the TD_STATE_RUNNING " + "state"); +} + +static volatile int exiting9; + +static void * +busyFunction9(void *arg) +{ + + while (exiting9 == 0) + usleep(50000); + + return NULL; +} + +static int +iterateThreads9(td_thread_t *thread, void *arg) +{ + int *counter = (int *)arg; + + ++(*counter); + + return TD_ERR_OK; +} + +ATF_TC_BODY(threads9, tc) +{ + struct td_proc_callbacks_t dummy_callbacks; + td_proc_t *main_ta; + size_t i; + pthread_t threads[MAX_THREADS]; + int count = 0; + + dummy_callbacks.proc_read = basic_proc_read; + dummy_callbacks.proc_write = basic_proc_write; + dummy_callbacks.proc_lookup = basic_proc_lookup; + dummy_callbacks.proc_regsize = dummy_proc_regsize; + dummy_callbacks.proc_getregs = dummy_proc_getregs; + dummy_callbacks.proc_setregs = dummy_proc_setregs; + + for (i = 0; i < MAX_THREADS; i++) { + printf("Creating thread %zu\n", i); + PTHREAD_REQUIRE + (pthread_create(&threads[i], NULL, busyFunction9, NULL)); + } + + printf("Calling td_open(3)\n"); + ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK); + + for (i = 0; i < MAX_THREADS; i++) { + td_thread_t *td_thread; + td_thread_info_t info; + ATF_REQUIRE(td_map_pth2thr(main_ta, threads[i], &td_thread) + == TD_ERR_OK); + ATF_REQUIRE(td_thr_info(td_thread, &info) == TD_ERR_OK); + ATF_REQUIRE_EQ(info.thread_state, TD_STATE_RUNNING); + } + + ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads9, &count) == TD_ERR_OK); + + exiting9 = 1; + + printf("Calling td_close(3)\n"); + ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK); + + ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1, + "counted threads (%d) != expected threads (%zu)", + count, MAX_THREADS + 1); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, threads1); + ATF_TP_ADD_TC(tp, threads2); + ATF_TP_ADD_TC(tp, threads3); + ATF_TP_ADD_TC(tp, threads4); + ATF_TP_ADD_TC(tp, threads5); + ATF_TP_ADD_TC(tp, threads6); + ATF_TP_ADD_TC(tp, threads7); + ATF_TP_ADD_TC(tp, threads8); + ATF_TP_ADD_TC(tp, threads9); + + return atf_no_error(); +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread_dbg/t_threads.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/librefuse/t_refuse_opt.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/librefuse/t_refuse_opt.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/librefuse/t_refuse_opt.c (revision 312126) @@ -0,0 +1,418 @@ +/* $NetBSD: t_refuse_opt.c,v 1.8 2017/01/13 21:30:41 christos Exp $ */ + +/*- + * Copyright (c) 2016 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 +__RCSID("$NetBSD: t_refuse_opt.c,v 1.8 2017/01/13 21:30:41 christos Exp $"); + +#define _KERNTYPES +#include + +#include + +#include + +#include "h_macros.h" + +ATF_TC(t_fuse_opt_add_arg); +ATF_TC_HEAD(t_fuse_opt_add_arg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_add_arg(3) works"); +} + +ATF_TC_BODY(t_fuse_opt_add_arg, tc) +{ + struct fuse_args args = FUSE_ARGS_INIT(0, NULL); + + RZ(fuse_opt_add_arg(&args, "foo")); + RZ(fuse_opt_add_arg(&args, "bar")); + + ATF_REQUIRE_EQ(args.argc, 2); + ATF_CHECK_STREQ(args.argv[0], "foo"); + ATF_CHECK_STREQ(args.argv[1], "bar"); + ATF_CHECK(args.allocated != 0); +} + +ATF_TC(t_fuse_opt_insert_arg); +ATF_TC_HEAD(t_fuse_opt_insert_arg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_insert_arg(3) works"); +} + +ATF_TC_BODY(t_fuse_opt_insert_arg, tc) +{ + struct fuse_args args = FUSE_ARGS_INIT(0, NULL); + + RZ(fuse_opt_insert_arg(&args, 0, "foo")); + RZ(fuse_opt_insert_arg(&args, 0, "bar")); + + ATF_REQUIRE_EQ(args.argc, 2); + ATF_CHECK_STREQ(args.argv[0], "bar"); + ATF_CHECK_STREQ(args.argv[1], "foo"); + ATF_CHECK(args.allocated != 0); +} + +ATF_TC(t_fuse_opt_add_opt); +ATF_TC_HEAD(t_fuse_opt_add_opt, tc) +{ + atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_add_opt(3) works"); +} + +ATF_TC_BODY(t_fuse_opt_add_opt, tc) +{ + char* opt = NULL; + + RZ(fuse_opt_add_opt(&opt, "fo\\o")); + ATF_CHECK_STREQ(opt, "fo\\o"); + + RZ(fuse_opt_add_opt(&opt, "ba,r")); + ATF_CHECK_STREQ(opt, "fo\\o,ba,r"); +} + +ATF_TC(t_fuse_opt_add_opt_escaped); +ATF_TC_HEAD(t_fuse_opt_add_opt_escaped, tc) +{ + atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_add_opt_escaped(3) works"); +} + +ATF_TC_BODY(t_fuse_opt_add_opt_escaped, tc) +{ + char* opt = NULL; + + RZ(fuse_opt_add_opt_escaped(&opt, "fo\\o")); + ATF_CHECK_STREQ(opt, "fo\\\\o"); + + RZ(fuse_opt_add_opt_escaped(&opt, "ba,r")); + ATF_CHECK_STREQ(opt, "fo\\\\o,ba\\,r"); +} + +ATF_TC(t_fuse_opt_match); +ATF_TC_HEAD(t_fuse_opt_match, tc) +{ + atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_match(3) works" + " for every form of templates"); +} + +ATF_TC_BODY(t_fuse_opt_match, tc) +{ + struct fuse_opt o1[] = { FUSE_OPT_KEY("-x" , 0), FUSE_OPT_END }; + struct fuse_opt o2[] = { FUSE_OPT_KEY("foo" , 0), FUSE_OPT_END }; + struct fuse_opt o3[] = { FUSE_OPT_KEY("foo=" , 0), FUSE_OPT_END }; + struct fuse_opt o4[] = { FUSE_OPT_KEY("foo=%s", 0), FUSE_OPT_END }; + struct fuse_opt o5[] = { FUSE_OPT_KEY("-x " , 0), FUSE_OPT_END }; + struct fuse_opt o6[] = { FUSE_OPT_KEY("-x %s" , 0), FUSE_OPT_END }; + + ATF_CHECK(fuse_opt_match(o1, "-x") == 1); + ATF_CHECK(fuse_opt_match(o1, "x") == 0); + + ATF_CHECK(fuse_opt_match(o2, "foo") == 1); + ATF_CHECK(fuse_opt_match(o2, "-foo") == 0); + + ATF_CHECK(fuse_opt_match(o3, "foo=bar") == 1); + ATF_CHECK(fuse_opt_match(o3, "foo" ) == 0); + + ATF_CHECK(fuse_opt_match(o4, "foo=bar") == 1); + ATF_CHECK(fuse_opt_match(o4, "foo" ) == 0); + + ATF_CHECK(fuse_opt_match(o5, "-xbar" ) == 1); + ATF_CHECK(fuse_opt_match(o5, "-x" ) == 1); + ATF_CHECK(fuse_opt_match(o5, "-x=bar") == 1); + ATF_CHECK(fuse_opt_match(o5, "bar" ) == 0); + + ATF_CHECK(fuse_opt_match(o6, "-xbar" ) == 1); + ATF_CHECK(fuse_opt_match(o6, "-x" ) == 1); + ATF_CHECK(fuse_opt_match(o6, "-x=bar") == 1); + ATF_CHECK(fuse_opt_match(o6, "bar" ) == 0); +} + +struct foofs_config { + int number; + char *string; + char* nonopt; +}; + +#define FOOFS_OPT(t, p, v) { t, offsetof(struct foofs_config, p), v } + +static struct fuse_opt foofs_opts[] = { + FOOFS_OPT("number=%i" , number, 0), + FOOFS_OPT("-n %i" , number, 0), + FOOFS_OPT("string=%s" , string, 0), + FOOFS_OPT("number1" , number, 1), + FOOFS_OPT("number2" , number, 2), + FOOFS_OPT("--number=three", number, 3), + FOOFS_OPT("--number=four" , number, 4), + FUSE_OPT_END +}; + +static int foo_opt_proc(void *data, const char *arg, int key, struct fuse_args *outargs) { + struct foofs_config *config = data; + + if (key == FUSE_OPT_KEY_NONOPT && config->nonopt == NULL) { + config->nonopt = strdup(arg); + return 0; + } + else { + return 1; + } +} + +ATF_TC(t_fuse_opt_parse_null_args); +ATF_TC_HEAD(t_fuse_opt_parse_null_args, tc) +{ + atf_tc_set_md_var(tc, "descr", "NULL args means an empty arguments vector"); +} + +ATF_TC_BODY(t_fuse_opt_parse_null_args, tc) +{ + struct foofs_config config; + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(NULL, &config, NULL, NULL) == 0); + ATF_CHECK_EQ(config.number, 0); + ATF_CHECK_EQ(config.string, NULL); + ATF_CHECK_EQ(config.nonopt, NULL); +} + +ATF_TC(t_fuse_opt_parse_null_opts); +ATF_TC_HEAD(t_fuse_opt_parse_null_opts, tc) +{ + atf_tc_set_md_var(tc, "descr", "NULL opts means an opts array which only has FUSE_OPT_END"); +} + +ATF_TC_BODY(t_fuse_opt_parse_null_opts, tc) +{ + struct fuse_args args = FUSE_ARGS_INIT(0, NULL); + struct foofs_config config; + + RZ(fuse_opt_add_arg(&args, "foofs")); + RZ(fuse_opt_add_arg(&args, "-o")); + RZ(fuse_opt_add_arg(&args, "number=1,string=foo")); + RZ(fuse_opt_add_arg(&args, "bar")); + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(&args, &config, NULL, NULL) == 0); + ATF_CHECK_EQ(config.number, 0); + ATF_CHECK_EQ(config.string, NULL); + ATF_CHECK_EQ(config.nonopt, NULL); + ATF_CHECK_EQ(args.argc, 4); + ATF_CHECK_STREQ(args.argv[0], "foofs"); + ATF_CHECK_STREQ(args.argv[1], "-o"); + ATF_CHECK_STREQ(args.argv[2], "number=1,string=foo"); + ATF_CHECK_STREQ(args.argv[3], "bar"); +} + +ATF_TC(t_fuse_opt_parse_null_proc); +ATF_TC_HEAD(t_fuse_opt_parse_null_proc, tc) +{ + atf_tc_set_md_var(tc, "descr", "NULL proc means a processor function always returning 1," + " i.e. keep the argument"); +} + +ATF_TC_BODY(t_fuse_opt_parse_null_proc, tc) +{ + struct fuse_args args = FUSE_ARGS_INIT(0, NULL); + struct foofs_config config; + + RZ(fuse_opt_add_arg(&args, "foofs")); + RZ(fuse_opt_add_arg(&args, "-o")); + RZ(fuse_opt_add_arg(&args, "number=1,string=foo")); + RZ(fuse_opt_add_arg(&args, "bar")); + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, NULL) == 0); + ATF_CHECK_EQ(config.number, 1); + ATF_CHECK_STREQ(config.string, "foo"); + ATF_CHECK_EQ(config.nonopt, NULL); + ATF_CHECK_EQ(args.argc, 2); + ATF_CHECK_STREQ(args.argv[0], "foofs"); + ATF_CHECK_STREQ(args.argv[1], "bar"); +} + +ATF_TC(t_fuse_opt_parse); +ATF_TC_HEAD(t_fuse_opt_parse, tc) +{ + atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_parse(3) fully works"); +} + +ATF_TC_BODY(t_fuse_opt_parse, tc) +{ + struct fuse_args args = FUSE_ARGS_INIT(0, NULL); + struct foofs_config config; + + /* Standard form */ + fuse_opt_free_args(&args); + RZ(fuse_opt_add_arg(&args, "foofs")); + RZ(fuse_opt_add_arg(&args, "-o")); + RZ(fuse_opt_add_arg(&args, "number=1,string=foo")); + RZ(fuse_opt_add_arg(&args, "bar")); + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0); + ATF_CHECK_EQ(config.number, 1); + ATF_CHECK_STREQ(config.string, "foo"); + ATF_CHECK_STREQ(config.nonopt, "bar"); + ATF_CHECK_EQ(args.argc, 1); + ATF_CHECK_STREQ(args.argv[0], "foofs"); + + /* Concatenated -o */ + fuse_opt_free_args(&args); + RZ(fuse_opt_add_arg(&args, "foofs")); + RZ(fuse_opt_add_arg(&args, "-onumber=1,unknown,string=foo")); + RZ(fuse_opt_add_arg(&args, "bar")); + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0); + ATF_CHECK_EQ(config.number, 1); + ATF_CHECK_STREQ(config.string, "foo"); + ATF_CHECK_STREQ(config.nonopt, "bar"); + ATF_CHECK_EQ(args.argc, 3); + ATF_CHECK_STREQ(args.argv[0], "foofs"); + ATF_CHECK_STREQ(args.argv[1], "-o"); + ATF_CHECK_STREQ(args.argv[2], "unknown"); + + /* Sparse -o */ + fuse_opt_free_args(&args); + RZ(fuse_opt_add_arg(&args, "foofs")); + RZ(fuse_opt_add_arg(&args, "bar")); + RZ(fuse_opt_add_arg(&args, "baz")); + RZ(fuse_opt_add_arg(&args, "-o")); + RZ(fuse_opt_add_arg(&args, "number=1")); + RZ(fuse_opt_add_arg(&args, "-o")); + RZ(fuse_opt_add_arg(&args, "unknown")); + RZ(fuse_opt_add_arg(&args, "-o")); + RZ(fuse_opt_add_arg(&args, "string=foo")); + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0); + ATF_CHECK_EQ(config.number, 1); + ATF_CHECK_STREQ(config.string, "foo"); + ATF_CHECK_STREQ(config.nonopt, "bar"); + ATF_CHECK_EQ(args.argc, 4); + ATF_CHECK_STREQ(args.argv[0], "foofs"); + ATF_CHECK_STREQ(args.argv[1], "-o"); + ATF_CHECK_STREQ(args.argv[2], "unknown"); + ATF_CHECK_STREQ(args.argv[3], "baz"); + + /* Separate -n %i */ + fuse_opt_free_args(&args); + RZ(fuse_opt_add_arg(&args, "foofs")); + RZ(fuse_opt_add_arg(&args, "-n")); + RZ(fuse_opt_add_arg(&args, "3")); + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0); + ATF_CHECK_EQ(config.number, 3); + ATF_CHECK_EQ(config.string, NULL); + ATF_CHECK_EQ(config.nonopt, NULL); + ATF_CHECK_EQ(args.argc, 1); + ATF_CHECK_STREQ(args.argv[0], "foofs"); + + /* Concatenated -n %i */ + fuse_opt_free_args(&args); + RZ(fuse_opt_add_arg(&args, "foofs")); + RZ(fuse_opt_add_arg(&args, "-n3")); + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0); + ATF_CHECK_EQ(config.number, 3); + ATF_CHECK_EQ(config.string, NULL); + ATF_CHECK_EQ(config.nonopt, NULL); + ATF_CHECK_EQ(args.argc, 1); + ATF_CHECK_STREQ(args.argv[0], "foofs"); + + /* -o constant */ + fuse_opt_free_args(&args); + RZ(fuse_opt_add_arg(&args, "foofs")); + RZ(fuse_opt_add_arg(&args, "-o")); + RZ(fuse_opt_add_arg(&args, "number2")); + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0); + ATF_CHECK_EQ(config.number, 2); + ATF_CHECK_EQ(config.string, NULL); + ATF_CHECK_EQ(config.nonopt, NULL); + ATF_CHECK_EQ(args.argc, 1); + ATF_CHECK_STREQ(args.argv[0], "foofs"); + + /* -x constant */ + fuse_opt_free_args(&args); + RZ(fuse_opt_add_arg(&args, "foofs")); + RZ(fuse_opt_add_arg(&args, "--number=four")); + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0); + ATF_CHECK_EQ(config.number, 4); + ATF_CHECK_EQ(config.string, NULL); + ATF_CHECK_EQ(config.nonopt, NULL); + ATF_CHECK_EQ(args.argc, 1); + ATF_CHECK_STREQ(args.argv[0], "foofs"); + + /* end-of-options "--" marker */ + fuse_opt_free_args(&args); + RZ(fuse_opt_add_arg(&args, "foofs")); + RZ(fuse_opt_add_arg(&args, "--")); + RZ(fuse_opt_add_arg(&args, "-onumber=1")); + RZ(fuse_opt_add_arg(&args, "-ostring=foo")); + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0); + ATF_CHECK_EQ(config.number, 0); + ATF_CHECK_EQ(config.string, NULL); + ATF_CHECK_STREQ(config.nonopt, "-onumber=1"); + ATF_CHECK_EQ(args.argc, 3); + ATF_CHECK_STREQ(args.argv[0], "foofs"); + ATF_CHECK_STREQ(args.argv[1], "--"); + ATF_CHECK_STREQ(args.argv[2], "-ostring=foo"); + + /* The "--" marker at the last of outargs should be removed */ + fuse_opt_free_args(&args); + RZ(fuse_opt_add_arg(&args, "foofs")); + RZ(fuse_opt_add_arg(&args, "--")); + RZ(fuse_opt_add_arg(&args, "-onumber=1")); + + memset(&config, 0, sizeof(config)); + ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0); + ATF_CHECK_EQ(config.number, 0); + ATF_CHECK_EQ(config.string, NULL); + ATF_CHECK_STREQ(config.nonopt, "-onumber=1"); + ATF_CHECK_EQ(args.argc, 1); + ATF_CHECK_STREQ(args.argv[0], "foofs"); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, t_fuse_opt_add_arg); + ATF_TP_ADD_TC(tp, t_fuse_opt_insert_arg); + ATF_TP_ADD_TC(tp, t_fuse_opt_add_opt); + ATF_TP_ADD_TC(tp, t_fuse_opt_add_opt_escaped); + ATF_TP_ADD_TC(tp, t_fuse_opt_match); + ATF_TP_ADD_TC(tp, t_fuse_opt_parse_null_args); + ATF_TP_ADD_TC(tp, t_fuse_opt_parse_null_opts); + ATF_TP_ADD_TC(tp, t_fuse_opt_parse_null_proc); + ATF_TP_ADD_TC(tp, t_fuse_opt_parse); + + return atf_no_error(); +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/librefuse/t_refuse_opt.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/librumpclient/t_fd.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/librumpclient/t_fd.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/librumpclient/t_fd.c (revision 312126) @@ -1,146 +1,146 @@ -/* $NetBSD: t_fd.c,v 1.5 2016/08/10 21:10:18 kre Exp $ */ +/* $NetBSD: t_fd.c,v 1.6 2017/01/13 21:30:41 christos Exp $ */ /* * Copyright (c) 2011 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 #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC_WITH_CLEANUP(bigenough); ATF_TC_HEAD(bigenough, tc) { atf_tc_set_md_var(tc, "descr", "Check that rumpclient uses " "fd > 2"); } ATF_TC_WITH_CLEANUP(sigio); ATF_TC_HEAD(sigio, tc) { atf_tc_set_md_var(tc, "descr", "Check that rump client receives " "SIGIO"); } #define RUMPSERV "unix://sucket" ATF_TC_CLEANUP(bigenough, tc){system("env RUMP_SERVER=" RUMPSERV " rump.halt");} ATF_TC_CLEANUP(sigio, tc) { system("env RUMP_SERVER=" RUMPSERV " rump.halt"); } ATF_TC_BODY(bigenough, tc) { struct stat sb; RZ(system("rump_server " RUMPSERV)); RL(setenv("RUMP_SERVER", RUMPSERV, 1)); RL(dup2(0, 10)); RL(dup2(1, 11)); RL(dup2(2, 12)); RL(close(0)); RL(close(1)); RL(close(2)); RL(rumpclient_init()); RL(rump_sys_getpid()); ATF_REQUIRE_ERRNO(EBADF, fstat(0, &sb) == -1); ATF_REQUIRE_ERRNO(EBADF, fstat(1, &sb) == -1); ATF_REQUIRE_ERRNO(EBADF, fstat(2, &sb) == -1); RL(rump_sys_getpid()); /* restore these. does it help? */ dup2(10, 0); dup2(11, 1); dup2(12, 2); } static volatile sig_atomic_t sigcnt; static void gotsig(int sig) { sigcnt++; } ATF_TC_BODY(sigio, tc) { struct sockaddr_in sin; int ls; int cs; int fl; int sc; signal(SIGIO, gotsig); RZ(system("rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet " "-lrumpdev -lrumpvfs " RUMPSERV)); RL(setenv("RUMP_SERVER", RUMPSERV, 1)); RL(rumpclient_init()); RL(ls = rump_sys_socket(PF_INET, SOCK_STREAM, 0)); RL(rump_sys_fcntl(ls, F_SETOWN, rump_sys_getpid())); RL(fl = rump_sys_fcntl(ls, F_GETFL)); RL(rump_sys_fcntl(ls, F_SETFL, fl | O_ASYNC)); memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_port = htons(12345); RL(rump_sys_bind(ls, (struct sockaddr *)&sin, sizeof(sin))); RL(rump_sys_listen(ls, 5)); RL(cs = rump_sys_socket(PF_INET, SOCK_STREAM, 0)); sin.sin_addr.s_addr = inet_addr("127.0.0.1"); ATF_REQUIRE_EQ(sigcnt, 0); RL(rump_sys_connect(cs, (struct sockaddr *)&sin, sizeof(sin))); sc = sigcnt; printf("sigcnt after connect: %d\n", sc); ATF_REQUIRE(sc >= 1); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, bigenough); ATF_TP_ADD_TC(tp, sigio); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/semaphore/sem.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/semaphore/sem.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/semaphore/sem.c (revision 312126) @@ -1,332 +1,332 @@ -/* $NetBSD: sem.c,v 1.10 2012/03/09 14:25:34 joerg Exp $ */ +/* $NetBSD: sem.c,v 1.11 2017/01/13 21:30:42 christos Exp $ */ /* * Common code for semaphore tests. This can be included both into * programs using librt and libpthread. */ #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(postwait); ATF_TC_HEAD(postwait, tc) { atf_tc_set_md_var(tc, "descr", "tests post and wait from a " "single thread (%s)", LIBNAME); } ATF_TC_BODY(postwait, tc) { sem_t sem; int rv; rump_init(); ATF_REQUIRE_EQ(sem_init(&sem, 1, 0), 0); sem_post(&sem); sem_post(&sem); sem_wait(&sem); sem_wait(&sem); rv = sem_trywait(&sem); ATF_REQUIRE(errno == EAGAIN); ATF_REQUIRE(rv == -1); } ATF_TC(initvalue); ATF_TC_HEAD(initvalue, tc) { atf_tc_set_md_var(tc, "descr", "tests initialization with a non-zero " "value (%s)", LIBNAME); } ATF_TC_BODY(initvalue, tc) { sem_t sem; rump_init(); sem_init(&sem, 1, 4); ATF_REQUIRE_EQ(sem_trywait(&sem), 0); ATF_REQUIRE_EQ(sem_trywait(&sem), 0); ATF_REQUIRE_EQ(sem_trywait(&sem), 0); ATF_REQUIRE_EQ(sem_trywait(&sem), 0); ATF_REQUIRE_EQ(sem_trywait(&sem), -1); } ATF_TC(destroy); ATF_TC_HEAD(destroy, tc) { atf_tc_set_md_var(tc, "descr", "tests sem_destroy works (%s)", LIBNAME); } ATF_TC_BODY(destroy, tc) { sem_t sem; int rv, i; rump_init(); for (i = 0; i < 2; i++) { sem_init(&sem, 1, 1); ATF_REQUIRE_EQ(sem_trywait(&sem), 0); ATF_REQUIRE_EQ(sem_trywait(&sem), -1); ATF_REQUIRE_EQ(sem_destroy(&sem), 0); rv = sem_trywait(&sem); ATF_REQUIRE_EQ(errno, EINVAL); ATF_REQUIRE_EQ(rv, -1); } } ATF_TC(busydestroy); ATF_TC_HEAD(busydestroy, tc) { atf_tc_set_md_var(tc, "descr", "tests sem_destroy report EBUSY for " "a busy semaphore (%s)", LIBNAME); } static void * hthread(void *arg) { sem_t *semmarit = arg; for (;;) { sem_post(&semmarit[2]); sem_wait(&semmarit[1]); sem_wait(&semmarit[0]); } return NULL; } ATF_TC_BODY(busydestroy, tc) { sem_t semmarit[3]; pthread_t pt; int i; /* use a unicpu rump kernel. this means less chance for race */ setenv("RUMP_NCPU", "1", 1); rump_init(); sem_init(&semmarit[0], 1, 0); sem_init(&semmarit[1], 1, 0); sem_init(&semmarit[2], 1, 0); pthread_create(&pt, NULL, hthread, semmarit); /* * Make a best-effort to catch the other thread with its pants down. * We can't do this for sure, can we? Although, we could reach * inside the rump kernel and inquire about the thread's sleep * status. */ for (i = 0; i < 1000; i++) { sem_wait(&semmarit[2]); usleep(1); if (sem_destroy(&semmarit[1]) == -1) if (errno == EBUSY) break; /* * Didn't catch it? ok, recreate and post to make the * other thread run */ sem_init(&semmarit[1], 1, 0); sem_post(&semmarit[0]); sem_post(&semmarit[1]); } if (i == 1000) atf_tc_fail("sem destroy not reporting EBUSY"); pthread_cancel(pt); pthread_join(pt, NULL); } ATF_TC(blockwait); ATF_TC_HEAD(blockwait, tc) { atf_tc_set_md_var(tc, "descr", "tests sem_wait can handle blocking " "(%s)", LIBNAME); atf_tc_set_md_var(tc, "timeout", "2"); } ATF_TC_BODY(blockwait, tc) { sem_t semmarit[3]; pthread_t pt; int i; rump_init(); sem_init(&semmarit[0], 1, 0); sem_init(&semmarit[1], 1, 0); sem_init(&semmarit[2], 1, 0); pthread_create(&pt, NULL, hthread, semmarit); /* * Make a best-effort. Unless we're extremely unlucky, we should * at least one blocking wait. */ for (i = 0; i < 10; i++) { sem_wait(&semmarit[2]); usleep(1); sem_post(&semmarit[0]); sem_post(&semmarit[1]); } pthread_cancel(pt); pthread_join(pt, NULL); } ATF_TC(blocktimedwait); ATF_TC_HEAD(blocktimedwait, tc) { atf_tc_set_md_var(tc, "descr", "tests sem_timedwait can handle blocking" " (%s)", LIBNAME); atf_tc_set_md_var(tc, "timeout", "2"); } ATF_TC_BODY(blocktimedwait, tc) { sem_t semid; struct timespec tp; rump_init(); clock_gettime(CLOCK_REALTIME, &tp); tp.tv_nsec += 50000000; tp.tv_sec += tp.tv_nsec / 1000000000; tp.tv_nsec %= 1000000000; ATF_REQUIRE_EQ(sem_init(&semid, 1, 0), 0); ATF_REQUIRE_ERRNO(ETIMEDOUT, sem_timedwait(&semid, &tp) == -1); } ATF_TC(named); ATF_TC_HEAD(named, tc) { atf_tc_set_md_var(tc, "descr", "tests named semaphores (%s)", LIBNAME); } /* * Wow, easy naming rules. it's these times i'm really happy i can * single-step into the kernel. */ #define SEM1 "/precious_sem" #define SEM2 "/justsem" ATF_TC_BODY(named, tc) { sem_t *sem1, *sem2; void *rv; rump_init(); sem1 = sem_open(SEM1, 0); ATF_REQUIRE_EQ(errno, ENOENT); ATF_REQUIRE_EQ(sem1, NULL); sem1 = sem_open(SEM1, O_CREAT, 0444, 1); if (sem1 == NULL) atf_tc_fail_errno("sem_open O_CREAT"); rv = sem_open(SEM1, O_CREAT | O_EXCL); ATF_REQUIRE_EQ(errno, EEXIST); ATF_REQUIRE_EQ(rv, NULL); sem2 = sem_open(SEM2, O_CREAT, 0444, 0); if (sem2 == NULL) atf_tc_fail_errno("sem_open O_CREAT"); /* check that semaphores are independent */ ATF_REQUIRE_EQ(sem_trywait(sem2), -1); ATF_REQUIRE_EQ(sem_trywait(sem1), 0); ATF_REQUIRE_EQ(sem_trywait(sem1), -1); /* check that unlinked remains valid */ sem_unlink(SEM2); ATF_REQUIRE_EQ(sem_post(sem2), 0); ATF_REQUIRE_EQ(sem_trywait(sem2), 0); ATF_REQUIRE_EQ(sem_trywait(sem2), -1); ATF_REQUIRE_EQ(errno, EAGAIN); #if 0 /* see unlink */ /* close it and check that it's gone */ if (sem_close(sem2) != 0) atf_tc_fail_errno("sem close"); ATF_REQUIRE_EQ(sem_trywait(sem2), -1); ATF_REQUIRE_EQ(errno, EINVAL); #endif /* check that we still have sem1 */ sem_post(sem1); ATF_REQUIRE_EQ(sem_trywait(sem1), 0); ATF_REQUIRE_EQ(sem_trywait(sem1), -1); ATF_REQUIRE_EQ(errno, EAGAIN); } ATF_TC(unlink); ATF_TC_HEAD(unlink, tc) { /* this is currently broken. i'll append the PR number soon */ atf_tc_set_md_var(tc, "descr", "tests unlinked semaphores can be " "closed (%s)", LIBNAME); } #define SEM "/thesem" ATF_TC_BODY(unlink, tc) { sem_t *sem; rump_init(); sem = sem_open(SEM, O_CREAT, 0444, 0); ATF_REQUIRE(sem); if (sem_unlink(SEM) == -1) atf_tc_fail_errno("unlink"); if (sem_close(sem) == -1) atf_tc_fail_errno("close unlinked semaphore"); } /* use rump calls for libpthread _ksem_foo() calls */ #define F1(name, a) int _ksem_##name(a); \ int _ksem_##name(a v1) {return rump_sys__ksem_##name(v1);} #define F2(name, a, b) int _ksem_##name(a, b); \ int _ksem_##name(a v1, b v2) {return rump_sys__ksem_##name(v1, v2);} F2(init, unsigned int, intptr_t *); F1(close, intptr_t); F1(destroy, intptr_t); F1(post, intptr_t); F1(unlink, const char *); F1(trywait, intptr_t); F1(wait, intptr_t); F2(getvalue, intptr_t, unsigned int *); F2(timedwait, intptr_t, const struct timespec *); int _ksem_open(const char *, int, mode_t, unsigned int, intptr_t *); int _ksem_open(const char *a, int b, mode_t c, unsigned int d, intptr_t *e) {return rump_sys__ksem_open(a,b,c,d,e);} Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-cleared.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-cleared.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-cleared.c (revision 312126) @@ -1,67 +1,67 @@ -/* $NetBSD: t_dlerror-cleared.c,v 1.1 2010/12/14 05:57:32 skrll Exp $ */ +/* $NetBSD: t_dlerror-cleared.c,v 1.2 2017/01/13 21:30:42 christos Exp $ */ /* * Copyright (c) 2009 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 "../../h_macros.h" +#include "h_macros.h" ATF_TC(rtld_dlerror_cleared); ATF_TC_HEAD(rtld_dlerror_cleared, tc) { atf_tc_set_md_var(tc, "descr", "error set by dlopen persists past a successful dlopen call"); } ATF_TC_BODY(rtld_dlerror_cleared, tc) { void *handle; char *error; /* * Test that an error set by dlopen() persists past a successful * dlopen() call. */ handle = dlopen("libnonexistent.so", RTLD_LAZY); ATF_CHECK(handle == NULL); handle = dlopen("libm.so", RTLD_NOW); ATF_CHECK(handle); error = dlerror(); ATF_CHECK(error); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, rtld_dlerror_cleared); return 0; } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-false.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-false.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-false.c (revision 312126) @@ -1,79 +1,79 @@ -/* $NetBSD: t_dlerror-false.c,v 1.1 2010/12/14 05:57:32 skrll Exp $ */ +/* $NetBSD: t_dlerror-false.c,v 1.2 2017/01/13 21:30:42 christos Exp $ */ /* * Copyright (c) 2009 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 "../../h_macros.h" +#include "h_macros.h" ATF_TC(rtld_dlerror_false); ATF_TC_HEAD(rtld_dlerror_false, tc) { atf_tc_set_md_var(tc, "descr", "error set by dlopen persists past a successful dlopen call"); } ATF_TC_BODY(rtld_dlerror_false, tc) { void *handle, *sym; char *error; /* * * Test for dlerror() being set by a successful library open. * Requires that the rpath be set to something that does not * include libm.so. */ handle = dlopen("libm.so", RTLD_LAZY); error = dlerror(); ATF_CHECK(error == NULL); ATF_CHECK(handle != NULL); sym = dlsym(handle, "sin"); error = dlerror(); ATF_CHECK(sym != NULL); ATF_CHECK(error == NULL); dlclose(handle); error = dlerror(); ATF_CHECK(error == NULL); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, rtld_dlerror_false); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_dlinfo.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_dlinfo.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_dlinfo.c (revision 312126) @@ -1,120 +1,120 @@ -/* $NetBSD: t_dlinfo.c,v 1.4 2011/03/25 14:47:31 pooka Exp $ */ +/* $NetBSD: t_dlinfo.c,v 1.5 2017/01/13 21:30:42 christos Exp $ */ /* * Copyright (c) 2009 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 "../../h_macros.h" +#include "h_macros.h" ATF_TC(rtld_dlinfo_linkmap_self); ATF_TC_HEAD(rtld_dlinfo_linkmap_self, tc) { atf_tc_set_md_var(tc, "descr", "dlinfo with RTLD_SELF handle works"); } ATF_TC_BODY(rtld_dlinfo_linkmap_self, tc) { struct link_map *map; int rv; rv = dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map); ATF_CHECK_EQ(rv, 0); ATF_CHECK((strstr(map->l_name, "t_dlinfo") != NULL)); } ATF_TC(rtld_dlinfo_linkmap_inval); ATF_TC_HEAD(rtld_dlinfo_linkmap_inval, tc) { atf_tc_set_md_var(tc, "descr", "dlinfo with invalid handle fails"); } ATF_TC_BODY(rtld_dlinfo_linkmap_inval, tc) { void *v; int rv; rv = dlinfo(NULL, RTLD_DI_LINKMAP, &v); ATF_CHECK_EQ(rv, -1); } ATF_TC(rtld_dlinfo_linkmap_dlopen); ATF_TC_HEAD(rtld_dlinfo_linkmap_dlopen, tc) { atf_tc_set_md_var(tc, "descr", "dlinfo dlopen'd handle works"); } ATF_TC_BODY(rtld_dlinfo_linkmap_dlopen, tc) { struct link_map *map; void *handle; int rv; handle = dlopen("libutil.so", RTLD_LAZY); ATF_CHECK(handle); rv = dlinfo(handle, RTLD_DI_LINKMAP, &map); ATF_CHECK_EQ(rv, 0); ATF_CHECK((strstr(map->l_name, "libutil.so") != NULL)); dlclose(handle); } ATF_TC(rtld_dlinfo_linkmap_dlopen_iter); ATF_TC_HEAD(rtld_dlinfo_linkmap_dlopen_iter, tc) { atf_tc_set_md_var(tc, "descr", "dlopen'd dso's show up in the list"); } ATF_TC_BODY(rtld_dlinfo_linkmap_dlopen_iter, tc) { struct link_map *map; void *handle; handle = dlopen("libutil.so", RTLD_LAZY); ATF_CHECK(handle); RZ(dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map)); for (; map->l_next; map = map->l_next) continue; for (; map; map = map->l_prev) if (strstr(map->l_name, "libutil.so") != NULL) break; ATF_REQUIRE_MSG(map, "dlopen()d object not found from linkmap"); ATF_REQUIRE_MSG(dlopen(map->l_name, RTLD_LAZY) != NULL, "could not dlopen() name in linkmap"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_self); ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_inval); ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_dlopen); ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_dlopen_iter); return 0; } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_ifunc.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_ifunc.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/libexec/ld.elf_so/t_ifunc.c (revision 312126) @@ -1,92 +1,92 @@ -/* $NetBSD: t_ifunc.c,v 1.1 2014/08/25 20:40:53 joerg Exp $ */ +/* $NetBSD: t_ifunc.c,v 1.2 2017/01/13 21:30:42 christos Exp $ */ /* * Copyright (c) 2014 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 "../../h_macros.h" +#include "h_macros.h" ATF_TC(rtld_ifunc); ATF_TC_HEAD(rtld_ifunc, tc) { atf_tc_set_md_var(tc, "descr", "ifunc functions are resolved"); } ATF_TC_BODY(rtld_ifunc, tc) { const char *envstr[] = { "0", "1" }; int expected_result[] = { 0xdeadbeef, 0xbeefdead }; void *handle; int (*sym)(void); int result; const char *error; size_t i; for (i = 0; i < __arraycount(envstr); ++i) { setenv("USE_IFUNC2", envstr[i], 1); handle = dlopen("libh_helper_ifunc_dso.so", RTLD_LAZY); error = dlerror(); ATF_CHECK(error == NULL); ATF_CHECK(handle != NULL); sym = dlsym(handle, "ifunc"); error = dlerror(); ATF_CHECK(error == NULL); ATF_CHECK(sym != NULL); result = (*sym)(); ATF_CHECK(result == expected_result[i]); dlclose(handle); error = dlerror(); ATF_CHECK(error == NULL); char *command; easprintf(&command, "%s/h_ifunc %d", atf_tc_get_config_var(tc, "srcdir"), expected_result[i]); if (system(command) != EXIT_SUCCESS) atf_tc_fail("Test failed; see output for details"); free(command); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, rtld_ifunc); return 0; } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/modules/t_builtin.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/modules/t_builtin.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/modules/t_builtin.c (revision 312126) @@ -1,194 +1,194 @@ -/* $NetBSD: t_builtin.c,v 1.2 2010/11/03 16:10:23 christos Exp $ */ +/* $NetBSD: t_builtin.c,v 1.3 2017/01/13 21:30:42 christos 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 #include #include -#include "../h_macros.h" +#include "h_macros.h" #define MYMP "/mnt" #define HZFILE MYMP "/hz" static char kernfs[] = "kernfs"; static bool check_kernfs(void) { char buf[16]; bool rv = true; int fd; fd = rump_sys_open(HZFILE, O_RDONLY); if (fd == -1) return false; if (rump_sys_read(fd, buf, sizeof(buf)) < 1) rv = false; RL(rump_sys_close(fd)); return rv; } ATF_TC(disable); ATF_TC_HEAD(disable, tc) { atf_tc_set_md_var(tc, "descr", "Tests that builtin modules can " "be disabled"); } ATF_TC_BODY(disable, tc) { rump_init(); RL(rump_sys_mkdir(MYMP, 0777)); RL(rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0)); ATF_REQUIRE(check_kernfs()); RL(rump_sys_unmount(MYMP, 0)); RL(rump_sys_modctl(MODCTL_UNLOAD, kernfs)); } ATF_TC(noauto); ATF_TC_HEAD(noauto, tc) { atf_tc_set_md_var(tc, "descr", "Tests that disabled builtin modules " "will not autoload"); } ATF_TC_BODY(noauto, tc) { rump_init(); RL(rump_sys_mkdir(MYMP, 0777)); RL(rump_sys_modctl(MODCTL_UNLOAD, kernfs)); ATF_REQUIRE_ERRNO(ENODEV, rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0) == -1); } ATF_TC(forcereload); ATF_TC_HEAD(forcereload, tc) { atf_tc_set_md_var(tc, "descr", "Tests that disabled builtin modules " "can be force-reloaded"); } ATF_TC_BODY(forcereload, tc) { struct modctl_load mod; rump_init(); RL(rump_sys_mkdir(MYMP, 0777)); RL(rump_sys_modctl(MODCTL_UNLOAD, kernfs)); ATF_REQUIRE_ERRNO(ENODEV, rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0) == -1); memset(&mod, 0, sizeof(mod)); mod.ml_filename = kernfs; mod.ml_flags = MODCTL_LOAD_FORCE; RL(rump_sys_modctl(MODCTL_LOAD, &mod)); RL(rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0)); ATF_REQUIRE(check_kernfs()); RL(rump_sys_unmount(MYMP, 0)); } ATF_TC(disabledstat); ATF_TC_HEAD(disabledstat, tc) { atf_tc_set_md_var(tc, "descr", "Tests that disabled builtin modules " "show up in modstat with refcount -1"); } ATF_TC_BODY(disabledstat, tc) { struct modstat ms[128]; struct iovec iov; size_t i; bool found = false; rump_init(); RL(rump_sys_mkdir(MYMP, 0777)); RL(rump_sys_modctl(MODCTL_UNLOAD, kernfs)); iov.iov_base = ms; iov.iov_len = sizeof(ms); RL(rump_sys_modctl(MODCTL_STAT, &iov)); for (i = 0; i < __arraycount(ms); i++) { if (strcmp(ms[i].ms_name, kernfs) == 0) { ATF_REQUIRE_EQ(ms[i].ms_refcnt, (u_int)-1); found = 1; break; } } ATF_REQUIRE(found); } ATF_TC(busydisable); ATF_TC_HEAD(busydisable, tc) { atf_tc_set_md_var(tc, "descr", "Tests that busy builtin modules " "cannot be disabled"); } ATF_TC_BODY(busydisable, tc) { rump_init(); RL(rump_sys_mkdir(MYMP, 0777)); RL(rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0)); ATF_REQUIRE(check_kernfs()); ATF_REQUIRE_ERRNO(EBUSY, rump_sys_modctl(MODCTL_UNLOAD, kernfs) == -1); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, disable); ATF_TP_ADD_TC(tp, noauto); ATF_TP_ADD_TC(tp, forcereload); ATF_TP_ADD_TC(tp, disabledstat); ATF_TP_ADD_TC(tp, busydisable); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpf/t_bpf.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpf/t_bpf.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpf/t_bpf.c (revision 312126) @@ -1,177 +1,177 @@ -/* $NetBSD: t_bpf.c,v 1.5 2012/08/14 19:40:30 alnsn Exp $ */ +/* $NetBSD: t_bpf.c,v 1.6 2017/01/13 21:30:42 christos Exp $ */ /*- * Copyright (c) 2010 Antti Kantee. 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 ``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. */ #include -__RCSID("$NetBSD: t_bpf.c,v 1.5 2012/08/14 19:40:30 alnsn Exp $"); +__RCSID("$NetBSD: t_bpf.c,v 1.6 2017/01/13 21:30:42 christos Exp $"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* XXX: atf-c.h has collisions with mbuf */ #undef m_type #undef m_data #include -#include "../../h_macros.h" +#include "h_macros.h" #include "../config/netconfig.c" ATF_TC(bpfwriteleak); ATF_TC_HEAD(bpfwriteleak, tc) { atf_tc_set_md_var(tc, "descr", "Checks that writing to /dev/bpf " "does not leak mbufs"); } static int getmtdata(void) { struct mbstat mbstat; size_t mbstatlen = sizeof(mbstat); const int mbstat_mib[] = { CTL_KERN, KERN_MBUF, MBUF_STATS }; RL(rump_sys___sysctl(mbstat_mib, __arraycount(mbstat_mib), &mbstat, &mbstatlen, NULL, 0)); return mbstat.m_mtypes[MT_DATA]; } ATF_TC_BODY(bpfwriteleak, tc) { char buf[28]; /* sizeof(garbage) > etherhdrlen */ struct ifreq ifr; int ifnum, bpfd; RZ(rump_init()); RZ(rump_pub_shmif_create(NULL, &ifnum)); sprintf(ifr.ifr_name, "shmif%d", ifnum); RL(bpfd = rump_sys_open("/dev/bpf", O_RDWR)); RL(rump_sys_ioctl(bpfd, BIOCSETIF, &ifr)); RL(rump_sys_ioctl(bpfd, BIOCSFEEDBACK, &ifr)); if (getmtdata() != 0) atf_tc_fail("test precondition failed: MT_DATA mbufs != 0"); ATF_REQUIRE_ERRNO(ENETDOWN, rump_sys_write(bpfd, buf, sizeof(buf))==-1); ATF_REQUIRE_EQ(getmtdata(), 0); } #if (SIZE_MAX > UINT_MAX) ATF_TC(bpfwritetrunc); ATF_TC_HEAD(bpfwritetrunc, tc) { atf_tc_set_md_var(tc, "descr", "Checks that write to /dev/bpf " "does not truncate size_t to int"); } ATF_TC_BODY(bpfwritetrunc, tc) { int bpfd; struct ifreq ifr; struct iovec *iov; size_t iovlen, sz; const size_t extra_bytes = 28; const size_t total = extra_bytes + UINT_MAX + 1; long iov_max, vm_page_size; /* round_page wants vm_page_size variable */ memset(&ifr, 0, sizeof(ifr)); iov_max = sysconf(_SC_IOV_MAX); vm_page_size = sysconf(_SC_PAGE_SIZE); ATF_REQUIRE(iov_max > 1 && vm_page_size > 1); /* * Minimize memory consumption by using many iovecs * all pointing to one memory region. */ iov = calloc(iov_max, sizeof(struct iovec)); ATF_REQUIRE(iov != NULL); sz = round_page((total + (iov_max - 1)) / iov_max); iov[0].iov_len = sz; iov[0].iov_base = mmap(NULL, sz, PROT_READ, MAP_ANON, -1, 0); ATF_REQUIRE(iov[0].iov_base != MAP_FAILED); iovlen = 1; while (sz + iov[0].iov_len <= total) { iov[iovlen].iov_len = iov[0].iov_len; iov[iovlen].iov_base = iov[0].iov_base; sz += iov[0].iov_len; iovlen++; } if (sz < total) { iov[iovlen].iov_len = total - sz; iov[iovlen].iov_base = iov[0].iov_base; iovlen++; } /* Sanity checks */ ATF_REQUIRE(iovlen >= 1 && iovlen <= (size_t)iov_max); ATF_REQUIRE_EQ(iov[iovlen-1].iov_len, total % iov[0].iov_len); RZ(rump_init()); netcfg_rump_makeshmif("bpfwritetrunc", ifr.ifr_name); netcfg_rump_if(ifr.ifr_name, "10.1.1.1", "255.0.0.0"); RL(bpfd = rump_sys_open("/dev/bpf", O_RDWR)); RL(rump_sys_ioctl(bpfd, BIOCSETIF, &ifr)); ATF_CHECK_ERRNO(EMSGSIZE, rump_sys_writev(bpfd, iov, iovlen) == -1); munmap(iov[0].iov_base, iov[0].iov_len); free(iov); } #endif /* #if (SIZE_MAX > UINT_MAX) */ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, bpfwriteleak); #if (SIZE_MAX > UINT_MAX) ATF_TP_ADD_TC(tp, bpfwritetrunc); #endif return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpf/t_mbuf.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpf/t_mbuf.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpf/t_mbuf.c (revision 312126) @@ -1,961 +1,961 @@ -/* $NetBSD: t_mbuf.c,v 1.2 2014/07/08 21:44:26 alnsn Exp $ */ +/* $NetBSD: t_mbuf.c,v 1.3 2017/01/13 21:30:42 christos Exp $ */ /*- * Copyright (c) 2014 Alexander Nasonov. * 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 ``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. */ #include -__RCSID("$NetBSD: t_mbuf.c,v 1.2 2014/07/08 21:44:26 alnsn Exp $"); +__RCSID("$NetBSD: t_mbuf.c,v 1.3 2017/01/13 21:30:42 christos Exp $"); #include #include #include #include #include #include #include #include "../../net/bpf/h_bpf.h" /* XXX: atf-c.h has collisions with mbuf */ #undef m_type #undef m_data #include -#include "../../h_macros.h" +#include "h_macros.h" static bool test_ldb_abs(size_t split) { /* Return a product of all packet bytes. */ static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 0), /* A <- P[0] */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 1), /* A <- P[1] */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 2), /* A <- P[2] */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 3), /* A <- P[3] */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 4), /* A <- P[4] */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 120; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == res; } static bool test_ldh_abs(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 0), /* A <- P[0:2] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 1), /* A <- P[1:2] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 2), /* A <- P[2:2] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 3), /* A <- P[3:2] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 0x0a0e; /* 10 14 */ if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == res; } static bool test_ldw_abs(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0), /* A <- P[0:4] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 1), /* A <- P[1:4] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 0x03050709; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == res; } static bool test_ldb_ind(size_t split) { /* Return a sum of all packet bytes. */ static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_B+BPF_IND, 0), /* A <- P[0+X] */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_IND, 1), /* A <- P[1+X] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_B+BPF_IND, 1), /* A <- P[1+X] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_B+BPF_IND, 2), /* A <- P[2+X] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_B+BPF_IND, 3), /* A <- P[3+X] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 15; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == res; } static bool test_ldw_ind(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_IND, 0), /* A <- P[X+0:4] */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_W+BPF_IND, 0), /* A <- P[X+0:4] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0), /* X <- 0 */ BPF_STMT(BPF_LD+BPF_W+BPF_IND, 1), /* A <- P[X+1:4] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 0x05080b0e; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == res; } static bool test_ldh_ind(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_IND, 0), /* A <- P[X+0:2] */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LD+BPF_H+BPF_IND, 1), /* A <- P[X+1:2] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_H+BPF_IND, 1), /* A <- P[X+1:2] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_H+BPF_IND, 2), /* A <- P[X+2:2] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 0x0a0e; /* 10 14 */ if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == res; } static bool test_msh(size_t split) { /* Return a product of all packet bytes. */ static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 1), /* A <- 1 */ BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 0), /* X <- 4*(P[0]&0xf) */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 4), /* A <- A / 4 */ BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 1), /* X <- 4*(P[1]&0xf) */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 4), /* A <- A / 4 */ BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 2), /* X <- 4*(P[2]&0xf) */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 4), /* A <- A / 4 */ BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 3), /* X <- 4*(P[3]&0xf) */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 4), /* A <- A / 4 */ BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 4), /* X <- 4*(P[4]&0xf) */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 4), /* A <- A / 4 */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 120; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == res; } static bool test_ldb_abs_overflow(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 5), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_ldh_abs_overflow(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_ldw_abs_overflow(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 2), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_ldb_ind_overflow1(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_B+BPF_IND, 5), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_ldb_ind_overflow2(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 4), BPF_STMT(BPF_LD+BPF_B+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_ldb_ind_overflow3(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_MAX), BPF_STMT(BPF_LD+BPF_B+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_ldh_ind_overflow1(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_IND, 4), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_ldh_ind_overflow2(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 3), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_ldh_ind_overflow3(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_MAX), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_ldw_ind_overflow1(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_IND, 2), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_ldw_ind_overflow2(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_ldw_ind_overflow3(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_MAX), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } static bool test_msh_overflow(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 5), BPF_STMT(BPF_MISC+BPF_TXA, 0), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; if (!prog_validate(insns, sizeof(insns) / sizeof(insns[0]))) return false; return interp_prog_mchain2(insns, P, sizeof(P), split) == 0; } ATF_TC(bpf_mbuf_ldb_abs); ATF_TC_HEAD(bpf_mbuf_ldb_abs, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_ABS " "loads bytes from mbuf correctly"); } ATF_TC_BODY(bpf_mbuf_ldb_abs, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_abs(0)); ATF_CHECK(test_ldb_abs(1)); ATF_CHECK(test_ldb_abs(2)); ATF_CHECK(test_ldb_abs(3)); ATF_CHECK(test_ldb_abs(4)); ATF_CHECK(test_ldb_abs(5)); } ATF_TC(bpf_mbuf_ldh_abs); ATF_TC_HEAD(bpf_mbuf_ldh_abs, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_ABS " "loads halfwords from mbuf correctly"); } ATF_TC_BODY(bpf_mbuf_ldh_abs, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_abs(0)); ATF_CHECK(test_ldh_abs(1)); ATF_CHECK(test_ldh_abs(2)); ATF_CHECK(test_ldh_abs(3)); ATF_CHECK(test_ldh_abs(4)); ATF_CHECK(test_ldh_abs(5)); } ATF_TC(bpf_mbuf_ldw_abs); ATF_TC_HEAD(bpf_mbuf_ldw_abs, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_ABS " "loads words from mbuf correctly"); } ATF_TC_BODY(bpf_mbuf_ldw_abs, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_abs(0)); ATF_CHECK(test_ldw_abs(1)); ATF_CHECK(test_ldw_abs(2)); ATF_CHECK(test_ldw_abs(3)); ATF_CHECK(test_ldw_abs(4)); ATF_CHECK(test_ldw_abs(5)); } ATF_TC(bpf_mbuf_ldb_ind); ATF_TC_HEAD(bpf_mbuf_ldb_ind, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_IND " "loads bytes from mbuf correctly"); } ATF_TC_BODY(bpf_mbuf_ldb_ind, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_ind(0)); ATF_CHECK(test_ldb_ind(1)); ATF_CHECK(test_ldb_ind(2)); ATF_CHECK(test_ldb_ind(3)); ATF_CHECK(test_ldb_ind(4)); ATF_CHECK(test_ldb_ind(5)); } ATF_TC(bpf_mbuf_ldh_ind); ATF_TC_HEAD(bpf_mbuf_ldh_ind, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_IND " "loads halfwords from mbuf correctly"); } ATF_TC_BODY(bpf_mbuf_ldh_ind, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_ind(0)); ATF_CHECK(test_ldh_ind(1)); ATF_CHECK(test_ldh_ind(2)); ATF_CHECK(test_ldh_ind(3)); ATF_CHECK(test_ldh_ind(4)); ATF_CHECK(test_ldh_ind(5)); } ATF_TC(bpf_mbuf_ldw_ind); ATF_TC_HEAD(bpf_mbuf_ldw_ind, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_IND " "loads words from mbuf correctly"); } ATF_TC_BODY(bpf_mbuf_ldw_ind, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_ind(0)); ATF_CHECK(test_ldw_ind(1)); ATF_CHECK(test_ldw_ind(2)); ATF_CHECK(test_ldw_ind(3)); ATF_CHECK(test_ldw_ind(4)); ATF_CHECK(test_ldw_ind(5)); } ATF_TC(bpf_mbuf_msh); ATF_TC_HEAD(bpf_mbuf_msh, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LDX+BPF_B+BPF_MSH " "loads bytes from mbuf correctly"); } ATF_TC_BODY(bpf_mbuf_msh, tc) { RZ(rump_init()); ATF_CHECK(test_msh(0)); ATF_CHECK(test_msh(1)); ATF_CHECK(test_msh(2)); ATF_CHECK(test_msh(3)); ATF_CHECK(test_msh(4)); ATF_CHECK(test_msh(5)); } ATF_TC(bpf_mbuf_ldb_abs_overflow); ATF_TC_HEAD(bpf_mbuf_ldb_abs_overflow, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_ABS " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldb_abs_overflow, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_abs_overflow(0)); ATF_CHECK(test_ldb_abs_overflow(1)); ATF_CHECK(test_ldb_abs_overflow(2)); ATF_CHECK(test_ldb_abs_overflow(3)); ATF_CHECK(test_ldb_abs_overflow(4)); ATF_CHECK(test_ldb_abs_overflow(5)); } ATF_TC(bpf_mbuf_ldh_abs_overflow); ATF_TC_HEAD(bpf_mbuf_ldh_abs_overflow, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_ABS " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldh_abs_overflow, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_abs_overflow(0)); ATF_CHECK(test_ldh_abs_overflow(1)); ATF_CHECK(test_ldh_abs_overflow(2)); ATF_CHECK(test_ldh_abs_overflow(3)); ATF_CHECK(test_ldh_abs_overflow(4)); ATF_CHECK(test_ldh_abs_overflow(5)); } ATF_TC(bpf_mbuf_ldw_abs_overflow); ATF_TC_HEAD(bpf_mbuf_ldw_abs_overflow, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_ABS " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldw_abs_overflow, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_abs_overflow(0)); ATF_CHECK(test_ldw_abs_overflow(1)); ATF_CHECK(test_ldw_abs_overflow(2)); ATF_CHECK(test_ldw_abs_overflow(3)); ATF_CHECK(test_ldw_abs_overflow(4)); ATF_CHECK(test_ldw_abs_overflow(5)); } ATF_TC(bpf_mbuf_ldb_ind_overflow1); ATF_TC_HEAD(bpf_mbuf_ldb_ind_overflow1, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldb_ind_overflow1, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_ind_overflow1(0)); ATF_CHECK(test_ldb_ind_overflow1(1)); ATF_CHECK(test_ldb_ind_overflow1(2)); ATF_CHECK(test_ldb_ind_overflow1(3)); ATF_CHECK(test_ldb_ind_overflow1(4)); ATF_CHECK(test_ldb_ind_overflow1(5)); } ATF_TC(bpf_mbuf_ldb_ind_overflow2); ATF_TC_HEAD(bpf_mbuf_ldb_ind_overflow2, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldb_ind_overflow2, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_ind_overflow2(0)); ATF_CHECK(test_ldb_ind_overflow2(1)); ATF_CHECK(test_ldb_ind_overflow2(2)); ATF_CHECK(test_ldb_ind_overflow2(3)); ATF_CHECK(test_ldb_ind_overflow2(4)); ATF_CHECK(test_ldb_ind_overflow2(5)); } ATF_TC(bpf_mbuf_ldb_ind_overflow3); ATF_TC_HEAD(bpf_mbuf_ldb_ind_overflow3, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldb_ind_overflow3, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_ind_overflow3(0)); ATF_CHECK(test_ldb_ind_overflow3(1)); ATF_CHECK(test_ldb_ind_overflow3(2)); ATF_CHECK(test_ldb_ind_overflow3(3)); ATF_CHECK(test_ldb_ind_overflow3(4)); ATF_CHECK(test_ldb_ind_overflow3(5)); } ATF_TC(bpf_mbuf_ldh_ind_overflow1); ATF_TC_HEAD(bpf_mbuf_ldh_ind_overflow1, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldh_ind_overflow1, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_ind_overflow1(0)); ATF_CHECK(test_ldh_ind_overflow1(1)); ATF_CHECK(test_ldh_ind_overflow1(2)); ATF_CHECK(test_ldh_ind_overflow1(3)); ATF_CHECK(test_ldh_ind_overflow1(4)); ATF_CHECK(test_ldh_ind_overflow1(5)); } ATF_TC(bpf_mbuf_ldh_ind_overflow2); ATF_TC_HEAD(bpf_mbuf_ldh_ind_overflow2, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldh_ind_overflow2, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_ind_overflow2(0)); ATF_CHECK(test_ldh_ind_overflow2(1)); ATF_CHECK(test_ldh_ind_overflow2(2)); ATF_CHECK(test_ldh_ind_overflow2(3)); ATF_CHECK(test_ldh_ind_overflow2(4)); ATF_CHECK(test_ldh_ind_overflow2(5)); } ATF_TC(bpf_mbuf_ldh_ind_overflow3); ATF_TC_HEAD(bpf_mbuf_ldh_ind_overflow3, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldh_ind_overflow3, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_ind_overflow3(0)); ATF_CHECK(test_ldh_ind_overflow3(1)); ATF_CHECK(test_ldh_ind_overflow3(2)); ATF_CHECK(test_ldh_ind_overflow3(3)); ATF_CHECK(test_ldh_ind_overflow3(4)); ATF_CHECK(test_ldh_ind_overflow3(5)); } ATF_TC(bpf_mbuf_ldw_ind_overflow1); ATF_TC_HEAD(bpf_mbuf_ldw_ind_overflow1, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldw_ind_overflow1, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_ind_overflow1(0)); ATF_CHECK(test_ldw_ind_overflow1(1)); ATF_CHECK(test_ldw_ind_overflow1(2)); ATF_CHECK(test_ldw_ind_overflow1(3)); ATF_CHECK(test_ldw_ind_overflow1(4)); ATF_CHECK(test_ldw_ind_overflow1(5)); } ATF_TC(bpf_mbuf_ldw_ind_overflow2); ATF_TC_HEAD(bpf_mbuf_ldw_ind_overflow2, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldw_ind_overflow2, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_ind_overflow2(0)); ATF_CHECK(test_ldw_ind_overflow2(1)); ATF_CHECK(test_ldw_ind_overflow2(2)); ATF_CHECK(test_ldw_ind_overflow2(3)); ATF_CHECK(test_ldw_ind_overflow2(4)); ATF_CHECK(test_ldw_ind_overflow2(5)); } ATF_TC(bpf_mbuf_ldw_ind_overflow3); ATF_TC_HEAD(bpf_mbuf_ldw_ind_overflow3, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_ldw_ind_overflow3, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_ind_overflow3(0)); ATF_CHECK(test_ldw_ind_overflow3(1)); ATF_CHECK(test_ldw_ind_overflow3(2)); ATF_CHECK(test_ldw_ind_overflow3(3)); ATF_CHECK(test_ldw_ind_overflow3(4)); ATF_CHECK(test_ldw_ind_overflow3(5)); } ATF_TC(bpf_mbuf_msh_overflow); ATF_TC_HEAD(bpf_mbuf_msh_overflow, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LDX+BPF_B+BPF_MSH " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpf_mbuf_msh_overflow, tc) { RZ(rump_init()); ATF_CHECK(test_msh_overflow(0)); ATF_CHECK(test_msh_overflow(1)); ATF_CHECK(test_msh_overflow(2)); ATF_CHECK(test_msh_overflow(3)); ATF_CHECK(test_msh_overflow(4)); ATF_CHECK(test_msh_overflow(5)); } ATF_TP_ADD_TCS(tp) { /* * For every new test please also add a similar test * to ../../net/bpfjit/t_mbuf.c */ ATF_TP_ADD_TC(tp, bpf_mbuf_ldb_abs); ATF_TP_ADD_TC(tp, bpf_mbuf_ldh_abs); ATF_TP_ADD_TC(tp, bpf_mbuf_ldw_abs); ATF_TP_ADD_TC(tp, bpf_mbuf_ldb_ind); ATF_TP_ADD_TC(tp, bpf_mbuf_ldh_ind); ATF_TP_ADD_TC(tp, bpf_mbuf_ldw_ind); ATF_TP_ADD_TC(tp, bpf_mbuf_msh); ATF_TP_ADD_TC(tp, bpf_mbuf_ldb_abs_overflow); ATF_TP_ADD_TC(tp, bpf_mbuf_ldh_abs_overflow); ATF_TP_ADD_TC(tp, bpf_mbuf_ldw_abs_overflow); ATF_TP_ADD_TC(tp, bpf_mbuf_ldb_ind_overflow1); ATF_TP_ADD_TC(tp, bpf_mbuf_ldb_ind_overflow2); ATF_TP_ADD_TC(tp, bpf_mbuf_ldb_ind_overflow3); ATF_TP_ADD_TC(tp, bpf_mbuf_ldh_ind_overflow1); ATF_TP_ADD_TC(tp, bpf_mbuf_ldh_ind_overflow2); ATF_TP_ADD_TC(tp, bpf_mbuf_ldh_ind_overflow3); ATF_TP_ADD_TC(tp, bpf_mbuf_ldw_ind_overflow1); ATF_TP_ADD_TC(tp, bpf_mbuf_ldw_ind_overflow2); ATF_TP_ADD_TC(tp, bpf_mbuf_ldw_ind_overflow3); ATF_TP_ADD_TC(tp, bpf_mbuf_msh_overflow); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfilter/t_bpfilter.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfilter/t_bpfilter.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfilter/t_bpfilter.c (revision 312126) @@ -1,482 +1,482 @@ -/* $NetBSD: t_bpfilter.c,v 1.10 2015/02/11 23:39:07 alnsn Exp $ */ +/* $NetBSD: t_bpfilter.c,v 1.11 2017/01/13 21:30:42 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * * 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 ``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. */ #include -__RCSID("$NetBSD: t_bpfilter.c,v 1.10 2015/02/11 23:39:07 alnsn Exp $"); +__RCSID("$NetBSD: t_bpfilter.c,v 1.11 2017/01/13 21:30:42 christos Exp $"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* XXX: atf-c.h has collisions with mbuf */ #undef m_type #undef m_data #include -#include "../../h_macros.h" +#include "h_macros.h" #include "../config/netconfig.c" #define SNAPLEN UINT32_MAX #define BMAGIC UINT32_C(0x37) #define HMAGIC UINT32_C(0xc2c2) #define WMAGIC UINT32_C(0x7d7d7d7d) static const char magic_echo_reply_tail[7] = { BMAGIC, HMAGIC & 0xff, HMAGIC & 0xff, WMAGIC & 0xff, WMAGIC & 0xff, WMAGIC & 0xff, WMAGIC & 0xff }; /* * Match ICMP_ECHOREPLY packet with 7 magic bytes at the end. */ static struct bpf_insn magic_echo_reply_prog[] = { BPF_STMT(BPF_LD+BPF_ABS+BPF_B, sizeof(struct ip) + offsetof(struct icmp, icmp_type)), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ICMP_ECHOREPLY, 1, 0), BPF_STMT(BPF_RET+BPF_K, 0), BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), /* A <- len */ BPF_STMT(BPF_ALU+BPF_SUB+BPF_K, 7), /* A <- A - 7 */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_IND+BPF_B, 0), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, BMAGIC, 1, 0), BPF_STMT(BPF_RET+BPF_K, 0), BPF_STMT(BPF_LD+BPF_IND+BPF_H, 1), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, HMAGIC, 1, 0), BPF_STMT(BPF_RET+BPF_K, 0), BPF_STMT(BPF_LD+BPF_IND+BPF_W, 3), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, WMAGIC, 1, 0), BPF_STMT(BPF_RET+BPF_K, 0), BPF_STMT(BPF_RET+BPF_K, SNAPLEN) }; static struct bpf_insn badmem_prog[] = { BPF_STMT(BPF_LD+BPF_MEM, 5), BPF_STMT(BPF_RET+BPF_A, 0), }; static struct bpf_insn noinitA_prog[] = { BPF_STMT(BPF_RET+BPF_A, 0), }; static struct bpf_insn noinitX_prog[] = { BPF_STMT(BPF_MISC+BPF_TXA, 0), BPF_STMT(BPF_RET+BPF_A, 0), }; static struct bpf_insn badjmp_prog[] = { BPF_STMT(BPF_JMP+BPF_JA, 5), BPF_STMT(BPF_RET+BPF_A, 0), }; static struct bpf_insn negjmp_prog[] = { BPF_STMT(BPF_JMP+BPF_JA, 0), BPF_STMT(BPF_JMP+BPF_JA, UINT32_MAX - 1), // -2 BPF_STMT(BPF_RET+BPF_A, 0), }; static struct bpf_insn badret_prog[] = { BPF_STMT(BPF_RET+BPF_A+0x8000, 0), }; static uint16_t in_cksum(void *data, size_t len) { uint16_t *buf = data; unsigned sum; for (sum = 0; len > 1; len -= 2) sum += *buf++; if (len) sum += *(uint8_t *)buf; sum = (sum >> 16) + (sum & 0xffff); sum += (sum >> 16); return ~sum; } /* * Based on netcfg_rump_pingtest(). */ static bool __unused pingtest(const char *dst, unsigned int wirelen, const char tail[7]) { struct timeval tv; struct sockaddr_in sin; struct icmp *icmp; char *pkt; unsigned int pktsize; socklen_t slen; int s; bool rv = false; if (wirelen < ETHER_HDR_LEN + sizeof(struct ip)) return false; pktsize = wirelen - ETHER_HDR_LEN - sizeof(struct ip); if (pktsize < sizeof(struct icmp) + 7) return false; s = rump_sys_socket(PF_INET, SOCK_RAW, IPPROTO_ICMP); if (s == -1) return false; pkt = NULL; tv.tv_sec = 1; tv.tv_usec = 0; if (rump_sys_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) goto out; memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr(dst); pkt = calloc(1, pktsize); icmp = (struct icmp *)pkt; if (pkt == NULL) goto out; memcpy(pkt + pktsize - 7, tail, 7); icmp->icmp_type = ICMP_ECHO; icmp->icmp_id = htons(37); icmp->icmp_seq = htons(1); icmp->icmp_cksum = in_cksum(pkt, pktsize); slen = sizeof(sin); if (rump_sys_sendto(s, pkt, pktsize, 0, (struct sockaddr *)&sin, slen) == -1) { goto out; } if (rump_sys_recvfrom(s, pkt, pktsize, 0, (struct sockaddr *)&sin, &slen) == -1) goto out; rv = true; out: if (pkt != NULL) free(pkt); rump_sys_close(s); return rv; } static void magic_ping_test(const char *name, unsigned int wirelen) { struct bpf_program prog; struct bpf_stat bstat; struct ifreq ifr; struct timeval tv; unsigned int bufsize; bool pinged; ssize_t n; char *buf; pid_t child; int bpfd; char token; int channel[2]; struct bpf_hdr *hdr; RL(pipe(channel)); prog.bf_len = __arraycount(magic_echo_reply_prog); prog.bf_insns = magic_echo_reply_prog; child = fork(); RZ(rump_init()); netcfg_rump_makeshmif(name, ifr.ifr_name); switch (child) { case -1: atf_tc_fail_errno("fork failed"); case 0: netcfg_rump_if(ifr.ifr_name, "10.1.1.10", "255.0.0.0"); close(channel[0]); ATF_CHECK(write(channel[1], "U", 1) == 1); close(channel[1]); pause(); return; default: break; } netcfg_rump_if(ifr.ifr_name, "10.1.1.20", "255.0.0.0"); RL(bpfd = rump_sys_open("/dev/bpf", O_RDONLY)); tv.tv_sec = 0; tv.tv_usec = 500; RL(rump_sys_ioctl(bpfd, BIOCSRTIMEOUT, &tv)); RL(rump_sys_ioctl(bpfd, BIOCGBLEN, &bufsize)); RL(rump_sys_ioctl(bpfd, BIOCSETF, &prog)); RL(rump_sys_ioctl(bpfd, BIOCSETIF, &ifr)); close(channel[1]); ATF_CHECK(read(channel[0], &token, 1) == 1 && token == 'U'); pinged = pingtest("10.1.1.10", wirelen, magic_echo_reply_tail); ATF_CHECK(pinged); buf = malloc(bufsize); hdr = (struct bpf_hdr *)buf; ATF_REQUIRE(buf != NULL); ATF_REQUIRE(bufsize > sizeof(struct bpf_hdr)); n = rump_sys_read(bpfd, buf, bufsize); ATF_CHECK(n > (int)sizeof(struct bpf_hdr)); ATF_CHECK(hdr->bh_caplen == MIN(SNAPLEN, wirelen)); RL(rump_sys_ioctl(bpfd, BIOCGSTATS, &bstat)); ATF_CHECK(bstat.bs_capt >= 1); /* XXX == 1 */ rump_sys_close(bpfd); free(buf); close(channel[0]); kill(child, SIGKILL); } static int send_bpf_prog(const char *ifname, struct bpf_program *prog) { struct ifreq ifr; int bpfd, e, rv; RZ(rump_init()); netcfg_rump_makeshmif(ifname, ifr.ifr_name); netcfg_rump_if(ifr.ifr_name, "10.1.1.20", "255.0.0.0"); RL(bpfd = rump_sys_open("/dev/bpf", O_RDONLY)); rv = rump_sys_ioctl(bpfd, BIOCSETF, prog); e = errno; rump_sys_close(bpfd); errno = e; return rv; } ATF_TC(bpfiltercontig); ATF_TC_HEAD(bpfiltercontig, tc) { atf_tc_set_md_var(tc, "descr", "Checks that bpf program " "can read bytes from contiguous buffer."); atf_tc_set_md_var(tc, "timeout", "30"); } ATF_TC_BODY(bpfiltercontig, tc) { magic_ping_test("bpfiltercontig", 128); } ATF_TC(bpfiltermchain); ATF_TC_HEAD(bpfiltermchain, tc) { atf_tc_set_md_var(tc, "descr", "Checks that bpf program " "can read bytes from mbuf chain."); atf_tc_set_md_var(tc, "timeout", "30"); } ATF_TC_BODY(bpfiltermchain, tc) { magic_ping_test("bpfiltermchain", MINCLSIZE + 1); } ATF_TC(bpfilterbadmem); ATF_TC_HEAD(bpfilterbadmem, tc) { atf_tc_set_md_var(tc, "descr", "Checks that bpf program that " "doesn't initialize memomy store is rejected by the kernel"); atf_tc_set_md_var(tc, "timeout", "30"); } ATF_TC_BODY(bpfilterbadmem, tc) { struct bpf_program prog; prog.bf_len = __arraycount(badmem_prog); prog.bf_insns = badmem_prog; ATF_CHECK_ERRNO(EINVAL, send_bpf_prog("bpfilterbadmem", &prog) == -1); } ATF_TC(bpfilternoinitA); ATF_TC_HEAD(bpfilternoinitA, tc) { atf_tc_set_md_var(tc, "descr", "Checks that bpf program that " "doesn't initialize the A register is accepted by the kernel"); atf_tc_set_md_var(tc, "timeout", "30"); } ATF_TC_BODY(bpfilternoinitA, tc) { struct bpf_program prog; prog.bf_len = __arraycount(noinitA_prog); prog.bf_insns = noinitA_prog; RL(send_bpf_prog("bpfilternoinitA", &prog)); } ATF_TC(bpfilternoinitX); ATF_TC_HEAD(bpfilternoinitX, tc) { atf_tc_set_md_var(tc, "descr", "Checks that bpf program that " "doesn't initialize the X register is accepted by the kernel"); atf_tc_set_md_var(tc, "timeout", "30"); } ATF_TC_BODY(bpfilternoinitX, tc) { struct bpf_program prog; prog.bf_len = __arraycount(noinitX_prog); prog.bf_insns = noinitX_prog; RL(send_bpf_prog("bpfilternoinitX", &prog)); } ATF_TC(bpfilterbadjmp); ATF_TC_HEAD(bpfilterbadjmp, tc) { atf_tc_set_md_var(tc, "descr", "Checks that bpf program that " "jumps to invalid destination is rejected by the kernel"); atf_tc_set_md_var(tc, "timeout", "30"); } ATF_TC_BODY(bpfilterbadjmp, tc) { struct bpf_program prog; prog.bf_len = __arraycount(badjmp_prog); prog.bf_insns = badjmp_prog; ATF_CHECK_ERRNO(EINVAL, send_bpf_prog("bpfilterbadjmp", &prog) == -1); } ATF_TC(bpfilternegjmp); ATF_TC_HEAD(bpfilternegjmp, tc) { atf_tc_set_md_var(tc, "descr", "Checks that bpf program that " "jumps backwards is rejected by the kernel"); atf_tc_set_md_var(tc, "timeout", "30"); } ATF_TC_BODY(bpfilternegjmp, tc) { struct bpf_program prog; prog.bf_len = __arraycount(negjmp_prog); prog.bf_insns = negjmp_prog; ATF_CHECK_ERRNO(EINVAL, send_bpf_prog("bpfilternegjmp", &prog) == -1); } ATF_TC(bpfilterbadret); ATF_TC_HEAD(bpfilterbadret, tc) { atf_tc_set_md_var(tc, "descr", "Checks that bpf program that " "ends with invalid BPF_RET instruction is rejected by the kernel"); atf_tc_set_md_var(tc, "timeout", "30"); } ATF_TC_BODY(bpfilterbadret, tc) { struct bpf_program prog; struct bpf_insn *last; prog.bf_len = __arraycount(badret_prog); prog.bf_insns = badret_prog; /* * The point of this test is checking a bad instruction of * a valid class and with a valid BPF_RVAL data. */ last = &prog.bf_insns[prog.bf_len - 1]; ATF_CHECK(BPF_CLASS(last->code) == BPF_RET && (BPF_RVAL(last->code) == BPF_K || BPF_RVAL(last->code) == BPF_A)); ATF_CHECK_ERRNO(EINVAL, send_bpf_prog("bpfilterbadret", &prog) == -1); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, bpfiltercontig); ATF_TP_ADD_TC(tp, bpfiltermchain); ATF_TP_ADD_TC(tp, bpfilterbadmem); ATF_TP_ADD_TC(tp, bpfilternoinitA); ATF_TP_ADD_TC(tp, bpfilternoinitX); ATF_TP_ADD_TC(tp, bpfilterbadjmp); ATF_TP_ADD_TC(tp, bpfilternegjmp); ATF_TP_ADD_TC(tp, bpfilterbadret); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_bpfjit.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_bpfjit.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_bpfjit.c (revision 312126) @@ -1,4689 +1,4689 @@ -/* $NetBSD: t_bpfjit.c,v 1.11 2015/02/14 22:34:33 alnsn Exp $ */ +/* $NetBSD: t_bpfjit.c,v 1.12 2017/01/13 21:30:42 christos Exp $ */ /*- * Copyright (c) 2011-2012, 2014-2015 Alexander Nasonov. * 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 ``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. */ #include -__RCSID("$NetBSD: t_bpfjit.c,v 1.11 2015/02/14 22:34:33 alnsn Exp $"); +__RCSID("$NetBSD: t_bpfjit.c,v 1.12 2017/01/13 21:30:42 christos Exp $"); #include #include #include #include #include #include #include #include #include #include "../../net/bpf/h_bpf.h" /* XXX: atf-c.h has collisions with mbuf */ #undef m_type #undef m_data #include -#include "../../h_macros.h" +#include "h_macros.h" static uint8_t deadbeef_at_5[16] = { 0, 0xf1, 2, 0xf3, 4, 0xde, 0xad, 0xbe, 0xef, 0xff }; static inline unsigned int jitcall(bpfjit_func_t fn, const uint8_t *pkt, unsigned int wirelen, unsigned int buflen) { bpf_args_t args; args.pkt = pkt; args.wirelen = wirelen; args.buflen = buflen; return fn(NULL, &args); } ATF_TC(bpfjit_empty); ATF_TC_HEAD(bpfjit_empty, tc) { atf_tc_set_md_var(tc, "descr", "Test that JIT compilation of an empty bpf program fails"); } ATF_TC_BODY(bpfjit_empty, tc) { struct bpf_insn dummy; bpfjit_func_t code; RZ(rump_init()); ATF_CHECK(!prog_validate(&dummy, 0)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, &dummy, 0); rump_unschedule(); ATF_CHECK(code == NULL); } ATF_TC(bpfjit_ret_k); ATF_TC_HEAD(bpfjit_ret_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of a trivial bpf program"); } ATF_TC_BODY(bpfjit_ret_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_RET+BPF_K, 17) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 17); } ATF_TC(bpfjit_bad_ret_k); ATF_TC_HEAD(bpfjit_bad_ret_k, tc) { atf_tc_set_md_var(tc, "descr", "Test that JIT compilation of a program with bad BPF_RET fails"); } ATF_TC_BODY(bpfjit_bad_ret_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_RET+BPF_K+0x8000, 13) }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); uint8_t pkt[1]; /* the program doesn't read any data */ /* * The point of this test is checking a bad instruction of * a valid class and with a valid BPF_RVAL data. */ const uint16_t rcode = insns[0].code; ATF_CHECK(BPF_CLASS(rcode) == BPF_RET && (BPF_RVAL(rcode) == BPF_K || BPF_RVAL(rcode) == BPF_A)); RZ(rump_init()); ATF_CHECK(!prog_validate(insns, insn_count)); /* Current implementation generates code. */ ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 13); } ATF_TC(bpfjit_alu_add_k); ATF_TC_HEAD(bpfjit_alu_add_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_ADD+BPF_K"); } ATF_TC_BODY(bpfjit_alu_add_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 3), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 2), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 5); } ATF_TC(bpfjit_alu_sub_k); ATF_TC_HEAD(bpfjit_alu_sub_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_SUB+BPF_K"); } ATF_TC_BODY(bpfjit_alu_sub_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 1), BPF_STMT(BPF_ALU+BPF_SUB+BPF_K, 2), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == UINT32_MAX); } ATF_TC(bpfjit_alu_mul_k); ATF_TC_HEAD(bpfjit_alu_mul_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MUL+BPF_K"); } ATF_TC_BODY(bpfjit_alu_mul_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0xffffffff)), BPF_STMT(BPF_ALU+BPF_MUL+BPF_K, 3), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xfffffffd); } ATF_TC(bpfjit_alu_div0_k); ATF_TC_HEAD(bpfjit_alu_div0_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_K with k=0"); } ATF_TC_BODY(bpfjit_alu_div0_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); //ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0); } ATF_TC(bpfjit_alu_div1_k); ATF_TC_HEAD(bpfjit_alu_div1_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_K with k=1"); } ATF_TC_BODY(bpfjit_alu_div1_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 7), BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 7); } ATF_TC(bpfjit_alu_div2_k); ATF_TC_HEAD(bpfjit_alu_div2_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_K with k=2"); } ATF_TC_BODY(bpfjit_alu_div2_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 7), BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 2), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 3); } ATF_TC(bpfjit_alu_div4_k); ATF_TC_HEAD(bpfjit_alu_div4_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_K with k=4"); } ATF_TC_BODY(bpfjit_alu_div4_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0xffffffff)), BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 4), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0x3fffffff); } ATF_TC(bpfjit_alu_div10_k); ATF_TC_HEAD(bpfjit_alu_div10_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_K with k=10"); } ATF_TC_BODY(bpfjit_alu_div10_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294843849)), BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 10), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 429484384); } ATF_TC(bpfjit_alu_div10000_k); ATF_TC_HEAD(bpfjit_alu_div10000_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_K with k=10000"); } ATF_TC_BODY(bpfjit_alu_div10000_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294843849)), BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 10000), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 429484); } ATF_TC(bpfjit_alu_div7609801_k); ATF_TC_HEAD(bpfjit_alu_div7609801_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_K with k=7609801"); } ATF_TC_BODY(bpfjit_alu_div7609801_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294967295)), BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, UINT32_C(7609801)), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 564); } ATF_TC(bpfjit_alu_div80000000_k); ATF_TC_HEAD(bpfjit_alu_div80000000_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_K with k=0x80000000"); } ATF_TC_BODY(bpfjit_alu_div80000000_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0xffffffde)), BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, UINT32_C(0x80000000)), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 1); } ATF_TC(bpfjit_alu_mod0_k); ATF_TC_HEAD(bpfjit_alu_mod0_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_K with k=0"); } ATF_TC_BODY(bpfjit_alu_mod0_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_ALU+BPF_MOD+BPF_K, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); //ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0); } ATF_TC(bpfjit_alu_mod1_k); ATF_TC_HEAD(bpfjit_alu_mod1_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_K with k=1"); } ATF_TC_BODY(bpfjit_alu_mod1_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 7), BPF_STMT(BPF_ALU+BPF_MOD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0); } ATF_TC(bpfjit_alu_mod2_k); ATF_TC_HEAD(bpfjit_alu_mod2_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_K with k=2"); } ATF_TC_BODY(bpfjit_alu_mod2_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 7), BPF_STMT(BPF_ALU+BPF_MOD+BPF_K, 2), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 1); } ATF_TC(bpfjit_alu_mod4_k); ATF_TC_HEAD(bpfjit_alu_mod4_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_K with k=4"); } ATF_TC_BODY(bpfjit_alu_mod4_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0xffffffff)), BPF_STMT(BPF_ALU+BPF_MOD+BPF_K, 4), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 3); } ATF_TC(bpfjit_alu_mod10_k); ATF_TC_HEAD(bpfjit_alu_mod10_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_K with k=10"); } ATF_TC_BODY(bpfjit_alu_mod10_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294843849)), BPF_STMT(BPF_ALU+BPF_MOD+BPF_K, 10), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 9); } ATF_TC(bpfjit_alu_mod10000_k); ATF_TC_HEAD(bpfjit_alu_mod10000_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_K with k=10000"); } ATF_TC_BODY(bpfjit_alu_mod10000_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294843849)), BPF_STMT(BPF_ALU+BPF_MOD+BPF_K, 10000), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 3849); } ATF_TC(bpfjit_alu_mod7609801_k); ATF_TC_HEAD(bpfjit_alu_mod7609801_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_K with k=7609801"); } ATF_TC_BODY(bpfjit_alu_mod7609801_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294967295)), BPF_STMT(BPF_ALU+BPF_MOD+BPF_K, UINT32_C(7609801)), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 3039531); } ATF_TC(bpfjit_alu_mod80000000_k); ATF_TC_HEAD(bpfjit_alu_mod80000000_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_K with k=0x80000000"); } ATF_TC_BODY(bpfjit_alu_mod80000000_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0xffffffde)), BPF_STMT(BPF_ALU+BPF_MOD+BPF_K, UINT32_C(0x80000000)), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == UINT32_C(0x7fffffde)); } ATF_TC(bpfjit_alu_and_k); ATF_TC_HEAD(bpfjit_alu_and_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_AND+BPF_K"); } ATF_TC_BODY(bpfjit_alu_and_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdead), BPF_STMT(BPF_ALU+BPF_AND+BPF_K, 0xbeef), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == (0xdead&0xbeef)); } ATF_TC(bpfjit_alu_or_k); ATF_TC_HEAD(bpfjit_alu_or_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_OR+BPF_K"); } ATF_TC_BODY(bpfjit_alu_or_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdead0000), BPF_STMT(BPF_ALU+BPF_OR+BPF_K, 0x0000beef), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xdeadbeef); } ATF_TC(bpfjit_alu_xor_k); ATF_TC_HEAD(bpfjit_alu_xor_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_XOR+BPF_K"); } ATF_TC_BODY(bpfjit_alu_xor_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdead0f0f), BPF_STMT(BPF_ALU+BPF_XOR+BPF_K, 0x0000b1e0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xdeadbeef); } ATF_TC(bpfjit_alu_lsh_k); ATF_TC_HEAD(bpfjit_alu_lsh_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_LSH+BPF_K"); } ATF_TC_BODY(bpfjit_alu_lsh_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdeadbeef), BPF_STMT(BPF_ALU+BPF_LSH+BPF_K, 16), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xbeef0000); } ATF_TC(bpfjit_alu_lsh0_k); ATF_TC_HEAD(bpfjit_alu_lsh0_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_LSH+BPF_K with k=0"); } ATF_TC_BODY(bpfjit_alu_lsh0_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdeadbeef), BPF_STMT(BPF_ALU+BPF_LSH+BPF_K, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xdeadbeef); } ATF_TC(bpfjit_alu_rsh_k); ATF_TC_HEAD(bpfjit_alu_rsh_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_RSH+BPF_K"); } ATF_TC_BODY(bpfjit_alu_rsh_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdeadbeef), BPF_STMT(BPF_ALU+BPF_RSH+BPF_K, 16), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0x0000dead); } ATF_TC(bpfjit_alu_rsh0_k); ATF_TC_HEAD(bpfjit_alu_rsh0_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_RSH+BPF_K with k=0"); } ATF_TC_BODY(bpfjit_alu_rsh0_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdeadbeef), BPF_STMT(BPF_ALU+BPF_RSH+BPF_K, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xdeadbeef); } ATF_TC(bpfjit_alu_modulo_k); ATF_TC_HEAD(bpfjit_alu_modulo_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of modulo logic of BPF_ALU+BPF_K operations"); } ATF_TC_BODY(bpfjit_alu_modulo_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0x7fffff77)), /* (7FFFFF77 * 0FFFFF77) = 07FFFFB2,F0004951 */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_K, UINT32_C(0x0fffff77)), /* 07FFFFB2,F0004951 << 1 = 0FFFFF65,E00092A2 */ BPF_STMT(BPF_ALU+BPF_LSH+BPF_K, 1), /* 0FFFFF65,E00092A2 + DDDDDDDD = 0FFFFF66,BDDE707F */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, UINT32_C(0xdddddddd)), /* 0FFFFF66,BDDE707F - FFFFFFFF = 0FFFFF65,BDDE7080 */ BPF_STMT(BPF_ALU+BPF_SUB+BPF_K, UINT32_C(0xffffffff)), /* 0FFFFF65,BDDE7080 | 0000030C = 0FFFFF65,BDDE738C */ BPF_STMT(BPF_ALU+BPF_OR+BPF_K, UINT32_C(0x0000030c)), /* -0FFFFF65,BDDE738C mod(2^64) = F000009A,42218C74 */ BPF_STMT(BPF_ALU+BPF_NEG, 0), /* F000009A,42218C74 & FFFFFF0F = F000009A,42218C04 */ BPF_STMT(BPF_ALU+BPF_AND+BPF_K, UINT32_C(0xffffff0f)), /* F000009A,42218C74 >> 3 = 1E000013,48443180 */ /* 00000000,42218C74 >> 3 = 00000000,08443180 */ BPF_STMT(BPF_ALU+BPF_RSH+BPF_K, 3), /* 00000000,08443180 * 7FFFFF77 = 042218BB,93818280 */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_K, UINT32_C(0x7fffff77)), /* 042218BB,93818280 / DEAD = 000004C0,71CBBBC3 */ /* 00000000,93818280 / DEAD = 00000000,0000A994 */ BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, UINT32_C(0xdead)), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) != UINT32_C(0x71cbbbc3)); ATF_CHECK(jitcall(code, pkt, 1, 1) == UINT32_C(0x0000a994)); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_alu_add_x); ATF_TC_HEAD(bpfjit_alu_add_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_ADD+BPF_X"); } ATF_TC_BODY(bpfjit_alu_add_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 3), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 2), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 5); } ATF_TC(bpfjit_alu_sub_x); ATF_TC_HEAD(bpfjit_alu_sub_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_SUB+BPF_X"); } ATF_TC_BODY(bpfjit_alu_sub_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 1), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 2), BPF_STMT(BPF_ALU+BPF_SUB+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == UINT32_MAX); } ATF_TC(bpfjit_alu_mul_x); ATF_TC_HEAD(bpfjit_alu_mul_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MUL+BPF_X"); } ATF_TC_BODY(bpfjit_alu_mul_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0xffffffff)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 3), BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xfffffffd); } ATF_TC(bpfjit_alu_div0_x); ATF_TC_HEAD(bpfjit_alu_div0_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_X with X=0"); } ATF_TC_BODY(bpfjit_alu_div0_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0), BPF_STMT(BPF_ALU+BPF_DIV+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0); } ATF_TC(bpfjit_alu_div1_x); ATF_TC_HEAD(bpfjit_alu_div1_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_X with X=1"); } ATF_TC_BODY(bpfjit_alu_div1_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 7), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), BPF_STMT(BPF_ALU+BPF_DIV+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 7); } ATF_TC(bpfjit_alu_div2_x); ATF_TC_HEAD(bpfjit_alu_div2_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_X with X=2"); } ATF_TC_BODY(bpfjit_alu_div2_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 7), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 2), BPF_STMT(BPF_ALU+BPF_DIV+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 3); } ATF_TC(bpfjit_alu_div4_x); ATF_TC_HEAD(bpfjit_alu_div4_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_X with X=4"); } ATF_TC_BODY(bpfjit_alu_div4_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0xffffffff)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 4), BPF_STMT(BPF_ALU+BPF_DIV+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0x3fffffff); } ATF_TC(bpfjit_alu_div10_x); ATF_TC_HEAD(bpfjit_alu_div10_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_X with X=10"); } ATF_TC_BODY(bpfjit_alu_div10_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294843849)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 10), BPF_STMT(BPF_ALU+BPF_DIV+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 429484384); } ATF_TC(bpfjit_alu_div10000_x); ATF_TC_HEAD(bpfjit_alu_div10000_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_X with X=10000"); } ATF_TC_BODY(bpfjit_alu_div10000_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294843849)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 10000), BPF_STMT(BPF_ALU+BPF_DIV+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 429484); } ATF_TC(bpfjit_alu_div7609801_x); ATF_TC_HEAD(bpfjit_alu_div7609801_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_X with X=7609801"); } ATF_TC_BODY(bpfjit_alu_div7609801_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294967295)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(7609801)), BPF_STMT(BPF_ALU+BPF_DIV+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 564); } ATF_TC(bpfjit_alu_div80000000_x); ATF_TC_HEAD(bpfjit_alu_div80000000_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_DIV+BPF_X with X=0x80000000"); } ATF_TC_BODY(bpfjit_alu_div80000000_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0xffffffde)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(0x80000000)), BPF_STMT(BPF_ALU+BPF_DIV+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 1); } ATF_TC(bpfjit_alu_mod0_x); ATF_TC_HEAD(bpfjit_alu_mod0_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_X with X=0"); } ATF_TC_BODY(bpfjit_alu_mod0_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0), BPF_STMT(BPF_ALU+BPF_MOD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0); } ATF_TC(bpfjit_alu_mod1_x); ATF_TC_HEAD(bpfjit_alu_mod1_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_X with X=1"); } ATF_TC_BODY(bpfjit_alu_mod1_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 7), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), BPF_STMT(BPF_ALU+BPF_MOD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0); } ATF_TC(bpfjit_alu_mod2_x); ATF_TC_HEAD(bpfjit_alu_mod2_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_X with X=2"); } ATF_TC_BODY(bpfjit_alu_mod2_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 7), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 2), BPF_STMT(BPF_ALU+BPF_MOD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 1); } ATF_TC(bpfjit_alu_mod4_x); ATF_TC_HEAD(bpfjit_alu_mod4_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_X with X=4"); } ATF_TC_BODY(bpfjit_alu_mod4_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0xffffffff)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 4), BPF_STMT(BPF_ALU+BPF_MOD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 3); } ATF_TC(bpfjit_alu_mod10_x); ATF_TC_HEAD(bpfjit_alu_mod10_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_X with X=10"); } ATF_TC_BODY(bpfjit_alu_mod10_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294843849)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 10), BPF_STMT(BPF_ALU+BPF_MOD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 9); } ATF_TC(bpfjit_alu_mod10000_x); ATF_TC_HEAD(bpfjit_alu_mod10000_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_X with X=10000"); } ATF_TC_BODY(bpfjit_alu_mod10000_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294843849)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 10000), BPF_STMT(BPF_ALU+BPF_MOD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 3849); } ATF_TC(bpfjit_alu_mod7609801_x); ATF_TC_HEAD(bpfjit_alu_mod7609801_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_X with X=7609801"); } ATF_TC_BODY(bpfjit_alu_mod7609801_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(4294967295)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(7609801)), BPF_STMT(BPF_ALU+BPF_MOD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 3039531); } ATF_TC(bpfjit_alu_mod80000000_x); ATF_TC_HEAD(bpfjit_alu_mod80000000_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_MOD+BPF_X with X=0x80000000"); } ATF_TC_BODY(bpfjit_alu_mod80000000_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0xffffffde)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(0x80000000)), BPF_STMT(BPF_ALU+BPF_MOD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == UINT32_C(0x7fffffde)); } ATF_TC(bpfjit_alu_and_x); ATF_TC_HEAD(bpfjit_alu_and_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_AND+BPF_X"); } ATF_TC_BODY(bpfjit_alu_and_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdead), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0xbeef), BPF_STMT(BPF_ALU+BPF_AND+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == (0xdead&0xbeef)); } ATF_TC(bpfjit_alu_or_x); ATF_TC_HEAD(bpfjit_alu_or_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_OR+BPF_X"); } ATF_TC_BODY(bpfjit_alu_or_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdead0000), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0x0000beef), BPF_STMT(BPF_ALU+BPF_OR+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xdeadbeef); } ATF_TC(bpfjit_alu_xor_x); ATF_TC_HEAD(bpfjit_alu_xor_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_XOR+BPF_X"); } ATF_TC_BODY(bpfjit_alu_xor_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdead0f0f), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0x0000b1e0), BPF_STMT(BPF_ALU+BPF_XOR+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xdeadbeef); } ATF_TC(bpfjit_alu_lsh_x); ATF_TC_HEAD(bpfjit_alu_lsh_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_LSH+BPF_X"); } ATF_TC_BODY(bpfjit_alu_lsh_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdeadbeef), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 16), BPF_STMT(BPF_ALU+BPF_LSH+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xbeef0000); } ATF_TC(bpfjit_alu_lsh0_x); ATF_TC_HEAD(bpfjit_alu_lsh0_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_LSH+BPF_X with k=0"); } ATF_TC_BODY(bpfjit_alu_lsh0_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdeadbeef), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0), BPF_STMT(BPF_ALU+BPF_LSH+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xdeadbeef); } ATF_TC(bpfjit_alu_rsh_x); ATF_TC_HEAD(bpfjit_alu_rsh_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_RSH+BPF_X"); } ATF_TC_BODY(bpfjit_alu_rsh_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdeadbeef), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 16), BPF_STMT(BPF_ALU+BPF_RSH+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0x0000dead); } ATF_TC(bpfjit_alu_rsh0_x); ATF_TC_HEAD(bpfjit_alu_rsh0_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_RSH+BPF_X with k=0"); } ATF_TC_BODY(bpfjit_alu_rsh0_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 0xdeadbeef), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0), BPF_STMT(BPF_ALU+BPF_RSH+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0xdeadbeef); } ATF_TC(bpfjit_alu_modulo_x); ATF_TC_HEAD(bpfjit_alu_modulo_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of modulo logic of BPF_ALU+BPF_X operations"); } ATF_TC_BODY(bpfjit_alu_modulo_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0x7fffff77)), /* (7FFFFF77 * 0FFFFF77) = 07FFFFB2,F0004951 */ BPF_STMT(BPF_LDX+BPF_W+BPF_K, UINT32_C(0x0fffff77)), BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* 07FFFFB2,F0004951 << 1 = 0FFFFF65,E00092A2 */ BPF_STMT(BPF_LDX+BPF_W+BPF_K, 1), BPF_STMT(BPF_ALU+BPF_LSH+BPF_X, 0), /* 0FFFFF65,E00092A2 + DDDDDDDD = 0FFFFF66,BDDE707F */ BPF_STMT(BPF_LDX+BPF_W+BPF_K, UINT32_C(0xdddddddd)), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* 0FFFFF66,BDDE707F - FFFFFFFF = 0FFFFF65,BDDE7080 */ BPF_STMT(BPF_LDX+BPF_W+BPF_K, UINT32_C(0xffffffff)), BPF_STMT(BPF_ALU+BPF_SUB+BPF_X, 0), /* 0FFFFF65,BDDE7080 | 0000030C = 0FFFFF65,BDDE738C */ BPF_STMT(BPF_LDX+BPF_W+BPF_K, UINT32_C(0x0000030c)), BPF_STMT(BPF_ALU+BPF_OR+BPF_X, 0), /* -0FFFFF65,BDDE738C mod(2^64) = F000009A,42218C74 */ BPF_STMT(BPF_ALU+BPF_NEG, 0), /* F000009A,42218C74 & FFFFFF0F = F000009A,42218C04 */ BPF_STMT(BPF_LDX+BPF_W+BPF_K, UINT32_C(0xffffff0f)), BPF_STMT(BPF_ALU+BPF_AND+BPF_X, 0), /* F000009A,42218C74 >> 3 = 1E000013,48443180 */ /* 00000000,42218C74 >> 3 = 00000000,08443180 */ BPF_STMT(BPF_LDX+BPF_W+BPF_K, 3), BPF_STMT(BPF_ALU+BPF_RSH+BPF_X, 0), /* 00000000,08443180 * 7FFFFF77 = 042218BB,93818280 */ BPF_STMT(BPF_LDX+BPF_W+BPF_K, UINT32_C(0x7fffff77)), BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* 042218BB,93818280 / DEAD = 000004C0,71CBBBC3 */ /* 00000000,93818280 / DEAD = 00000000,0000A994 */ BPF_STMT(BPF_LDX+BPF_W+BPF_K, UINT32_C(0xdead)), BPF_STMT(BPF_ALU+BPF_DIV+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) != UINT32_C(0x71cbbbc3)); ATF_CHECK(jitcall(code, pkt, 1, 1) == UINT32_C(0x0000a994)); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_alu_neg); ATF_TC_HEAD(bpfjit_alu_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ALU+BPF_NEG"); } ATF_TC_BODY(bpfjit_alu_neg, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 777), BPF_STMT(BPF_ALU+BPF_NEG, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0u-777u); } ATF_TC(bpfjit_jmp_ja); ATF_TC_HEAD(bpfjit_jmp_ja, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_JMP+BPF_JA"); } ATF_TC_BODY(bpfjit_jmp_ja, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_JMP+BPF_JA, 1), BPF_STMT(BPF_RET+BPF_K, 0), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_STMT(BPF_RET+BPF_K, 3), }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == UINT32_MAX); } ATF_TC(bpfjit_jmp_ja_invalid); ATF_TC_HEAD(bpfjit_jmp_ja_invalid, tc) { atf_tc_set_md_var(tc, "descr", "Test BPF_JMP+BPF_JA to invalid destination"); } ATF_TC_BODY(bpfjit_jmp_ja_invalid, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_JMP+BPF_JA, 4), BPF_STMT(BPF_RET+BPF_K, 0), BPF_STMT(BPF_RET+BPF_K, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_STMT(BPF_RET+BPF_K, 3), }; bpfjit_func_t code; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(!prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_CHECK(code == NULL); } ATF_TC(bpfjit_jmp_ja_overflow); ATF_TC_HEAD(bpfjit_jmp_ja_overflow, tc) { atf_tc_set_md_var(tc, "descr", "Test BPF_JMP+BPF_JA with negative offset"); } ATF_TC_BODY(bpfjit_jmp_ja_overflow, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_JMP+BPF_JA, 1), BPF_STMT(BPF_RET+BPF_K, 777), BPF_STMT(BPF_JMP+BPF_JA, UINT32_MAX - 1), // -2 BPF_STMT(BPF_RET+BPF_K, 0) }; bpfjit_func_t code; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); /* Jumps with negative offsets work only in userspace. */ ATF_CHECK(!prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_CHECK(code == NULL); } ATF_TC(bpfjit_jmp_jgt_k); ATF_TC_HEAD(bpfjit_jmp_jgt_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_JMP+BPF_JGT+BPF_K"); } ATF_TC_BODY(bpfjit_jmp_jgt_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, 7, 0, 1), BPF_STMT(BPF_RET+BPF_K, 0), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, 2, 2, 0), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, 9, 0, 0), BPF_STMT(BPF_RET+BPF_K, 1), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, 4, 1, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, 6, 2, 3), BPF_STMT(BPF_RET+BPF_K, 3), BPF_STMT(BPF_RET+BPF_K, 4), BPF_STMT(BPF_RET+BPF_K, 5), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, 5, 3, 1), BPF_STMT(BPF_RET+BPF_K, 6), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, 0, 0, 0), BPF_STMT(BPF_RET+BPF_K, 7), BPF_STMT(BPF_RET+BPF_K, 8) }; bpfjit_func_t code; uint8_t pkt[8]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 1); ATF_CHECK(jitcall(code, pkt, 2, 2) == 1); ATF_CHECK(jitcall(code, pkt, 3, 3) == 7); ATF_CHECK(jitcall(code, pkt, 4, 4) == 7); ATF_CHECK(jitcall(code, pkt, 5, 5) == 7); ATF_CHECK(jitcall(code, pkt, 6, 6) == 8); ATF_CHECK(jitcall(code, pkt, 7, 7) == 5); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_jmp_jge_k); ATF_TC_HEAD(bpfjit_jmp_jge_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_JMP+BPF_JGE+BPF_K"); } ATF_TC_BODY(bpfjit_jmp_jge_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, 8, 0, 1), BPF_STMT(BPF_RET+BPF_K, 0), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, 3, 2, 0), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, 9, 0, 0), BPF_STMT(BPF_RET+BPF_K, 1), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, 5, 1, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, 7, 2, 3), BPF_STMT(BPF_RET+BPF_K, 3), BPF_STMT(BPF_RET+BPF_K, 4), BPF_STMT(BPF_RET+BPF_K, 5), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, 6, 3, 1), BPF_STMT(BPF_RET+BPF_K, 6), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, 1, 0, 0), BPF_STMT(BPF_RET+BPF_K, 7), BPF_STMT(BPF_RET+BPF_K, 8) }; bpfjit_func_t code; uint8_t pkt[8]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 1); ATF_CHECK(jitcall(code, pkt, 2, 2) == 1); ATF_CHECK(jitcall(code, pkt, 3, 3) == 7); ATF_CHECK(jitcall(code, pkt, 4, 4) == 7); ATF_CHECK(jitcall(code, pkt, 5, 5) == 7); ATF_CHECK(jitcall(code, pkt, 6, 6) == 8); ATF_CHECK(jitcall(code, pkt, 7, 7) == 5); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_jmp_jeq_k); ATF_TC_HEAD(bpfjit_jmp_jeq_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_JMP+BPF_JEQ+BPF_K"); } ATF_TC_BODY(bpfjit_jmp_jeq_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 8, 0, 1), BPF_STMT(BPF_RET+BPF_K, 0), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 3, 1, 0), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 9, 1, 1), BPF_STMT(BPF_RET+BPF_K, 1), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 5, 1, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 7, 2, 3), BPF_STMT(BPF_RET+BPF_K, 3), BPF_STMT(BPF_RET+BPF_K, 4), BPF_STMT(BPF_RET+BPF_K, 5), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 6, 3, 1), BPF_STMT(BPF_RET+BPF_K, 6), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 1, 0, 0), BPF_STMT(BPF_RET+BPF_K, 7), BPF_STMT(BPF_RET+BPF_K, 8) }; bpfjit_func_t code; uint8_t pkt[8]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 7); ATF_CHECK(jitcall(code, pkt, 2, 2) == 7); ATF_CHECK(jitcall(code, pkt, 3, 3) == 1); ATF_CHECK(jitcall(code, pkt, 4, 4) == 7); ATF_CHECK(jitcall(code, pkt, 5, 5) == 7); ATF_CHECK(jitcall(code, pkt, 6, 6) == 8); ATF_CHECK(jitcall(code, pkt, 7, 7) == 5); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_jmp_jset_k); ATF_TC_HEAD(bpfjit_jmp_jset_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_JMP+BPF_JSET+BPF_K"); } ATF_TC_BODY(bpfjit_jmp_jset_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, 8, 0, 1), BPF_STMT(BPF_RET+BPF_K, 0), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, 4, 2, 0), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, 3, 0, 0), BPF_STMT(BPF_RET+BPF_K, 1), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, 2, 1, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, 1, 2, 3), BPF_STMT(BPF_RET+BPF_K, 3), BPF_STMT(BPF_RET+BPF_K, 4), BPF_STMT(BPF_RET+BPF_K, 5), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, 2, 3, 1), BPF_STMT(BPF_RET+BPF_K, 6), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, 7, 0, 0), BPF_STMT(BPF_RET+BPF_K, 7), BPF_STMT(BPF_RET+BPF_K, 8) }; bpfjit_func_t code; uint8_t pkt[8]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 1); ATF_CHECK(jitcall(code, pkt, 2, 2) == 1); ATF_CHECK(jitcall(code, pkt, 3, 3) == 1); ATF_CHECK(jitcall(code, pkt, 4, 4) == 7); ATF_CHECK(jitcall(code, pkt, 5, 5) == 5); ATF_CHECK(jitcall(code, pkt, 6, 6) == 8); ATF_CHECK(jitcall(code, pkt, 7, 7) == 5); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_jmp_modulo_k); ATF_TC_HEAD(bpfjit_jmp_modulo_k, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of modulo logic of BPF_JMP+BPF_K operations"); } ATF_TC_BODY(bpfjit_jmp_modulo_k, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0x7fffff77)), BPF_STMT(BPF_ALU+BPF_LSH+BPF_K, 4), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, UINT32_C(0xfffff770), 1, 0), BPF_STMT(BPF_RET+BPF_K, 0), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, UINT32_C(0xfffff770), 0, 1), BPF_STMT(BPF_RET+BPF_K, 1), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, UINT32_C(0xfffff771), 0, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, UINT32_C(0xfffff770), 0, 3), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, UINT32_C(0xfffff770), 2, 0), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, UINT32_C(0xfffff771), 1, 0), BPF_STMT(BPF_JMP+BPF_JA, 1), BPF_STMT(BPF_RET+BPF_K, 3), /* FFFFF770+FFFFF770 = 00000001,FFFFEEE0 */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, UINT32_C(0xfffff770)), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, UINT32_C(0xffffeee0), 1, 0), BPF_STMT(BPF_RET+BPF_K, 4), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, UINT32_C(0xffffeee0), 0, 1), BPF_STMT(BPF_RET+BPF_K, 5), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, UINT32_C(0xffffeee1), 0, 1), BPF_STMT(BPF_RET+BPF_K, 6), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, UINT32_C(0xffffeee0), 0, 3), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, UINT32_C(0xffffeee0), 2, 0), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, UINT32_C(0xffffeee1), 1, 0), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 7) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == UINT32_MAX); } ATF_TC(bpfjit_jmp_jgt_x); ATF_TC_HEAD(bpfjit_jmp_jgt_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_JMP+BPF_JGT+BPF_X"); } ATF_TC_BODY(bpfjit_jmp_jgt_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 7), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 2), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_X, 0, 3, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 9), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_X, 0, 0, 0), BPF_STMT(BPF_RET+BPF_K, 1), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 4), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_X, 0, 1, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 6), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_X, 0, 2, 3), BPF_STMT(BPF_RET+BPF_K, 3), BPF_STMT(BPF_RET+BPF_K, 4), BPF_STMT(BPF_RET+BPF_K, 5), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 5), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_X, 0, 4, 1), BPF_STMT(BPF_RET+BPF_K, 6), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_X, 0, 0, 0), BPF_STMT(BPF_RET+BPF_K, 7), BPF_STMT(BPF_RET+BPF_K, 8) }; bpfjit_func_t code; uint8_t pkt[8]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 1); ATF_CHECK(jitcall(code, pkt, 2, 2) == 1); ATF_CHECK(jitcall(code, pkt, 3, 3) == 7); ATF_CHECK(jitcall(code, pkt, 4, 4) == 7); ATF_CHECK(jitcall(code, pkt, 5, 5) == 7); ATF_CHECK(jitcall(code, pkt, 6, 6) == 8); ATF_CHECK(jitcall(code, pkt, 7, 7) == 5); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_jmp_jge_x); ATF_TC_HEAD(bpfjit_jmp_jge_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_JMP+BPF_JGE+BPF_X"); } ATF_TC_BODY(bpfjit_jmp_jge_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 8), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 3), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_X, 0, 3, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 9), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_X, 0, 0, 0), BPF_STMT(BPF_RET+BPF_K, 1), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 5), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_X, 0, 1, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 7), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_X, 0, 2, 3), BPF_STMT(BPF_RET+BPF_K, 3), BPF_STMT(BPF_RET+BPF_K, 4), BPF_STMT(BPF_RET+BPF_K, 5), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 6), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_X, 0, 4, 1), BPF_STMT(BPF_RET+BPF_K, 6), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_X, 0, 0, 0), BPF_STMT(BPF_RET+BPF_K, 7), BPF_STMT(BPF_RET+BPF_K, 8) }; bpfjit_func_t code; uint8_t pkt[8]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 1); ATF_CHECK(jitcall(code, pkt, 2, 2) == 1); ATF_CHECK(jitcall(code, pkt, 3, 3) == 7); ATF_CHECK(jitcall(code, pkt, 4, 4) == 7); ATF_CHECK(jitcall(code, pkt, 5, 5) == 7); ATF_CHECK(jitcall(code, pkt, 6, 6) == 8); ATF_CHECK(jitcall(code, pkt, 7, 7) == 5); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_jmp_jeq_x); ATF_TC_HEAD(bpfjit_jmp_jeq_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_JMP+BPF_JEQ+BPF_X"); } ATF_TC_BODY(bpfjit_jmp_jeq_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 8), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 1), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 3), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 2, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 9), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 5), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 3), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 7), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 2, 3), BPF_STMT(BPF_RET+BPF_K, 4), BPF_STMT(BPF_RET+BPF_K, 5), BPF_STMT(BPF_RET+BPF_K, 6), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 6), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 3, 1), BPF_STMT(BPF_RET+BPF_K, 7), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 0), BPF_STMT(BPF_RET+BPF_K, 8), BPF_STMT(BPF_RET+BPF_K, 9) }; bpfjit_func_t code; uint8_t pkt[8]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 8); ATF_CHECK(jitcall(code, pkt, 2, 2) == 8); ATF_CHECK(jitcall(code, pkt, 3, 3) == 2); ATF_CHECK(jitcall(code, pkt, 4, 4) == 8); ATF_CHECK(jitcall(code, pkt, 5, 5) == 3); ATF_CHECK(jitcall(code, pkt, 6, 6) == 9); ATF_CHECK(jitcall(code, pkt, 7, 7) == 6); ATF_CHECK(jitcall(code, pkt, 8, 8) == 1); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_jmp_jset_x); ATF_TC_HEAD(bpfjit_jmp_jset_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_JMP+BPF_JSET+BPF_X"); } ATF_TC_BODY(bpfjit_jmp_jset_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 8), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 4), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_X, 0, 2, 0), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_X, 3, 0, 0), BPF_STMT(BPF_RET+BPF_K, 1), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 2), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_X, 0, 1, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_X, 0, 2, 3), BPF_STMT(BPF_RET+BPF_K, 3), BPF_STMT(BPF_RET+BPF_K, 4), BPF_STMT(BPF_RET+BPF_K, 5), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 2), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_X, 0, 4, 1), BPF_STMT(BPF_RET+BPF_K, 6), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 7), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_X, 0, 0, 0), BPF_STMT(BPF_RET+BPF_K, 7), BPF_STMT(BPF_RET+BPF_K, 8) }; bpfjit_func_t code; uint8_t pkt[8]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 1); ATF_CHECK(jitcall(code, pkt, 2, 2) == 1); ATF_CHECK(jitcall(code, pkt, 3, 3) == 1); ATF_CHECK(jitcall(code, pkt, 4, 4) == 7); ATF_CHECK(jitcall(code, pkt, 5, 5) == 5); ATF_CHECK(jitcall(code, pkt, 6, 6) == 8); ATF_CHECK(jitcall(code, pkt, 7, 7) == 5); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_jmp_jeq_x_noinit_ax); ATF_TC_HEAD(bpfjit_jmp_jeq_x_noinit_ax, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation " "of BPF_JMP+BPF_EQ+BPF_X with uninitialised A and X"); } ATF_TC_BODY(bpfjit_jmp_jeq_x_noinit_ax, tc) { static struct bpf_insn insns[] = { BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 10), BPF_STMT(BPF_RET+BPF_K, 11) }; bpfjit_func_t code; uint8_t pkt[8]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 10); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_jmp_jeq_x_noinit_a); ATF_TC_HEAD(bpfjit_jmp_jeq_x_noinit_a, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation " "of BPF_JMP+BPF_EQ+BPF_X with uninitialised A"); } ATF_TC_BODY(bpfjit_jmp_jeq_x_noinit_a, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_LEN, 0), /* X > 0 */ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 10), BPF_STMT(BPF_RET+BPF_K, 11) }; bpfjit_func_t code; uint8_t pkt[8]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 11); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_jmp_jeq_x_noinit_x); ATF_TC_HEAD(bpfjit_jmp_jeq_x_noinit_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation " "of BPF_JMP+BPF_EQ+BPF_X with uninitialised X"); } ATF_TC_BODY(bpfjit_jmp_jeq_x_noinit_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_LEN, 0), /* A > 0 */ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 10), BPF_STMT(BPF_RET+BPF_K, 11) }; bpfjit_func_t code; uint8_t pkt[8]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 11); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_jmp_modulo_x); ATF_TC_HEAD(bpfjit_jmp_modulo_x, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of modulo logic of BPF_JMP+BPF_X operations"); } ATF_TC_BODY(bpfjit_jmp_modulo_x, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_C(0x7fffff77)), /* FFFFF770 << 4 = FFFFF770 */ BPF_STMT(BPF_ALU+BPF_LSH+BPF_K, 4), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(0xfffff770)), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 0), BPF_STMT(BPF_RET+BPF_K, 0), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 1), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(0xfffff771)), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 2), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(0xfffff770)), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 4), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_X, 0, 3, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(0xfffff771)), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_X, 0, 1, 0), BPF_STMT(BPF_JMP+BPF_JA, 1), BPF_STMT(BPF_RET+BPF_K, 3), /* FFFFF770+FFFFF770 = 00000001,FFFFEEE0 */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, UINT32_C(0xfffff770)), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(0xffffeee0)), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 0), BPF_STMT(BPF_RET+BPF_K, 4), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 5), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(0xffffeee1)), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_X, 0, 0, 1), BPF_STMT(BPF_RET+BPF_K, 6), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(0xffffeee0)), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 4), BPF_JUMP(BPF_JMP+BPF_JGT+BPF_X, 0, 3, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_C(0xffffeee1)), BPF_JUMP(BPF_JMP+BPF_JGE+BPF_X, 0, 1, 0), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 7) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == UINT32_MAX); } ATF_TC(bpfjit_ld_abs); ATF_TC_HEAD(bpfjit_ld_abs, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LD+BPF_ABS"); } ATF_TC_BODY(bpfjit_ld_abs, tc) { static struct bpf_insn insns[3][2] = { { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 5), BPF_STMT(BPF_RET+BPF_A, 0) }, { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 5), BPF_STMT(BPF_RET+BPF_A, 0) }, { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 5), BPF_STMT(BPF_RET+BPF_A, 0) } }; static size_t lengths[3] = { 1, 2, 4 }; static unsigned int expected[3] = { 0xde, 0xdead, 0xdeadbeef }; size_t i, l; uint8_t *pkt = deadbeef_at_5; size_t pktsize = sizeof(deadbeef_at_5); size_t insn_count = sizeof(insns[0]) / sizeof(insns[0][0]); RZ(rump_init()); for (i = 0; i < 3; i++) { bpfjit_func_t code; ATF_CHECK(prog_validate(insns[i], insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns[i], insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (l = 1; l < 5 + lengths[i]; l++) { ATF_CHECK(jitcall(code, pkt, l, l) == 0); ATF_CHECK(jitcall(code, pkt, pktsize, l) == 0); } l = 5 + lengths[i]; ATF_CHECK(jitcall(code, pkt, l, l) == expected[i]); ATF_CHECK(jitcall(code, pkt, pktsize, l) == expected[i]); l = pktsize; ATF_CHECK(jitcall(code, pkt, l, l) == expected[i]); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } } ATF_TC(bpfjit_ld_abs_k_overflow); ATF_TC_HEAD(bpfjit_ld_abs_k_overflow, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LD+BPF_ABS with overflow in k+4"); } ATF_TC_BODY(bpfjit_ld_abs_k_overflow, tc) { static struct bpf_insn insns[12][3] = { { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, UINT32_MAX), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, UINT32_MAX - 1), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, UINT32_MAX), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, UINT32_MAX - 1), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, UINT32_MAX - 2), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, UINT32_MAX - 3), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_LD+BPF_H+BPF_ABS, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_LD+BPF_H+BPF_ABS, UINT32_MAX - 1), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, UINT32_MAX - 1), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, UINT32_MAX - 2), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, UINT32_MAX - 3), BPF_STMT(BPF_RET+BPF_K, 1) } }; int i; uint8_t pkt[8] = { 0 }; size_t insn_count = sizeof(insns[0]) / sizeof(insns[0][0]); RZ(rump_init()); for (i = 0; i < 3; i++) { ATF_CHECK(prog_validate(insns[i], insn_count)); ATF_CHECK(exec_prog(insns[i], insn_count, pkt, 8) == 0); } } ATF_TC(bpfjit_ld_ind); ATF_TC_HEAD(bpfjit_ld_ind, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LD+BPF_IND"); } ATF_TC_BODY(bpfjit_ld_ind, tc) { static struct bpf_insn insns[6][3] = { { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 3), BPF_STMT(BPF_LD+BPF_B+BPF_IND, 2), BPF_STMT(BPF_RET+BPF_A, 0) }, { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 3), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 2), BPF_STMT(BPF_RET+BPF_A, 0) }, { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 3), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 2), BPF_STMT(BPF_RET+BPF_A, 0) }, { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 5), BPF_STMT(BPF_LD+BPF_B+BPF_IND, 0), BPF_STMT(BPF_RET+BPF_A, 0) }, { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 5), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 0), BPF_STMT(BPF_RET+BPF_A, 0) }, { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 5), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 0), BPF_STMT(BPF_RET+BPF_A, 0) } }; static size_t lengths[6] = { 1, 2, 4, 1, 2, 4 }; static unsigned int expected[6] = { 0xde, 0xdead, 0xdeadbeef, 0xde, 0xdead, 0xdeadbeef }; size_t i, l; uint8_t *pkt = deadbeef_at_5; size_t pktsize = sizeof(deadbeef_at_5); size_t insn_count = sizeof(insns[0]) / sizeof(insns[0][0]); RZ(rump_init()); for (i = 0; i < 3; i++) { bpfjit_func_t code; ATF_CHECK(prog_validate(insns[i], insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns[i], insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (l = 1; l < 5 + lengths[i]; l++) { ATF_CHECK(jitcall(code, pkt, l, l) == 0); ATF_CHECK(jitcall(code, pkt, pktsize, l) == 0); } l = 5 + lengths[i]; ATF_CHECK(jitcall(code, pkt, l, l) == expected[i]); ATF_CHECK(jitcall(code, pkt, pktsize, l) == expected[i]); l = pktsize; ATF_CHECK(jitcall(code, pkt, l, l) == expected[i]); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } } ATF_TC(bpfjit_ld_ind_k_overflow); ATF_TC_HEAD(bpfjit_ld_ind_k_overflow, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LD+BPF_IND with overflow in k+4"); } ATF_TC_BODY(bpfjit_ld_ind_k_overflow, tc) { static struct bpf_insn insns[12][3] = { { BPF_STMT(BPF_LD+BPF_H+BPF_IND, UINT32_MAX), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_H+BPF_IND, UINT32_MAX - 1), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_W+BPF_IND, UINT32_MAX), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_W+BPF_IND, UINT32_MAX - 1), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_W+BPF_IND, UINT32_MAX - 2), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_W+BPF_IND, UINT32_MAX - 3), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_LD+BPF_H+BPF_IND, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_LD+BPF_H+BPF_IND, UINT32_MAX - 1), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_LD+BPF_W+BPF_IND, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_LD+BPF_W+BPF_IND, UINT32_MAX - 1), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_LD+BPF_W+BPF_IND, UINT32_MAX - 2), BPF_STMT(BPF_RET+BPF_K, 1) }, { BPF_STMT(BPF_LD+BPF_H+BPF_IND, 7), BPF_STMT(BPF_LD+BPF_W+BPF_IND, UINT32_MAX - 3), BPF_STMT(BPF_RET+BPF_K, 1) } }; int i; uint8_t pkt[8] = { 0 }; size_t insn_count = sizeof(insns[0]) / sizeof(insns[0][0]); RZ(rump_init()); for (i = 0; i < 3; i++) { ATF_CHECK(prog_validate(insns[i], insn_count)); ATF_CHECK(exec_prog(insns[i], insn_count, pkt, 8) == 0); } } ATF_TC(bpfjit_ld_ind_x_overflow1); ATF_TC_HEAD(bpfjit_ld_ind_x_overflow1, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LD+BPF_IND with overflow in X+4"); } ATF_TC_BODY(bpfjit_ld_ind_x_overflow1, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_LEN, 0), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, UINT32_C(0xffffffff)), BPF_STMT(BPF_MISC+BPF_TAX, 0), BPF_STMT(BPF_LD+BPF_B+BPF_IND, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; size_t i; bpfjit_func_t code; uint8_t pkt[8] = { 10, 20, 30, 40, 50, 60, 70, 80 }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 1; i <= sizeof(pkt); i++) { //ATF_CHECK(bpf_filter(insns, pkt, i, i) == 10 * i); ATF_CHECK(jitcall(code, pkt, i, i) == 10 * i); } rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_ld_ind_x_overflow2); ATF_TC_HEAD(bpfjit_ld_ind_x_overflow2, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LD+BPF_IND with overflow in X+4"); } ATF_TC_BODY(bpfjit_ld_ind_x_overflow2, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_LEN, 0), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, UINT32_C(0xffffffff)), BPF_STMT(BPF_ST, 3), BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 3), BPF_STMT(BPF_LD+BPF_B+BPF_IND, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; size_t i; bpfjit_func_t code; uint8_t pkt[8] = { 10, 20, 30, 40, 50, 60, 70, 80 }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 1; i <= sizeof(pkt); i++) { //ATF_CHECK(bpf_filter(insns, pkt, i, i) == 10 * i); ATF_CHECK(jitcall(code, pkt, i, i) == 10 * i); } rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_ld_len); ATF_TC_HEAD(bpfjit_ld_len, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LD+BPF_W+BPF_LEN"); } ATF_TC_BODY(bpfjit_ld_len, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; size_t i; bpfjit_func_t code; uint8_t pkt[32]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 0; i < sizeof(pkt); i++) ATF_CHECK(jitcall(code, pkt, i, 1) == i); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_ld_imm); ATF_TC_HEAD(bpfjit_ld_imm, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LD+BPF_IMM"); } ATF_TC_BODY(bpfjit_ld_imm, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, UINT32_MAX), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == UINT32_MAX); } ATF_TC(bpfjit_ldx_imm1); ATF_TC_HEAD(bpfjit_ldx_imm1, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LDX+BPF_IMM"); } ATF_TC_BODY(bpfjit_ldx_imm1, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_MAX - 5), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == UINT32_MAX - 5); } ATF_TC(bpfjit_ldx_imm2); ATF_TC_HEAD(bpfjit_ldx_imm2, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LDX+BPF_IMM"); } ATF_TC_BODY(bpfjit_ldx_imm2, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 5), BPF_STMT(BPF_LD+BPF_IMM, 5), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 0), BPF_STMT(BPF_RET+BPF_K, 7), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == UINT32_MAX); } ATF_TC(bpfjit_ldx_len1); ATF_TC_HEAD(bpfjit_ldx_len1, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LDX+BPF_LEN"); } ATF_TC_BODY(bpfjit_ldx_len1, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; size_t i; bpfjit_func_t code; uint8_t pkt[5]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 1; i < sizeof(pkt); i++) { ATF_CHECK(jitcall(code, pkt, i, 1) == i); ATF_CHECK(jitcall(code, pkt, i + 1, i) == i + 1); } rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_ldx_len2); ATF_TC_HEAD(bpfjit_ldx_len2, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LDX+BPF_LEN"); } ATF_TC_BODY(bpfjit_ldx_len2, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_LD+BPF_IMM, 5), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 0), BPF_STMT(BPF_RET+BPF_K, 7), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX) }; bpfjit_func_t code; uint8_t pkt[5]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 5, 1) == UINT32_MAX); ATF_CHECK(jitcall(code, pkt, 6, 5) == 7); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_ldx_msh); ATF_TC_HEAD(bpfjit_ldx_msh, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_LDX+BPF_MSH"); } ATF_TC_BODY(bpfjit_ldx_msh, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[2] = { 0, 0x7a }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 2) == 40); } ATF_TC(bpfjit_misc_tax); ATF_TC_HEAD(bpfjit_misc_tax, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_MISC+BPF_TAX"); } ATF_TC_BODY(bpfjit_misc_tax, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 3), BPF_STMT(BPF_MISC+BPF_TAX, 0), BPF_STMT(BPF_LD+BPF_B+BPF_IND, 2), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[6] = { 0, 11, 22, 33, 44, 55 }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 6) == 55); } ATF_TC(bpfjit_misc_txa); ATF_TC_HEAD(bpfjit_misc_txa, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_MISC+BPF_TXA"); } ATF_TC_BODY(bpfjit_misc_txa, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 391), BPF_STMT(BPF_MISC+BPF_TXA, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 391); } ATF_TC(bpfjit_st1); ATF_TC_HEAD(bpfjit_st1, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ST"); } ATF_TC_BODY(bpfjit_st1, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_ST, 0), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_LD+BPF_MEM, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; size_t i; bpfjit_func_t code; uint8_t pkt[16]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 1; i <= sizeof(pkt); i++) ATF_CHECK(jitcall(code, pkt, i, sizeof(pkt)) == i); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_st2); ATF_TC_HEAD(bpfjit_st2, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ST"); } ATF_TC_BODY(bpfjit_st2, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_ST, 0), BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_ST, BPF_MEMWORDS-1), BPF_STMT(BPF_LD+BPF_MEM, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0); } ATF_TC(bpfjit_st3); ATF_TC_HEAD(bpfjit_st3, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ST"); } ATF_TC_BODY(bpfjit_st3, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_ST, 0), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 100), BPF_STMT(BPF_ST, BPF_MEMWORDS-1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 200), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 301, 2, 0), BPF_STMT(BPF_LD+BPF_MEM, BPF_MEMWORDS-1), BPF_STMT(BPF_RET+BPF_A, 0), BPF_STMT(BPF_LD+BPF_MEM, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[2]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); ATF_REQUIRE(BPF_MEMWORDS > 1); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 1); ATF_CHECK(jitcall(code, pkt, 2, 2) == 102); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_st4); ATF_TC_HEAD(bpfjit_st4, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ST"); } ATF_TC_BODY(bpfjit_st4, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_ST, 5), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 100), BPF_STMT(BPF_ST, BPF_MEMWORDS-1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 200), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 301, 2, 0), BPF_STMT(BPF_LD+BPF_MEM, BPF_MEMWORDS-1), BPF_STMT(BPF_RET+BPF_A, 0), BPF_STMT(BPF_LD+BPF_MEM, 5), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[2]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); ATF_REQUIRE(BPF_MEMWORDS > 6); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 1); ATF_CHECK(jitcall(code, pkt, 2, 2) == 102); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_st5); ATF_TC_HEAD(bpfjit_st5, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_ST"); } ATF_TC_BODY(bpfjit_st5, tc) { struct bpf_insn insns[5*BPF_MEMWORDS+2]; size_t insn_count = sizeof(insns) / sizeof(insns[0]); size_t k; bpfjit_func_t code; uint8_t pkt[BPF_MEMWORDS]; /* the program doesn't read any data */ memset(insns, 0, sizeof(insns)); /* for each k do M[k] = k */ for (k = 0; k < BPF_MEMWORDS; k++) { insns[2*k].code = BPF_LD+BPF_IMM; insns[2*k].k = 3*k; insns[2*k+1].code = BPF_ST; insns[2*k+1].k = k; } /* load wirelen into A */ insns[2*BPF_MEMWORDS].code = BPF_LD+BPF_W+BPF_LEN; /* for each k, if (A == k + 1) return M[k] */ for (k = 0; k < BPF_MEMWORDS; k++) { insns[2*BPF_MEMWORDS+3*k+1].code = BPF_JMP+BPF_JEQ+BPF_K; insns[2*BPF_MEMWORDS+3*k+1].k = k+1; insns[2*BPF_MEMWORDS+3*k+1].jt = 0; insns[2*BPF_MEMWORDS+3*k+1].jf = 2; insns[2*BPF_MEMWORDS+3*k+2].code = BPF_LD+BPF_MEM; insns[2*BPF_MEMWORDS+3*k+2].k = k; insns[2*BPF_MEMWORDS+3*k+3].code = BPF_RET+BPF_A; insns[2*BPF_MEMWORDS+3*k+3].k = 0; } insns[5*BPF_MEMWORDS+1].code = BPF_RET+BPF_K; insns[5*BPF_MEMWORDS+1].k = UINT32_MAX; RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (k = 1; k <= sizeof(pkt); k++) ATF_CHECK(jitcall(code, pkt, k, k) == 3*(k-1)); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_stx1); ATF_TC_HEAD(bpfjit_stx1, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_STX"); } ATF_TC_BODY(bpfjit_stx1, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_STX, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; size_t i; bpfjit_func_t code; uint8_t pkt[16]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 1; i <= sizeof(pkt); i++) ATF_CHECK(jitcall(code, pkt, i, sizeof(pkt)) == i); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_stx2); ATF_TC_HEAD(bpfjit_stx2, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_STX"); } ATF_TC_BODY(bpfjit_stx2, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_ST, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_STX, BPF_MEMWORDS-1), BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), BPF_STMT(BPF_MISC+BPF_TXA, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == 0); } ATF_TC(bpfjit_stx3); ATF_TC_HEAD(bpfjit_stx3, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_STX"); } ATF_TC_BODY(bpfjit_stx3, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_STX, 6), BPF_STMT(BPF_ST, 1), BPF_STMT(BPF_LDX+BPF_W+BPF_LEN, 0), BPF_STMT(BPF_STX, 5), BPF_STMT(BPF_STX, 2), BPF_STMT(BPF_STX, 3), BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 2), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 3), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 5), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 6), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; size_t i; bpfjit_func_t code; uint8_t pkt[16]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 1; i <= sizeof(pkt); i++) ATF_CHECK(jitcall(code, pkt, i, sizeof(pkt)) == 3 * i); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_stx4); ATF_TC_HEAD(bpfjit_stx4, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation of BPF_STX"); } ATF_TC_BODY(bpfjit_stx4, tc) { struct bpf_insn insns[5*BPF_MEMWORDS+2]; size_t insn_count = sizeof(insns) / sizeof(insns[0]); size_t k; bpfjit_func_t code; uint8_t pkt[BPF_MEMWORDS]; /* the program doesn't read any data */ memset(insns, 0, sizeof(insns)); /* for each k do M[k] = k */ for (k = 0; k < BPF_MEMWORDS; k++) { insns[2*k].code = BPF_LDX+BPF_W+BPF_IMM; insns[2*k].k = 3*k; insns[2*k+1].code = BPF_STX; insns[2*k+1].k = k; } /* load wirelen into A */ insns[2*BPF_MEMWORDS].code = BPF_LD+BPF_W+BPF_LEN; /* for each k, if (A == k + 1) return M[k] */ for (k = 0; k < BPF_MEMWORDS; k++) { insns[2*BPF_MEMWORDS+3*k+1].code = BPF_JMP+BPF_JEQ+BPF_K; insns[2*BPF_MEMWORDS+3*k+1].k = k+1; insns[2*BPF_MEMWORDS+3*k+1].jt = 0; insns[2*BPF_MEMWORDS+3*k+1].jf = 2; insns[2*BPF_MEMWORDS+3*k+2].code = BPF_LD+BPF_MEM; insns[2*BPF_MEMWORDS+3*k+2].k = k; insns[2*BPF_MEMWORDS+3*k+3].code = BPF_RET+BPF_A; insns[2*BPF_MEMWORDS+3*k+3].k = 0; } insns[5*BPF_MEMWORDS+1].code = BPF_RET+BPF_K; insns[5*BPF_MEMWORDS+1].k = UINT32_MAX; RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (k = 1; k <= sizeof(pkt); k++) ATF_CHECK(jitcall(code, pkt, k, k) == 3*(k-1)); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_opt_ld_abs_1); ATF_TC_HEAD(bpfjit_opt_ld_abs_1, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation with length optimization " "applied to BPF_LD+BPF_ABS"); } ATF_TC_BODY(bpfjit_opt_ld_abs_1, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x800, 0, 8), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 26), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 2), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 30), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 3, 4), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 0, 3), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 30), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 1), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 0), }; size_t i, j; bpfjit_func_t code; uint8_t pkt[2][34] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x0f, 0x80, 0x03, 0x70, 0x23 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x23, 0x80, 0x03, 0x70, 0x0f } }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 0; i < 2; i++) { for (j = 1; j < sizeof(pkt[i]); j++) ATF_CHECK(jitcall(code, pkt[i], j, j) == 0); ATF_CHECK(jitcall(code, pkt[i], j, j) == UINT32_MAX); } rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_opt_ld_abs_2); ATF_TC_HEAD(bpfjit_opt_ld_abs_2, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation with length optimization " "applied to BPF_LD+BPF_ABS"); } ATF_TC_BODY(bpfjit_opt_ld_abs_2, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 26), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 2), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 30), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 3, 6), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 0, 5), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 30), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 3), BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x800, 0, 1), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 0), }; size_t i, j; bpfjit_func_t code; uint8_t pkt[2][34] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x0f, 0x80, 0x03, 0x70, 0x23 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x23, 0x80, 0x03, 0x70, 0x0f } }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 0; i < 2; i++) { for (j = 1; j < sizeof(pkt[i]); j++) ATF_CHECK(jitcall(code, pkt[i], j, j) == 0); ATF_CHECK(jitcall(code, pkt[i], j, j) == UINT32_MAX); } rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_opt_ld_abs_3); ATF_TC_HEAD(bpfjit_opt_ld_abs_3, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation with length optimization " "applied to BPF_LD+BPF_ABS"); } ATF_TC_BODY(bpfjit_opt_ld_abs_3, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 30), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 0, 2), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 26), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 3, 6), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 5), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 26), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 0, 3), BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x800, 0, 1), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 0), }; size_t i, j; bpfjit_func_t code; uint8_t pkt[2][34] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x0f, 0x80, 0x03, 0x70, 0x23 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x23, 0x80, 0x03, 0x70, 0x0f } }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 0; i < 2; i++) { for (j = 1; j < sizeof(pkt[i]); j++) ATF_CHECK(jitcall(code, pkt[i], j, j) == 0); ATF_CHECK(jitcall(code, pkt[i], j, j) == UINT32_MAX); } rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_opt_ld_ind_1); ATF_TC_HEAD(bpfjit_opt_ld_ind_1, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation with length optimization " "applied to BPF_LD+BPF_IND"); } ATF_TC_BODY(bpfjit_opt_ld_ind_1, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 12), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 0), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x800, 0, 8), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 14), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 2), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 18), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 3, 4), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 0, 3), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 18), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 1), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 0), }; size_t i, j; bpfjit_func_t code; uint8_t pkt[2][34] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x0f, 0x80, 0x03, 0x70, 0x23 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x23, 0x80, 0x03, 0x70, 0x0f } }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 0; i < 2; i++) { for (j = 1; j < sizeof(pkt[i]); j++) ATF_CHECK(jitcall(code, pkt[i], j, j) == 0); ATF_CHECK(jitcall(code, pkt[i], j, j) == UINT32_MAX); } rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_opt_ld_ind_2); ATF_TC_HEAD(bpfjit_opt_ld_ind_2, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation with length optimization " "applied to BPF_LD+BPF_IND"); } ATF_TC_BODY(bpfjit_opt_ld_ind_2, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 26), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 2), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 30), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 3, 6), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 0, 5), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 30), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 3), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 12), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x800, 0, 1), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 0), }; size_t i, j; bpfjit_func_t code; uint8_t pkt[2][34] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x0f, 0x80, 0x03, 0x70, 0x23 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x23, 0x80, 0x03, 0x70, 0x0f } }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 0; i < 2; i++) { for (j = 1; j < sizeof(pkt[i]); j++) ATF_CHECK(jitcall(code, pkt[i], j, j) == 0); ATF_CHECK(jitcall(code, pkt[i], j, j) == UINT32_MAX); } rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_opt_ld_ind_3); ATF_TC_HEAD(bpfjit_opt_ld_ind_3, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation with length optimization " "applied to BPF_LD+BPF_IND"); } ATF_TC_BODY(bpfjit_opt_ld_ind_3, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 15), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 15), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 0, 2), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 11), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 3, 7), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 6), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 11), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 0, 4), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 12), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x800, 0, 1), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 0), }; size_t i, j; bpfjit_func_t code; uint8_t pkt[2][34] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x0f, 0x80, 0x03, 0x70, 0x23 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x23, 0x80, 0x03, 0x70, 0x0f } }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 0; i < 2; i++) { for (j = 1; j < sizeof(pkt[i]); j++) ATF_CHECK(jitcall(code, pkt[i], j, j) == 0); ATF_CHECK(jitcall(code, pkt[i], j, j) == UINT32_MAX); } rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_opt_ld_ind_4); ATF_TC_HEAD(bpfjit_opt_ld_ind_4, tc) { atf_tc_set_md_var(tc, "descr", "Test JIT compilation with length optimization " "applied to BPF_LD+BPF_IND"); } ATF_TC_BODY(bpfjit_opt_ld_ind_4, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 11), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 19), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 0, 2), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 15), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 3, 7), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 6), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 15), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 0, 4), BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 12), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x800, 0, 1), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 0), }; size_t i, j; bpfjit_func_t code; uint8_t pkt[2][34] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x0f, 0x80, 0x03, 0x70, 0x23 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0x80, 0x03, 0x70, 0x23, 0x80, 0x03, 0x70, 0x0f } }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); for (i = 0; i < 2; i++) { for (j = 1; j < sizeof(pkt[i]); j++) ATF_CHECK(jitcall(code, pkt[i], j, j) == 0); ATF_CHECK(jitcall(code, pkt[i], j, j) == UINT32_MAX); } rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_abc_ja); ATF_TC_HEAD(bpfjit_abc_ja, tc) { atf_tc_set_md_var(tc, "descr", "Test ABC optimization with a single BPF_JMP+BPF_JA"); } ATF_TC_BODY(bpfjit_abc_ja, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 3), /* min. length 4 */ BPF_STMT(BPF_JMP+BPF_JA, 2), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, UINT32_MAX - 1), BPF_STMT(BPF_RET+BPF_K, 0), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 2), /* min. length 6 */ BPF_STMT(BPF_RET+BPF_A, 0), BPF_STMT(BPF_RET+BPF_K, 1), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 6), BPF_STMT(BPF_RET+BPF_K, 2), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 7), BPF_STMT(BPF_RET+BPF_K, 3), }; bpfjit_func_t code; uint8_t pkt[6] = {0, 0, /* UINT32_MAX: */ 255, 255, 255, 255}; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(jitcall(code, pkt, 1, 1) == 0); ATF_CHECK(jitcall(code, pkt, 2, 2) == 0); ATF_CHECK(jitcall(code, pkt, 3, 3) == 0); ATF_CHECK(jitcall(code, pkt, 4, 4) == 0); ATF_CHECK(jitcall(code, pkt, 5, 5) == 0); ATF_CHECK(jitcall(code, pkt, 6, 6) == UINT32_MAX); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_abc_ja_over); ATF_TC_HEAD(bpfjit_abc_ja_over, tc) { atf_tc_set_md_var(tc, "descr", "Test ABC optimization when BPF_JMP+BPF_JA jumps over all loads"); } ATF_TC_BODY(bpfjit_abc_ja_over, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_JMP+BPF_JA, 2), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 3), BPF_STMT(BPF_RET+BPF_K, 0), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 4), BPF_STMT(BPF_RET+BPF_K, 1), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 5), BPF_STMT(BPF_RET+BPF_K, 2), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 6), BPF_STMT(BPF_RET+BPF_K, 3), }; uint8_t pkt[1]; /* the program doesn't read any data */ size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); ATF_CHECK(exec_prog(insns, insn_count, pkt, 1) == UINT32_MAX); } ATF_TC(bpfjit_abc_ld_chain); ATF_TC_HEAD(bpfjit_abc_ld_chain, tc) { atf_tc_set_md_var(tc, "descr", "Test ABC optimization of a chain of BPF_LD instructions " "with exits leading to a single BPF_RET"); } ATF_TC_BODY(bpfjit_abc_ld_chain, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 3), /* min. length 4 */ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 8, 0, 4), BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4), /* min. length 6 */ BPF_JUMP(BPF_JMP+BPF_JGE+BPF_K, 7, 0, 2), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 6), /* min. length 10 */ BPF_JUMP(BPF_JMP+BPF_JGT+BPF_K, 6, 0, 1), BPF_STMT(BPF_RET+BPF_K, 123456789), BPF_STMT(BPF_RET+BPF_K, 987654321), }; bpfjit_func_t code; uint8_t pkt[10] = {}; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); /* Packet is too short. */ ATF_CHECK(jitcall(code, pkt, 1, 1) == 0); ATF_CHECK(jitcall(code, pkt, 2, 2) == 0); ATF_CHECK(jitcall(code, pkt, 3, 3) == 0); /* !(pkt[3] == 8) => return 123456789 */ ATF_CHECK(jitcall(code, pkt, 4, 4) == 123456789); ATF_CHECK(jitcall(code, pkt, 5, 5) == 123456789); ATF_CHECK(jitcall(code, pkt, 6, 6) == 123456789); ATF_CHECK(jitcall(code, pkt, 7, 7) == 123456789); ATF_CHECK(jitcall(code, pkt, 8, 8) == 123456789); ATF_CHECK(jitcall(code, pkt, 9, 9) == 123456789); /* !(pkt[4:2] >= 7) => too short or return 123456789 */ pkt[3] = 8; ATF_CHECK(jitcall(code, pkt, 1, 1) == 0); ATF_CHECK(jitcall(code, pkt, 2, 2) == 0); ATF_CHECK(jitcall(code, pkt, 3, 3) == 0); ATF_CHECK(jitcall(code, pkt, 4, 4) == 0); ATF_CHECK(jitcall(code, pkt, 5, 5) == 0); ATF_CHECK(jitcall(code, pkt, 6, 6) == 123456789); ATF_CHECK(jitcall(code, pkt, 9, 9) == 123456789); /* !(pkt[6:4] > 6) => too short or return 987654321 */ pkt[4] = pkt[5] = 1; ATF_CHECK(jitcall(code, pkt, 1, 1) == 0); ATF_CHECK(jitcall(code, pkt, 2, 2) == 0); ATF_CHECK(jitcall(code, pkt, 3, 3) == 0); ATF_CHECK(jitcall(code, pkt, 4, 4) == 0); ATF_CHECK(jitcall(code, pkt, 5, 5) == 0); ATF_CHECK(jitcall(code, pkt, 6, 6) == 0); ATF_CHECK(jitcall(code, pkt, 7, 7) == 0); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); ATF_CHECK(jitcall(code, pkt, 9, 9) == 0); ATF_CHECK(jitcall(code, pkt, 10, 10) == 987654321); /* (pkt[6:4] > 6) => too short or return 123456789 */ pkt[6] = pkt[7] = pkt[8] = pkt[9] = 1; ATF_CHECK(jitcall(code, pkt, 1, 1) == 0); ATF_CHECK(jitcall(code, pkt, 2, 2) == 0); ATF_CHECK(jitcall(code, pkt, 3, 3) == 0); ATF_CHECK(jitcall(code, pkt, 4, 4) == 0); ATF_CHECK(jitcall(code, pkt, 5, 5) == 0); ATF_CHECK(jitcall(code, pkt, 6, 6) == 0); ATF_CHECK(jitcall(code, pkt, 7, 7) == 0); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); ATF_CHECK(jitcall(code, pkt, 9, 9) == 0); ATF_CHECK(jitcall(code, pkt, 10, 10) == 123456789); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_examples_1); ATF_TC_HEAD(bpfjit_examples_1, tc) { atf_tc_set_md_var(tc, "descr", "Test the first example from bpf(4) - " "accept Reverse ARP requests"); } ATF_TC_BODY(bpfjit_examples_1, tc) { /* * The following filter is taken from the Reverse ARP * Daemon. It accepts only Reverse ARP requests. */ struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8035, 0, 3), BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 20), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 3, 0, 1), BPF_STMT(BPF_RET+BPF_K, 42), BPF_STMT(BPF_RET+BPF_K, 0), }; bpfjit_func_t code; uint8_t pkt[22] = {}; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); /* Packet is too short. */ ATF_CHECK(jitcall(code, pkt, 1, 1) == 0); ATF_CHECK(jitcall(code, pkt, 2, 2) == 0); ATF_CHECK(jitcall(code, pkt, 3, 3) == 0); ATF_CHECK(jitcall(code, pkt, 4, 4) == 0); ATF_CHECK(jitcall(code, pkt, 5, 5) == 0); ATF_CHECK(jitcall(code, pkt, 6, 6) == 0); ATF_CHECK(jitcall(code, pkt, 7, 7) == 0); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); ATF_CHECK(jitcall(code, pkt, 9, 9) == 0); ATF_CHECK(jitcall(code, pkt, 10, 10) == 0); ATF_CHECK(jitcall(code, pkt, 11, 11) == 0); ATF_CHECK(jitcall(code, pkt, 12, 12) == 0); ATF_CHECK(jitcall(code, pkt, 13, 13) == 0); ATF_CHECK(jitcall(code, pkt, 14, 14) == 0); ATF_CHECK(jitcall(code, pkt, 15, 15) == 0); ATF_CHECK(jitcall(code, pkt, 16, 16) == 0); ATF_CHECK(jitcall(code, pkt, 17, 17) == 0); ATF_CHECK(jitcall(code, pkt, 18, 18) == 0); ATF_CHECK(jitcall(code, pkt, 19, 19) == 0); ATF_CHECK(jitcall(code, pkt, 20, 20) == 0); ATF_CHECK(jitcall(code, pkt, 21, 21) == 0); /* The packet doesn't match. */ ATF_CHECK(jitcall(code, pkt, 22, 22) == 0); /* Still no match after setting the protocol field. */ pkt[12] = 0x80; pkt[13] = 0x35; ATF_CHECK(jitcall(code, pkt, 22, 22) == 0); /* Set RARP message type. */ pkt[21] = 3; ATF_CHECK(jitcall(code, pkt, 22, 22) == 42); /* Packet is too short. */ ATF_CHECK(jitcall(code, pkt, 1, 1) == 0); ATF_CHECK(jitcall(code, pkt, 2, 2) == 0); ATF_CHECK(jitcall(code, pkt, 3, 3) == 0); ATF_CHECK(jitcall(code, pkt, 4, 4) == 0); ATF_CHECK(jitcall(code, pkt, 5, 5) == 0); ATF_CHECK(jitcall(code, pkt, 6, 6) == 0); ATF_CHECK(jitcall(code, pkt, 7, 7) == 0); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); ATF_CHECK(jitcall(code, pkt, 9, 9) == 0); ATF_CHECK(jitcall(code, pkt, 10, 10) == 0); ATF_CHECK(jitcall(code, pkt, 11, 11) == 0); ATF_CHECK(jitcall(code, pkt, 12, 12) == 0); ATF_CHECK(jitcall(code, pkt, 13, 13) == 0); ATF_CHECK(jitcall(code, pkt, 14, 14) == 0); ATF_CHECK(jitcall(code, pkt, 15, 15) == 0); ATF_CHECK(jitcall(code, pkt, 16, 16) == 0); ATF_CHECK(jitcall(code, pkt, 17, 17) == 0); ATF_CHECK(jitcall(code, pkt, 18, 18) == 0); ATF_CHECK(jitcall(code, pkt, 19, 19) == 0); ATF_CHECK(jitcall(code, pkt, 20, 20) == 0); ATF_CHECK(jitcall(code, pkt, 21, 21) == 0); /* Change RARP message type. */ pkt[20] = 3; ATF_CHECK(jitcall(code, pkt, 22, 22) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_examples_2); ATF_TC_HEAD(bpfjit_examples_2, tc) { atf_tc_set_md_var(tc, "descr", "Test the second example from bpf(4) - " "accept IP packets between two specified hosts"); } ATF_TC_BODY(bpfjit_examples_2, tc) { /* * This filter accepts only IP packets between host 128.3.112.15 * and 128.3.112.35. */ static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x0800, 0, 8), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 26), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 2), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 30), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 3, 4), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x80037023, 0, 3), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 30), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x8003700f, 0, 1), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 0), }; bpfjit_func_t code; uint8_t pkt[34] = {}; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); /* Packet is too short. */ ATF_CHECK(jitcall(code, pkt, 1, 1) == 0); ATF_CHECK(jitcall(code, pkt, 2, 2) == 0); ATF_CHECK(jitcall(code, pkt, 3, 3) == 0); ATF_CHECK(jitcall(code, pkt, 4, 4) == 0); ATF_CHECK(jitcall(code, pkt, 5, 5) == 0); ATF_CHECK(jitcall(code, pkt, 6, 6) == 0); ATF_CHECK(jitcall(code, pkt, 7, 7) == 0); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); ATF_CHECK(jitcall(code, pkt, 9, 9) == 0); ATF_CHECK(jitcall(code, pkt, 10, 10) == 0); ATF_CHECK(jitcall(code, pkt, 11, 11) == 0); ATF_CHECK(jitcall(code, pkt, 12, 12) == 0); ATF_CHECK(jitcall(code, pkt, 13, 13) == 0); ATF_CHECK(jitcall(code, pkt, 14, 14) == 0); ATF_CHECK(jitcall(code, pkt, 15, 15) == 0); ATF_CHECK(jitcall(code, pkt, 16, 16) == 0); ATF_CHECK(jitcall(code, pkt, 17, 17) == 0); ATF_CHECK(jitcall(code, pkt, 18, 18) == 0); ATF_CHECK(jitcall(code, pkt, 19, 19) == 0); ATF_CHECK(jitcall(code, pkt, 20, 20) == 0); ATF_CHECK(jitcall(code, pkt, 21, 21) == 0); ATF_CHECK(jitcall(code, pkt, 22, 22) == 0); ATF_CHECK(jitcall(code, pkt, 23, 23) == 0); ATF_CHECK(jitcall(code, pkt, 24, 24) == 0); ATF_CHECK(jitcall(code, pkt, 25, 25) == 0); ATF_CHECK(jitcall(code, pkt, 26, 26) == 0); ATF_CHECK(jitcall(code, pkt, 27, 27) == 0); ATF_CHECK(jitcall(code, pkt, 28, 28) == 0); ATF_CHECK(jitcall(code, pkt, 29, 29) == 0); ATF_CHECK(jitcall(code, pkt, 30, 30) == 0); ATF_CHECK(jitcall(code, pkt, 31, 31) == 0); ATF_CHECK(jitcall(code, pkt, 32, 32) == 0); ATF_CHECK(jitcall(code, pkt, 33, 33) == 0); /* The packet doesn't match. */ ATF_CHECK(jitcall(code, pkt, 34, 34) == 0); /* Still no match after setting the protocol field. */ pkt[12] = 8; ATF_CHECK(jitcall(code, pkt, 34, 34) == 0); pkt[26] = 128; pkt[27] = 3; pkt[28] = 112; pkt[29] = 15; ATF_CHECK(jitcall(code, pkt, 34, 34) == 0); pkt[30] = 128; pkt[31] = 3; pkt[32] = 112; pkt[33] = 35; ATF_CHECK(jitcall(code, pkt, 34, 34) == UINT32_MAX); /* Swap the ip addresses. */ pkt[26] = 128; pkt[27] = 3; pkt[28] = 112; pkt[29] = 35; ATF_CHECK(jitcall(code, pkt, 34, 34) == 0); pkt[30] = 128; pkt[31] = 3; pkt[32] = 112; pkt[33] = 15; ATF_CHECK(jitcall(code, pkt, 34, 34) == UINT32_MAX); /* Packet is too short. */ ATF_CHECK(jitcall(code, pkt, 1, 1) == 0); ATF_CHECK(jitcall(code, pkt, 2, 2) == 0); ATF_CHECK(jitcall(code, pkt, 3, 3) == 0); ATF_CHECK(jitcall(code, pkt, 4, 4) == 0); ATF_CHECK(jitcall(code, pkt, 5, 5) == 0); ATF_CHECK(jitcall(code, pkt, 6, 6) == 0); ATF_CHECK(jitcall(code, pkt, 7, 7) == 0); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); ATF_CHECK(jitcall(code, pkt, 9, 9) == 0); ATF_CHECK(jitcall(code, pkt, 10, 10) == 0); ATF_CHECK(jitcall(code, pkt, 11, 11) == 0); ATF_CHECK(jitcall(code, pkt, 12, 12) == 0); ATF_CHECK(jitcall(code, pkt, 13, 13) == 0); ATF_CHECK(jitcall(code, pkt, 14, 14) == 0); ATF_CHECK(jitcall(code, pkt, 15, 15) == 0); ATF_CHECK(jitcall(code, pkt, 16, 16) == 0); ATF_CHECK(jitcall(code, pkt, 17, 17) == 0); ATF_CHECK(jitcall(code, pkt, 18, 18) == 0); ATF_CHECK(jitcall(code, pkt, 19, 19) == 0); ATF_CHECK(jitcall(code, pkt, 20, 20) == 0); ATF_CHECK(jitcall(code, pkt, 21, 21) == 0); ATF_CHECK(jitcall(code, pkt, 22, 22) == 0); ATF_CHECK(jitcall(code, pkt, 23, 23) == 0); ATF_CHECK(jitcall(code, pkt, 24, 24) == 0); ATF_CHECK(jitcall(code, pkt, 25, 25) == 0); ATF_CHECK(jitcall(code, pkt, 26, 26) == 0); ATF_CHECK(jitcall(code, pkt, 27, 27) == 0); ATF_CHECK(jitcall(code, pkt, 28, 28) == 0); ATF_CHECK(jitcall(code, pkt, 29, 29) == 0); ATF_CHECK(jitcall(code, pkt, 30, 30) == 0); ATF_CHECK(jitcall(code, pkt, 31, 31) == 0); ATF_CHECK(jitcall(code, pkt, 32, 32) == 0); ATF_CHECK(jitcall(code, pkt, 33, 33) == 0); /* Change the protocol field. */ pkt[13] = 8; ATF_CHECK(jitcall(code, pkt, 34, 34) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_examples_3); ATF_TC_HEAD(bpfjit_examples_3, tc) { atf_tc_set_md_var(tc, "descr", "Test the third example from bpf(4) - " "accept TCP finger packets"); } ATF_TC_BODY(bpfjit_examples_3, tc) { /* * This filter returns only TCP finger packets. */ struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x0800, 0, 10), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 23), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 6, 0, 8), BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 20), BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, 0x1fff, 6, 0), BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 14), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 14), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 79, 2, 0), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 16), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 79, 0, 1), BPF_STMT(BPF_RET+BPF_K, UINT32_MAX), BPF_STMT(BPF_RET+BPF_K, 0), }; bpfjit_func_t code; uint8_t pkt[30] = {}; /* Set IP fragment offset to non-zero. */ pkt[20] = 1; pkt[21] = 1; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); /* Packet is too short. */ ATF_CHECK(jitcall(code, pkt, 1, 1) == 0); ATF_CHECK(jitcall(code, pkt, 2, 2) == 0); ATF_CHECK(jitcall(code, pkt, 3, 3) == 0); ATF_CHECK(jitcall(code, pkt, 4, 4) == 0); ATF_CHECK(jitcall(code, pkt, 5, 5) == 0); ATF_CHECK(jitcall(code, pkt, 6, 6) == 0); ATF_CHECK(jitcall(code, pkt, 7, 7) == 0); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); ATF_CHECK(jitcall(code, pkt, 9, 9) == 0); ATF_CHECK(jitcall(code, pkt, 10, 10) == 0); ATF_CHECK(jitcall(code, pkt, 11, 11) == 0); ATF_CHECK(jitcall(code, pkt, 12, 12) == 0); ATF_CHECK(jitcall(code, pkt, 13, 13) == 0); ATF_CHECK(jitcall(code, pkt, 14, 14) == 0); ATF_CHECK(jitcall(code, pkt, 15, 15) == 0); ATF_CHECK(jitcall(code, pkt, 16, 16) == 0); ATF_CHECK(jitcall(code, pkt, 17, 17) == 0); ATF_CHECK(jitcall(code, pkt, 18, 18) == 0); ATF_CHECK(jitcall(code, pkt, 19, 19) == 0); ATF_CHECK(jitcall(code, pkt, 20, 20) == 0); ATF_CHECK(jitcall(code, pkt, 21, 21) == 0); ATF_CHECK(jitcall(code, pkt, 22, 22) == 0); ATF_CHECK(jitcall(code, pkt, 23, 23) == 0); ATF_CHECK(jitcall(code, pkt, 24, 24) == 0); ATF_CHECK(jitcall(code, pkt, 25, 25) == 0); ATF_CHECK(jitcall(code, pkt, 26, 26) == 0); ATF_CHECK(jitcall(code, pkt, 27, 27) == 0); ATF_CHECK(jitcall(code, pkt, 28, 28) == 0); ATF_CHECK(jitcall(code, pkt, 29, 29) == 0); /* The packet doesn't match. */ ATF_CHECK(jitcall(code, pkt, 30, 30) == 0); /* Still no match after setting the protocol field. */ pkt[12] = 8; ATF_CHECK(jitcall(code, pkt, 30, 30) == 0); /* Get one step closer to the match. */ pkt[23] = 6; ATF_CHECK(jitcall(code, pkt, 30, 30) == 0); /* Set IP fragment offset to zero. */ pkt[20] = 0x20; pkt[21] = 0; ATF_CHECK(jitcall(code, pkt, 30, 30) == 0); /* Set IP header length to 12. */ pkt[14] = 0xd3; ATF_CHECK(jitcall(code, pkt, 30, 30) == 0); /* Match one branch of the program. */ pkt[27] = 79; ATF_CHECK(jitcall(code, pkt, 30, 30) == UINT32_MAX); /* Match the other branch of the program. */ pkt[29] = 79; pkt[27] = 0; ATF_CHECK(jitcall(code, pkt, 30, 30) == UINT32_MAX); /* Packet is too short. */ ATF_CHECK(jitcall(code, pkt, 1, 1) == 0); ATF_CHECK(jitcall(code, pkt, 2, 2) == 0); ATF_CHECK(jitcall(code, pkt, 3, 3) == 0); ATF_CHECK(jitcall(code, pkt, 4, 4) == 0); ATF_CHECK(jitcall(code, pkt, 5, 5) == 0); ATF_CHECK(jitcall(code, pkt, 6, 6) == 0); ATF_CHECK(jitcall(code, pkt, 7, 7) == 0); ATF_CHECK(jitcall(code, pkt, 8, 8) == 0); ATF_CHECK(jitcall(code, pkt, 9, 9) == 0); ATF_CHECK(jitcall(code, pkt, 10, 10) == 0); ATF_CHECK(jitcall(code, pkt, 11, 11) == 0); ATF_CHECK(jitcall(code, pkt, 12, 12) == 0); ATF_CHECK(jitcall(code, pkt, 13, 13) == 0); ATF_CHECK(jitcall(code, pkt, 14, 14) == 0); ATF_CHECK(jitcall(code, pkt, 15, 15) == 0); ATF_CHECK(jitcall(code, pkt, 16, 16) == 0); ATF_CHECK(jitcall(code, pkt, 17, 17) == 0); ATF_CHECK(jitcall(code, pkt, 18, 18) == 0); ATF_CHECK(jitcall(code, pkt, 19, 19) == 0); ATF_CHECK(jitcall(code, pkt, 20, 20) == 0); ATF_CHECK(jitcall(code, pkt, 21, 21) == 0); ATF_CHECK(jitcall(code, pkt, 22, 22) == 0); ATF_CHECK(jitcall(code, pkt, 23, 23) == 0); ATF_CHECK(jitcall(code, pkt, 24, 24) == 0); ATF_CHECK(jitcall(code, pkt, 25, 25) == 0); ATF_CHECK(jitcall(code, pkt, 26, 26) == 0); ATF_CHECK(jitcall(code, pkt, 27, 27) == 0); ATF_CHECK(jitcall(code, pkt, 28, 28) == 0); ATF_CHECK(jitcall(code, pkt, 29, 29) == 0); /* Set IP header length to 16. Packet is too short. */ pkt[14] = 4; ATF_CHECK(jitcall(code, pkt, 30, 30) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_cop_no_ctx); ATF_TC_HEAD(bpfjit_cop_no_ctx, tc) { atf_tc_set_md_var(tc, "descr", "Test that BPF_MISC|BPF_COP " "instruction can't be accepted without a context"); } ATF_TC_BODY(bpfjit_cop_no_ctx, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_MISC+BPF_COP, 0), BPF_STMT(BPF_RET+BPF_K, 7) }; bpfjit_func_t code; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(!prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_CHECK(code == NULL); } ATF_TC(bpfjit_copx_no_ctx); ATF_TC_HEAD(bpfjit_copx_no_ctx, tc) { atf_tc_set_md_var(tc, "descr", "Test that BPF_MISC|BPF_COPX " "instruction can't be accepted without a context"); } ATF_TC_BODY(bpfjit_copx_no_ctx, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_MISC+BPF_COPX, 0), BPF_STMT(BPF_RET+BPF_K, 7) }; bpfjit_func_t code; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(!prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_CHECK(code == NULL); } ATF_TP_ADD_TCS(tp) { /* * For every new test please also add a similar test * to ../../lib/libbpfjit/t_bpfjit.c */ ATF_TP_ADD_TC(tp, bpfjit_empty); ATF_TP_ADD_TC(tp, bpfjit_ret_k); ATF_TP_ADD_TC(tp, bpfjit_bad_ret_k); ATF_TP_ADD_TC(tp, bpfjit_alu_add_k); ATF_TP_ADD_TC(tp, bpfjit_alu_sub_k); ATF_TP_ADD_TC(tp, bpfjit_alu_mul_k); ATF_TP_ADD_TC(tp, bpfjit_alu_div0_k); ATF_TP_ADD_TC(tp, bpfjit_alu_div1_k); ATF_TP_ADD_TC(tp, bpfjit_alu_div2_k); ATF_TP_ADD_TC(tp, bpfjit_alu_div4_k); ATF_TP_ADD_TC(tp, bpfjit_alu_div10_k); ATF_TP_ADD_TC(tp, bpfjit_alu_div10000_k); ATF_TP_ADD_TC(tp, bpfjit_alu_div7609801_k); ATF_TP_ADD_TC(tp, bpfjit_alu_div80000000_k); ATF_TP_ADD_TC(tp, bpfjit_alu_mod0_k); ATF_TP_ADD_TC(tp, bpfjit_alu_mod1_k); ATF_TP_ADD_TC(tp, bpfjit_alu_mod2_k); ATF_TP_ADD_TC(tp, bpfjit_alu_mod4_k); ATF_TP_ADD_TC(tp, bpfjit_alu_mod10_k); ATF_TP_ADD_TC(tp, bpfjit_alu_mod10000_k); ATF_TP_ADD_TC(tp, bpfjit_alu_mod7609801_k); ATF_TP_ADD_TC(tp, bpfjit_alu_mod80000000_k); ATF_TP_ADD_TC(tp, bpfjit_alu_and_k); ATF_TP_ADD_TC(tp, bpfjit_alu_or_k); ATF_TP_ADD_TC(tp, bpfjit_alu_xor_k); ATF_TP_ADD_TC(tp, bpfjit_alu_lsh_k); ATF_TP_ADD_TC(tp, bpfjit_alu_lsh0_k); ATF_TP_ADD_TC(tp, bpfjit_alu_rsh_k); ATF_TP_ADD_TC(tp, bpfjit_alu_rsh0_k); ATF_TP_ADD_TC(tp, bpfjit_alu_modulo_k); ATF_TP_ADD_TC(tp, bpfjit_alu_add_x); ATF_TP_ADD_TC(tp, bpfjit_alu_sub_x); ATF_TP_ADD_TC(tp, bpfjit_alu_mul_x); ATF_TP_ADD_TC(tp, bpfjit_alu_div0_x); ATF_TP_ADD_TC(tp, bpfjit_alu_div1_x); ATF_TP_ADD_TC(tp, bpfjit_alu_div2_x); ATF_TP_ADD_TC(tp, bpfjit_alu_div4_x); ATF_TP_ADD_TC(tp, bpfjit_alu_div10_x); ATF_TP_ADD_TC(tp, bpfjit_alu_div10000_x); ATF_TP_ADD_TC(tp, bpfjit_alu_div7609801_x); ATF_TP_ADD_TC(tp, bpfjit_alu_div80000000_x); ATF_TP_ADD_TC(tp, bpfjit_alu_mod0_x); ATF_TP_ADD_TC(tp, bpfjit_alu_mod1_x); ATF_TP_ADD_TC(tp, bpfjit_alu_mod2_x); ATF_TP_ADD_TC(tp, bpfjit_alu_mod4_x); ATF_TP_ADD_TC(tp, bpfjit_alu_mod10_x); ATF_TP_ADD_TC(tp, bpfjit_alu_mod10000_x); ATF_TP_ADD_TC(tp, bpfjit_alu_mod7609801_x); ATF_TP_ADD_TC(tp, bpfjit_alu_mod80000000_x); ATF_TP_ADD_TC(tp, bpfjit_alu_and_x); ATF_TP_ADD_TC(tp, bpfjit_alu_or_x); ATF_TP_ADD_TC(tp, bpfjit_alu_xor_x); ATF_TP_ADD_TC(tp, bpfjit_alu_lsh_x); ATF_TP_ADD_TC(tp, bpfjit_alu_lsh0_x); ATF_TP_ADD_TC(tp, bpfjit_alu_rsh_x); ATF_TP_ADD_TC(tp, bpfjit_alu_rsh0_x); ATF_TP_ADD_TC(tp, bpfjit_alu_modulo_x); ATF_TP_ADD_TC(tp, bpfjit_alu_neg); ATF_TP_ADD_TC(tp, bpfjit_jmp_ja); ATF_TP_ADD_TC(tp, bpfjit_jmp_ja_invalid); ATF_TP_ADD_TC(tp, bpfjit_jmp_ja_overflow); ATF_TP_ADD_TC(tp, bpfjit_jmp_jgt_k); ATF_TP_ADD_TC(tp, bpfjit_jmp_jge_k); ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_k); ATF_TP_ADD_TC(tp, bpfjit_jmp_jset_k); ATF_TP_ADD_TC(tp, bpfjit_jmp_modulo_k); ATF_TP_ADD_TC(tp, bpfjit_jmp_jgt_x); ATF_TP_ADD_TC(tp, bpfjit_jmp_jge_x); ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_x); ATF_TP_ADD_TC(tp, bpfjit_jmp_jset_x); ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_x_noinit_ax); ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_x_noinit_a); ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_x_noinit_x); ATF_TP_ADD_TC(tp, bpfjit_jmp_modulo_x); ATF_TP_ADD_TC(tp, bpfjit_ld_abs); ATF_TP_ADD_TC(tp, bpfjit_ld_abs_k_overflow); ATF_TP_ADD_TC(tp, bpfjit_ld_ind); ATF_TP_ADD_TC(tp, bpfjit_ld_ind_k_overflow); ATF_TP_ADD_TC(tp, bpfjit_ld_ind_x_overflow1); ATF_TP_ADD_TC(tp, bpfjit_ld_ind_x_overflow2); ATF_TP_ADD_TC(tp, bpfjit_ld_len); ATF_TP_ADD_TC(tp, bpfjit_ld_imm); ATF_TP_ADD_TC(tp, bpfjit_ldx_imm1); ATF_TP_ADD_TC(tp, bpfjit_ldx_imm2); ATF_TP_ADD_TC(tp, bpfjit_ldx_len1); ATF_TP_ADD_TC(tp, bpfjit_ldx_len2); ATF_TP_ADD_TC(tp, bpfjit_ldx_msh); ATF_TP_ADD_TC(tp, bpfjit_misc_tax); ATF_TP_ADD_TC(tp, bpfjit_misc_txa); ATF_TP_ADD_TC(tp, bpfjit_st1); ATF_TP_ADD_TC(tp, bpfjit_st2); ATF_TP_ADD_TC(tp, bpfjit_st3); ATF_TP_ADD_TC(tp, bpfjit_st4); ATF_TP_ADD_TC(tp, bpfjit_st5); ATF_TP_ADD_TC(tp, bpfjit_stx1); ATF_TP_ADD_TC(tp, bpfjit_stx2); ATF_TP_ADD_TC(tp, bpfjit_stx3); ATF_TP_ADD_TC(tp, bpfjit_stx4); ATF_TP_ADD_TC(tp, bpfjit_opt_ld_abs_1); ATF_TP_ADD_TC(tp, bpfjit_opt_ld_abs_2); ATF_TP_ADD_TC(tp, bpfjit_opt_ld_abs_3); ATF_TP_ADD_TC(tp, bpfjit_opt_ld_ind_1); ATF_TP_ADD_TC(tp, bpfjit_opt_ld_ind_2); ATF_TP_ADD_TC(tp, bpfjit_opt_ld_ind_3); ATF_TP_ADD_TC(tp, bpfjit_opt_ld_ind_4); ATF_TP_ADD_TC(tp, bpfjit_abc_ja); ATF_TP_ADD_TC(tp, bpfjit_abc_ja_over); ATF_TP_ADD_TC(tp, bpfjit_abc_ld_chain); ATF_TP_ADD_TC(tp, bpfjit_examples_1); ATF_TP_ADD_TC(tp, bpfjit_examples_2); ATF_TP_ADD_TC(tp, bpfjit_examples_3); ATF_TP_ADD_TC(tp, bpfjit_cop_no_ctx); ATF_TP_ADD_TC(tp, bpfjit_copx_no_ctx); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_cop.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_cop.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_cop.c (revision 312126) @@ -1,757 +1,757 @@ -/* $NetBSD: t_cop.c,v 1.3 2014/07/13 21:35:33 alnsn Exp $ */ +/* $NetBSD: t_cop.c,v 1.4 2017/01/13 21:30:42 christos Exp $ */ /*- * Copyright (c) 2014 Alexander Nasonov. * 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 COPYRIGHT HOLDERS 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 * COPYRIGHT HOLDERS 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 -__RCSID("$NetBSD: t_cop.c,v 1.3 2014/07/13 21:35:33 alnsn Exp $"); +__RCSID("$NetBSD: t_cop.c,v 1.4 2017/01/13 21:30:42 christos Exp $"); #include #include #define __BPF_PRIVATE #include #include #include "../../net/bpf/h_bpf.h" /* XXX: atf-c.h has collisions with mbuf */ #undef m_type #undef m_data #include -#include "../../h_macros.h" +#include "h_macros.h" static uint32_t retA(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A); static uint32_t retBL(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A); static uint32_t retWL(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A); static uint32_t retNF(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A); static uint32_t setARG(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A); static const bpf_copfunc_t copfuncs[] = { &retA, &retBL, &retWL, &retNF, &setARG }; static const bpf_ctx_t ctx = { .copfuncs = copfuncs, .nfuncs = sizeof(copfuncs) / sizeof(copfuncs[0]), .extwords = 0 }; static uint32_t retA(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A) { return A; } static uint32_t retBL(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A) { return args->buflen; } static uint32_t retWL(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A) { return args->wirelen; } static uint32_t retNF(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A) { return bc->nfuncs; } /* * COP function with a side effect. */ static uint32_t setARG(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A) { bool *arg = (bool *)args->arg; bool old = *arg; *arg = true; return old; } ATF_TC(bpfjit_cop_no_ctx); ATF_TC_HEAD(bpfjit_cop_no_ctx, tc) { atf_tc_set_md_var(tc, "descr", "Test that bpf program with BPF_COP " "instruction isn't valid without a context"); } ATF_TC_BODY(bpfjit_cop_no_ctx, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_MISC+BPF_COP, 0), BPF_STMT(BPF_RET+BPF_K, 7) }; bpfjit_func_t code; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(!prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_CHECK(code == NULL); } ATF_TC(bpfjit_cop_ret_A); ATF_TC_HEAD(bpfjit_cop_ret_A, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function " "that returns a content of the A register"); } ATF_TC_BODY(bpfjit_cop_ret_A, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_MISC+BPF_COP, 0), // retA BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 13); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_cop_ret_buflen); ATF_TC_HEAD(bpfjit_cop_ret_buflen, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function " "that returns the buflen argument"); } ATF_TC_BODY(bpfjit_cop_ret_buflen, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_MISC+BPF_COP, 1), // retBL BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt) }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == sizeof(pkt)); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_cop_ret_wirelen); ATF_TC_HEAD(bpfjit_cop_ret_wirelen, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function " "that returns the wirelen argument"); } ATF_TC_BODY(bpfjit_cop_ret_wirelen, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_MISC+BPF_COP, 2), // retWL BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt) }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == sizeof(pkt)); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_cop_ret_nfuncs); ATF_TC_HEAD(bpfjit_cop_ret_nfuncs, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function " "that returns nfuncs member of the context argument"); } ATF_TC_BODY(bpfjit_cop_ret_nfuncs, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_MISC+BPF_COP, 3), // retNF BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt) }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == ctx.nfuncs); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_cop_side_effect); ATF_TC_HEAD(bpfjit_cop_side_effect, tc) { atf_tc_set_md_var(tc, "descr", "Test that ABC optimization doesn't skip BPF_COP call"); } ATF_TC_BODY(bpfjit_cop_side_effect, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 0), BPF_STMT(BPF_MISC+BPF_COP, 4), // setARG BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 99999), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; bool arg = false; uint8_t pkt[1] = { 0 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), .mem = NULL, .arg = &arg }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 0); ATF_CHECK(arg == true); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_cop_copx); ATF_TC_HEAD(bpfjit_cop_copx, tc) { atf_tc_set_md_var(tc, "descr", "Test BPF_COP call followed by BPF_COPX call"); } ATF_TC_BODY(bpfjit_cop_copx, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 1), /* A <- 1 */ BPF_STMT(BPF_MISC+BPF_COP, 0), /* retA */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 0), /* A = P[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 1), /* A = A + X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_MISC+BPF_COPX, 0), /* retNF */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 1), /* A = A + X */ BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 2 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 3 + ctx.nfuncs); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_cop_invalid_index); ATF_TC_HEAD(bpfjit_cop_invalid_index, tc) { atf_tc_set_md_var(tc, "descr", "Test that out-of-range coprocessor function fails validation"); } ATF_TC_BODY(bpfjit_cop_invalid_index, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_MISC+BPF_COP, 6), // invalid index BPF_STMT(BPF_RET+BPF_K, 27) }; bpfjit_func_t code; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_CHECK(code == NULL); } ATF_TC(bpfjit_copx_no_ctx); ATF_TC_HEAD(bpfjit_copx_no_ctx, tc) { atf_tc_set_md_var(tc, "descr", "Test that bpf program with BPF_COPX " "instruction isn't valid without a context"); } ATF_TC_BODY(bpfjit_copx_no_ctx, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_MISC+BPF_COP, 0), BPF_STMT(BPF_RET+BPF_K, 7) }; bpfjit_func_t code; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); ATF_CHECK(!prog_validate(insns, insn_count)); rump_schedule(); code = rumpns_bpfjit_generate_code(NULL, insns, insn_count); rump_unschedule(); ATF_CHECK(code == NULL); } ATF_TC(bpfjit_copx_ret_A); ATF_TC_HEAD(bpfjit_copx_ret_A, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function " "that returns a content of the A register"); } ATF_TC_BODY(bpfjit_copx_ret_A, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_LDX+BPF_IMM, 0), // retA BPF_STMT(BPF_MISC+BPF_COPX, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 13); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_copx_ret_buflen); ATF_TC_HEAD(bpfjit_copx_ret_buflen, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function " "that returns the buflen argument"); } ATF_TC_BODY(bpfjit_copx_ret_buflen, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_LDX+BPF_IMM, 1), // retBL BPF_STMT(BPF_MISC+BPF_COPX, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt) }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == sizeof(pkt)); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_copx_ret_wirelen); ATF_TC_HEAD(bpfjit_copx_ret_wirelen, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function " "that returns the wirelen argument"); } ATF_TC_BODY(bpfjit_copx_ret_wirelen, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_IMM, 2), // retWL BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_MISC+BPF_COPX, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt) }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == sizeof(pkt)); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_copx_ret_nfuncs); ATF_TC_HEAD(bpfjit_copx_ret_nfuncs, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function " "that returns nfuncs member of the context argument"); } ATF_TC_BODY(bpfjit_copx_ret_nfuncs, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_LDX+BPF_IMM, 3), // retNF BPF_STMT(BPF_MISC+BPF_COPX, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt) }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == ctx.nfuncs); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_copx_side_effect); ATF_TC_HEAD(bpfjit_copx_side_effect, tc) { atf_tc_set_md_var(tc, "descr", "Test that ABC optimization doesn't skip BPF_COPX call"); } ATF_TC_BODY(bpfjit_copx_side_effect, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 0), BPF_STMT(BPF_LDX+BPF_IMM, 4), // setARG BPF_STMT(BPF_MISC+BPF_COPX, 0), BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 99999), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; bool arg = false; uint8_t pkt[1] = { 0 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), .mem = NULL, .arg = &arg }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 0); ATF_CHECK(arg == true); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_copx_cop); ATF_TC_HEAD(bpfjit_copx_cop, tc) { atf_tc_set_md_var(tc, "descr", "Test BPF_COPX call followed by BPF_COP call"); } ATF_TC_BODY(bpfjit_copx_cop, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_IMM, 2), /* X <- 2 */ BPF_STMT(BPF_MISC+BPF_COPX, 0), /* retWL */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 1), /* A = A + X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 0), /* A = P[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 1), /* A = A + X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_MISC+BPF_COP, 3), /* retNF */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 1), /* A = A + X */ BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 2 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 5 + ctx.nfuncs); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_copx_invalid_index); ATF_TC_HEAD(bpfjit_copx_invalid_index, tc) { atf_tc_set_md_var(tc, "descr", "Test that out-of-range BPF_COPX call fails at runtime"); } ATF_TC_BODY(bpfjit_copx_invalid_index, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_IMM, 5), // invalid index BPF_STMT(BPF_MISC+BPF_COPX, 0), BPF_STMT(BPF_RET+BPF_K, 27) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt) }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TP_ADD_TCS(tp) { /* * For every new test please also add a similar test * to ../../lib/libbpfjit/t_cop.c */ ATF_TP_ADD_TC(tp, bpfjit_cop_no_ctx); ATF_TP_ADD_TC(tp, bpfjit_cop_ret_A); ATF_TP_ADD_TC(tp, bpfjit_cop_ret_buflen); ATF_TP_ADD_TC(tp, bpfjit_cop_ret_wirelen); ATF_TP_ADD_TC(tp, bpfjit_cop_ret_nfuncs); ATF_TP_ADD_TC(tp, bpfjit_cop_side_effect); ATF_TP_ADD_TC(tp, bpfjit_cop_copx); ATF_TP_ADD_TC(tp, bpfjit_cop_invalid_index); ATF_TP_ADD_TC(tp, bpfjit_copx_no_ctx); ATF_TP_ADD_TC(tp, bpfjit_copx_ret_A); ATF_TP_ADD_TC(tp, bpfjit_copx_ret_buflen); ATF_TP_ADD_TC(tp, bpfjit_copx_ret_wirelen); ATF_TP_ADD_TC(tp, bpfjit_copx_ret_nfuncs); ATF_TP_ADD_TC(tp, bpfjit_copx_side_effect); ATF_TP_ADD_TC(tp, bpfjit_copx_cop); ATF_TP_ADD_TC(tp, bpfjit_copx_invalid_index); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_extmem.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_extmem.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_extmem.c (revision 312126) @@ -1,506 +1,506 @@ -/* $NetBSD: t_extmem.c,v 1.1 2014/07/09 13:49:49 alnsn Exp $ */ +/* $NetBSD: t_extmem.c,v 1.2 2017/01/13 21:30:42 christos Exp $ */ /*- * Copyright (c) 2014 Alexander Nasonov. * 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 COPYRIGHT HOLDERS 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 * COPYRIGHT HOLDERS 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 -__RCSID("$NetBSD: t_extmem.c,v 1.1 2014/07/09 13:49:49 alnsn Exp $"); +__RCSID("$NetBSD: t_extmem.c,v 1.2 2017/01/13 21:30:42 christos Exp $"); #include #include #define __BPF_PRIVATE #include #include #include "../../net/bpf/h_bpf.h" /* XXX: atf-c.h has collisions with mbuf */ #undef m_type #undef m_data #include -#include "../../h_macros.h" +#include "h_macros.h" static uint32_t retM(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A); static const bpf_copfunc_t copfuncs[] = { &retM }; static const bpf_ctx_t ctx = { .copfuncs = copfuncs, .nfuncs = sizeof(copfuncs) / sizeof(copfuncs[0]), .extwords = 4, .preinited = BPF_MEMWORD_INIT(0) | BPF_MEMWORD_INIT(3), }; static uint32_t retM(const bpf_ctx_t *bc, bpf_args_t *args, uint32_t A) { return args->mem[(uintptr_t)args->arg]; } ATF_TC(bpfjit_extmem_load_preinited); ATF_TC_HEAD(bpfjit_extmem_load_preinited, tc) { atf_tc_set_md_var(tc, "descr", "Test a load of external " "pre-initialized memory"); } ATF_TC_BODY(bpfjit_extmem_load_preinited, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_MEM, 3), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; uint32_t mem[ctx.extwords]; /* Pre-inited words. */ mem[0] = 0; mem[3] = 3; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), .mem = mem, }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 3); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_extmem_invalid_load); ATF_TC_HEAD(bpfjit_extmem_invalid_load, tc) { atf_tc_set_md_var(tc, "descr", "Test that out-of-range load " "fails validation"); } ATF_TC_BODY(bpfjit_extmem_invalid_load, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_MEM, 4), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_CHECK(code == NULL); } ATF_TC(bpfjit_extmem_store); ATF_TC_HEAD(bpfjit_extmem_store, tc) { atf_tc_set_md_var(tc, "descr", "Test stores to external memory"); } ATF_TC_BODY(bpfjit_extmem_store, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 1), /* A <- 1 */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 2), /* X <- 2 */ BPF_STMT(BPF_ST, 1), /* M[1] <- A */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_STX, 2), /* M[2] <- X */ BPF_STMT(BPF_ST, 3), /* M[3] <- A */ BPF_STMT(BPF_RET+BPF_A, 0) /* ret A */ }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; uint32_t mem[ctx.extwords]; /* Pre-inited words. */ mem[0] = 0; mem[3] = 7; mem[1] = mem[2] = 0xdeadbeef; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), .mem = mem, }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 3); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); ATF_CHECK(mem[0] == 0); ATF_CHECK(mem[1] == 1); ATF_CHECK(mem[2] == 2); ATF_CHECK(mem[3] == 3); } ATF_TC(bpfjit_extmem_side_effect); ATF_TC_HEAD(bpfjit_extmem_side_effect, tc) { atf_tc_set_md_var(tc, "descr", "Test that ABC optimization doesn\'t " "skip stores to external memory"); } ATF_TC_BODY(bpfjit_extmem_side_effect, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 0), /* A <- P[0] */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 2), /* X <- 2 */ BPF_STMT(BPF_ST, 1), /* M[1] <- A */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_STX, 2), /* M[2] <- X */ BPF_STMT(BPF_ST, 3), /* M[3] <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 99), /* A <- P[99] */ BPF_STMT(BPF_RET+BPF_A, 0) /* ret A */ }; bpfjit_func_t code; uint8_t pkt[1] = { 1 }; uint32_t mem[ctx.extwords]; /* Pre-inited words. */ mem[0] = 0; mem[3] = 7; mem[1] = mem[2] = 0xdeadbeef; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), .mem = mem, }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 0); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); ATF_CHECK(mem[0] == 0); ATF_CHECK(mem[1] == 1); ATF_CHECK(mem[2] == 2); ATF_CHECK(mem[3] == 3); } ATF_TC(bpfjit_extmem_invalid_store); ATF_TC_HEAD(bpfjit_extmem_invalid_store, tc) { atf_tc_set_md_var(tc, "descr", "Test that out-of-range store " "fails validation"); } ATF_TC_BODY(bpfjit_extmem_invalid_store, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_ST, 4), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_CHECK(code == NULL); } ATF_TC(bpfjit_cop_ret_mem); ATF_TC_HEAD(bpfjit_cop_ret_mem, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function " "that returns a content of external memory word"); } ATF_TC_BODY(bpfjit_cop_ret_mem, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_ST, 2), BPF_STMT(BPF_LD+BPF_IMM, 137), BPF_STMT(BPF_ST, 1), BPF_STMT(BPF_MISC+BPF_COP, 0), // retM BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; uint32_t mem[ctx.extwords]; void *arg = (void*)(uintptr_t)2; /* Pre-inited words. */ mem[0] = 0; mem[3] = 3; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), .arg = arg, .mem = mem, }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 13); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_cop_ret_preinited_mem); ATF_TC_HEAD(bpfjit_cop_ret_preinited_mem, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function that " "returns a content of external pre-initialized memory word"); } ATF_TC_BODY(bpfjit_cop_ret_preinited_mem, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_ST, 2), BPF_STMT(BPF_LD+BPF_IMM, 137), BPF_STMT(BPF_ST, 1), BPF_STMT(BPF_MISC+BPF_COP, 0), // retM BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; uint32_t mem[ctx.extwords]; void *arg = (void*)(uintptr_t)3; /* Pre-inited words. */ mem[0] = 0; mem[3] = 3; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), .arg = arg, .mem = mem, }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 3); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_copx_ret_mem); ATF_TC_HEAD(bpfjit_copx_ret_mem, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function " "that returns a content of external memory word"); } ATF_TC_BODY(bpfjit_copx_ret_mem, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_ST, 2), BPF_STMT(BPF_LD+BPF_IMM, 137), BPF_STMT(BPF_ST, 1), BPF_STMT(BPF_LDX+BPF_IMM, 0), // retM BPF_STMT(BPF_MISC+BPF_COPX, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; uint32_t mem[ctx.extwords]; void *arg = (void*)(uintptr_t)2; /* Pre-inited words. */ mem[0] = 0; mem[3] = 3; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), .arg = arg, .mem = mem, }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 13); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TC(bpfjit_copx_ret_preinited_mem); ATF_TC_HEAD(bpfjit_copx_ret_preinited_mem, tc) { atf_tc_set_md_var(tc, "descr", "Test coprocessor function that " "returns a content of external pre-initialized memory word"); } ATF_TC_BODY(bpfjit_copx_ret_preinited_mem, tc) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 13), BPF_STMT(BPF_ST, 2), BPF_STMT(BPF_LD+BPF_IMM, 137), BPF_STMT(BPF_ST, 1), BPF_STMT(BPF_LDX+BPF_IMM, 0), // retM BPF_STMT(BPF_MISC+BPF_COPX, 0), BPF_STMT(BPF_RET+BPF_A, 0) }; bpfjit_func_t code; uint8_t pkt[1] = { 0 }; uint32_t mem[ctx.extwords]; void *arg = (void*)(uintptr_t)3; /* Pre-inited words. */ mem[0] = 0; mem[3] = 3; bpf_args_t args = { .pkt = pkt, .buflen = sizeof(pkt), .wirelen = sizeof(pkt), .arg = arg, .mem = mem, }; size_t insn_count = sizeof(insns) / sizeof(insns[0]); RZ(rump_init()); rump_schedule(); code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count); rump_unschedule(); ATF_REQUIRE(code != NULL); ATF_CHECK(code(&ctx, &args) == 3); rump_schedule(); rumpns_bpfjit_free_code(code); rump_unschedule(); } ATF_TP_ADD_TCS(tp) { /* * For every new test please also add a similar test * to ../../lib/libbpfjit/t_extmem.c */ //ATF_TP_ADD_TC(tp, bpfjit_extmem_load_default); ATF_TP_ADD_TC(tp, bpfjit_extmem_load_preinited); ATF_TP_ADD_TC(tp, bpfjit_extmem_invalid_load); ATF_TP_ADD_TC(tp, bpfjit_extmem_store); ATF_TP_ADD_TC(tp, bpfjit_extmem_side_effect); ATF_TP_ADD_TC(tp, bpfjit_extmem_invalid_store); ATF_TP_ADD_TC(tp, bpfjit_cop_ret_mem); ATF_TP_ADD_TC(tp, bpfjit_cop_ret_preinited_mem); ATF_TP_ADD_TC(tp, bpfjit_copx_ret_mem); ATF_TP_ADD_TC(tp, bpfjit_copx_ret_preinited_mem); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_mbuf.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_mbuf.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/bpfjit/t_mbuf.c (revision 312126) @@ -1,982 +1,982 @@ -/* $NetBSD: t_mbuf.c,v 1.1 2014/07/08 21:45:55 alnsn Exp $ */ +/* $NetBSD: t_mbuf.c,v 1.2 2017/01/13 21:30:42 christos Exp $ */ /*- * Copyright (c) 2014 Alexander Nasonov. * 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 ``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. */ #include -__RCSID("$NetBSD: t_mbuf.c,v 1.1 2014/07/08 21:45:55 alnsn Exp $"); +__RCSID("$NetBSD: t_mbuf.c,v 1.2 2017/01/13 21:30:42 christos Exp $"); #include #include #include #include #include #include #include #include #include "../../net/bpf/h_bpf.h" /* XXX: atf-c.h has collisions with mbuf */ #undef m_type #undef m_data #include -#include "../../h_macros.h" +#include "h_macros.h" static bool test_ldb_abs(size_t split) { /* Return a product of all packet bytes. */ static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 0), /* A <- P[0] */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 1), /* A <- P[1] */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 2), /* A <- P[2] */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 3), /* A <- P[3] */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 4), /* A <- P[4] */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 120; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == res; } static bool test_ldh_abs(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 0), /* A <- P[0:2] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 1), /* A <- P[1:2] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 2), /* A <- P[2:2] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 3), /* A <- P[3:2] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 0x0a0e; /* 10 14 */ const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == res; } static bool test_ldw_abs(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0), /* A <- P[0:4] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_MISC+BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 1), /* A <- P[1:4] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 0x03050709; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == res; } static bool test_ldb_ind(size_t split) { /* Return a sum of all packet bytes. */ static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_B+BPF_IND, 0), /* A <- P[0+X] */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LD+BPF_B+BPF_IND, 1), /* A <- P[1+X] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_B+BPF_IND, 1), /* A <- P[1+X] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_B+BPF_IND, 2), /* A <- P[2+X] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_B+BPF_IND, 3), /* A <- P[3+X] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 15; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == res; } static bool test_ldw_ind(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_IND, 0), /* A <- P[X+0:4] */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_W+BPF_IND, 0), /* A <- P[X+0:4] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 0), /* X <- 0 */ BPF_STMT(BPF_LD+BPF_W+BPF_IND, 1), /* A <- P[X+1:4] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 0x05080b0e; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == res; } static bool test_ldh_ind(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_IND, 0), /* A <- P[X+0:2] */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LD+BPF_H+BPF_IND, 1), /* A <- P[X+1:2] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_H+BPF_IND, 1), /* A <- P[X+1:2] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_ST, 0), /* M[0] <- A */ BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), /* X <- 1 */ BPF_STMT(BPF_LD+BPF_H+BPF_IND, 2), /* A <- P[X+2:2] */ BPF_STMT(BPF_LDX+BPF_W+BPF_MEM, 0), /* X <- M[0] */ BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), /* A <- A + X */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 0x0a0e; /* 10 14 */ const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == res; } static bool test_msh(size_t split) { /* Return a product of all packet bytes. */ static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_IMM, 1), /* A <- 1 */ BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 0), /* X <- 4*(P[0]&0xf) */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 4), /* A <- A / 4 */ BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 1), /* X <- 4*(P[1]&0xf) */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 4), /* A <- A / 4 */ BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 2), /* X <- 4*(P[2]&0xf) */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 4), /* A <- A / 4 */ BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 3), /* X <- 4*(P[3]&0xf) */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 4), /* A <- A / 4 */ BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 4), /* X <- 4*(P[4]&0xf) */ BPF_STMT(BPF_ALU+BPF_MUL+BPF_X, 0), /* A <- A * X */ BPF_STMT(BPF_ALU+BPF_DIV+BPF_K, 4), /* A <- A / 4 */ BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const unsigned int res = 120; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == res; } static bool test_ldb_abs_overflow(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 5), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_ldh_abs_overflow(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_ldw_abs_overflow(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 2), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_ldb_ind_overflow1(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_B+BPF_IND, 5), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_ldb_ind_overflow2(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 4), BPF_STMT(BPF_LD+BPF_B+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_ldb_ind_overflow3(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_MAX), BPF_STMT(BPF_LD+BPF_B+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_ldh_ind_overflow1(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_IND, 4), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_ldh_ind_overflow2(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 3), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_ldh_ind_overflow3(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_MAX), BPF_STMT(BPF_LD+BPF_H+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_ldw_ind_overflow1(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_W+BPF_IND, 2), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_ldw_ind_overflow2(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 1), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_X, 0), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_ldw_ind_overflow3(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, UINT32_MAX), BPF_STMT(BPF_LD+BPF_W+BPF_IND, 1), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } static bool test_msh_overflow(size_t split) { static struct bpf_insn insns[] = { BPF_STMT(BPF_LDX+BPF_B+BPF_MSH, 5), BPF_STMT(BPF_MISC+BPF_TXA, 0), BPF_STMT(BPF_ALU+BPF_ADD+BPF_K, 1), BPF_STMT(BPF_RET+BPF_A, 0), }; static unsigned char P[] = { 1, 2, 3, 4, 5 }; const size_t insn_count = sizeof(insns) / sizeof(insns[0]); if (!prog_validate(insns, insn_count)) return false; return exec_prog_mchain2(insns, insn_count, P, sizeof(P), split) == 0; } ATF_TC(bpfjit_mbuf_ldb_abs); ATF_TC_HEAD(bpfjit_mbuf_ldb_abs, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_ABS " "loads bytes from mbuf correctly"); } ATF_TC_BODY(bpfjit_mbuf_ldb_abs, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_abs(0)); ATF_CHECK(test_ldb_abs(1)); ATF_CHECK(test_ldb_abs(2)); ATF_CHECK(test_ldb_abs(3)); ATF_CHECK(test_ldb_abs(4)); ATF_CHECK(test_ldb_abs(5)); } ATF_TC(bpfjit_mbuf_ldh_abs); ATF_TC_HEAD(bpfjit_mbuf_ldh_abs, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_ABS " "loads halfwords from mbuf correctly"); } ATF_TC_BODY(bpfjit_mbuf_ldh_abs, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_abs(0)); ATF_CHECK(test_ldh_abs(1)); ATF_CHECK(test_ldh_abs(2)); ATF_CHECK(test_ldh_abs(3)); ATF_CHECK(test_ldh_abs(4)); ATF_CHECK(test_ldh_abs(5)); } ATF_TC(bpfjit_mbuf_ldw_abs); ATF_TC_HEAD(bpfjit_mbuf_ldw_abs, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_ABS " "loads words from mbuf correctly"); } ATF_TC_BODY(bpfjit_mbuf_ldw_abs, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_abs(0)); ATF_CHECK(test_ldw_abs(1)); ATF_CHECK(test_ldw_abs(2)); ATF_CHECK(test_ldw_abs(3)); ATF_CHECK(test_ldw_abs(4)); ATF_CHECK(test_ldw_abs(5)); } ATF_TC(bpfjit_mbuf_ldb_ind); ATF_TC_HEAD(bpfjit_mbuf_ldb_ind, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_IND " "loads bytes from mbuf correctly"); } ATF_TC_BODY(bpfjit_mbuf_ldb_ind, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_ind(0)); ATF_CHECK(test_ldb_ind(1)); ATF_CHECK(test_ldb_ind(2)); ATF_CHECK(test_ldb_ind(3)); ATF_CHECK(test_ldb_ind(4)); ATF_CHECK(test_ldb_ind(5)); } ATF_TC(bpfjit_mbuf_ldh_ind); ATF_TC_HEAD(bpfjit_mbuf_ldh_ind, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_IND " "loads halfwords from mbuf correctly"); } ATF_TC_BODY(bpfjit_mbuf_ldh_ind, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_ind(0)); ATF_CHECK(test_ldh_ind(1)); ATF_CHECK(test_ldh_ind(2)); ATF_CHECK(test_ldh_ind(3)); ATF_CHECK(test_ldh_ind(4)); ATF_CHECK(test_ldh_ind(5)); } ATF_TC(bpfjit_mbuf_ldw_ind); ATF_TC_HEAD(bpfjit_mbuf_ldw_ind, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_IND " "loads words from mbuf correctly"); } ATF_TC_BODY(bpfjit_mbuf_ldw_ind, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_ind(0)); ATF_CHECK(test_ldw_ind(1)); ATF_CHECK(test_ldw_ind(2)); ATF_CHECK(test_ldw_ind(3)); ATF_CHECK(test_ldw_ind(4)); ATF_CHECK(test_ldw_ind(5)); } ATF_TC(bpfjit_mbuf_msh); ATF_TC_HEAD(bpfjit_mbuf_msh, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LDX+BPF_B+BPF_MSH " "loads bytes from mbuf correctly"); } ATF_TC_BODY(bpfjit_mbuf_msh, tc) { RZ(rump_init()); ATF_CHECK(test_msh(0)); ATF_CHECK(test_msh(1)); ATF_CHECK(test_msh(2)); ATF_CHECK(test_msh(3)); ATF_CHECK(test_msh(4)); ATF_CHECK(test_msh(5)); } ATF_TC(bpfjit_mbuf_ldb_abs_overflow); ATF_TC_HEAD(bpfjit_mbuf_ldb_abs_overflow, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_ABS " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldb_abs_overflow, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_abs_overflow(0)); ATF_CHECK(test_ldb_abs_overflow(1)); ATF_CHECK(test_ldb_abs_overflow(2)); ATF_CHECK(test_ldb_abs_overflow(3)); ATF_CHECK(test_ldb_abs_overflow(4)); ATF_CHECK(test_ldb_abs_overflow(5)); } ATF_TC(bpfjit_mbuf_ldh_abs_overflow); ATF_TC_HEAD(bpfjit_mbuf_ldh_abs_overflow, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_ABS " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldh_abs_overflow, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_abs_overflow(0)); ATF_CHECK(test_ldh_abs_overflow(1)); ATF_CHECK(test_ldh_abs_overflow(2)); ATF_CHECK(test_ldh_abs_overflow(3)); ATF_CHECK(test_ldh_abs_overflow(4)); ATF_CHECK(test_ldh_abs_overflow(5)); } ATF_TC(bpfjit_mbuf_ldw_abs_overflow); ATF_TC_HEAD(bpfjit_mbuf_ldw_abs_overflow, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_ABS " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldw_abs_overflow, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_abs_overflow(0)); ATF_CHECK(test_ldw_abs_overflow(1)); ATF_CHECK(test_ldw_abs_overflow(2)); ATF_CHECK(test_ldw_abs_overflow(3)); ATF_CHECK(test_ldw_abs_overflow(4)); ATF_CHECK(test_ldw_abs_overflow(5)); } ATF_TC(bpfjit_mbuf_ldb_ind_overflow1); ATF_TC_HEAD(bpfjit_mbuf_ldb_ind_overflow1, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldb_ind_overflow1, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_ind_overflow1(0)); ATF_CHECK(test_ldb_ind_overflow1(1)); ATF_CHECK(test_ldb_ind_overflow1(2)); ATF_CHECK(test_ldb_ind_overflow1(3)); ATF_CHECK(test_ldb_ind_overflow1(4)); ATF_CHECK(test_ldb_ind_overflow1(5)); } ATF_TC(bpfjit_mbuf_ldb_ind_overflow2); ATF_TC_HEAD(bpfjit_mbuf_ldb_ind_overflow2, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldb_ind_overflow2, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_ind_overflow2(0)); ATF_CHECK(test_ldb_ind_overflow2(1)); ATF_CHECK(test_ldb_ind_overflow2(2)); ATF_CHECK(test_ldb_ind_overflow2(3)); ATF_CHECK(test_ldb_ind_overflow2(4)); ATF_CHECK(test_ldb_ind_overflow2(5)); } ATF_TC(bpfjit_mbuf_ldb_ind_overflow3); ATF_TC_HEAD(bpfjit_mbuf_ldb_ind_overflow3, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_B+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldb_ind_overflow3, tc) { RZ(rump_init()); ATF_CHECK(test_ldb_ind_overflow3(0)); ATF_CHECK(test_ldb_ind_overflow3(1)); ATF_CHECK(test_ldb_ind_overflow3(2)); ATF_CHECK(test_ldb_ind_overflow3(3)); ATF_CHECK(test_ldb_ind_overflow3(4)); ATF_CHECK(test_ldb_ind_overflow3(5)); } ATF_TC(bpfjit_mbuf_ldh_ind_overflow1); ATF_TC_HEAD(bpfjit_mbuf_ldh_ind_overflow1, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldh_ind_overflow1, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_ind_overflow1(0)); ATF_CHECK(test_ldh_ind_overflow1(1)); ATF_CHECK(test_ldh_ind_overflow1(2)); ATF_CHECK(test_ldh_ind_overflow1(3)); ATF_CHECK(test_ldh_ind_overflow1(4)); ATF_CHECK(test_ldh_ind_overflow1(5)); } ATF_TC(bpfjit_mbuf_ldh_ind_overflow2); ATF_TC_HEAD(bpfjit_mbuf_ldh_ind_overflow2, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldh_ind_overflow2, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_ind_overflow2(0)); ATF_CHECK(test_ldh_ind_overflow2(1)); ATF_CHECK(test_ldh_ind_overflow2(2)); ATF_CHECK(test_ldh_ind_overflow2(3)); ATF_CHECK(test_ldh_ind_overflow2(4)); ATF_CHECK(test_ldh_ind_overflow2(5)); } ATF_TC(bpfjit_mbuf_ldh_ind_overflow3); ATF_TC_HEAD(bpfjit_mbuf_ldh_ind_overflow3, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_H+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldh_ind_overflow3, tc) { RZ(rump_init()); ATF_CHECK(test_ldh_ind_overflow3(0)); ATF_CHECK(test_ldh_ind_overflow3(1)); ATF_CHECK(test_ldh_ind_overflow3(2)); ATF_CHECK(test_ldh_ind_overflow3(3)); ATF_CHECK(test_ldh_ind_overflow3(4)); ATF_CHECK(test_ldh_ind_overflow3(5)); } ATF_TC(bpfjit_mbuf_ldw_ind_overflow1); ATF_TC_HEAD(bpfjit_mbuf_ldw_ind_overflow1, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldw_ind_overflow1, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_ind_overflow1(0)); ATF_CHECK(test_ldw_ind_overflow1(1)); ATF_CHECK(test_ldw_ind_overflow1(2)); ATF_CHECK(test_ldw_ind_overflow1(3)); ATF_CHECK(test_ldw_ind_overflow1(4)); ATF_CHECK(test_ldw_ind_overflow1(5)); } ATF_TC(bpfjit_mbuf_ldw_ind_overflow2); ATF_TC_HEAD(bpfjit_mbuf_ldw_ind_overflow2, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldw_ind_overflow2, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_ind_overflow2(0)); ATF_CHECK(test_ldw_ind_overflow2(1)); ATF_CHECK(test_ldw_ind_overflow2(2)); ATF_CHECK(test_ldw_ind_overflow2(3)); ATF_CHECK(test_ldw_ind_overflow2(4)); ATF_CHECK(test_ldw_ind_overflow2(5)); } ATF_TC(bpfjit_mbuf_ldw_ind_overflow3); ATF_TC_HEAD(bpfjit_mbuf_ldw_ind_overflow3, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LD+BPF_W+BPF_IND " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_ldw_ind_overflow3, tc) { RZ(rump_init()); ATF_CHECK(test_ldw_ind_overflow3(0)); ATF_CHECK(test_ldw_ind_overflow3(1)); ATF_CHECK(test_ldw_ind_overflow3(2)); ATF_CHECK(test_ldw_ind_overflow3(3)); ATF_CHECK(test_ldw_ind_overflow3(4)); ATF_CHECK(test_ldw_ind_overflow3(5)); } ATF_TC(bpfjit_mbuf_msh_overflow); ATF_TC_HEAD(bpfjit_mbuf_msh_overflow, tc) { atf_tc_set_md_var(tc, "descr", "Check that BPF_LDX+BPF_B+BPF_MSH " "with out-of-bounds index aborts a filter program"); } ATF_TC_BODY(bpfjit_mbuf_msh_overflow, tc) { RZ(rump_init()); ATF_CHECK(test_msh_overflow(0)); ATF_CHECK(test_msh_overflow(1)); ATF_CHECK(test_msh_overflow(2)); ATF_CHECK(test_msh_overflow(3)); ATF_CHECK(test_msh_overflow(4)); ATF_CHECK(test_msh_overflow(5)); } ATF_TP_ADD_TCS(tp) { /* * For every new test please also add a similar test * to ../../net/bpf/t_mbuf.c */ ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldb_abs); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldh_abs); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldw_abs); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldb_ind); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldh_ind); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldw_ind); ATF_TP_ADD_TC(tp, bpfjit_mbuf_msh); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldb_abs_overflow); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldh_abs_overflow); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldw_abs_overflow); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldb_ind_overflow1); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldb_ind_overflow2); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldb_ind_overflow3); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldh_ind_overflow1); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldh_ind_overflow2); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldh_ind_overflow3); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldw_ind_overflow1); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldw_ind_overflow2); ATF_TP_ADD_TC(tp, bpfjit_mbuf_ldw_ind_overflow3); ATF_TP_ADD_TC(tp, bpfjit_mbuf_msh_overflow); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/carp/t_basic.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/carp/t_basic.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/carp/t_basic.c (revision 312126) @@ -1,221 +1,221 @@ -/* $NetBSD: t_basic.c,v 1.5 2011/06/26 13:13:31 christos Exp $ */ +/* $NetBSD: t_basic.c,v 1.6 2017/01/13 21:30:42 christos 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 #ifndef lint -__RCSID("$NetBSD: t_basic.c,v 1.5 2011/06/26 13:13:31 christos Exp $"); +__RCSID("$NetBSD: t_basic.c,v 1.6 2017/01/13 21:30:42 christos Exp $"); #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../config/netconfig.c" -#include "../../h_macros.h" +#include "h_macros.h" static bool oknow = false; static void sighnd(int sig) { ATF_REQUIRE_EQ(sig, SIGCHLD); if (oknow) return; atf_tc_fail("child died unexpectedly"); } ATF_TC(handover); ATF_TC_HEAD(handover, tc) { atf_tc_set_md_var(tc, "descr", "check that carp handover works if " "the master dies"); } #define THEBUS "buuuuuuus,etherbus" static void child(bool master) { char ifname[IFNAMSIZ]; struct carpreq cr; struct ifreq ifr; const char *carpif; int s; /* helps reading carp debug output */ if (master) carpif = "carp0"; else carpif = "carp1"; /* * Should use sysctl, bug debug is dabug. */ { //extern int rumpns_carp_opts[]; /* XXX */ //rumpns_carp_opts[CARPCTL_LOG] = 1; } rump_init(); memset(&ifr, 0, sizeof(ifr)); strlcpy(ifr.ifr_name, carpif, sizeof(ifr.ifr_name)); RL(s = rump_sys_socket(PF_INET, SOCK_DGRAM, 0)); RL(rump_sys_ioctl(s, SIOCIFCREATE, &ifr)); netcfg_rump_makeshmif(THEBUS, ifname); if (master) netcfg_rump_if(ifname, "10.1.1.1", "255.255.255.0"); else netcfg_rump_if(ifname, "10.1.1.2", "255.255.255.0"); /* configure the carp interface */ ifr.ifr_data = &cr; RL(rump_sys_ioctl(s, SIOCGVH, &ifr)); strlcpy(cr.carpr_carpdev, ifname, sizeof(cr.carpr_carpdev)); cr.carpr_vhid = 175; if (master) cr.carpr_advskew = 0; else cr.carpr_advskew = 200; cr.carpr_advbase = 1; strcpy((char *)cr.carpr_key, "s3cret"); RL(rump_sys_ioctl(s, SIOCSVH, &ifr)); netcfg_rump_if(carpif, "10.1.1.100", "255.255.255.0"); /* tassa pause()en enka muuta voi */ pause(); } ATF_TC_BODY(handover, tc) { char ifname[IFNAMSIZ]; pid_t mpid, cpid; int i, status; signal(SIGCHLD, sighnd); /* fork master */ switch (mpid = fork()) { case -1: atf_tc_fail_errno("fork failed"); /*NOTREACHED*/ case 0: child(true); /*NOTREACHED*/ default: break; } usleep(500000); /* fork backup */ switch (cpid = fork()) { case -1: kill(mpid, SIGKILL); atf_tc_fail_errno("fork failed"); /*NOTREACHED*/ case 0: child(false); /*NOTREACHED*/ default: break; } usleep(500000); rump_init(); netcfg_rump_makeshmif(THEBUS, ifname); netcfg_rump_if(ifname, "10.1.1.240", "255.255.255.0"); /* check that the primary addresses are up */ ATF_REQUIRE_EQ(netcfg_rump_pingtest("10.1.1.1", 1000), true); ATF_REQUIRE_EQ(netcfg_rump_pingtest("10.1.1.2", 1000), true); /* give carp a while to croak */ sleep(4); /* check that the shared IP works */ ATF_REQUIRE_EQ(netcfg_rump_pingtest("10.1.1.100", 500), true); /* KILLING SPREE */ oknow = true; kill(mpid, SIGKILL); wait(&status); usleep(10000); /* just in case */ oknow = false; /* check that primary is now dead */ ATF_REQUIRE_EQ(netcfg_rump_pingtest("10.1.1.1", 100), false); /* do it in installments. carp will cluck meanwhile */ for (i = 0; i < 5; i++) { if (netcfg_rump_pingtest("10.1.1.100", 1000) == true) break; } if (i == 5) atf_tc_fail("failed to failover"); /* to kill the child */ oknow = true; kill(cpid, SIGKILL); /* clean & done */ } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, handover); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/config/netconfig.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/config/netconfig.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/config/netconfig.c (revision 312126) @@ -1,231 +1,231 @@ -/* $NetBSD: netconfig.c,v 1.8 2013/07/03 19:13:33 pooka Exp $ */ +/* $NetBSD: netconfig.c,v 1.9 2017/01/13 21:30:42 christos 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 #ifndef lint -__RCSID("$NetBSD: netconfig.c,v 1.8 2013/07/03 19:13:33 pooka Exp $"); +__RCSID("$NetBSD: netconfig.c,v 1.9 2017/01/13 21:30:42 christos Exp $"); #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" int noatf; static void __unused netcfg_rump_makeshmif(const char *busname, char *ifname) { int rv, ifnum; if ((rv = rump_pub_shmif_create(busname, &ifnum)) != 0) { if (noatf) err(1, "makeshmif: rump_pub_shmif_create %d", rv); else atf_tc_fail("makeshmif: rump_pub_shmif_create %d", rv); } sprintf(ifname, "shmif%d", ifnum); } static void __unused netcfg_rump_if(const char *ifname, const char *addr, const char *mask) { struct ifaliasreq ia; struct sockaddr_in *sin; in_addr_t inaddr, inmask; int s, rv; s = -1; if ((s = rump_sys_socket(PF_INET, SOCK_DGRAM, 0)) < 0) { if (noatf) err(1, "if config socket"); else atf_tc_fail_errno("if config socket"); } inaddr = inet_addr(addr); inmask = inet_addr(mask); /* Address */ memset(&ia, 0, sizeof(ia)); strcpy(ia.ifra_name, ifname); sin = (struct sockaddr_in *)&ia.ifra_addr; sin->sin_family = AF_INET; sin->sin_len = sizeof(struct sockaddr_in); sin->sin_addr.s_addr = inaddr; /* Netmask */ sin = (struct sockaddr_in *)&ia.ifra_mask; sin->sin_family = AF_INET; sin->sin_len = sizeof(struct sockaddr_in); sin->sin_addr.s_addr = inmask; /* Broadcast address */ sin = (struct sockaddr_in *)&ia.ifra_broadaddr; sin->sin_family = AF_INET; sin->sin_len = sizeof(struct sockaddr_in); sin->sin_addr.s_addr = inaddr | ~inmask; rv = rump_sys_ioctl(s, SIOCAIFADDR, &ia); if (rv == -1) { if (noatf) err(1, "SIOCAIFADDR"); else atf_tc_fail_errno("SIOCAIFADDR"); } rump_sys_close(s); } static void __unused netcfg_rump_route(const char *dst, const char *mask, const char *gw) { size_t len; struct { struct rt_msghdr m_rtm; uint8_t m_space[512]; } m_rtmsg; #define rtm m_rtmsg.m_rtm uint8_t *bp = m_rtmsg.m_space; struct sockaddr_in sinstore; int s, rv; s = rump_sys_socket(PF_ROUTE, SOCK_RAW, 0); if (s == -1) { if (noatf) err(1, "routing socket"); else atf_tc_fail_errno("routing socket"); } memset(&m_rtmsg, 0, sizeof(m_rtmsg)); rtm.rtm_type = RTM_ADD; rtm.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC; rtm.rtm_version = RTM_VERSION; rtm.rtm_seq = 2; rtm.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK; /* dst */ memset(&sinstore, 0, sizeof(sinstore)); sinstore.sin_family = AF_INET; sinstore.sin_len = sizeof(sinstore); sinstore.sin_addr.s_addr = inet_addr(dst); memcpy(bp, &sinstore, sizeof(sinstore)); bp += sizeof(sinstore); /* gw */ memset(&sinstore, 0, sizeof(sinstore)); sinstore.sin_family = AF_INET; sinstore.sin_len = sizeof(sinstore); sinstore.sin_addr.s_addr = inet_addr(gw); memcpy(bp, &sinstore, sizeof(sinstore)); bp += sizeof(sinstore); /* netmask */ memset(&sinstore, 0, sizeof(sinstore)); sinstore.sin_family = AF_INET; sinstore.sin_len = sizeof(sinstore); sinstore.sin_addr.s_addr = inet_addr(mask); memcpy(bp, &sinstore, sizeof(sinstore)); bp += sizeof(sinstore); len = bp - (uint8_t *)&m_rtmsg; rtm.rtm_msglen = len; rv = rump_sys_write(s, &m_rtmsg, len); if (rv != (int)len) { if (noatf) err(1, "write routing message"); else atf_tc_fail_errno("write routing message"); } rump_sys_close(s); } static bool __unused netcfg_rump_pingtest(const char *dst, int ms_timo) { struct timeval tv; struct sockaddr_in sin; struct icmp icmp; socklen_t slen; int s; bool rv = false; s = rump_sys_socket(PF_INET, SOCK_RAW, IPPROTO_ICMP); if (s == -1) return false; tv.tv_sec = ms_timo / 1000; tv.tv_usec = 1000 * (ms_timo % 1000); if (rump_sys_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) goto out; memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr(dst); memset(&icmp, 0, sizeof(icmp)); icmp.icmp_type = ICMP_ECHO; icmp.icmp_id = htons(37); icmp.icmp_cksum = htons(0xf7da); /* precalc */ slen = sizeof(sin); if (rump_sys_sendto(s, &icmp, sizeof(icmp), 0, (struct sockaddr *)&sin, slen) == -1) { goto out; } if (rump_sys_recvfrom(s, &icmp, sizeof(icmp), 0, (struct sockaddr *)&sin, &slen) == -1) goto out; rv = true; out: rump_sys_close(s); return rv; } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/icmp/t_forward.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/icmp/t_forward.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/icmp/t_forward.c (revision 312126) @@ -1,169 +1,169 @@ -/* $NetBSD: t_forward.c,v 1.9 2015/02/26 13:03:21 martin Exp $ */ +/* $NetBSD: t_forward.c,v 1.10 2017/01/13 21:30:42 christos 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 #ifndef lint -__RCSID("$NetBSD: t_forward.c,v 1.9 2015/02/26 13:03:21 martin Exp $"); +__RCSID("$NetBSD: t_forward.c,v 1.10 2017/01/13 21:30:42 christos Exp $"); #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #include "../config/netconfig.c" /* * Since our maxttl is in our private namespace, we don't need raw packet * construction like traceroute(8) -- we can just use the global maxttl. */ static void sendttl(void) { struct sockaddr_in sin; char payload[1024]; char ifname[IFNAMSIZ]; int mib[4] = { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_DEFTTL }; int nv; int s; netcfg_rump_makeshmif("bus1", ifname); netcfg_rump_if(ifname, "1.0.0.1", "255.255.255.0"); netcfg_rump_route("0.0.0.0", "0.0.0.0", "1.0.0.2"); /* default router */ /* set global ttl to 1 */ nv = 1; if (rump_sys___sysctl(mib, 4, NULL, NULL, &nv, sizeof(nv)) == -1) atf_tc_fail_errno("set ttl"); s = rump_sys_socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) atf_tc_fail_errno("create send socket"); memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_port = htons(33434); sin.sin_addr.s_addr = inet_addr("9.9.9.9"); /* send udp datagram with ttl == 1 */ if (rump_sys_sendto(s, payload, sizeof(payload), 0, (struct sockaddr *)&sin, sizeof(sin)) == -1) atf_tc_fail_errno("sendto"); } static void router(void) { int mib[4] = { CTL_NET, PF_INET, IPPROTO_ICMP, ICMPCTL_RETURNDATABYTES }; char ifname[IFNAMSIZ]; int nv; /* set returndatabytes to 200 */ nv = 200; if (rump_sys___sysctl(mib, 4, NULL, NULL, &nv, sizeof(nv)) == -1) atf_tc_fail_errno("sysctl returndatabytes"); netcfg_rump_makeshmif("bus1", ifname); netcfg_rump_if(ifname, "1.0.0.2", "255.255.255.0"); /* * Wait for parent to send us the data and for us to have * a chance to process it. */ sleep(1); exit(0); } ATF_TC(returndatabytes); ATF_TC_HEAD(returndatabytes, tc) { atf_tc_set_md_var(tc, "descr", "icmp.returndatabytes with certain " "packets can cause kernel panic (PR kern/43548)"); atf_tc_set_md_var(tc, "timeout", "20"); /* just in case */ } ATF_TC_BODY(returndatabytes, tc) { pid_t cpid; int status; cpid = fork(); rump_init(); switch (cpid) { case -1: atf_tc_fail_errno("fork failed"); case 0: router(); break; default: sendttl(); if (wait(&status) == -1) atf_tc_fail_errno("wait"); if (WIFEXITED(status)) { if (WEXITSTATUS(status)) atf_tc_fail("child exited with status %d", WEXITSTATUS(status)); } else { atf_tc_fail("child died"); } } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, returndatabytes); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/icmp/t_ping.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/icmp/t_ping.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/icmp/t_ping.c (revision 312126) @@ -1,438 +1,438 @@ -/* $NetBSD: t_ping.c,v 1.16 2015/02/26 13:06:10 martin Exp $ */ +/* $NetBSD: t_ping.c,v 1.17 2017/01/13 21:30:42 christos 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 #ifndef lint -__RCSID("$NetBSD: t_ping.c,v 1.16 2015/02/26 13:06:10 martin Exp $"); +__RCSID("$NetBSD: t_ping.c,v 1.17 2017/01/13 21:30:42 christos Exp $"); #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" #include "../config/netconfig.c" ATF_TC(simpleping); ATF_TC_HEAD(simpleping, tc) { atf_tc_set_md_var(tc, "descr", "check that kernel responds to ping"); atf_tc_set_md_var(tc, "timeout", "20"); } ATF_TC_BODY(simpleping, tc) { char ifname[IFNAMSIZ]; pid_t cpid; bool win, win2; char token; int channel[2]; RL(pipe(channel)); cpid = fork(); rump_init(); netcfg_rump_makeshmif("but-can-i-buy-your-ether-bus", ifname); switch (cpid) { case -1: atf_tc_fail_errno("fork failed"); case 0: netcfg_rump_if(ifname, "1.1.1.10", "255.255.255.0"); close(channel[0]); ATF_CHECK(write(channel[1], "U", 1) == 1); close(channel[1]); pause(); break; default: break; } close(channel[1]); ATF_CHECK(read(channel[0], &token, 1) == 1 && token == 'U'); close(channel[0]); netcfg_rump_if(ifname, "1.1.1.20", "255.255.255.0"); /* * The beauty of shmif is that we don't have races here. */ win = netcfg_rump_pingtest("1.1.1.10", 500); win2 = netcfg_rump_pingtest("1.1.1.30", 500); kill(cpid, SIGKILL); if (!win) atf_tc_fail("ping failed"); if (win2) atf_tc_fail("non-existent host responded"); } ATF_TC(floodping); ATF_TC_HEAD(floodping, tc) { atf_tc_set_md_var(tc, "descr", "see how kernel responds to floodping"); } /* why the hell isn't this available in userspace??? */ static uint16_t in_cksum(void *data, size_t len) { uint16_t *buf = data; unsigned sum; for (sum = 0; len > 1; len -= 2) sum += *buf++; if (len) sum += *(uint8_t *)buf; sum = (sum >> 16) + (sum & 0xffff); sum += (sum >> 16); return ~sum; } static int doping(const char *target, int loops, u_int pktsize) { union { char buf[IP_MAXPACKET - sizeof(struct ip)]; struct icmp i; /* ensure proper alignment */ } sndbuf; char recvbuf[IP_MAXPACKET]; struct sockaddr_in dst, pingee; struct icmp *icmp; socklen_t slen; ssize_t n; int loop, succ; int x, xnon, s; RL(s = rump_sys_socket(PF_INET, SOCK_RAW, IPPROTO_ICMP)); RL(x = rump_sys_fcntl(s, F_GETFL, 0)); xnon = x | O_NONBLOCK; memset(&dst, 0, sizeof(dst)); dst.sin_len = sizeof(dst); dst.sin_family = AF_INET; dst.sin_addr.s_addr = inet_addr(target); icmp = (struct icmp *)&sndbuf; memset(icmp, 0, sizeof(*icmp)); icmp->icmp_type = ICMP_ECHO; icmp->icmp_id = htons(37); if (pktsize < sizeof(*icmp)) pktsize = sizeof(*icmp); if (pktsize > sizeof(sndbuf.buf)) pktsize = sizeof(sndbuf.buf); RL(rump_sys_setsockopt(s, SOL_SOCKET, SO_SNDBUF, &pktsize, sizeof(pktsize))); RL(rump_sys_setsockopt(s, SOL_SOCKET, SO_RCVBUF, &pktsize, sizeof(pktsize))); slen = sizeof(pingee); succ = 0; for (loop = 0; loop < loops; loop++) { RL(rump_sys_fcntl(s, F_SETFL, x)); icmp->icmp_seq = htons(loop); icmp->icmp_cksum = 0; icmp->icmp_cksum = in_cksum(icmp, pktsize); RL(rump_sys_sendto(s, icmp, pktsize, 0, (struct sockaddr *)&dst, sizeof(dst))); RL(rump_sys_fcntl(s, F_SETFL, xnon)); while ((n = rump_sys_recvfrom(s, recvbuf, sizeof(recvbuf), 0, (struct sockaddr *)&pingee, &slen)) > 0) { succ++; } if (n == -1 && errno == EAGAIN) continue; atf_tc_fail_errno("recv failed"); } rump_sys_close(s); return succ; } #define LOOPS 10000 ATF_TC_BODY(floodping, tc) { char ifname[IFNAMSIZ]; pid_t cpid; int succ; cpid = fork(); rump_init(); netcfg_rump_makeshmif("thank-you-driver-for-getting-me-here", ifname); switch (cpid) { case -1: atf_tc_fail_errno("fork failed"); case 0: netcfg_rump_if(ifname, "1.1.1.10", "255.255.255.0"); pause(); break; default: break; } netcfg_rump_if(ifname, "1.1.1.20", "255.255.255.0"); succ = doping("1.1.1.10", LOOPS, 56); printf("got %d/%d\n", succ, LOOPS); kill(cpid, SIGKILL); } ATF_TC(floodping2); ATF_TC_HEAD(floodping2, tc) { atf_tc_set_md_var(tc, "descr", "two hosts floodpinging each other"); } ATF_TC_BODY(floodping2, tc) { char ifname[IFNAMSIZ]; pid_t cpid; int succ; cpid = fork(); rump_init(); netcfg_rump_makeshmif("floodping2", ifname); switch (cpid) { case -1: atf_tc_fail_errno("fork failed"); case 0: netcfg_rump_if(ifname, "1.1.1.10", "255.255.255.0"); succ = doping("1.1.1.20", LOOPS, 56); break; default: netcfg_rump_if(ifname, "1.1.1.20", "255.255.255.0"); succ = doping("1.1.1.10", LOOPS, 56); break; } printf("got %d/%d\n", succ, LOOPS); } ATF_TC(pingsize); ATF_TC_HEAD(pingsize, tc) { atf_tc_set_md_var(tc, "descr", "ping with packets min <= size <= max"); } ATF_TC_BODY(pingsize, tc) { char ifname[IFNAMSIZ]; pid_t cpid; int succ, i; cpid = fork(); rump_init(); netcfg_rump_makeshmif("jippikaiee", ifname); switch (cpid) { case -1: atf_tc_fail_errno("fork failed"); case 0: netcfg_rump_if(ifname, "1.1.1.10", "255.255.255.0"); pause(); break; default: break; } netcfg_rump_if(ifname, "1.1.1.20", "255.255.255.0"); succ = 0; /* small sizes */ for (i = 0 ; i < IP_MAXPACKET - 60000; i++) succ += doping("1.1.1.10", 1, i); /* medium sizes */ for (i = IP_MAXPACKET - 60000; i < IP_MAXPACKET - 100; i += 1000) succ += doping("1.1.1.10", 1, i); /* big sizes */ for (i = IP_MAXPACKET - 100; i < IP_MAXPACKET; i += 10) succ += doping("1.1.1.10", 1, i); printf("got %d/%d\n", succ, IP_MAXPACKET); kill(cpid, SIGKILL); } ATF_TC(ping_of_death); ATF_TC_HEAD(ping_of_death, tc) { atf_tc_set_md_var(tc, "descr", "send a \"ping of death\""); atf_tc_set_md_var(tc, "timeout", "20"); } ATF_TC_BODY(ping_of_death, tc) { char data[1500]; struct sockaddr_in dst; struct ip *ip; struct icmp *icmp; char ifname[IFNAMSIZ]; pid_t cpid; size_t tot, frag; int s, x, loop; cpid = fork(); rump_init(); netcfg_rump_makeshmif("jippikaiee", ifname); switch (cpid) { case -1: atf_tc_fail_errno("fork failed"); case 0: /* wait until we receive a too long IP packet */ for (loop = 0;; loop++) { uint64_t ipstat[IP_NSTATS]; size_t arglen; int mib[4]; if (loop == 1) netcfg_rump_if(ifname, "1.1.1.10", "255.255.255.0"); mib[0] = CTL_NET; mib[1] = PF_INET; mib[2] = IPPROTO_IP; mib[3] = IPCTL_STATS; arglen = sizeof(ipstat); RL(rump_sys___sysctl(mib, 4, &ipstat, &arglen, NULL, 0)); if (loop == 0 && ipstat[IP_STAT_TOOLONG] != 0) _exit(1); if (ipstat[IP_STAT_TOOLONG]) break; usleep(10000); } _exit(0); break; default: break; } netcfg_rump_if(ifname, "1.1.1.20", "255.255.255.0"); RL(s = rump_sys_socket(PF_INET, SOCK_RAW, 0)); x = 1; RL(rump_sys_setsockopt(s, IPPROTO_IP, IP_HDRINCL, &x, sizeof(x))); memset(&dst, 0, sizeof(dst)); dst.sin_len = sizeof(dst); dst.sin_family = AF_INET; dst.sin_addr.s_addr = inet_addr("1.1.1.10"); /* construct packet */ memset(data, 0, sizeof(data)); ip = (struct ip *)data; ip->ip_v = 4; ip->ip_hl = sizeof(*ip) >> 2; ip->ip_p = IPPROTO_ICMP; ip->ip_ttl = IPDEFTTL; ip->ip_dst = dst.sin_addr; ip->ip_id = 1234; icmp = (struct icmp *)(ip + 1); icmp->icmp_type = ICMP_ECHO; icmp->icmp_cksum = in_cksum(icmp, sizeof(*icmp)); for (;;) { int status; /* resolve arp before sending raw stuff */ netcfg_rump_pingtest("1.1.1.10", 1); for (tot = 0; tot < 65538 - sizeof(*ip); tot += (frag - sizeof(*ip))) { frag = MIN(65538 - tot, sizeof(data)); ip->ip_off = tot >> 3; assert((size_t)ip->ip_off << 3 == tot); ip->ip_len = frag; if (frag == sizeof(data)) { ip->ip_off |= IP_MF; } RL(rump_sys_sendto(s, data, frag, 0, (struct sockaddr *)&dst, sizeof(dst))); } if (waitpid(-1, &status, WNOHANG) > 0) { if (WIFEXITED(status) && WEXITSTATUS(status) == 0) break; atf_tc_fail("child did not exit clean"); } usleep(10000); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, simpleping); ATF_TP_ADD_TC(tp, floodping); ATF_TP_ADD_TC(tp, floodping2); ATF_TP_ADD_TC(tp, pingsize); ATF_TP_ADD_TC(tp, ping_of_death); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/if_loop/t_pr.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/if_loop/t_pr.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/if_loop/t_pr.c (revision 312126) @@ -1,229 +1,229 @@ -/* $NetBSD: t_pr.c,v 1.7 2012/03/18 09:46:50 jruoho Exp $ */ +/* $NetBSD: t_pr.c,v 1.8 2017/01/13 21:30:42 christos 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 #ifndef lint -__RCSID("$NetBSD: t_pr.c,v 1.7 2012/03/18 09:46:50 jruoho Exp $"); +__RCSID("$NetBSD: t_pr.c,v 1.8 2017/01/13 21:30:42 christos Exp $"); #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../config/netconfig.c" -#include "../../h_macros.h" +#include "h_macros.h" /* * Prepare rump, configure interface and route to cause fragmentation */ static void setup(void) { char ifname[IFNAMSIZ]; struct { struct rt_msghdr m_rtm; struct sockaddr_in m_sin; } m_rtmsg; #define rtm m_rtmsg.m_rtm #define rsin m_rtmsg.m_sin struct ifreq ifr; int s; rump_init(); /* first, config lo0 & route */ strcpy(ifname, "lo0"); netcfg_rump_if(ifname, "127.0.0.1", "255.0.0.0"); netcfg_rump_route("127.0.0.1", "255.0.0.0", "127.0.0.1"); if ((s = rump_sys_socket(PF_ROUTE, SOCK_RAW, 0)) == -1) atf_tc_fail_errno("routing socket"); /* * set MTU for interface so that route MTU doesn't * get overridden by it. */ memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, "lo0"); ifr.ifr_mtu = 1300; if (rump_sys_ioctl(s, SIOCSIFMTU, &ifr) == -1) atf_tc_fail_errno("set mtu"); /* change route MTU to 100 */ memset(&m_rtmsg, 0, sizeof(m_rtmsg)); rtm.rtm_type = RTM_CHANGE; rtm.rtm_flags = RTF_STATIC; rtm.rtm_version = RTM_VERSION; rtm.rtm_seq = 3; rtm.rtm_inits = RTV_MTU; rtm.rtm_addrs = RTA_DST; rtm.rtm_rmx.rmx_mtu = 100; rtm.rtm_msglen = sizeof(m_rtmsg); memset(&rsin, 0, sizeof(rsin)); rsin.sin_family = AF_INET; rsin.sin_len = sizeof(rsin); rsin.sin_addr.s_addr = inet_addr("127.0.0.1"); if (rump_sys_write(s, &m_rtmsg, sizeof(m_rtmsg)) != sizeof(m_rtmsg)) atf_tc_fail_errno("set route mtu"); rump_sys_close(s); } /* * Turn on checksums on loopback interfaces */ static int enable_locsums(void) { struct sysctlnode q, ans[256]; int mib[5], enable; size_t alen; unsigned i; mib[0] = CTL_NET; mib[1] = PF_INET; mib[2] = IPPROTO_IP; mib[3] = CTL_QUERY; alen = sizeof(ans); memset(&q, 0, sizeof(q)); q.sysctl_flags = SYSCTL_VERSION; if (rump_sys___sysctl(mib, 4, ans, &alen, &q, sizeof(q)) == -1) return -1; for (i = 0; i < __arraycount(ans); i++) if (strcmp("do_loopback_cksum", ans[i].sysctl_name) == 0) break; if (i == __arraycount(ans)) { errno = ENOENT; return -1; } mib[3] = ans[i].sysctl_num; enable = 1; if (rump_sys___sysctl(mib, 4, NULL, NULL, &enable, sizeof(enable)) == -1) return errno; return 0; } ATF_TC(loopmtu); ATF_TC_HEAD(loopmtu, tc) { atf_tc_set_md_var(tc, "descr", "test lo0 fragmentation (PR kern/43664)"); } ATF_TC_BODY(loopmtu, tc) { struct sockaddr_in sin; char data[2000]; int s; setup(); /* open raw socket */ s = rump_sys_socket(PF_INET, SOCK_RAW, 0); if (s == -1) atf_tc_fail_errno("raw socket"); /* then, send data */ memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_len = sizeof(sin); sin.sin_port = htons(12345); sin.sin_addr.s_addr = inet_addr("127.0.0.1"); if (rump_sys_sendto(s, data, sizeof(data), 0, (struct sockaddr *)&sin, sizeof(sin)) == -1) atf_tc_fail_errno("sendto failed"); } ATF_TC(loopmtu_csum); ATF_TC_HEAD(loopmtu_csum, tc) { atf_tc_set_md_var(tc, "descr", "test lo0 fragmentation with checksums (PR kern/43664)"); } ATF_TC_BODY(loopmtu_csum, tc) { struct sockaddr_in sin; char data[2000]; int s; setup(); ATF_CHECK(enable_locsums() == 0); /* open raw socket */ s = rump_sys_socket(PF_INET, SOCK_RAW, 0); if (s == -1) atf_tc_fail_errno("raw socket"); /* then, send data */ memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_len = sizeof(sin); sin.sin_port = htons(12345); sin.sin_addr.s_addr = inet_addr("127.0.0.1"); if (rump_sys_sendto(s, data, sizeof(data), 0, (struct sockaddr *)&sin, sizeof(sin)) == -1) atf_tc_fail_errno("sendto failed"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, loopmtu); ATF_TP_ADD_TC(tp, loopmtu_csum); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/if_tun/t_tun.sh =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/if_tun/t_tun.sh (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/if_tun/t_tun.sh (revision 312126) @@ -0,0 +1,138 @@ +# $NetBSD: t_tun.sh,v 1.4 2016/11/07 05:25:37 ozaki-r Exp $ +# +# Copyright (c) 2016 Internet Initiative Japan 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. +# + +RUMP_FLAGS="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6" +RUMP_FLAGS="$RUMP_FLAGS -lrumpnet_shmif -lrumpnet_tun -lrumpdev" + +BUS=bus +SOCK_LOCAL=unix://commsock1 +SOCK_REMOTE=unix://commsock2 +IP_LOCAL=10.0.0.1 +IP_REMOTE=10.0.0.2 + +DEBUG=${DEBUG:-true} + +atf_test_case tun_create_destroy cleanup +tun_create_destroy_head() +{ + + atf_set "descr" "tests of creation and deletion of tun interface" + atf_set "require.progs" "rump_server" +} + +tun_create_destroy_body() +{ + + atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL} + + export RUMP_SERVER=${SOCK_LOCAL} + + atf_check -s exit:0 rump.ifconfig tun0 create + atf_check -s exit:0 rump.ifconfig tun0 up + atf_check -s exit:0 rump.ifconfig tun0 down + atf_check -s exit:0 rump.ifconfig tun0 destroy +} + +tun_create_destroy_cleanup() +{ + + RUMP_SERVER=${SOCK_LOCAL} rump.halt +} + +atf_test_case tun_setup cleanup +tun_setup_head() +{ + + atf_set "descr" "tests of setting up a tunnel" + atf_set "require.progs" "rump_server" +} + +check_route_entry() +{ + local ip=$(echo $1 |sed 's/\./\\./g') + local gw=$2 + local flags=$3 + local iface=$4 + + atf_check -s exit:0 -o match:" $flags " -e ignore -x \ + "rump.netstat -rn -f inet | grep ^'$ip'" + atf_check -s exit:0 -o match:" $gw " -e ignore -x \ + "rump.netstat -rn -f inet | grep ^'$ip'" + atf_check -s exit:0 -o match:" $iface" -e ignore -x \ + "rump.netstat -rn -f inet | grep ^'$ip'" +} + +tun_setup_body() +{ + + atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL} + atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_REMOTE} + + export RUMP_SERVER=${SOCK_LOCAL} + + atf_check -s exit:0 rump.ifconfig shmif0 create + atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS + atf_check -s exit:0 rump.ifconfig shmif0 ${IP_LOCAL}/24 up + atf_check -s exit:0 rump.ifconfig -w 10 + + export RUMP_SERVER=${SOCK_REMOTE} + + atf_check -s exit:0 rump.ifconfig shmif0 create + atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS + atf_check -s exit:0 rump.ifconfig shmif0 ${IP_REMOTE}/24 up + atf_check -s exit:0 rump.ifconfig -w 10 + + export RUMP_SERVER=${SOCK_LOCAL} + atf_check -s exit:0 rump.ifconfig tun0 create + atf_check -s exit:0 rump.ifconfig tun0 ${IP_LOCAL} ${IP_REMOTE} up + atf_check -s exit:0 \ + -o match:"inet ${IP_LOCAL}/32 -> ${IP_REMOTE}" rump.ifconfig tun0 + $DEBUG && rump.netstat -nr -f inet + check_route_entry ${IP_REMOTE} ${IP_LOCAL} UH tun0 + + export RUMP_SERVER=${SOCK_REMOTE} + atf_check -s exit:0 rump.ifconfig tun0 create + atf_check -s exit:0 rump.ifconfig tun0 ${IP_REMOTE} ${IP_LOCAL} up + atf_check -s exit:0 \ + -o match:"inet ${IP_REMOTE}/32 -> ${IP_LOCAL}" rump.ifconfig tun0 + $DEBUG && rump.netstat -nr -f inet + check_route_entry ${IP_LOCAL} ${IP_REMOTE} UH tun0 +} + +tun_setup_cleanup() +{ + + RUMP_SERVER=${SOCK_LOCAL} rump.halt + RUMP_SERVER=${SOCK_REMOTE} rump.halt +} + +atf_init_test_cases() +{ + + atf_add_test_case tun_create_destroy + atf_add_test_case tun_setup +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/if_tun/t_tun.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ 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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/if_vlan/t_vlan.sh =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/if_vlan/t_vlan.sh (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/if_vlan/t_vlan.sh (revision 312126) @@ -0,0 +1,115 @@ +# $NetBSD: t_vlan.sh,v 1.1 2016/11/26 03:19:49 ozaki-r Exp $ +# +# Copyright (c) 2016 Internet Initiative Japan 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. +# + +BUS=bus +SOCK_LOCAL=unix://commsock1 +SOCK_REMOTE=unix://commsock2 +IP_LOCAL=10.0.0.1 +IP_REMOTE=10.0.0.2 + +DEBUG=${DEBUG:-false} + +atf_test_case vlan_create_destroy cleanup +vlan_create_destroy_head() +{ + + atf_set "descr" "tests of creation and deletion of vlan interface" + atf_set "require.progs" "rump_server" +} + +vlan_create_destroy_body() +{ + + rump_server_start $SOCK_LOCAL vlan + + export RUMP_SERVER=${SOCK_LOCAL} + + atf_check -s exit:0 rump.ifconfig vlan0 create + atf_check -s exit:0 rump.ifconfig vlan0 up + atf_check -s exit:0 rump.ifconfig vlan0 down + atf_check -s exit:0 rump.ifconfig vlan0 destroy +} + +vlan_create_destroy_cleanup() +{ + + $DEBUG && dump + cleanup +} + +atf_test_case vlan_basic cleanup +vlan_basic_head() +{ + + atf_set "descr" "tests of communications over vlan interfaces" + atf_set "require.progs" "rump_server" +} + +vlan_basic_body() +{ + + rump_server_start $SOCK_LOCAL vlan + rump_server_add_iface $SOCK_LOCAL shmif0 $BUS + rump_server_start $SOCK_REMOTE vlan + rump_server_add_iface $SOCK_REMOTE shmif0 $BUS + + export RUMP_SERVER=$SOCK_LOCAL + atf_check -s exit:0 rump.ifconfig shmif0 up + export RUMP_SERVER=$SOCK_REMOTE + atf_check -s exit:0 rump.ifconfig shmif0 up + + export RUMP_SERVER=$SOCK_LOCAL + atf_check -s exit:0 rump.ifconfig vlan0 create + atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0 + atf_check -s exit:0 rump.ifconfig vlan0 $IP_LOCAL/24 + atf_check -s exit:0 rump.ifconfig vlan0 up + atf_check -s exit:0 rump.ifconfig -w 10 + + export RUMP_SERVER=$SOCK_REMOTE + atf_check -s exit:0 rump.ifconfig vlan0 create + atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0 + atf_check -s exit:0 rump.ifconfig vlan0 $IP_REMOTE/24 + atf_check -s exit:0 rump.ifconfig vlan0 up + atf_check -s exit:0 rump.ifconfig -w 10 + + export RUMP_SERVER=$SOCK_LOCAL + atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP_REMOTE +} + +vlan_basic_cleanup() +{ + + $DEBUG && dump + cleanup +} + +atf_init_test_cases() +{ + + atf_add_test_case vlan_create_destroy + atf_add_test_case vlan_basic +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/if_vlan/t_vlan.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ 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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/ndp/t_ra.sh =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/ndp/t_ra.sh (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/ndp/t_ra.sh (revision 312126) @@ -1,687 +1,703 @@ -# $NetBSD: t_ra.sh,v 1.20 2017/01/11 03:15:44 ozaki-r Exp $ +# $NetBSD: t_ra.sh,v 1.24 2017/01/13 08:11:01 ozaki-r Exp $ # # Copyright (c) 2015 Internet Initiative Japan 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. # RUMPSRV=unix://r1 RUMPSRV1_2=unix://r12 RUMPCLI=unix://r2 RUMPSRV3=unix://r3 RUMPSRV4=unix://r4 IP6SRV=fc00:1::1 IP6SRV1_2=fc00:1::2 IP6SRV_PREFIX=fc00:1: IP6CLI=fc00:2::2 IP6SRV3=fc00:3::1 IP6SRV3_PREFIX=fc00:3: IP6SRV4=fc00:4::1 IP6SRV4_PREFIX=fc00:4: PIDFILE=./rump.rtadvd.pid PIDFILE1_2=./rump.rtadvd.pid12 PIDFILE3=./rump.rtadvd.pid3 PIDFILE4=./rump.rtadvd.pid4 CONFIG=./rtadvd.conf WAITTIME=2 DEBUG=${DEBUG:-true} init_server() { export RUMP_SERVER=$1 atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.forwarding=1 export LD_PRELOAD=/usr/lib/librumphijack.so atf_check -s exit:0 mkdir -p /rump/var/chroot/rtadvd unset LD_PRELOAD unset RUMP_SERVER } setup_shmif0() { local sock=$1 local IP6ADDR=$2 rump_server_add_iface $sock shmif0 bus1 export RUMP_SERVER=$sock atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6ADDR} atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig -w 10 $DEBUG && rump.ifconfig } wait_term() { local PIDFILE=${1} shift while [ -f ${PIDFILE} ] do sleep 0.2 done return 0 } create_rtadvdconfig() { cat << _EOF > ${CONFIG} shmif0:\ :mtu#1300:maxinterval#4:mininterval#3: _EOF } start_rtadvd() { local sock=$1 local pidfile=$2 export RUMP_SERVER=$sock atf_check -s exit:0 rump.rtadvd -c ${CONFIG} -p $pidfile shmif0 while [ ! -f $pidfile ]; do sleep 0.2 done unset RUMP_SERVER } check_entries() { local cli=$1 local srv=$2 local addr_prefix=$3 local mac_srv= ll_srv= ll_srv=$(get_linklocal_addr $srv shmif0) mac_srv=$(get_macaddr $srv shmif0) export RUMP_SERVER=$cli $DEBUG && dump_entries atf_check -s exit:0 -o match:'if=shmif0' rump.ndp -r atf_check -s exit:0 -o match:'advertised' rump.ndp -p atf_check -s exit:0 -o match:"${ll_srv}%shmif0 \(reachable\)" rump.ndp -p atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0 atf_check -s exit:0 \ -o match:"$ll_srv%shmif0 +$mac_srv +shmif0 +(23h59m|1d0h0m)..s S R" \ rump.ndp -n -a atf_check -s exit:0 -o match:$addr_prefix rump.ndp -n -a - atf_check -s exit:0 -o match:"$addr_prefix.+" \ + atf_check -s exit:0 \ + -o match:"$addr_prefix.+<(TENTATIVE,)?AUTOCONF>" \ rump.ifconfig shmif0 inet6 unset RUMP_SERVER } dump_entries() { echo ndp -n -a rump.ndp -n -a echo ndp -p rump.ndp -p echo ndp -r rump.ndp -r } atf_test_case ra_basic cleanup ra_basic_head() { atf_set "descr" "Tests for basic functions of router advaertisement(RA)" atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" } ra_basic_body() { rump_server_fs_start $RUMPSRV netinet6 rump_server_start $RUMPCLI netinet6 setup_shmif0 ${RUMPSRV} ${IP6SRV} init_server $RUMPSRV setup_shmif0 ${RUMPCLI} ${IP6CLI} export RUMP_SERVER=${RUMPCLI} $DEBUG && rump.ndp -n -a atf_check -s exit:0 -o match:'= 0' rump.sysctl net.inet6.ip6.accept_rtadv unset RUMP_SERVER create_rtadvdconfig start_rtadvd $RUMPSRV $PIDFILE sleep $WAITTIME export RUMP_SERVER=${RUMPCLI} atf_check -s exit:0 -o empty rump.ndp -r atf_check -s exit:0 -o not-match:'advertised' rump.ndp -p atf_check -s exit:0 -o match:'linkmtu=0' rump.ndp -n -i shmif0 atf_check -s exit:0 -o not-match:'S R' rump.ndp -n -a atf_check -s exit:0 -o not-match:'fc00:1:' rump.ndp -n -a atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6 unset RUMP_SERVER atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} export RUMP_SERVER=${RUMPCLI} atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 unset RUMP_SERVER start_rtadvd $RUMPSRV $PIDFILE sleep $WAITTIME check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} rump_server_destroy_ifaces } ra_basic_cleanup() { if [ -f ${PIDFILE} ]; then kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} fi $DEBUG && dump cleanup } atf_test_case ra_flush_prefix_entries cleanup ra_flush_prefix_entries_head() { atf_set "descr" "Tests for flushing prefixes (ndp -P)" atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" } ra_flush_prefix_entries_body() { rump_server_fs_start $RUMPSRV netinet6 rump_server_start $RUMPCLI netinet6 setup_shmif0 ${RUMPSRV} ${IP6SRV} setup_shmif0 ${RUMPCLI} ${IP6CLI} init_server $RUMPSRV create_rtadvdconfig export RUMP_SERVER=${RUMPCLI} atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 unset RUMP_SERVER start_rtadvd $RUMPSRV $PIDFILE sleep $WAITTIME check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX export RUMP_SERVER=${RUMPCLI} # Terminate rtadvd to prevent new RA messages from coming # Note that ifconfig down; kill -TERM doesn't work kill -KILL `cat ${PIDFILE}` # Flush all the entries in the prefix list atf_check -s exit:0 rump.ndp -P $DEBUG && dump_entries atf_check -s exit:0 -o match:'if=shmif0' rump.ndp -r atf_check -s exit:0 -o empty rump.ndp -p atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0 atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6 unset RUMP_SERVER rump_server_destroy_ifaces } ra_flush_prefix_entries_cleanup() { $DEBUG && dump cleanup } atf_test_case ra_flush_defrouter_entries cleanup ra_flush_defrouter_entries_head() { atf_set "descr" "Tests for flushing default routers (ndp -R)" atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" } ra_flush_defrouter_entries_body() { rump_server_fs_start $RUMPSRV netinet6 rump_server_start $RUMPCLI netinet6 setup_shmif0 ${RUMPSRV} ${IP6SRV} setup_shmif0 ${RUMPCLI} ${IP6CLI} init_server $RUMPSRV create_rtadvdconfig export RUMP_SERVER=${RUMPCLI} atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 unset RUMP_SERVER start_rtadvd $RUMPSRV $PIDFILE sleep $WAITTIME check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX export RUMP_SERVER=${RUMPCLI} # Terminate rtadvd to prevent new RA messages from coming # Note that ifconfig down; kill -TERM doesn't work kill -KILL `cat ${PIDFILE}` # Flush all the entries in the default router list atf_check -s exit:0 rump.ndp -R $DEBUG && dump_entries atf_check -s exit:0 -o empty rump.ndp -r atf_check -s exit:0 -o match:'No advertising router' rump.ndp -p atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0 atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a atf_check -s exit:0 -o match:'fc00:1:' rump.ifconfig shmif0 inet6 unset RUMP_SERVER rump_server_destroy_ifaces } ra_flush_defrouter_entries_cleanup() { $DEBUG && dump cleanup } atf_test_case ra_delete_address cleanup ra_delete_address_head() { atf_set "descr" "Tests for deleting auto-configured address" atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" } ra_delete_address_body() { rump_server_fs_start $RUMPSRV netinet6 rump_server_start $RUMPCLI netinet6 setup_shmif0 ${RUMPSRV} ${IP6SRV} setup_shmif0 ${RUMPCLI} ${IP6CLI} init_server $RUMPSRV create_rtadvdconfig export RUMP_SERVER=${RUMPCLI} atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 unset RUMP_SERVER start_rtadvd $RUMPSRV $PIDFILE sleep $WAITTIME check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX export RUMP_SERVER=${RUMPCLI} $DEBUG && rump.ifconfig shmif0 atf_check -s exit:0 rump.ifconfig shmif0 inet6 \ $(rump.ifconfig shmif0 |awk '/AUTOCONF/ {print $2}') delete unset RUMP_SERVER atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} rump_server_destroy_ifaces } ra_delete_address_cleanup() { if [ -f ${PIDFILE} ]; then kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} fi $DEBUG && dump cleanup } atf_test_case ra_multiple_routers cleanup ra_multiple_routers_head() { atf_set "descr" "Tests for multiple routers" atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" } ra_multiple_routers_body() { local n= rump_server_fs_start $RUMPSRV netinet6 rump_server_fs_start $RUMPSRV3 netinet6 rump_server_start $RUMPCLI netinet6 setup_shmif0 ${RUMPSRV} ${IP6SRV} setup_shmif0 ${RUMPSRV3} ${IP6SRV3} setup_shmif0 ${RUMPCLI} ${IP6CLI} init_server $RUMPSRV init_server $RUMPSRV3 create_rtadvdconfig export RUMP_SERVER=${RUMPCLI} atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 unset RUMP_SERVER start_rtadvd $RUMPSRV $PIDFILE start_rtadvd $RUMPSRV3 $PIDFILE3 sleep $WAITTIME check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX check_entries $RUMPCLI $RUMPSRV3 $IP6SRV3_PREFIX export RUMP_SERVER=$RUMPCLI # Two prefixes are advertised by differnt two routers n=$(rump.ndp -p |grep 'advertised by' |wc -l) atf_check_equal $n 2 unset RUMP_SERVER atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} atf_check -s exit:0 kill -TERM `cat ${PIDFILE3}` wait_term ${PIDFILE3} rump_server_destroy_ifaces } ra_multiple_routers_cleanup() { if [ -f ${PIDFILE} ]; then kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} fi if [ -f ${PIDFILE3} ]; then kill -TERM `cat ${PIDFILE3}` wait_term ${PIDFILE3} fi $DEBUG && dump cleanup } atf_test_case ra_multiple_routers_single_prefix cleanup ra_multiple_routers_single_prefix_head() { atf_set "descr" "Tests for multiple routers with a single prefix" atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" } ra_multiple_routers_single_prefix_body() { local n= rump_server_fs_start $RUMPSRV netinet6 rump_server_fs_start $RUMPSRV1_2 netinet6 rump_server_start $RUMPCLI netinet6 setup_shmif0 ${RUMPSRV} ${IP6SRV} setup_shmif0 ${RUMPSRV1_2} ${IP6SRV1_2} setup_shmif0 ${RUMPCLI} ${IP6CLI} init_server $RUMPSRV init_server $RUMPSRV1_2 create_rtadvdconfig export RUMP_SERVER=${RUMPCLI} atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 unset RUMP_SERVER start_rtadvd $RUMPSRV $PIDFILE start_rtadvd $RUMPSRV1_2 $PIDFILE1_2 sleep $WAITTIME check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX check_entries $RUMPCLI $RUMPSRV1_2 $IP6SRV_PREFIX export RUMP_SERVER=$RUMPCLI # One prefix is advertised by differnt two routers n=$(rump.ndp -p |grep 'advertised by' |wc -l) atf_check_equal $n 1 unset RUMP_SERVER atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} atf_check -s exit:0 kill -TERM `cat ${PIDFILE1_2}` wait_term ${PIDFILE1_2} rump_server_destroy_ifaces } ra_multiple_routers_single_prefix_cleanup() { if [ -f ${PIDFILE} ]; then kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} fi if [ -f ${PIDFILE1_2} ]; then kill -TERM `cat ${PIDFILE1_2}` wait_term ${PIDFILE1_2} fi $DEBUG && dump cleanup } atf_test_case ra_multiple_routers_maxifprefixes cleanup ra_multiple_routers_maxifprefixes_head() { atf_set "descr" "Tests for exceeding the number of maximum prefixes" atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" } ra_multiple_routers_maxifprefixes_body() { local n= rump_server_fs_start $RUMPSRV netinet6 rump_server_fs_start $RUMPSRV3 netinet6 rump_server_fs_start $RUMPSRV4 netinet6 rump_server_start $RUMPCLI netinet6 setup_shmif0 ${RUMPSRV} ${IP6SRV} setup_shmif0 ${RUMPSRV3} ${IP6SRV3} setup_shmif0 ${RUMPSRV4} ${IP6SRV4} setup_shmif0 ${RUMPCLI} ${IP6CLI} init_server $RUMPSRV init_server $RUMPSRV3 init_server $RUMPSRV4 create_rtadvdconfig export RUMP_SERVER=${RUMPCLI} atf_check -s exit:0 -o match:'0.->.1' \ rump.sysctl -w net.inet6.ip6.accept_rtadv=1 # Limit the maximum number of prefix entries to 2 atf_check -s exit:0 -o match:'16.->.2' \ rump.sysctl -w net.inet6.ip6.maxifprefixes=2 unset RUMP_SERVER start_rtadvd $RUMPSRV $PIDFILE start_rtadvd $RUMPSRV3 $PIDFILE3 sleep $WAITTIME check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX check_entries $RUMPCLI $RUMPSRV3 $IP6SRV3_PREFIX start_rtadvd $RUMPSRV4 $PIDFILE4 sleep $WAITTIME export RUMP_SERVER=${RUMPCLI} $DEBUG && dump_entries # There should remain two prefixes n=$(rump.ndp -p |grep 'advertised by' |wc -l) atf_check_equal $n 2 # TODO check other conditions unset RUMP_SERVER atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} atf_check -s exit:0 kill -TERM `cat ${PIDFILE3}` wait_term ${PIDFILE3} atf_check -s exit:0 kill -TERM `cat ${PIDFILE4}` wait_term ${PIDFILE4} rump_server_destroy_ifaces } ra_multiple_routers_maxifprefixes_cleanup() { if [ -f ${PIDFILE} ]; then kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} fi if [ -f ${PIDFILE3} ]; then kill -TERM `cat ${PIDFILE3}` wait_term ${PIDFILE3} fi if [ -f ${PIDFILE4} ]; then kill -TERM `cat ${PIDFILE4}` wait_term ${PIDFILE4} fi $DEBUG && dump cleanup } atf_test_case ra_temporary_address cleanup ra_temporary_address_head() { atf_set "descr" "Tests for IPv6 temporary address" atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" } +check_echo_request_pkt() +{ + local pkt="$2 > $3: .+ echo request" + + extract_new_packets $1 > ./out + $DEBUG && echo $pkt + $DEBUG && cat ./out + atf_check -s exit:0 -o match:"$pkt" cat ./out +} + ra_temporary_address_body() { + local ip_auto= ip_temp= rump_server_fs_start $RUMPSRV netinet6 rump_server_start $RUMPCLI netinet6 - setup_shmif0 ${RUMPSRV} ${IP6SRV} + setup_shmif0 $RUMPSRV $IP6SRV init_server $RUMPSRV + setup_shmif0 $RUMPCLI $IP6CLI - setup_shmif0 ${RUMPCLI} ${IP6CLI} - export RUMP_SERVER=${RUMPCLI} - $DEBUG && rump.ndp -n -a - atf_check -s exit:0 -o match:'= 0' \ - rump.sysctl net.inet6.ip6.accept_rtadv - atf_check -s exit:0 -o match:'= 0' \ - rump.sysctl net.inet6.ip6.use_tempaddr - unset RUMP_SERVER - - create_rtadvdconfig - start_rtadvd $RUMPSRV $PIDFILE - sleep $WAITTIME - - export RUMP_SERVER=${RUMPCLI} - atf_check -s exit:0 -o empty rump.ndp -r - atf_check -s exit:0 -o not-match:'advertised' rump.ndp -p - atf_check -s exit:0 -o match:'linkmtu=0' rump.ndp -n -i shmif0 - atf_check -s exit:0 -o not-match:'S R' rump.ndp -n -a - atf_check -s exit:0 -o not-match:'fc00:1:' rump.ndp -n -a - atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6 - unset RUMP_SERVER - - atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` - wait_term ${PIDFILE} - - export RUMP_SERVER=${RUMPCLI} + export RUMP_SERVER=$RUMPCLI atf_check -s exit:0 -o match:'0.->.1' \ rump.sysctl -w net.inet6.ip6.accept_rtadv=1 atf_check -s exit:0 -o match:'0.->.1' \ rump.sysctl -w net.inet6.ip6.use_tempaddr=1 unset RUMP_SERVER + create_rtadvdconfig start_rtadvd $RUMPSRV $PIDFILE sleep $WAITTIME check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX + export RUMP_SERVER=$RUMPCLI + # Check temporary address - export RUMP_SERVER=${RUMPCLI} - atf_check -s exit:0 -o match:"$IP6SRV_PREFIX.+" \ + atf_check -s exit:0 \ + -o match:"$IP6SRV_PREFIX.+<(TENTATIVE,)?AUTOCONF,TEMPORARY>" \ rump.ifconfig shmif0 inet6 + + # + # Testing net.inet6.ip6.prefer_tempaddr + # + atf_check -s exit:0 rump.ifconfig -w 10 + $DEBUG && rump.ifconfig shmif0 + ip_auto=$(rump.ifconfig shmif0 |awk '// {sub(/\/[0-9]*/, ""); print $2;}') + ip_temp=$(rump.ifconfig shmif0 |awk '// {sub(/\/[0-9]*/, ""); print $2;}') + $DEBUG && echo $ip_auto $ip_temp + + # Ignore old packets + extract_new_packets bus1 > /dev/null + + atf_check -s exit:0 -o ignore rump.ping6 -n -X 2 -c 1 $IP6SRV + # autoconf (non-temporal) address should be used as the source address + check_echo_request_pkt bus1 $ip_auto $IP6SRV + + # Enable net.inet6.ip6.prefer_tempaddr + atf_check -s exit:0 -o match:'0.->.1' \ + rump.sysctl -w net.inet6.ip6.prefer_tempaddr=1 + + atf_check -s exit:0 -o ignore rump.ping6 -n -X 2 -c 1 $IP6SRV + # autoconf, temporal address should be used as the source address + check_echo_request_pkt bus1 $ip_temp $IP6SRV + unset RUMP_SERVER atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` - wait_term ${PIDFILE} + wait_term $PIDFILE rump_server_destroy_ifaces } ra_temporary_address_cleanup() { if [ -f ${PIDFILE} ]; then kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} fi $DEBUG && dump cleanup } atf_init_test_cases() { atf_add_test_case ra_basic atf_add_test_case ra_flush_prefix_entries atf_add_test_case ra_flush_defrouter_entries atf_add_test_case ra_delete_address atf_add_test_case ra_multiple_routers atf_add_test_case ra_multiple_routers_single_prefix atf_add_test_case ra_multiple_routers_maxifprefixes atf_add_test_case ra_temporary_address } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/net/t_raw.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/net/t_raw.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/net/t_raw.c (revision 312126) @@ -1,41 +1,41 @@ -/* $NetBSD: t_raw.c,v 1.1 2011/01/11 10:51:45 pooka Exp $ */ +/* $NetBSD: t_raw.c,v 1.2 2017/01/13 21:30:42 christos Exp $ */ #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(PRU_SENSE); ATF_TC_HEAD(PRU_SENSE, tc) { atf_tc_set_md_var(tc, "descr", "Biglock leak with PRU_SENSE on " "raw sockets (PR kern/44369)"); } ATF_TC_BODY(PRU_SENSE, tc) { struct stat sb; int s; rump_init(); RL(s = rump_sys_socket(PF_ROUTE, SOCK_RAW, 0)); /* call PRU_SENSE. unfixed bug causes panic in rump_unschedule() */ RL(rump_sys_fstat(s, &sb)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, PRU_SENSE); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/modautoload/t_modautoload.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/modautoload/t_modautoload.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/modautoload/t_modautoload.c (revision 312126) @@ -1,88 +1,88 @@ -/* $NetBSD: t_modautoload.c,v 1.5 2016/09/14 03:19:11 ozaki-r Exp $ */ +/* $NetBSD: t_modautoload.c,v 1.6 2017/01/13 21:30:42 christos Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(modautoload); ATF_TC_HEAD(modautoload, tc) { atf_tc_set_md_var(tc, "descr", "tests that kernel module " "autoload works in rump"); } static void mountkernfs(void) { bool old_autoload, new_autoload; size_t old_len, new_len; int error; if (!rump_nativeabi_p()) atf_tc_skip("host kernel modules not supported"); rump_init(); if (rump_sys_mkdir("/kern", 0777) == -1) atf_tc_fail_errno("mkdir /kern"); new_autoload = true; old_len = sizeof(old_autoload); new_len = sizeof(new_autoload); error = sysctlbyname("kern.module.autoload", &old_autoload, &old_len, &new_autoload, new_len); if (error != 0) atf_tc_fail_errno("could not enable module autoload"); if (rump_sys_mount(MOUNT_KERNFS, "/kern", 0, NULL, 0) == -1) atf_tc_fail_errno("could not mount kernfs"); } /* * Why use kernfs here? It talks to plenty of other parts with the * kernel (e.g. vfs_attach() in modcmd), but is still easy to verify * it's working correctly. */ #define MAGICNUM 1323 ATF_TC_BODY(modautoload, tc) { extern int rumpns_hz; char buf[64]; int fd; mountkernfs(); rumpns_hz = MAGICNUM; if ((fd = rump_sys_open("/kern/hz", O_RDONLY)) == -1) atf_tc_fail_errno("open /kern/hz"); if (rump_sys_read(fd, buf, sizeof(buf)) <= 0) atf_tc_fail_errno("read"); ATF_REQUIRE(atoi(buf) == MAGICNUM); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, modautoload); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_kern.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_kern.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_kern.c (revision 312126) @@ -1,119 +1,119 @@ -/* $NetBSD: t_kern.c,v 1.3 2012/01/30 13:05:52 njoly Exp $ */ +/* $NetBSD: t_kern.c,v 1.4 2017/01/13 21:30:43 christos Exp $ */ /*- * Copyright (c) 2011 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 #include -#include "../../h_macros.h" +#include "h_macros.h" #include "../kernspace/kernspace.h" #define LOCKFUN(_name_, _descr_,_needld_, _expect_) \ ATF_TC(lockme_##_name_); \ ATF_TC_HEAD(lockme_##_name_, tc) { \ atf_tc_set_md_var(tc, "descr", _descr_); \ } \ ATF_TC_BODY(lockme_##_name_, tc) { \ locktest(tc, LOCKME_##_name_, _needld_, _expect_); \ } static void locktest(const atf_tc_t *tc, enum locktest lt, int needld, const char *expect) { extern const int rump_lockdebug; int pipetti[2]; int status; if (needld && !rump_lockdebug) atf_tc_skip("test requires LOCKDEBUG kernel"); RL(pipe(pipetti)); switch (fork()) { case 0: RL(dup2(pipetti[1], STDOUT_FILENO)); RL(dup2(pipetti[1], STDOUT_FILENO)); rump_init(); rump_schedule(); rumptest_lockme(lt); rump_unschedule(); break; default: RL(wait(&status)); ATF_REQUIRE(WIFSIGNALED(status) && WTERMSIG(status) == SIGABRT); if (rump_lockdebug) { char buf[8192]; ATF_REQUIRE(read(pipetti[0], buf, sizeof(buf)) > 0); if (strncmp(buf, expect, strlen(expect)) != 0) atf_tc_fail("unexpected output"); } break; case -1: atf_tc_fail("fork"); } } LOCKFUN(DESTROYHELD, "destroy lock while held", 0, "mutex error: lockdebug_free: is locked or in use"); LOCKFUN(DOUBLEFREE, "free lock twice", 0, "panic: lockdebug_lookup: uninitialized lock"); LOCKFUN(DOUBLEINIT, "init lock twice", 1, "mutex error: lockdebug_alloc: already initialized"); LOCKFUN(MEMFREE, "free memory active lock is in", 1, "mutex error: kmem_intr_free: allocation contains active lock"); LOCKFUN(MTX, "locking-against-self mutex", 0, "mutex error: lockdebug_wantlock: locking against myself"); LOCKFUN(RWDOUBLEX, "locking-against-self exclusive rwlock", 0, "rwlock error: lockdebug_wantlock: locking against myself"); LOCKFUN(RWRX, "rw: first shared, then exclusive", 1, "rwlock error: lockdebug_wantlock: locking against myself"); LOCKFUN(RWXR, "rw: first execusive, then shared", 0, "rwlock error: lockdebug_wantlock: locking against myself"); ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, lockme_MTX); ATF_TP_ADD_TC(tp, lockme_RWDOUBLEX); ATF_TP_ADD_TC(tp, lockme_RWRX); ATF_TP_ADD_TC(tp, lockme_RWXR); ATF_TP_ADD_TC(tp, lockme_DOUBLEINIT); ATF_TP_ADD_TC(tp, lockme_DOUBLEFREE); ATF_TP_ADD_TC(tp, lockme_DESTROYHELD); ATF_TP_ADD_TC(tp, lockme_MEMFREE); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c (revision 312126) @@ -1,318 +1,318 @@ -/* $NetBSD: t_lwproc.c,v 1.8 2017/01/10 22:36:29 christos Exp $ */ +/* $NetBSD: t_lwproc.c,v 1.9 2017/01/13 21:30:43 christos 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 #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(makelwp); ATF_TC_HEAD(makelwp, tc) { atf_tc_set_md_var(tc, "descr", "tests that lwps can be attached to " "processes"); } ATF_TC_BODY(makelwp, tc) { struct lwp *l; pid_t pid; rump_init(); RZ(rump_pub_lwproc_newlwp(0)); ATF_REQUIRE_EQ(rump_pub_lwproc_newlwp(37), ESRCH); l = rump_pub_lwproc_curlwp(); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); ATF_REQUIRE(rump_pub_lwproc_curlwp() != l); l = rump_pub_lwproc_curlwp(); RZ(rump_pub_lwproc_newlwp(rump_sys_getpid())); ATF_REQUIRE(rump_pub_lwproc_curlwp() != l); pid = rump_sys_getpid(); ATF_REQUIRE(pid != -1 && pid != 0); } ATF_TC(proccreds); ATF_TC_HEAD(proccreds, tc) { atf_tc_set_md_var(tc, "descr", "check that procs have different creds"); } ATF_TC_BODY(proccreds, tc) { struct lwp *l1, *l2; rump_init(); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); l1 = rump_pub_lwproc_curlwp(); RZ(rump_pub_lwproc_newlwp(rump_sys_getpid())); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); l2 = rump_pub_lwproc_curlwp(); RL(rump_sys_setuid(22)); ATF_REQUIRE_EQ(rump_sys_getuid(), 22); rump_pub_lwproc_switch(l1); ATF_REQUIRE_EQ(rump_sys_getuid(), 0); /* from parent, proc0 */ RL(rump_sys_setuid(11)); ATF_REQUIRE_EQ(rump_sys_getuid(), 11); rump_pub_lwproc_switch(l2); ATF_REQUIRE_EQ(rump_sys_getuid(), 22); rump_pub_lwproc_newlwp(rump_sys_getpid()); ATF_REQUIRE_EQ(rump_sys_getuid(), 22); } ATF_TC(inherit); ATF_TC_HEAD(inherit, tc) { atf_tc_set_md_var(tc, "descr", "new processes inherit creds from " "parents"); } ATF_TC_BODY(inherit, tc) { rump_init(); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); RL(rump_sys_setuid(66)); ATF_REQUIRE_EQ(rump_sys_getuid(), 66); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); ATF_REQUIRE_EQ(rump_sys_getuid(), 66); /* release lwp and proc */ rump_pub_lwproc_releaselwp(); ATF_REQUIRE_EQ(rump_sys_getuid(), 0); } ATF_TC(lwps); ATF_TC_HEAD(lwps, tc) { atf_tc_set_md_var(tc, "descr", "proc can hold many lwps and is " "automatically g/c'd when the last one exits"); } #define LOOPS 128 ATF_TC_BODY(lwps, tc) { struct lwp *l[LOOPS]; pid_t mypid; struct lwp *l_orig; int i; rump_init(); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); mypid = rump_sys_getpid(); RL(rump_sys_setuid(375)); l_orig = rump_pub_lwproc_curlwp(); for (i = 0; i < LOOPS; i++) { mypid = rump_sys_getpid(); ATF_REQUIRE(mypid != -1 && mypid != 0); RZ(rump_pub_lwproc_newlwp(mypid)); l[i] = rump_pub_lwproc_curlwp(); ATF_REQUIRE_EQ(rump_sys_getuid(), 375); } rump_pub_lwproc_switch(l_orig); rump_pub_lwproc_releaselwp(); for (i = 0; i < LOOPS; i++) { rump_pub_lwproc_switch(l[i]); ATF_REQUIRE_EQ(rump_sys_getpid(), mypid); ATF_REQUIRE_EQ(rump_sys_getuid(), 375); rump_pub_lwproc_releaselwp(); ATF_REQUIRE_EQ(rump_sys_getpid(), 1); ATF_REQUIRE_EQ(rump_sys_getuid(), 0); } ATF_REQUIRE_EQ(rump_pub_lwproc_newlwp(mypid), ESRCH); } ATF_TC(nolwprelease); ATF_TC_HEAD(nolwprelease, tc) { atf_tc_set_md_var(tc, "descr", "check that lwp context is required " "for lwproc_releaselwp()"); } ATF_TC_BODY(nolwprelease, tc) { int status; switch (fork()) { case 0: rump_init(); rump_pub_lwproc_releaselwp(); atf_tc_fail("survived"); break; case -1: atf_tc_fail_errno("fork"); break; default: wait(&status); ATF_REQUIRE(WIFSIGNALED(status)); ATF_REQUIRE_EQ(WTERMSIG(status), SIGABRT); } } ATF_TC(nolwp); ATF_TC_HEAD(nolwp, tc) { atf_tc_set_md_var(tc, "descr", "check that curlwp for an implicit " "context is NULL"); } ATF_TC_BODY(nolwp, tc) { rump_init(); ATF_REQUIRE_EQ(rump_pub_lwproc_curlwp(), NULL); } ATF_TC(nullswitch); ATF_TC_HEAD(nullswitch, tc) { atf_tc_set_md_var(tc, "descr", "check that switching to NULL marks " "current lwp as not running"); } ATF_TC_BODY(nullswitch, tc) { struct lwp *l; rump_init(); RZ(rump_pub_lwproc_newlwp(0)); l = rump_pub_lwproc_curlwp(); rump_pub_lwproc_switch(NULL); /* if remains LP_RUNNING, next call will panic */ rump_pub_lwproc_switch(l); } ATF_TC(rfork); ATF_TC_HEAD(rfork, tc) { atf_tc_set_md_var(tc, "descr", "check that fork shares fd's"); } ATF_TC_BODY(rfork, tc) { struct stat sb; struct lwp *l, *l2; int fd; RZ(rump_init()); ATF_REQUIRE_EQ(rump_pub_lwproc_rfork(RUMP_RFFDG|RUMP_RFCFDG), EINVAL); RZ(rump_pub_lwproc_rfork(0)); l = rump_pub_lwproc_curlwp(); RL(fd = rump_sys_open("/file", O_RDWR | O_CREAT, 0777)); /* ok, first check rfork(RUMP_RFCFDG) does *not* preserve fd's */ RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); ATF_REQUIRE_ERRNO(EBADF, rump_sys_write(fd, &fd, sizeof(fd)) == -1); /* then check that rfork(0) does */ rump_pub_lwproc_switch(l); RZ(rump_pub_lwproc_rfork(0)); ATF_REQUIRE_EQ(rump_sys_write(fd, &fd, sizeof(fd)), sizeof(fd)); RL(rump_sys_fstat(fd, &sb)); l2 = rump_pub_lwproc_curlwp(); /* * check that the shared fd table is really shared by * closing fd in parent */ rump_pub_lwproc_switch(l); RL(rump_sys_close(fd)); rump_pub_lwproc_switch(l2); ATF_REQUIRE_ERRNO(EBADF, rump_sys_fstat(fd, &sb) == -1); /* redo, this time copying the fd table instead of sharing it */ rump_pub_lwproc_releaselwp(); rump_pub_lwproc_switch(l); RL(fd = rump_sys_open("/file", O_RDWR, 0777)); RZ(rump_pub_lwproc_rfork(RUMP_RFFDG)); ATF_REQUIRE_EQ(rump_sys_write(fd, &fd, sizeof(fd)), sizeof(fd)); RL(rump_sys_fstat(fd, &sb)); l2 = rump_pub_lwproc_curlwp(); /* check that the fd table is copied */ rump_pub_lwproc_switch(l); RL(rump_sys_close(fd)); rump_pub_lwproc_switch(l2); RL(rump_sys_fstat(fd, &sb)); ATF_REQUIRE_EQ(sb.st_size, sizeof(fd)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, makelwp); ATF_TP_ADD_TC(tp, proccreds); ATF_TP_ADD_TC(tp, inherit); ATF_TP_ADD_TC(tp, lwps); ATF_TP_ADD_TC(tp, nolwprelease); ATF_TP_ADD_TC(tp, nolwp); ATF_TP_ADD_TC(tp, nullswitch); ATF_TP_ADD_TC(tp, rfork); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_modcmd.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_modcmd.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_modcmd.c (revision 312126) @@ -1,182 +1,182 @@ -/* $NetBSD: t_modcmd.c,v 1.9 2010/05/31 23:51:28 pooka Exp $ */ +/* $NetBSD: t_modcmd.c,v 1.10 2017/01/13 21:30:43 christos Exp $ */ /* * Copyright (c) 2009 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 #include #include #include #include #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" /* * We verify that modules can be loaded and unloaded. * tmpfs was chosen because it does not depend on an image. */ ATF_TC(cmsg_modcmd); ATF_TC_HEAD(cmsg_modcmd, tc) { atf_tc_set_md_var(tc, "descr", "Checks that loading and unloading " "a module (vfs/tmpfs) is possible"); } static int disable_autoload(void) { struct sysctlnode q, ans[256]; int mib[3]; size_t alen; unsigned i; bool no; mib[0] = CTL_KERN; mib[1] = CTL_QUERY; alen = sizeof(ans); memset(&q, 0, sizeof(q)); q.sysctl_flags = SYSCTL_VERSION; if (rump_sys___sysctl(mib, 2, ans, &alen, &q, sizeof(q)) == -1) return -1; for (i = 0; i < __arraycount(ans); i++) if (strcmp("module", ans[i].sysctl_name) == 0) break; if (i == __arraycount(ans)) { errno = ENOENT; return -1; } mib[1] = ans[i].sysctl_num; mib[2] = CTL_QUERY; if (rump_sys___sysctl(mib, 3, ans, &alen, &q, sizeof(q)) == -1) return errno; for (i = 0; i < __arraycount(ans); i++) if (strcmp("autoload", ans[i].sysctl_name) == 0) break; if (i == __arraycount(ans)) { errno = ENOENT; return -1; } mib[2] = ans[i].sysctl_num; no = false; alen = 0; if (rump_sys___sysctl(mib, 3, NULL, &alen, &no, sizeof(no)) == -1) return errno; return 0; } #define TMPFSMODULE "librumpfs_tmpfs.so" ATF_TC_BODY(cmsg_modcmd, tc) { struct tmpfs_args args; const struct modinfo *const *mi_start, *const *mi_end; void *handle; int i, rv, loop = 0; rump_init(); if (disable_autoload() == -1) atf_tc_fail_errno("count not disable module autoload"); memset(&args, 0, sizeof(args)); args.ta_version = TMPFS_ARGS_VERSION; args.ta_root_mode = 0777; if (rump_sys_mkdir("/mp", 0777) == -1) atf_tc_fail_errno("mkdir mountpoint"); if (rump_sys_mount(MOUNT_TMPFS, "/mp", 0, &args, sizeof(args)) != -1) atf_tc_fail("mount unexpectedly succeeded"); handle = dlopen(TMPFSMODULE, RTLD_GLOBAL); if (handle == NULL) { const char *dlmsg = dlerror(); atf_tc_fail("cannot open %s: %s", TMPFSMODULE, dlmsg); } again: mi_start = dlsym(handle, "__start_link_set_modules"); mi_end = dlsym(handle, "__stop_link_set_modules"); if (mi_start == NULL || mi_end == NULL) atf_tc_fail("cannot find module info"); if ((rv = rump_pub_module_init(mi_start, (size_t)(mi_end-mi_start)))!=0) atf_tc_fail("module init failed: %d (%s)", rv, strerror(rv)); if ((rv = rump_pub_module_init(mi_start, (size_t)(mi_end-mi_start)))==0) atf_tc_fail("module double init succeeded"); if (rump_sys_mount(MOUNT_TMPFS, "/mp", 0, &args, sizeof(args)) == -1) atf_tc_fail_errno("still cannot mount"); if (rump_sys_unmount("/mp", 0) == -1) atf_tc_fail("cannot unmount"); for (i = 0; i < (int)(mi_end-mi_start); i++) { if ((rv = rump_pub_module_fini(mi_start[i])) != 0) atf_tc_fail("module fini failed: %d (%s)", rv, strerror(rv)); } for (i = 0; i < (int)(mi_end-mi_start); i++) { if ((rv = rump_pub_module_fini(mi_start[i])) == 0) atf_tc_fail("module double fini succeeded"); } if (loop++ == 0) goto again; if (dlclose(handle)) { const char *dlmsg = dlerror(); atf_tc_fail("cannot close %s: %s", TMPFSMODULE, dlmsg); } if (rump_sys_mount(MOUNT_TMPFS, "/mp", 0, &args, sizeof(args)) != -1) atf_tc_fail("mount unexpectedly succeeded"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, cmsg_modcmd); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_modlinkset.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_modlinkset.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_modlinkset.c (revision 312126) @@ -1,73 +1,73 @@ -/* $NetBSD: t_modlinkset.c,v 1.2 2009/11/06 15:26:54 pooka Exp $ */ +/* $NetBSD: t_modlinkset.c,v 1.3 2017/01/13 21:30:43 christos Exp $ */ /* * Copyright (c) 2009 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 #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(modlinkset); ATF_TC_HEAD(modlinkset, tc) { atf_tc_set_md_var(tc, "descr", "Check that module linkset bootstrap " "works"); } /* * We link against cd9660 and msdosfs (both chosed because the names * are unlikely to ever be a substring of a another file system). * Without proper linkset handling at most one will be reported. */ ATF_TC_BODY(modlinkset, tc) { char buf[1024]; rump_init(); if (ukfs_vfstypes(buf, sizeof(buf)) == -1) atf_tc_fail_errno("ukfs_vfstypes"); ATF_CHECK((strstr(buf, "msdos") != NULL)); ATF_CHECK((strstr(buf, "cd9660") != NULL)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, modlinkset); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_signals.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_signals.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_signals.c (revision 312126) @@ -1,127 +1,127 @@ -/* $NetBSD: t_signals.c,v 1.2 2011/02/20 19:45:45 pooka Exp $ */ +/* $NetBSD: t_signals.c,v 1.3 2017/01/13 21:30:43 christos Exp $ */ /*- * Copyright (c) 2011 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 #include #include "../kernspace/kernspace.h" -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(sigraise); ATF_TC_HEAD(sigraise, tc) { atf_tc_set_md_var(tc, "descr", "RUMP_SIGMODEL_RAISE"); } ATF_TC(sigignore); ATF_TC_HEAD(sigignore, tc) { atf_tc_set_md_var(tc, "descr", "RUMP_SIGMODEL_IGNORE"); } ATF_TC(sigpanic); ATF_TC_HEAD(sigpanic, tc) { atf_tc_set_md_var(tc, "descr", "RUMP_SIGMODEL_PANIC"); } static volatile sig_atomic_t sigcnt; static void thehand(int sig) { sigcnt++; } ATF_TC_BODY(sigraise, tc) { signal(SIGUSR2, thehand); rump_boot_setsigmodel(RUMP_SIGMODEL_RAISE); rump_init(); rump_schedule(); rumptest_localsig(SIGUSR2); rump_unschedule(); ATF_REQUIRE_EQ(sigcnt, 1); } ATF_TC_BODY(sigignore, tc) { rump_boot_setsigmodel(RUMP_SIGMODEL_IGNORE); rump_init(); rump_schedule(); rumptest_localsig(SIGKILL); rump_unschedule(); } ATF_TC_BODY(sigpanic, tc) { int status; rump_boot_setsigmodel(RUMP_SIGMODEL_PANIC); switch (fork()) { case 0: rump_init(); rump_schedule(); rumptest_localsig(SIGCONT); /* NOTREACHED */ exit(1); default: wait(&status); ATF_REQUIRE(WIFSIGNALED(status) && WTERMSIG(status) == SIGABRT); break; case -1: atf_tc_fail_errno("fork"); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, sigraise); ATF_TP_ADD_TC(tp, sigignore); ATF_TP_ADD_TC(tp, sigpanic); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_threads.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_threads.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_threads.c (revision 312126) @@ -1,81 +1,81 @@ -/* $NetBSD: t_threads.c,v 1.1 2010/05/31 23:36:12 pooka Exp $ */ +/* $NetBSD: t_threads.c,v 1.2 2017/01/13 21:30:43 christos 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 "../../h_macros.h" +#include "h_macros.h" #include "../kernspace/kernspace.h" ATF_TC(threadjoin); ATF_TC_HEAD(threadjoin, tc) { atf_tc_set_md_var(tc, "descr", "Checks joinable threads work"); } ATF_TC_BODY(threadjoin, tc) { rump_init(); rump_schedule(); rumptest_threadjoin(); /* panics if fails */ rump_unschedule(); } ATF_TC(kthread); ATF_TC_HEAD(kthread, tc) { atf_tc_set_md_var(tc, "descr", "Checks kthread_create/exit works"); } ATF_TC_BODY(kthread, tc) { rump_init(); rump_schedule(); rumptest_threadjoin(); /* panics if fails */ rump_unschedule(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, threadjoin); ATF_TP_ADD_TC(tp, kthread); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_tsleep.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_tsleep.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_tsleep.c (revision 312126) @@ -1,63 +1,63 @@ -/* $NetBSD: t_tsleep.c,v 1.1 2010/05/31 23:36:12 pooka Exp $ */ +/* $NetBSD: t_tsleep.c,v 1.2 2017/01/13 21:30:43 christos 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 "../../h_macros.h" +#include "h_macros.h" #include "../kernspace/kernspace.h" ATF_TC(tsleep); ATF_TC_HEAD(tsleep, tc) { atf_tc_set_md_var(tc, "descr", "Check tsleep variants"); } ATF_TC_BODY(tsleep, tc) { rump_init(); rump_schedule(); rumptest_tsleep(); /* panics if fails */ rump_unschedule(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, tsleep); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_vm.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_vm.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpkern/t_vm.c (revision 312126) @@ -1,91 +1,91 @@ -/* $NetBSD: t_vm.c,v 1.3 2012/03/17 18:00:28 hannken Exp $ */ +/* $NetBSD: t_vm.c,v 1.4 2017/01/13 21:30:43 christos 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 -#include "../../h_macros.h" +#include "h_macros.h" #include "../kernspace/kernspace.h" ATF_TC(busypage); ATF_TC_HEAD(busypage, tc) { atf_tc_set_md_var(tc, "descr", "Checks VM pagewaits work"); } ATF_TC_BODY(busypage, tc) { rump_init(); rump_schedule(); rumptest_busypage(); rump_unschedule(); } ATF_TC(uvmwait); ATF_TC_HEAD(uvmwait, tc) { atf_tc_set_md_var(tc, "descr", "Tests that uvm_wait works"); atf_tc_set_md_var(tc, "timeout", "30"); } #define UVMWAIT_LIMIT 1024*1024 ATF_TC_BODY(uvmwait, tc) { char buf[64]; /* limit rump kernel memory */ snprintf(buf, sizeof(buf), "%d", UVMWAIT_LIMIT); setenv("RUMP_MEMLIMIT", buf, 1); rump_init(); rump_schedule(); rumptest_alloc(UVMWAIT_LIMIT); rump_unschedule(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, busypage); ATF_TP_ADD_TC(tp, uvmwait); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpvfs/t_basic.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpvfs/t_basic.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpvfs/t_basic.c (revision 312126) @@ -1,81 +1,81 @@ -/* $NetBSD: t_basic.c,v 1.2 2011/02/22 13:25:18 pooka Exp $ */ +/* $NetBSD: t_basic.c,v 1.3 2017/01/13 21:30:43 christos Exp $ */ /*- * Copyright (c) 2011 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 #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(lseekrv); ATF_TC_HEAD(lseekrv, tc) { atf_tc_set_md_var(tc, "descr", "Test lseek return values"); } #define TESTFILE "testi" #define FIVE_MEGS (5*1024*1024) #define FIVE_GIGS (5*1024*1024*1024LL) ATF_TC_BODY(lseekrv, tc) { off_t rv; int fd; RZ(rump_init()); RL(fd = rump_sys_open(TESTFILE, O_RDWR | O_CREAT, 0777)); rv = rump_sys_lseek(37, FIVE_MEGS, SEEK_SET); ATF_REQUIRE_ERRNO(EBADF, rv == -1); rv = rump_sys_lseek(fd, FIVE_MEGS, SEEK_SET); ATF_REQUIRE_EQ(rv, FIVE_MEGS); rv = rump_sys_lseek(fd, FIVE_GIGS, SEEK_SET); ATF_REQUIRE_EQ(rv, FIVE_GIGS); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, lseekrv); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpvfs/t_etfs.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpvfs/t_etfs.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpvfs/t_etfs.c (revision 312126) @@ -1,302 +1,302 @@ -/* $NetBSD: t_etfs.c,v 1.10 2014/05/12 15:33:12 christos Exp $ */ +/* $NetBSD: t_etfs.c,v 1.11 2017/01/13 21:30:43 christos 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 #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(reregister_reg); ATF_TC_HEAD(reregister_reg, tc) { atf_tc_set_md_var(tc, "descr", "Tests register/unregister/register " "for a regular file"); } #define TESTSTR1 "hi, it's me again!" #define TESTSTR1SZ (sizeof(TESTSTR1)-1) #define TESTSTR2 "what about the old vulcan proverb?" #define TESTSTR2SZ (sizeof(TESTSTR2)-1) #define TESTPATH1 "/trip/to/the/moon" #define TESTPATH2 "/but/not/the/dark/size" ATF_TC_BODY(reregister_reg, tc) { char buf[1024]; int localfd, etcfd; ssize_t n; int tfd; etcfd = open("/etc/passwd", O_RDONLY); ATF_REQUIRE(etcfd != -1); localfd = open("./testfile", O_RDWR | O_CREAT, 0666); ATF_REQUIRE(localfd != -1); ATF_REQUIRE_EQ(write(localfd, TESTSTR1, TESTSTR1SZ), TESTSTR1SZ); /* testfile now contains test string */ rump_init(); ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH1, "/etc/passwd", RUMP_ETFS_REG), 0); tfd = rump_sys_open(TESTPATH1, O_RDONLY); ATF_REQUIRE(tfd != -1); ATF_REQUIRE(rump_sys_read(tfd, buf, sizeof(buf)) > 0); rump_sys_close(tfd); rump_pub_etfs_remove(TESTPATH1); ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH2, "./testfile", RUMP_ETFS_REG), 0); tfd = rump_sys_open(TESTPATH2, O_RDWR); ATF_REQUIRE(tfd != -1); memset(buf, 0, sizeof(buf)); ATF_REQUIRE((n = rump_sys_read(tfd, buf, sizeof(buf))) > 0); /* check that we have what we expected */ ATF_REQUIRE_STREQ(buf, TESTSTR1); /* ... while here, check that writing works too */ ATF_REQUIRE_EQ(rump_sys_lseek(tfd, 0, SEEK_SET), 0); ATF_REQUIRE(TESTSTR1SZ <= TESTSTR2SZ); ATF_REQUIRE_EQ(rump_sys_write(tfd, TESTSTR2, TESTSTR2SZ), TESTSTR2SZ); memset(buf, 0, sizeof(buf)); ATF_REQUIRE_EQ(lseek(localfd, 0, SEEK_SET), 0); ATF_REQUIRE(read(localfd, buf, sizeof(buf)) > 0); ATF_REQUIRE_STREQ(buf, TESTSTR2); close(etcfd); close(localfd); } ATF_TC(reregister_blk); ATF_TC_HEAD(reregister_blk, tc) { atf_tc_set_md_var(tc, "descr", "Tests register/unregister/register " "for a block device"); } ATF_TC_BODY(reregister_blk, tc) { char buf[512 * 128]; char cmpbuf[512 * 128]; int rv, tfd; /* first, create some image files */ rv = system("dd if=/dev/zero bs=512 count=64 " "| tr '\\0' '\\1' > disk1.img"); ATF_REQUIRE_EQ(rv, 0); rv = system("dd if=/dev/zero bs=512 count=128 " "| tr '\\0' '\\2' > disk2.img"); ATF_REQUIRE_EQ(rv, 0); rump_init(); ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH1, "./disk1.img", RUMP_ETFS_BLK), 0); tfd = rump_sys_open(TESTPATH1, O_RDONLY); ATF_REQUIRE(tfd != -1); ATF_REQUIRE_EQ(rump_sys_read(tfd, buf, sizeof(buf)), 64*512); memset(cmpbuf, 1, sizeof(cmpbuf)); ATF_REQUIRE_EQ(memcmp(buf, cmpbuf, 64*512), 0); ATF_REQUIRE_EQ(rump_sys_close(tfd), 0); ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH1), 0); ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH2, "./disk2.img", RUMP_ETFS_BLK), 0); tfd = rump_sys_open(TESTPATH2, O_RDONLY); ATF_REQUIRE(tfd != -1); ATF_REQUIRE_EQ(rump_sys_read(tfd, buf, sizeof(buf)), 128*512); memset(cmpbuf, 2, sizeof(cmpbuf)); ATF_REQUIRE_EQ(memcmp(buf, cmpbuf, 128*512), 0); ATF_REQUIRE_EQ(rump_sys_close(tfd), 0); ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH2), 0); } ATF_TC_WITH_CLEANUP(large_blk); ATF_TC_HEAD(large_blk, tc) { atf_tc_set_md_var(tc, "descr", "Check etfs block devices work for " ">2TB images"); } #define IMG_ON_MFS "mfsdir/disk.img" ATF_TC_BODY(large_blk, tc) { char buf[128]; char cmpbuf[128]; ssize_t n; int rv, tfd; /* * mount mfs. it would be nice if this would not be required, * but a) tmpfs doesn't "support" sparse files b) we don't really * know what fs atf workdir is on anyway. */ if (mkdir("mfsdir", 0777) == -1) atf_tc_fail_errno("mkdir failed"); if (system("mount_mfs -s 64m -o nosuid,nodev mfs mfsdir") != 0) atf_tc_skip("could not mount mfs"); /* create a 8TB sparse file */ rv = system("dd if=/dev/zero of=" IMG_ON_MFS " bs=1 count=1 seek=8t"); ATF_REQUIRE_EQ(rv, 0); /* * map it and issue write at 6TB, then unmap+remap and check * we get the same stuff back */ rump_init(); ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH1, IMG_ON_MFS, RUMP_ETFS_BLK), 0); tfd = rump_sys_open(TESTPATH1, O_RDWR); ATF_REQUIRE(tfd != -1); memset(buf, 12, sizeof(buf)); n = rump_sys_pwrite(tfd, buf, sizeof(buf), 6*1024*1024*1024ULL*1024ULL); ATF_REQUIRE_EQ(n, sizeof(buf)); ATF_REQUIRE_EQ(rump_sys_close(tfd), 0); ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH1), 0); ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH2, IMG_ON_MFS, RUMP_ETFS_BLK), 0); tfd = rump_sys_open(TESTPATH2, O_RDWR); ATF_REQUIRE(tfd != -1); memset(buf, 0, sizeof(buf)); n = rump_sys_pread(tfd, buf, sizeof(buf), 6*1024*1024*1024ULL*1024ULL); ATF_REQUIRE_EQ(n, sizeof(buf)); memset(cmpbuf, 12, sizeof(cmpbuf)); ATF_REQUIRE_EQ(memcmp(cmpbuf, buf, 128), 0); } ATF_TC_CLEANUP(large_blk, tc) { system("umount mfsdir"); } ATF_TC(range_blk); ATF_TC_HEAD(range_blk, tc) { atf_tc_set_md_var(tc, "descr", "Checks ranged (offset,size) mappings"); } ATF_TC_BODY(range_blk, tc) { char buf[32000]; char cmpbuf[32000]; ssize_t n; int rv, tfd; /* create a 64000 byte file with 16 1's at offset = 32000 */ rv = system("dd if=/dev/zero of=disk.img bs=1000 count=64"); ATF_REQUIRE_EQ(rv, 0); rv = system("yes | tr '\\ny' '\\1' " "| dd of=disk.img conv=notrunc bs=1 count=16 seek=32000"); ATF_REQUIRE_EQ(rv, 0); /* map the file at [16000,48000]. this puts our 1's at offset 16000 */ rump_init(); ATF_REQUIRE_EQ(rump_pub_etfs_register_withsize(TESTPATH1, "disk.img", RUMP_ETFS_BLK, 16000, 32000), 0); tfd = rump_sys_open(TESTPATH1, O_RDWR); ATF_REQUIRE(tfd != -1); n = rump_sys_read(tfd, buf, sizeof(buf)); ATF_REQUIRE_EQ(n, sizeof(buf)); ATF_REQUIRE_EQ(rump_sys_close(tfd), 0); ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH1), 0); /* check that we got what is expected */ memset(cmpbuf, 0, sizeof(cmpbuf)); memset(cmpbuf+16000, 1, 16); ATF_REQUIRE_EQ(memcmp(buf, cmpbuf, sizeof(buf)), 0); } ATF_TC(key); ATF_TC_HEAD(key, tc) { atf_tc_set_md_var(tc, "descr", "Checks key format"); } ATF_TC_BODY(key, tc) { RZ(rump_init()); RL(open("hostfile", O_RDWR | O_CREAT, 0777)); RZ(rump_pub_etfs_register("/key", "hostfile", RUMP_ETFS_REG)); ATF_REQUIRE_EQ(rump_pub_etfs_register("key", "hostfile", RUMP_ETFS_REG), EINVAL); RL(rump_sys_open("/key", O_RDONLY)); RL(rump_sys_open("////////key", O_RDONLY)); RZ(rump_pub_etfs_register("////key//with/slashes", "hostfile", RUMP_ETFS_REG)); RL(rump_sys_open("/key//with/slashes", O_RDONLY)); RL(rump_sys_open("key//with/slashes", O_RDONLY)); ATF_REQUIRE_ERRNO(ENOENT, rump_sys_open("/key/with/slashes", O_RDONLY) == -1); RL(rump_sys_mkdir("/a", 0777)); ATF_REQUIRE_ERRNO(ENOENT, rump_sys_open("/a/key//with/slashes", O_RDONLY) == -1); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, reregister_reg); ATF_TP_ADD_TC(tp, reregister_blk); ATF_TP_ADD_TC(tp, large_blk); ATF_TP_ADD_TC(tp, range_blk); ATF_TP_ADD_TC(tp, key); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpvfs/t_p2kifs.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpvfs/t_p2kifs.c (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/rump/rumpvfs/t_p2kifs.c (revision 312126) @@ -1,93 +1,93 @@ -/* $NetBSD: t_p2kifs.c,v 1.5 2016/01/25 11:45:57 pooka Exp $ */ +/* $NetBSD: t_p2kifs.c,v 1.6 2017/01/13 21:30:43 christos 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 #include #include #include #include -#include "../../h_macros.h" +#include "h_macros.h" ATF_TC(makecn); ATF_TC_HEAD(makecn, tc) { atf_tc_set_md_var(tc, "descr", "Tests makecn/LOOKUP/freecn"); } #define TESTFILE "testi" ATF_TC_BODY(makecn, tc) { struct componentname *cn; char pathstr[MAXPATHLEN] = TESTFILE; struct vnode *vp; extern struct vnode *rumpns_rootvnode; rump_init(); /* * Strategy is to create a componentname, edit the passed * string, and then do a lookup with the componentname. */ RL(rump_sys_mkdir("/" TESTFILE, 0777)); /* need stable lwp for componentname */ RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); /* try it once with the right path */ cn = rump_pub_makecn(RUMP_NAMEI_LOOKUP, 0, pathstr, strlen(pathstr), rump_pub_cred_create(0, 0, 0, NULL), rump_pub_lwproc_curlwp()); RZ(RUMP_VOP_LOOKUP(rumpns_rootvnode, &vp, cn)); rump_pub_freecn(cn, RUMPCN_FREECRED); /* and then with modification-in-the-middle */ cn = rump_pub_makecn(RUMP_NAMEI_LOOKUP, 0, pathstr, strlen(pathstr), rump_pub_cred_create(0, 0, 0, NULL), rump_pub_lwproc_curlwp()); strcpy(pathstr, "/muuta"); RZ(RUMP_VOP_LOOKUP(rumpns_rootvnode, &vp, cn)); rump_pub_freecn(cn, RUMPCN_FREECRED); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, makecn); return atf_no_error(); } Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/sys/uvm/t_uvm_physseg.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/sys/uvm/t_uvm_physseg.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/sys/uvm/t_uvm_physseg.c (revision 312126) @@ -0,0 +1,2377 @@ +/* $NetBSD: t_uvm_physseg.c,v 1.2 2016/12/22 08:15:20 cherry Exp $ */ + +/*- + * Copyright (c) 2015, 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Santhosh N. Raju and + * by Cherry G. Mathew + * + * 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 +__RCSID("$NetBSD: t_uvm_physseg.c,v 1.2 2016/12/22 08:15:20 cherry Exp $"); + +/* + * If this line is commented out tests related to uvm_physseg_get_pmseg() + * wont run. + * + * Have a look at machine/uvm_physseg.h for more details. + */ +#define __HAVE_PMAP_PHYSSEG + +/* + * This is a dummy struct used for testing purposes + * + * In reality this struct would exist in the MD part of the code residing in + * machines/vmparam.h + */ + +#ifdef __HAVE_PMAP_PHYSSEG +struct pmap_physseg { + int dummy_variable; /* Dummy variable use for testing */ +}; +#endif + +/* Testing API - assumes userland */ +/* Provide Kernel API equivalents */ +#include +#include +#include +#include /* memset(3) et. al */ +#include /* printf(3) */ +#include /* malloc(3) */ +#include +#include + +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +#define UVM_HOTPLUG /* Enable hotplug with rbtree. */ +#define PMAP_STEAL_MEMORY +#define DEBUG /* Enable debug functionality. */ + +typedef unsigned long vaddr_t; +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long vsize_t; + +#include +#include + +#ifndef DIAGNOSTIC +#define KASSERTMSG(e, msg, ...) /* NOTHING */ +#define KASSERT(e) /* NOTHING */ +#else +#define KASSERT(a) assert(a) +#define KASSERTMSG(exp, ...) printf(__VA_ARGS__); assert((exp)) +#endif + +#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH + +#define VM_NFREELIST 4 +#define VM_FREELIST_DEFAULT 0 +#define VM_FREELIST_FIRST16 3 +#define VM_FREELIST_FIRST1G 2 +#define VM_FREELIST_FIRST4G 1 + +/* + * Used in tests when Array implementation is tested + */ +#if !defined(VM_PHYSSEG_MAX) +#define VM_PHYSSEG_MAX 1 +#endif + +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) +#define atop(x) (((paddr_t)(x)) >> PAGE_SHIFT) +#define ptoa(x) (((paddr_t)(x)) << PAGE_SHIFT) + +#define mutex_enter(l) +#define mutex_exit(l) + +psize_t physmem; + +struct uvmexp uvmexp; /* decl */ + +/* + * uvm structure borrowed from uvm.h + * + * Remember this is a dummy structure used within the ATF Tests and + * uses only necessary fields from the original uvm struct. + * See uvm/uvm.h for the full struct. + */ + +struct uvm { + /* vm_page related parameters */ + + bool page_init_done; /* TRUE if uvm_page_init() finished */ +} uvm; + +#include + +void * +kmem_alloc(size_t size, km_flag_t flags) +{ + return malloc(size); +} + +void * +kmem_zalloc(size_t size, km_flag_t flags) +{ + void *ptr; + ptr = malloc(size); + + memset(ptr, 0, size); + + return ptr; +} + +void +kmem_free(void *mem, size_t size) +{ + free(mem); +} + +static void +panic(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vprintf(fmt, ap); + printf("\n"); + va_end(ap); + KASSERT(false); + + /*NOTREACHED*/ +} + +static void +uvm_pagefree(struct vm_page *pg) +{ + return; +} + +#if defined(UVM_HOTPLUG) +static void +uvmpdpol_reinit(void) +{ + return; +} +#endif /* UVM_HOTPLUG */ + +/* end - Provide Kernel API equivalents */ + + +#include "uvm/uvm_physseg.c" + +#include + +#define SIXTYFOUR_KILO (64 * 1024) +#define ONETWENTYEIGHT_KILO (128 * 1024) +#define TWOFIFTYSIX_KILO (256 * 1024) +#define FIVEONETWO_KILO (512 * 1024) +#define ONE_MEGABYTE (1024 * 1024) +#define TWO_MEGABYTE (2 * 1024 * 1024) + +/* Sample Page Frame Numbers */ +#define VALID_START_PFN_1 atop(0) +#define VALID_END_PFN_1 atop(ONE_MEGABYTE) +#define VALID_AVAIL_START_PFN_1 atop(0) +#define VALID_AVAIL_END_PFN_1 atop(ONE_MEGABYTE) + +#define VALID_START_PFN_2 atop(ONE_MEGABYTE + 1) +#define VALID_END_PFN_2 atop(ONE_MEGABYTE * 2) +#define VALID_AVAIL_START_PFN_2 atop(ONE_MEGABYTE + 1) +#define VALID_AVAIL_END_PFN_2 atop(ONE_MEGABYTE * 2) + +#define VALID_START_PFN_3 atop((ONE_MEGABYTE * 2) + 1) +#define VALID_END_PFN_3 atop(ONE_MEGABYTE * 3) +#define VALID_AVAIL_START_PFN_3 atop((ONE_MEGABYTE * 2) + 1) +#define VALID_AVAIL_END_PFN_3 atop(ONE_MEGABYTE * 3) + +#define VALID_START_PFN_4 atop((ONE_MEGABYTE * 3) + 1) +#define VALID_END_PFN_4 atop(ONE_MEGABYTE * 4) +#define VALID_AVAIL_START_PFN_4 atop((ONE_MEGABYTE * 3) + 1) +#define VALID_AVAIL_END_PFN_4 atop(ONE_MEGABYTE * 4) + +/* + * Total number of pages (of 4K size each) should be 256 for 1MB of memory. + */ +#define PAGE_COUNT_1M 256 + +/* + * A debug fucntion to print the content of upm. + */ + static inline void + uvm_physseg_dump_seg(uvm_physseg_t upm) + { +#if defined(DEBUG) + printf("%s: seg->start == %ld\n", __func__, + uvm_physseg_get_start(upm)); + printf("%s: seg->end == %ld\n", __func__, + uvm_physseg_get_end(upm)); + printf("%s: seg->avail_start == %ld\n", __func__, + uvm_physseg_get_avail_start(upm)); + printf("%s: seg->avail_end == %ld\n", __func__, + uvm_physseg_get_avail_end(upm)); + + printf("====\n\n"); +#else + return; +#endif /* DEBUG */ + } + +/* + * Private accessor that gets the value of uvm_physseg_graph.nentries + */ +static int +uvm_physseg_get_entries(void) +{ +#if defined(UVM_HOTPLUG) + return uvm_physseg_graph.nentries; +#else + return vm_nphysmem; +#endif /* UVM_HOTPLUG */ +} + +#if !defined(UVM_HOTPLUG) +static void * +uvm_physseg_alloc(size_t sz) +{ + return &vm_physmem[vm_nphysseg++]; +} +#endif + +/* + * Test Fixture SetUp(). + */ +static void +setup(void) +{ + /* Prerequisites for running certain calls in uvm_physseg */ + uvmexp.pagesize = PAGE_SIZE; + uvmexp.npages = 0; + uvm.page_init_done = false; + uvm_physseg_init(); +} + + +/* <---- Tests for Internal functions ----> */ +#if defined(UVM_HOTPLUG) +ATF_TC(uvm_physseg_alloc_atboot_mismatch); +ATF_TC_HEAD(uvm_physseg_alloc_atboot_mismatch, tc) +{ + atf_tc_set_md_var(tc, "descr", "boot time uvm_physseg_alloc() sanity" + "size mismatch alloc() test."); +} + +ATF_TC_BODY(uvm_physseg_alloc_atboot_mismatch, tc) +{ + uvm.page_init_done = false; + + atf_tc_expect_signal(SIGABRT, "size mismatch alloc()"); + + uvm_physseg_alloc(sizeof(struct uvm_physseg) - 1); +} + +ATF_TC(uvm_physseg_alloc_atboot_overrun); +ATF_TC_HEAD(uvm_physseg_alloc_atboot_overrun, tc) +{ + atf_tc_set_md_var(tc, "descr", "boot time uvm_physseg_alloc() sanity" + "array overrun alloc() test."); +} + +ATF_TC_BODY(uvm_physseg_alloc_atboot_overrun, tc) +{ + uvm.page_init_done = false; + + atf_tc_expect_signal(SIGABRT, "array overrun alloc()"); + + uvm_physseg_alloc((VM_PHYSSEG_MAX + 1) * sizeof(struct uvm_physseg)); + +} + +ATF_TC(uvm_physseg_alloc_sanity); +ATF_TC_HEAD(uvm_physseg_alloc_sanity, tc) +{ + atf_tc_set_md_var(tc, "descr", "further uvm_physseg_alloc() sanity checks"); +} + +ATF_TC_BODY(uvm_physseg_alloc_sanity, tc) +{ + + /* At boot time */ + uvm.page_init_done = false; + + /* Correct alloc */ + ATF_REQUIRE(uvm_physseg_alloc(VM_PHYSSEG_MAX * sizeof(struct uvm_physseg))); + + /* Retry static alloc()s as dynamic - we expect them to pass */ + uvm.page_init_done = true; + ATF_REQUIRE(uvm_physseg_alloc(sizeof(struct uvm_physseg) - 1)); + ATF_REQUIRE(uvm_physseg_alloc(2 * VM_PHYSSEG_MAX * sizeof(struct uvm_physseg))); +} + +ATF_TC(uvm_physseg_free_atboot_mismatch); +ATF_TC_HEAD(uvm_physseg_free_atboot_mismatch, tc) +{ + atf_tc_set_md_var(tc, "descr", "boot time uvm_physseg_free() sanity" + "size mismatch free() test."); +} + +ATF_TC_BODY(uvm_physseg_free_atboot_mismatch, tc) +{ + uvm.page_init_done = false; + + atf_tc_expect_signal(SIGABRT, "size mismatch free()"); + + uvm_physseg_free(&uvm_physseg[0], sizeof(struct uvm_physseg) - 1); +} + +ATF_TC(uvm_physseg_free_sanity); +ATF_TC_HEAD(uvm_physseg_free_sanity, tc) +{ + atf_tc_set_md_var(tc, "descr", "further uvm_physseg_free() sanity checks"); +} + +ATF_TC_BODY(uvm_physseg_free_sanity, tc) +{ + + /* At boot time */ + uvm.page_init_done = false; + + struct uvm_physseg *seg; + +#if VM_PHYSSEG_MAX > 1 + /* + * Note: free()ing the entire array is considered to be an + * error. Thus VM_PHYSSEG_MAX - 1. + */ + + seg = uvm_physseg_alloc((VM_PHYSSEG_MAX - 1) * sizeof(*seg)); + uvm_physseg_free(seg, (VM_PHYSSEG_MAX - 1) * sizeof(struct uvm_physseg)); +#endif + + /* Retry static alloc()s as dynamic - we expect them to pass */ + uvm.page_init_done = true; + + seg = uvm_physseg_alloc(sizeof(struct uvm_physseg) - 1); + uvm_physseg_free(seg, sizeof(struct uvm_physseg) - 1); + + seg = uvm_physseg_alloc(2 * VM_PHYSSEG_MAX * sizeof(struct uvm_physseg)); + + uvm_physseg_free(seg, 2 * VM_PHYSSEG_MAX * sizeof(struct uvm_physseg)); +} + +#if VM_PHYSSEG_MAX > 1 +ATF_TC(uvm_physseg_atboot_free_leak); +ATF_TC_HEAD(uvm_physseg_atboot_free_leak, tc) +{ + atf_tc_set_md_var(tc, "descr", + "does free() leak at boot ?\n" + "This test needs VM_PHYSSEG_MAX > 1)"); +} + +ATF_TC_BODY(uvm_physseg_atboot_free_leak, tc) +{ + + /* At boot time */ + uvm.page_init_done = false; + + /* alloc to array size */ + struct uvm_physseg *seg; + seg = uvm_physseg_alloc(VM_PHYSSEG_MAX * sizeof(*seg)); + + uvm_physseg_free(seg, sizeof(*seg)); + + atf_tc_expect_signal(SIGABRT, "array overrun on alloc() after leak"); + + ATF_REQUIRE(uvm_physseg_alloc(sizeof(struct uvm_physseg))); +} +#endif /* VM_PHYSSEG_MAX */ +#endif /* UVM_HOTPLUG */ + +/* + * Note: This function replicates verbatim what happens in + * uvm_page.c:uvm_page_init(). + * + * Please track any changes that happen there. + */ +static void +uvm_page_init_fake(struct vm_page *pagearray, psize_t pagecount) +{ + uvm_physseg_t bank; + size_t n; + + for (bank = uvm_physseg_get_first(), + uvm_physseg_seg_chomp_slab(bank, pagearray, pagecount); + uvm_physseg_valid_p(bank); + bank = uvm_physseg_get_next(bank)) { + + n = uvm_physseg_get_end(bank) - uvm_physseg_get_start(bank); + uvm_physseg_seg_alloc_from_slab(bank, n); + uvm_physseg_init_seg(bank, pagearray); + + /* set up page array pointers */ + pagearray += n; + pagecount -= n; + } + + uvm.page_init_done = true; +} + +ATF_TC(uvm_physseg_plug); +ATF_TC_HEAD(uvm_physseg_plug, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test plug functionality."); +} +/* Note: We only do the second boot time plug if VM_PHYSSEG_MAX > 1 */ +ATF_TC_BODY(uvm_physseg_plug, tc) +{ + int nentries = 0; /* Count of entries via plug done so far */ + uvm_physseg_t upm1; +#if VM_PHYSSEG_MAX > 2 + uvm_physseg_t upm2; +#endif + +#if VM_PHYSSEG_MAX > 1 + uvm_physseg_t upm3; +#endif + uvm_physseg_t upm4; + psize_t npages1 = (VALID_END_PFN_1 - VALID_START_PFN_1); + psize_t npages2 = (VALID_END_PFN_2 - VALID_START_PFN_2); + psize_t npages3 = (VALID_END_PFN_3 - VALID_START_PFN_3); + psize_t npages4 = (VALID_END_PFN_4 - VALID_START_PFN_4); + struct vm_page *pgs, *slab = malloc(sizeof(struct vm_page) * (npages1 +#if VM_PHYSSEG_MAX > 2 + + npages2 +#endif + + npages3)); + + /* Fake early boot */ + + setup(); + + /* Vanilla plug x 2 */ + ATF_REQUIRE_EQ(uvm_physseg_plug(VALID_START_PFN_1, npages1, &upm1), true); + ATF_REQUIRE_EQ(++nentries, uvm_physseg_get_entries()); + ATF_REQUIRE_EQ(0, uvmexp.npages); + +#if VM_PHYSSEG_MAX > 2 + ATF_REQUIRE_EQ(uvm_physseg_plug(VALID_START_PFN_2, npages2, &upm2), true); + ATF_REQUIRE_EQ(++nentries, uvm_physseg_get_entries()); + ATF_REQUIRE_EQ(0, uvmexp.npages); +#endif + /* Post boot: Fake all segments and pages accounted for. */ + uvm_page_init_fake(slab, npages1 + npages2 + npages3); + + ATF_CHECK_EQ(npages1 +#if VM_PHYSSEG_MAX > 2 + + npages2 +#endif + , uvmexp.npages); +#if VM_PHYSSEG_MAX > 1 + /* Scavenge plug - goes into the same slab */ + ATF_REQUIRE_EQ(uvm_physseg_plug(VALID_START_PFN_3, npages3, &upm3), true); + ATF_REQUIRE_EQ(++nentries, uvm_physseg_get_entries()); + ATF_REQUIRE_EQ(npages1 +#if VM_PHYSSEG_MAX > 2 + + npages2 +#endif + + npages3, uvmexp.npages); + + /* Scavenge plug should fit right in the slab */ + pgs = uvm_physseg_get_pg(upm3, 0); + ATF_REQUIRE(pgs > slab && pgs < (slab + npages1 + npages2 + npages3)); +#endif + /* Hot plug - goes into a brand new slab */ + ATF_REQUIRE_EQ(uvm_physseg_plug(VALID_START_PFN_4, npages4, &upm4), true); + /* The hot plug slab should have nothing to do with the original slab */ + pgs = uvm_physseg_get_pg(upm4, 0); + ATF_REQUIRE(pgs < slab || pgs > (slab + npages1 +#if VM_PHYSSEG_MAX > 2 + + npages2 +#endif + + npages3)); + +} +ATF_TC(uvm_physseg_unplug); +ATF_TC_HEAD(uvm_physseg_unplug, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test unplug functionality."); +} +ATF_TC_BODY(uvm_physseg_unplug, tc) +{ + paddr_t pa = 0; + + psize_t npages1 = (VALID_END_PFN_1 - VALID_START_PFN_1); + psize_t npages2 = (VALID_END_PFN_2 - VALID_START_PFN_2); + psize_t npages3 = (VALID_END_PFN_3 - VALID_START_PFN_3); + + struct vm_page *slab = malloc(sizeof(struct vm_page) * (npages1 + npages2 + npages3)); + + uvm_physseg_t upm; + + /* Boot time */ + setup(); + + /* We start with zero segments */ + ATF_REQUIRE_EQ(true, uvm_physseg_plug(atop(0), atop(ONE_MEGABYTE), NULL)); + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + /* Do we have an arbitrary offset in there ? */ + uvm_physseg_find(atop(TWOFIFTYSIX_KILO), &pa); + ATF_REQUIRE_EQ(pa, atop(TWOFIFTYSIX_KILO)); + ATF_REQUIRE_EQ(0, uvmexp.npages); /* Boot time sanity */ + +#if VM_PHYSSEG_MAX == 1 + /* + * This is the curious case at boot time, of having one + * extent(9) static entry per segment, which means that a + * fragmenting unplug will fail. + */ + atf_tc_expect_signal(SIGABRT, "fragmenting unplug for single segment"); + + /* + * In order to test the fragmenting cases, please set + * VM_PHYSSEG_MAX > 1 + */ +#endif + /* Now let's unplug from the middle */ + ATF_REQUIRE_EQ(true, uvm_physseg_unplug(atop(TWOFIFTYSIX_KILO), atop(FIVEONETWO_KILO))); + /* verify that a gap exists at TWOFIFTYSIX_KILO */ + pa = 0; /* reset */ + uvm_physseg_find(atop(TWOFIFTYSIX_KILO), &pa); + ATF_REQUIRE_EQ(pa, 0); + + /* Post boot: Fake all segments and pages accounted for. */ + uvm_page_init_fake(slab, npages1 + npages2 + npages3); + /* Account for the unplug */ + ATF_CHECK_EQ(atop(FIVEONETWO_KILO), uvmexp.npages); + + /* Original entry should fragment into two */ + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + upm = uvm_physseg_find(atop(TWOFIFTYSIX_KILO + FIVEONETWO_KILO), NULL); + + ATF_REQUIRE(uvm_physseg_valid_p(upm)); + + /* Now unplug the tail fragment - should swallow the complete entry */ + ATF_REQUIRE_EQ(true, uvm_physseg_unplug(atop(TWOFIFTYSIX_KILO + FIVEONETWO_KILO), atop(TWOFIFTYSIX_KILO))); + + /* The "swallow" above should have invalidated the handle */ + ATF_REQUIRE_EQ(false, uvm_physseg_valid_p(upm)); + + /* Only the first one is left now */ + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + /* Unplug from the back */ + ATF_REQUIRE_EQ(true, uvm_physseg_unplug(atop(ONETWENTYEIGHT_KILO), atop(ONETWENTYEIGHT_KILO))); + /* Shouldn't change the number of segments */ + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + /* Unplug from the front */ + ATF_REQUIRE_EQ(true, uvm_physseg_unplug(0, atop(SIXTYFOUR_KILO))); + /* Shouldn't change the number of segments */ + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + /* Unplugging the final fragment should fail */ + atf_tc_expect_signal(SIGABRT, "Unplugging the last segment"); + ATF_REQUIRE_EQ(true, uvm_physseg_unplug(atop(SIXTYFOUR_KILO), atop(SIXTYFOUR_KILO))); +} + + +/* <---- end Tests for Internal functions ----> */ + +/* Tests for functions exported via uvm_physseg.h */ +ATF_TC(uvm_physseg_init); +ATF_TC_HEAD(uvm_physseg_init, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the basic uvm_page_init() call\ + initializes the vm_physmem struct which holds the rb_tree."); +} +ATF_TC_BODY(uvm_physseg_init, tc) +{ + uvm_physseg_init(); + + ATF_REQUIRE_EQ(0, uvm_physseg_get_entries()); +} + +ATF_TC(uvm_page_physload_preload); +ATF_TC_HEAD(uvm_page_physload_preload, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the basic uvm_page_physload() \ + call works without a panic() in a preload scenario."); +} +ATF_TC_BODY(uvm_page_physload_preload, tc) +{ + uvm_physseg_t upm; + + setup(); + + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + /* Should return a valid handle */ + ATF_REQUIRE(uvm_physseg_valid_p(upm)); + + /* No pages should be allocated yet */ + ATF_REQUIRE_EQ(0, uvmexp.npages); + + /* After the first call one segment should exist */ + ATF_CHECK_EQ(1, uvm_physseg_get_entries()); + + /* Insert more than one segment iff VM_PHYSSEG_MAX > 1 */ +#if VM_PHYSSEG_MAX > 1 + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + /* Should return a valid handle */ + ATF_REQUIRE(uvm_physseg_valid_p(upm)); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + /* After the second call two segments should exist */ + ATF_CHECK_EQ(2, uvm_physseg_get_entries()); +#endif +} + +ATF_TC(uvm_page_physload_postboot); +ATF_TC_HEAD(uvm_page_physload_postboot, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the basic uvm_page_physload() \ + panic()s in a post boot scenario."); +} +ATF_TC_BODY(uvm_page_physload_postboot, tc) +{ + uvm_physseg_t upm; + + psize_t npages1 = (VALID_END_PFN_1 - VALID_START_PFN_1); + psize_t npages2 = (VALID_END_PFN_2 - VALID_START_PFN_2); + + struct vm_page *slab = malloc(sizeof(struct vm_page) * (npages1 + npages2)); + + setup(); + + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + /* Should return a valid handle */ + ATF_REQUIRE(uvm_physseg_valid_p(upm)); + + /* No pages should be allocated yet */ + ATF_REQUIRE_EQ(0, uvmexp.npages); + + /* After the first call one segment should exist */ + ATF_CHECK_EQ(1, uvm_physseg_get_entries()); + + /* Post boot: Fake all segments and pages accounted for. */ + uvm_page_init_fake(slab, npages1 + npages2); + + atf_tc_expect_signal(SIGABRT, + "uvm_page_physload() called post boot"); + + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + /* Should return a valid handle */ + ATF_REQUIRE(uvm_physseg_valid_p(upm)); + + ATF_REQUIRE_EQ(npages1 + npages2, uvmexp.npages); + + /* After the second call two segments should exist */ + ATF_CHECK_EQ(2, uvm_physseg_get_entries()); +} + +ATF_TC(uvm_physseg_handle_immutable); +ATF_TC_HEAD(uvm_physseg_handle_immutable, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the uvm_physseg_t handle is \ + immutable."); +} +ATF_TC_BODY(uvm_physseg_handle_immutable, tc) +{ + uvm_physseg_t upm; + + /* We insert the segments in out of order */ + + setup(); + + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_CHECK_EQ(UVM_PHYSSEG_TYPE_INVALID_EMPTY, uvm_physseg_get_prev(upm)); + + /* Insert more than one segment iff VM_PHYSSEG_MAX > 1 */ +#if VM_PHYSSEG_MAX > 1 + uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + /* Fetch Previous, we inserted a lower value */ + upm = uvm_physseg_get_prev(upm); + +#if !defined(UVM_HOTPLUG) + /* + * This test is going to fail for the Array Implementation but is + * expected to pass in the RB Tree implementation. + */ + /* Failure can be expected iff there are more than one handles */ + atf_tc_expect_fail("Mutable handle in static array impl."); +#endif + ATF_CHECK(UVM_PHYSSEG_TYPE_INVALID_EMPTY != upm); + ATF_CHECK_EQ(VALID_START_PFN_1, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_1, uvm_physseg_get_end(upm)); +#endif +} + +ATF_TC(uvm_physseg_seg_chomp_slab); +ATF_TC_HEAD(uvm_physseg_seg_chomp_slab, tc) +{ + atf_tc_set_md_var(tc, "descr", "The slab import code.()"); + +} +ATF_TC_BODY(uvm_physseg_seg_chomp_slab, tc) +{ + int err; + size_t i; + struct uvm_physseg *seg; + struct vm_page *slab, *pgs; + const size_t npages = UVM_PHYSSEG_BOOT_UNPLUG_MAX; /* Number of pages */ + + setup(); + + /* This is boot time */ + slab = malloc(sizeof(struct vm_page) * npages * 2); + + seg = uvm_physseg_alloc(sizeof(struct uvm_physseg)); + + uvm_physseg_seg_chomp_slab(PHYSSEG_NODE_TO_HANDLE(seg), slab, npages * 2); + + /* Should be able to allocate two 128 * sizeof(*slab) */ + ATF_REQUIRE_EQ(0, extent_alloc(seg->ext, sizeof(*slab), 1, 0, EX_BOUNDZERO, (void *)&pgs)); + err = extent_free(seg->ext, (u_long) pgs, sizeof(*slab), EX_BOUNDZERO); + +#if VM_PHYSSEG_MAX == 1 + /* + * free() needs an extra region descriptor, but we only have + * one! The classic alloc() at free() problem + */ + + ATF_REQUIRE_EQ(ENOMEM, err); +#else + /* Try alloc/free at static time */ + for (i = 0; i < npages; i++) { + ATF_REQUIRE_EQ(0, extent_alloc(seg->ext, sizeof(*slab), 1, 0, EX_BOUNDZERO, (void *)&pgs)); + err = extent_free(seg->ext, (u_long) pgs, sizeof(*slab), EX_BOUNDZERO); + ATF_REQUIRE_EQ(0, err); + } +#endif + + /* Now setup post boot */ + uvm.page_init_done = true; + + uvm_physseg_seg_chomp_slab(PHYSSEG_NODE_TO_HANDLE(seg), slab, npages * 2); + + /* Try alloc/free after uvm_page.c:uvm_page_init() as well */ + for (i = 0; i < npages; i++) { + ATF_REQUIRE_EQ(0, extent_alloc(seg->ext, sizeof(*slab), 1, 0, EX_BOUNDZERO, (void *)&pgs)); + err = extent_free(seg->ext, (u_long) pgs, sizeof(*slab), EX_BOUNDZERO); + ATF_REQUIRE_EQ(0, err); + } + +} + +ATF_TC(uvm_physseg_alloc_from_slab); +ATF_TC_HEAD(uvm_physseg_alloc_from_slab, tc) +{ + atf_tc_set_md_var(tc, "descr", "The slab alloc code.()"); + +} +ATF_TC_BODY(uvm_physseg_alloc_from_slab, tc) +{ + struct uvm_physseg *seg; + struct vm_page *slab, *pgs; + const size_t npages = UVM_PHYSSEG_BOOT_UNPLUG_MAX; /* Number of pages */ + + setup(); + + /* This is boot time */ + slab = malloc(sizeof(struct vm_page) * npages * 2); + + seg = uvm_physseg_alloc(sizeof(struct uvm_physseg)); + + uvm_physseg_seg_chomp_slab(PHYSSEG_NODE_TO_HANDLE(seg), slab, npages * 2); + + pgs = uvm_physseg_seg_alloc_from_slab(PHYSSEG_NODE_TO_HANDLE(seg), npages); + + ATF_REQUIRE(pgs != NULL); + + /* Now setup post boot */ + uvm.page_init_done = true; + +#if VM_PHYSSEG_MAX > 1 + pgs = uvm_physseg_seg_alloc_from_slab(PHYSSEG_NODE_TO_HANDLE(seg), npages); + ATF_REQUIRE(pgs != NULL); +#endif + atf_tc_expect_fail("alloc beyond extent"); + + pgs = uvm_physseg_seg_alloc_from_slab(PHYSSEG_NODE_TO_HANDLE(seg), npages); + ATF_REQUIRE(pgs != NULL); +} + +ATF_TC(uvm_physseg_init_seg); +ATF_TC_HEAD(uvm_physseg_init_seg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if uvm_physseg_init_seg adds pages to" + "uvmexp.npages"); +} +ATF_TC_BODY(uvm_physseg_init_seg, tc) +{ + struct uvm_physseg *seg; + struct vm_page *slab, *pgs; + const size_t npages = UVM_PHYSSEG_BOOT_UNPLUG_MAX; /* Number of pages */ + + setup(); + + /* This is boot time */ + slab = malloc(sizeof(struct vm_page) * npages * 2); + + seg = uvm_physseg_alloc(sizeof(struct uvm_physseg)); + + uvm_physseg_seg_chomp_slab(PHYSSEG_NODE_TO_HANDLE(seg), slab, npages * 2); + + pgs = uvm_physseg_seg_alloc_from_slab(PHYSSEG_NODE_TO_HANDLE(seg), npages); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + seg->start = 0; + seg->end = npages; + + seg->avail_start = 0; + seg->avail_end = npages; + + uvm_physseg_init_seg(PHYSSEG_NODE_TO_HANDLE(seg), pgs); + + ATF_REQUIRE_EQ(npages, uvmexp.npages); +} + +#if 0 +ATF_TC(uvm_physseg_init_seg); +ATF_TC_HEAD(uvm_physseg_init_seg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the basic uvm_page_physload() \ + call works without a panic() after Segment is inited."); +} +ATF_TC_BODY(uvm_physseg_init_seg, tc) +{ + uvm_physseg_t upm; + psize_t npages = (VALID_END_PFN_1 - VALID_START_PFN_1); + struct vm_page *pgs = malloc(sizeof(struct vm_page) * npages); + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_CHECK_EQ(0, uvmexp.npages); + + /* + * Boot time physplug needs explicit external init, + * Duplicate what uvm_page.c:uvm_page_init() does. + * Note: not everything uvm_page_init() does gets done here. + * Read the source. + */ + /* suck in backing slab, initialise extent. */ + uvm_physseg_seg_chomp_slab(upm, pgs, npages); + + /* + * Actual pgs[] allocation, from extent. + */ + uvm_physseg_alloc_from_slab(upm, npages); + + /* Now we initialize the segment */ + uvm_physseg_init_seg(upm, pgs); + + /* Done with boot simulation */ + extent_init(); + uvm.page_init_done = true; + + /* We have total memory of 1MB */ + ATF_CHECK_EQ(PAGE_COUNT_1M, uvmexp.npages); + + upm =uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + /* We added another 1MB so PAGE_COUNT_1M + PAGE_COUNT_1M */ + ATF_CHECK_EQ(PAGE_COUNT_1M + PAGE_COUNT_1M, uvmexp.npages); + +} +#endif + +ATF_TC(uvm_physseg_get_start); +ATF_TC_HEAD(uvm_physseg_get_start, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the start PFN is returned \ + correctly from a segment created via uvm_page_physload()."); +} +ATF_TC_BODY(uvm_physseg_get_start, tc) +{ + uvm_physseg_t upm; + + /* Fake early boot */ + setup(); + + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_CHECK_EQ(VALID_START_PFN_1, uvm_physseg_get_start(upm)); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_CHECK_EQ(VALID_START_PFN_2, uvm_physseg_get_start(upm)); +#endif +} + +ATF_TC(uvm_physseg_get_start_invalid); +ATF_TC_HEAD(uvm_physseg_get_start_invalid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the invalid / error conditions \ + correctly when uvm_physseg_get_start() is called with invalid \ + parameter values."); +} +ATF_TC_BODY(uvm_physseg_get_start_invalid, tc) +{ + /* Check for pgs == NULL */ + setup(); + uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + /* Force other check conditions */ + uvm.page_init_done = true; + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(true, uvm.page_init_done); + + /* Invalid uvm_physseg_t */ + ATF_CHECK_EQ((paddr_t) -1, + uvm_physseg_get_start(UVM_PHYSSEG_TYPE_INVALID)); +} + +ATF_TC(uvm_physseg_get_end); +ATF_TC_HEAD(uvm_physseg_get_end, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the end PFN is returned \ + correctly from a segment created via uvm_page_physload()."); +} +ATF_TC_BODY(uvm_physseg_get_end, tc) +{ + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_CHECK_EQ(VALID_END_PFN_1, uvm_physseg_get_end(upm)); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_CHECK_EQ(VALID_END_PFN_2, uvm_physseg_get_end(upm)); +#endif +} + +ATF_TC(uvm_physseg_get_end_invalid); +ATF_TC_HEAD(uvm_physseg_get_end_invalid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the invalid / error conditions \ + correctly when uvm_physseg_get_end() is called with invalid \ + parameter values."); +} +ATF_TC_BODY(uvm_physseg_get_end_invalid, tc) +{ + /* Check for pgs == NULL */ + setup(); + uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + /* Force other check conditions */ + uvm.page_init_done = true; + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(true, uvm.page_init_done); + + /* Invalid uvm_physseg_t */ + ATF_CHECK_EQ((paddr_t) -1, + uvm_physseg_get_end(UVM_PHYSSEG_TYPE_INVALID)); +} + +ATF_TC(uvm_physseg_get_avail_start); +ATF_TC_HEAD(uvm_physseg_get_avail_start, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the avail_start PFN is \ + returned correctly from a segment created via uvm_page_physload()."); +} +ATF_TC_BODY(uvm_physseg_get_avail_start, tc) +{ + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_1, uvm_physseg_get_avail_start(upm)); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_2, uvm_physseg_get_avail_start(upm)); +#endif +} + +ATF_TC(uvm_physseg_get_avail_start_invalid); +ATF_TC_HEAD(uvm_physseg_get_avail_start_invalid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the invalid / error conditions \ + correctly when uvm_physseg_get_avail_start() is called with invalid\ + parameter values."); +} +ATF_TC_BODY(uvm_physseg_get_avail_start_invalid, tc) +{ + /* Check for pgs == NULL */ + setup(); + uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + /* Force other check conditions */ + uvm.page_init_done = true; + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(true, uvm.page_init_done); + + /* Invalid uvm_physseg_t */ + ATF_CHECK_EQ((paddr_t) -1, + uvm_physseg_get_avail_start(UVM_PHYSSEG_TYPE_INVALID)); +} + +ATF_TC(uvm_physseg_get_avail_end); +ATF_TC_HEAD(uvm_physseg_get_avail_end, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the avail_end PFN is \ + returned correctly from a segment created via uvm_page_physload()."); +} +ATF_TC_BODY(uvm_physseg_get_avail_end, tc) +{ + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_1, uvm_physseg_get_avail_end(upm)); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_2, uvm_physseg_get_avail_end(upm)); +#endif +} + +ATF_TC(uvm_physseg_get_avail_end_invalid); +ATF_TC_HEAD(uvm_physseg_get_avail_end_invalid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the invalid / error conditions \ + correctly when uvm_physseg_get_avail_end() is called with invalid\ + parameter values."); +} +ATF_TC_BODY(uvm_physseg_get_avail_end_invalid, tc) +{ + /* Check for pgs == NULL */ + setup(); + uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + /* Force other check conditions */ + uvm.page_init_done = true; + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(true, uvm.page_init_done); + + /* Invalid uvm_physseg_t */ + ATF_CHECK_EQ((paddr_t) -1, + uvm_physseg_get_avail_end(UVM_PHYSSEG_TYPE_INVALID)); +} + +ATF_TC(uvm_physseg_get_next); +ATF_TC_HEAD(uvm_physseg_get_next, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the pointer values for next \ + segment using the uvm_physseg_get_next() call."); +} +ATF_TC_BODY(uvm_physseg_get_next, tc) +{ + uvm_physseg_t upm; +#if VM_PHYSSEG_MAX > 1 + uvm_physseg_t upm_next; +#endif + + /* We insert the segments in ascending order */ + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_CHECK_EQ(UVM_PHYSSEG_TYPE_INVALID_OVERFLOW, + uvm_physseg_get_next(upm)); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + upm_next = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + upm = uvm_physseg_get_next(upm); /* Fetch Next */ + + ATF_CHECK_EQ(upm_next, upm); + ATF_CHECK_EQ(VALID_START_PFN_2, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_2, uvm_physseg_get_end(upm)); +#endif + + /* This test will be triggered only if there are 3 or more segments. */ +#if VM_PHYSSEG_MAX > 2 + upm_next = uvm_page_physload(VALID_START_PFN_3, VALID_END_PFN_3, + VALID_AVAIL_START_PFN_3, VALID_AVAIL_END_PFN_3, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(3, uvm_physseg_get_entries()); + + upm = uvm_physseg_get_next(upm); /* Fetch Next */ + + ATF_CHECK_EQ(upm_next, upm); + ATF_CHECK_EQ(VALID_START_PFN_3, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_3, uvm_physseg_get_end(upm)); +#endif +} + +ATF_TC(uvm_physseg_get_next_invalid); +ATF_TC_HEAD(uvm_physseg_get_next_invalid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the invalid / error conditions \ + correctly when uvm_physseg_get_next() is called with invalid \ + parameter values."); +} +ATF_TC_BODY(uvm_physseg_get_next_invalid, tc) +{ + uvm_physseg_t upm = UVM_PHYSSEG_TYPE_INVALID; + + ATF_CHECK_EQ(UVM_PHYSSEG_TYPE_INVALID, uvm_physseg_get_next(upm)); +} + +ATF_TC(uvm_physseg_get_prev); +ATF_TC_HEAD(uvm_physseg_get_prev, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the pointer values for previous \ + segment using the uvm_physseg_get_prev() call."); +} +ATF_TC_BODY(uvm_physseg_get_prev, tc) +{ +#if VM_PHYSSEG_MAX > 1 + uvm_physseg_t upm; +#endif + uvm_physseg_t upm_prev; + + + setup(); + upm_prev = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_CHECK_EQ(UVM_PHYSSEG_TYPE_INVALID_EMPTY, + uvm_physseg_get_prev(upm_prev)); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + /* Fetch Previous, we inserted a lower value */ + upm = uvm_physseg_get_prev(upm); + + ATF_CHECK_EQ(upm_prev, upm); + ATF_CHECK_EQ(VALID_START_PFN_1, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_1, uvm_physseg_get_end(upm)); +#endif + + /* This test will be triggered only if there are 3 or more segments. */ +#if VM_PHYSSEG_MAX > 2 + uvm_page_physload(VALID_START_PFN_3, VALID_END_PFN_3, + VALID_AVAIL_START_PFN_3, VALID_AVAIL_END_PFN_3, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(3, uvm_physseg_get_entries()); + + /* + * This will return a UVM_PHYSSEG_TYPE_INVALID_EMPTY we are at the + * lowest + */ + upm = uvm_physseg_get_prev(upm); + + ATF_CHECK_EQ(UVM_PHYSSEG_TYPE_INVALID_EMPTY, upm); +#endif +} + +ATF_TC(uvm_physseg_get_prev_invalid); +ATF_TC_HEAD(uvm_physseg_get_prev_invalid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the invalid / error conditions \ + correctly when uvm_physseg_get_prev() is called with invalid \ + parameter values."); +} +ATF_TC_BODY(uvm_physseg_get_prev_invalid, tc) +{ + uvm_physseg_t upm = UVM_PHYSSEG_TYPE_INVALID; + + ATF_CHECK_EQ(UVM_PHYSSEG_TYPE_INVALID, uvm_physseg_get_prev(upm)); +} + +ATF_TC(uvm_physseg_get_first); +ATF_TC_HEAD(uvm_physseg_get_first, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the pointer values for first \ + segment (lowest node) using the uvm_physseg_get_first() call."); +} +ATF_TC_BODY(uvm_physseg_get_first, tc) +{ + uvm_physseg_t upm = UVM_PHYSSEG_TYPE_INVALID_EMPTY; + uvm_physseg_t upm_first; + + /* Fake early boot */ + setup(); + + /* No nodes exist */ + ATF_CHECK_EQ(upm, uvm_physseg_get_first()); + + upm_first = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + /* Pointer to first should be the least valued node */ + upm = uvm_physseg_get_first(); + ATF_CHECK_EQ(upm_first, upm); + ATF_CHECK_EQ(VALID_START_PFN_2, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_2, uvm_physseg_get_end(upm)); + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_2, uvm_physseg_get_avail_start(upm)); + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_2, uvm_physseg_get_avail_end(upm)); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + /* Insert a node of lesser value */ + upm_first = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_CHECK_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + /* Pointer to first should be the least valued node */ + upm = uvm_physseg_get_first(); + ATF_CHECK_EQ(upm_first, upm); + ATF_CHECK_EQ(VALID_START_PFN_1, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_1, uvm_physseg_get_end(upm)); + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_1, uvm_physseg_get_avail_start(upm)); + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_1, uvm_physseg_get_avail_end(upm)); +#endif + + /* This test will be triggered only if there are 3 or more segments. */ +#if VM_PHYSSEG_MAX > 2 + /* Insert a node of higher value */ + upm_first =uvm_page_physload(VALID_START_PFN_3, VALID_END_PFN_3, + VALID_AVAIL_START_PFN_3, VALID_AVAIL_END_PFN_3, VM_FREELIST_DEFAULT); + + ATF_CHECK_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(3, uvm_physseg_get_entries()); + + /* Pointer to first should be the least valued node */ + upm = uvm_physseg_get_first(); + ATF_CHECK(upm_first != upm); + ATF_CHECK_EQ(VALID_START_PFN_1, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_1, uvm_physseg_get_end(upm)); + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_1, uvm_physseg_get_avail_start(upm)); + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_1, uvm_physseg_get_avail_end(upm)); +#endif +} + +ATF_TC(uvm_physseg_get_last); +ATF_TC_HEAD(uvm_physseg_get_last, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the pointer values for last \ + segment using the uvm_physseg_get_last() call."); +} +ATF_TC_BODY(uvm_physseg_get_last, tc) +{ + uvm_physseg_t upm = UVM_PHYSSEG_TYPE_INVALID_EMPTY; + uvm_physseg_t upm_last; + + setup(); + + /* No nodes exist */ + ATF_CHECK_EQ(upm, uvm_physseg_get_last()); + + upm_last = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + /* Pointer to last should be the most valued node */ + upm = uvm_physseg_get_last(); + ATF_CHECK_EQ(upm_last, upm); + ATF_CHECK_EQ(VALID_START_PFN_1, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_1, uvm_physseg_get_end(upm)); + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_1, uvm_physseg_get_avail_start(upm)); + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_1, uvm_physseg_get_avail_end(upm)); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + /* Insert node of greater value */ + upm_last = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + /* Pointer to last should be the most valued node */ + upm = uvm_physseg_get_last(); + ATF_CHECK_EQ(upm_last, upm); + ATF_CHECK_EQ(VALID_START_PFN_2, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_2, uvm_physseg_get_end(upm)); + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_2, uvm_physseg_get_avail_start(upm)); + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_2, uvm_physseg_get_avail_end(upm)); +#endif + + /* This test will be triggered only if there are 3 or more segments. */ +#if VM_PHYSSEG_MAX > 2 + /* Insert node of greater value */ + upm_last = uvm_page_physload(VALID_START_PFN_3, VALID_END_PFN_3, + VALID_AVAIL_START_PFN_3, VALID_AVAIL_END_PFN_3, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(3, uvm_physseg_get_entries()); + + /* Pointer to last should be the most valued node */ + upm = uvm_physseg_get_last(); + ATF_CHECK_EQ(upm_last, upm); + ATF_CHECK_EQ(VALID_START_PFN_3, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_3, uvm_physseg_get_end(upm)); + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_3, uvm_physseg_get_avail_start(upm)); + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_3, uvm_physseg_get_avail_end(upm)); +#endif +} + +ATF_TC(uvm_physseg_valid); +ATF_TC_HEAD(uvm_physseg_valid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the pointer value for current \ + segment is valid using the uvm_physseg_valid_p() call."); +} +ATF_TC_BODY(uvm_physseg_valid, tc) +{ + psize_t npages = (VALID_END_PFN_1 - VALID_START_PFN_1); + + struct vm_page *pgs = malloc(sizeof(struct vm_page) * npages); + + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + uvm_physseg_init_seg(upm, pgs); + + ATF_REQUIRE_EQ(PAGE_COUNT_1M, uvmexp.npages); + + ATF_CHECK_EQ(true, uvm_physseg_valid_p(upm)); +} + +ATF_TC(uvm_physseg_valid_invalid); +ATF_TC_HEAD(uvm_physseg_valid_invalid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests the pointer value for current \ + segment is invalid using the uvm_physseg_valid_p() call."); +} +ATF_TC_BODY(uvm_physseg_valid_invalid, tc) +{ + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + /* Force other check conditions */ + uvm.page_init_done = true; + + ATF_REQUIRE_EQ(true, uvm.page_init_done); + + /* Invalid uvm_physseg_t */ + ATF_CHECK_EQ(false, uvm_physseg_valid_p(UVM_PHYSSEG_TYPE_INVALID)); + + /* + * Without any pages initialized for segment, it is considered + * invalid + */ + ATF_CHECK_EQ(false, uvm_physseg_valid_p(upm)); +} + +ATF_TC(uvm_physseg_get_highest); +ATF_TC_HEAD(uvm_physseg_get_highest, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the returned PFN matches \ + the highest PFN in use by the system."); +} +ATF_TC_BODY(uvm_physseg_get_highest, tc) +{ + setup(); + uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + /* Only one segment so highest is the current */ + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_1 - 1, uvm_physseg_get_highest_frame()); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + uvm_page_physload(VALID_START_PFN_3, VALID_END_PFN_3, + VALID_AVAIL_START_PFN_3, VALID_AVAIL_END_PFN_3, VM_FREELIST_DEFAULT); + + /* PFN_3 > PFN_1 */ + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_3 - 1, uvm_physseg_get_highest_frame()); +#endif + + /* This test will be triggered only if there are 3 or more segments. */ +#if VM_PHYSSEG_MAX > 2 + uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + /* PFN_3 > PFN_2 */ + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_3 - 1, uvm_physseg_get_highest_frame()); +#endif +} + +ATF_TC(uvm_physseg_get_free_list); +ATF_TC_HEAD(uvm_physseg_get_free_list, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the returned Free List type \ + of a segment matches the one returned from \ + uvm_physseg_get_free_list() call."); +} +ATF_TC_BODY(uvm_physseg_get_free_list, tc) +{ + uvm_physseg_t upm; + + /* Fake early boot */ + setup(); + + /* Insertions are made in ascending order */ + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_CHECK_EQ(VM_FREELIST_DEFAULT, uvm_physseg_get_free_list(upm)); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_FIRST16); + + ATF_CHECK_EQ(VM_FREELIST_FIRST16, uvm_physseg_get_free_list(upm)); +#endif + + /* This test will be triggered only if there are 3 or more segments. */ +#if VM_PHYSSEG_MAX > 2 + upm = uvm_page_physload(VALID_START_PFN_3, VALID_END_PFN_3, + VALID_AVAIL_START_PFN_3, VALID_AVAIL_END_PFN_3, VM_FREELIST_FIRST1G); + + ATF_CHECK_EQ(VM_FREELIST_FIRST1G, uvm_physseg_get_free_list(upm)); +#endif +} + +ATF_TC(uvm_physseg_get_start_hint); +ATF_TC_HEAD(uvm_physseg_get_start_hint, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the returned start_hint value \ + of a segment matches the one returned from \ + uvm_physseg_get_start_hint() call."); +} +ATF_TC_BODY(uvm_physseg_get_start_hint, tc) +{ + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + /* Will be Zero since no specific value is set during init */ + ATF_CHECK_EQ(0, uvm_physseg_get_start_hint(upm)); +} + +ATF_TC(uvm_physseg_set_start_hint); +ATF_TC_HEAD(uvm_physseg_set_start_hint, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the returned start_hint value \ + of a segment matches the one set by the \ + uvm_physseg_set_start_hint() call."); +} +ATF_TC_BODY(uvm_physseg_set_start_hint, tc) +{ + psize_t npages = (VALID_END_PFN_1 - VALID_START_PFN_1); + + struct vm_page *pgs = malloc(sizeof(struct vm_page) * npages); + + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + uvm_physseg_init_seg(upm, pgs); + + ATF_CHECK_EQ(true, uvm_physseg_set_start_hint(upm, atop(128))); + + /* Will be atop(128) since no specific value is set above */ + ATF_CHECK_EQ(atop(128), uvm_physseg_get_start_hint(upm)); +} + +ATF_TC(uvm_physseg_set_start_hint_invalid); +ATF_TC_HEAD(uvm_physseg_set_start_hint_invalid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the returned value is false \ + when an invalid segment matches the one trying to set by the \ + uvm_physseg_set_start_hint() call."); +} +ATF_TC_BODY(uvm_physseg_set_start_hint_invalid, tc) +{ + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + /* Force other check conditions */ + uvm.page_init_done = true; + + ATF_REQUIRE_EQ(true, uvm.page_init_done); + + ATF_CHECK_EQ(false, uvm_physseg_set_start_hint(upm, atop(128))); + + /* + * Will be Zero since no specific value is set after the init + * due to failure + */ + atf_tc_expect_signal(SIGABRT, "invalid uvm_physseg_t handle"); + + ATF_CHECK_EQ(0, uvm_physseg_get_start_hint(upm)); +} + +ATF_TC(uvm_physseg_get_pg); +ATF_TC_HEAD(uvm_physseg_get_pg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the returned vm_page struct \ + is correct when fetched by uvm_physseg_get_pg() call."); +} +ATF_TC_BODY(uvm_physseg_get_pg, tc) +{ + psize_t npages = (VALID_END_PFN_1 - VALID_START_PFN_1); + + struct vm_page *pgs = malloc(sizeof(struct vm_page) * npages); + + struct vm_page *extracted_pg = NULL; + + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + /* Now we initialize the segment */ + uvm_physseg_init_seg(upm, pgs); + + ATF_REQUIRE_EQ(PAGE_COUNT_1M, uvmexp.npages); + + ATF_REQUIRE_EQ(NULL, extracted_pg); + + /* Try fetching the 5th Page in the Segment */ + extracted_pg = uvm_physseg_get_pg(upm, 5); + + /* Values of phys_addr is n * PAGE_SIZE where n is the page number */ + ATF_CHECK_EQ(5 * PAGE_SIZE, extracted_pg->phys_addr); + + /* Try fetching the 113th Page in the Segment */ + extracted_pg = uvm_physseg_get_pg(upm, 113); + + ATF_CHECK_EQ(113 * PAGE_SIZE, extracted_pg->phys_addr); +} + +#ifdef __HAVE_PMAP_PHYSSEG +ATF_TC(uvm_physseg_get_pmseg); +ATF_TC_HEAD(uvm_physseg_get_pmseg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the returned pmap_physseg \ + struct is correct when fetched by uvm_physseg_get_pmseg() call."); +} +ATF_TC_BODY(uvm_physseg_get_pmseg, tc) +{ + psize_t npages = (VALID_END_PFN_1 - VALID_START_PFN_1); + + struct vm_page *pgs = malloc(sizeof(struct vm_page) * npages); + + struct pmap_physseg pmseg = { true }; + + struct pmap_physseg *extracted_pmseg = NULL; + + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + /* Now we initialize the segment */ + uvm_physseg_init_seg(upm, pgs); + + ATF_REQUIRE_EQ(PAGE_COUNT_1M, uvmexp.npages); + + ATF_REQUIRE_EQ(NULL, extracted_pmseg); + + ATF_REQUIRE_EQ(true, pmseg.dummy_variable); + + /* Extract the current pmseg */ + extracted_pmseg = uvm_physseg_get_pmseg(upm); + + /* + * We can only check if it is not NULL + * We do not know the value it contains + */ + ATF_CHECK(NULL != extracted_pmseg); + + extracted_pmseg->dummy_variable = pmseg.dummy_variable; + + /* Invert value to ensure test integrity */ + pmseg.dummy_variable = false; + + ATF_REQUIRE_EQ(false, pmseg.dummy_variable); + + extracted_pmseg = uvm_physseg_get_pmseg(upm); + + ATF_CHECK(NULL != extracted_pmseg); + + ATF_CHECK_EQ(true, extracted_pmseg->dummy_variable); +} +#endif + +ATF_TC(vm_physseg_find); +ATF_TC_HEAD(vm_physseg_find, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the returned segment number \ + is correct when an PFN is passed into uvm_physseg_find() call. \ + In addition to this the offset of the PFN from the start of \ + segment is also set if the parameter is passed in as not NULL."); +} +ATF_TC_BODY(vm_physseg_find, tc) +{ + psize_t offset = (psize_t) -1; + + uvm_physseg_t upm_first, result; +#if VM_PHYSSEG_MAX > 1 + uvm_physseg_t upm_second; +#endif + + setup(); + + upm_first = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + upm_second = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); +#endif + + /* Under ONE_MEGABYTE is segment upm_first */ + result = uvm_physseg_find(atop(ONE_MEGABYTE - 1024), NULL); + ATF_CHECK_EQ(upm_first, result); + ATF_CHECK_EQ(uvm_physseg_get_start(upm_first), + uvm_physseg_get_start(result)); + ATF_CHECK_EQ(uvm_physseg_get_end(upm_first), + uvm_physseg_get_end(result)); + ATF_CHECK_EQ(uvm_physseg_get_avail_start(upm_first), + uvm_physseg_get_avail_start(result)); + ATF_CHECK_EQ(uvm_physseg_get_avail_end(upm_first), + uvm_physseg_get_avail_end(result)); + + ATF_REQUIRE_EQ((psize_t) -1, offset); + + /* This test will be triggered only if there are 2 or more segments. */ +#if VM_PHYSSEG_MAX > 1 + /* Over ONE_MEGABYTE is segment upm_second */ + result = uvm_physseg_find(atop(ONE_MEGABYTE + 8192), &offset); + ATF_CHECK_EQ(upm_second, result); + ATF_CHECK_EQ(uvm_physseg_get_start(upm_second), + uvm_physseg_get_start(result)); + ATF_CHECK_EQ(uvm_physseg_get_end(upm_second), + uvm_physseg_get_end(result)); + ATF_CHECK_EQ(uvm_physseg_get_avail_start(upm_second), + uvm_physseg_get_avail_start(result)); + ATF_CHECK_EQ(uvm_physseg_get_avail_end(upm_second), + uvm_physseg_get_avail_end(result)); + + /* Offset is calculated based on PAGE_SIZE */ + /* atop(ONE_MEGABYTE + (2 * PAGE_SIZE)) - VALID_START_PFN1 = 2 */ + ATF_CHECK_EQ(2, offset); +#else + /* Under ONE_MEGABYTE is segment upm_first */ + result = uvm_physseg_find(atop(ONE_MEGABYTE - 12288), &offset); + ATF_CHECK_EQ(upm_first, result); + ATF_CHECK_EQ(uvm_physseg_get_start(upm_first), + uvm_physseg_get_start(result)); + ATF_CHECK_EQ(uvm_physseg_get_end(upm_first), + uvm_physseg_get_end(result)); + ATF_CHECK_EQ(uvm_physseg_get_avail_start(upm_first), + uvm_physseg_get_avail_start(result)); + ATF_CHECK_EQ(uvm_physseg_get_avail_end(upm_first), + uvm_physseg_get_avail_end(result)); + + /* Offset is calculated based on PAGE_SIZE */ + /* atop(ONE_MEGABYTE - (3 * PAGE_SIZE)) - VALID_START_PFN1 = 253 */ + ATF_CHECK_EQ(253, offset); +#endif +} + +ATF_TC(vm_physseg_find_invalid); +ATF_TC_HEAD(vm_physseg_find_invalid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the returned segment number \ + is (paddr_t) -1 when a non existant PFN is passed into \ + uvm_physseg_find() call."); +} +ATF_TC_BODY(vm_physseg_find_invalid, tc) +{ + psize_t offset = (psize_t) -1; + + setup(); + uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + /* No segments over 3 MB exists at the moment */ + ATF_CHECK_EQ(UVM_PHYSSEG_TYPE_INVALID, + uvm_physseg_find(atop(ONE_MEGABYTE * 3), NULL)); + + ATF_REQUIRE_EQ((psize_t) -1, offset); + + /* No segments over 3 MB exists at the moment */ + ATF_CHECK_EQ(UVM_PHYSSEG_TYPE_INVALID, + uvm_physseg_find(atop(ONE_MEGABYTE * 3), &offset)); + + ATF_CHECK_EQ((psize_t) -1, offset); +} + +ATF_TC(uvm_page_physunload_start); +ATF_TC_HEAD(uvm_page_physunload_start, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the basic uvm_page_physunload()\ + call works without a panic(). Unloads from Start of the segment."); +} +ATF_TC_BODY(uvm_page_physunload_start, tc) +{ + /* + * Would uvmexp.npages reduce everytime an uvm_page_physunload is called? + */ + psize_t npages = (VALID_END_PFN_2 - VALID_START_PFN_2); + + struct vm_page *pgs = malloc(sizeof(struct vm_page) * npages); + + paddr_t p = 0; + + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + uvm_physseg_init_seg(upm, pgs); + + ATF_CHECK_EQ(true, uvm_page_physunload(upm, VM_FREELIST_DEFAULT, &p)); + + /* + * When called for first time, uvm_page_physload() removes the first PFN + * + * New avail start will be VALID_AVAIL_START_PFN_2 + 1 + */ + ATF_CHECK_EQ(VALID_START_PFN_2, atop(p)); + + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_2 + 1, + uvm_physseg_get_avail_start(upm)); + + ATF_CHECK_EQ(VALID_START_PFN_2 + 1, uvm_physseg_get_start(upm)); + + /* Rest of the stuff should remain the same */ + ATF_CHECK_EQ(VALID_END_PFN_2, uvm_physseg_get_end(upm)); + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_2, uvm_physseg_get_avail_end(upm)); +} + +ATF_TC(uvm_page_physunload_end); +ATF_TC_HEAD(uvm_page_physunload_end, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the basic uvm_page_physunload()\ + call works without a panic(). Unloads from End of the segment."); +} +ATF_TC_BODY(uvm_page_physunload_end, tc) +{ + /* + * Would uvmexp.npages reduce everytime an uvm_page_physunload is called? + */ + paddr_t p = 0; + + uvm_physseg_t upm; + + setup(); + /* Note: start != avail_start to remove from end. */ + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2 + 1, VALID_AVAIL_END_PFN_2, + VM_FREELIST_DEFAULT); + + p = 0; + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE( + uvm_physseg_get_avail_start(upm) != uvm_physseg_get_start(upm)); + + ATF_CHECK_EQ(true, uvm_page_physunload(upm, VM_FREELIST_DEFAULT, &p)); + + /* + * Remember if X is the upper limit the actual valid pointer is X - 1 + * + * For example if 256 is the upper limit for 1MB memory, last valid + * pointer is 256 - 1 = 255 + */ + + ATF_CHECK_EQ(VALID_END_PFN_2 - 1, atop(p)); + + /* + * When called for second time, uvm_page_physload() removes the last PFN + * + * New avail end will be VALID_AVAIL_END_PFN_2 - 1 + * New end will be VALID_AVAIL_PFN_2 - 1 + */ + + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_2 - 1, uvm_physseg_get_avail_end(upm)); + + ATF_CHECK_EQ(VALID_END_PFN_2 - 1, uvm_physseg_get_end(upm)); + + /* Rest of the stuff should remain the same */ + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_2 + 1, + uvm_physseg_get_avail_start(upm)); + ATF_CHECK_EQ(VALID_START_PFN_2, uvm_physseg_get_start(upm)); +} + +ATF_TC(uvm_page_physunload_none); +ATF_TC_HEAD(uvm_page_physunload_none, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the basic uvm_page_physunload()\ + call works without a panic(). Does not unload from start or end \ + because of non-aligned start / avail_start and end / avail_end \ + respectively."); +} +ATF_TC_BODY(uvm_page_physunload_none, tc) +{ + psize_t npages = (VALID_END_PFN_2 - VALID_START_PFN_2); + + struct vm_page *pgs = malloc(sizeof(struct vm_page) * npages); + + paddr_t p = 0; + + uvm_physseg_t upm; + + setup(); + /* + * Note: start != avail_start and end != avail_end. + * + * This prevents any unload from occuring. + */ + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2 + 1, VALID_AVAIL_END_PFN_2 - 1, + VM_FREELIST_DEFAULT); + + p = 0; + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_REQUIRE( + uvm_physseg_get_avail_start(upm) != uvm_physseg_get_start(upm)); + + uvm_physseg_init_seg(upm, pgs); + + ATF_CHECK_EQ(false, uvm_page_physunload(upm, VM_FREELIST_DEFAULT, &p)); + + /* uvm_page_physload() will no longer unload memory */ + ATF_CHECK_EQ(0, p); + + /* Rest of the stuff should remain the same */ + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_2 + 1, + uvm_physseg_get_avail_start(upm)); + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_2 - 1, + uvm_physseg_get_avail_end(upm)); + ATF_CHECK_EQ(VALID_START_PFN_2, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_2, uvm_physseg_get_end(upm)); +} + +ATF_TC(uvm_page_physunload_delete_start); +ATF_TC_HEAD(uvm_page_physunload_delete_start, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the uvm_page_physunload() \ + works when the segment gets small enough to be deleted scenario. \ + NOTE: This one works deletes from start."); +} +ATF_TC_BODY(uvm_page_physunload_delete_start, tc) +{ + /* + * Would uvmexp.npages reduce everytime an uvm_page_physunload is called? + */ + paddr_t p = 0; + + uvm_physseg_t upm; + + setup(); + + /* + * Setup the Nuke from Starting point + */ + + upm = uvm_page_physload(VALID_END_PFN_1 - 1, VALID_END_PFN_1, + VALID_AVAIL_END_PFN_1 - 1, VALID_AVAIL_END_PFN_1, + VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + /* Insert more than one segment iff VM_PHYSSEG_MAX > 1 */ +#if VM_PHYSSEG_MAX > 1 + uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); +#endif + +#if VM_PHYSSEG_MAX == 1 + atf_tc_expect_signal(SIGABRT, + "cannot uvm_page_physunload() the last segment"); +#endif + + ATF_CHECK_EQ(true, uvm_page_physunload(upm, VM_FREELIST_DEFAULT, &p)); + + ATF_CHECK_EQ(VALID_END_PFN_1 - 1, atop(p)); + + ATF_CHECK_EQ(1, uvm_physseg_get_entries()); + + /* The only node now is the one we inserted second. */ + upm = uvm_physseg_get_first(); + + ATF_CHECK_EQ(VALID_START_PFN_2, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_2, uvm_physseg_get_end(upm)); + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_2, uvm_physseg_get_avail_start(upm)); + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_2, uvm_physseg_get_avail_end(upm)); +} + +ATF_TC(uvm_page_physunload_delete_end); +ATF_TC_HEAD(uvm_page_physunload_delete_end, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the uvm_page_physunload() \ + works when the segment gets small enough to be deleted scenario. \ + NOTE: This one works deletes from end."); +} +ATF_TC_BODY(uvm_page_physunload_delete_end, tc) +{ + /* + * Would uvmexp.npages reduce everytime an uvm_page_physunload is called? + */ + + paddr_t p = 0; + + uvm_physseg_t upm; + + setup(); + + /* + * Setup the Nuke from Ending point + */ + + upm = uvm_page_physload(VALID_START_PFN_1, VALID_START_PFN_1 + 2, + VALID_AVAIL_START_PFN_1 + 1, VALID_AVAIL_START_PFN_1 + 2, + VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + /* Insert more than one segment iff VM_PHYSSEG_MAX > 1 */ +#if VM_PHYSSEG_MAX > 1 + uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); +#endif + +#if VM_PHYSSEG_MAX == 1 + atf_tc_expect_signal(SIGABRT, + "cannot uvm_page_physunload() the last segment"); +#endif + + ATF_CHECK_EQ(true, uvm_page_physunload(upm, VM_FREELIST_DEFAULT, &p)); + + p = 0; + + ATF_CHECK_EQ(true, uvm_page_physunload(upm, VM_FREELIST_DEFAULT, &p)); + + ATF_CHECK_EQ(VALID_START_PFN_1 + 2, atop(p)); + + ATF_CHECK_EQ(1, uvm_physseg_get_entries()); + + /* The only node now is the one we inserted second. */ + upm = uvm_physseg_get_first(); + + ATF_CHECK_EQ(VALID_START_PFN_2, uvm_physseg_get_start(upm)); + ATF_CHECK_EQ(VALID_END_PFN_2, uvm_physseg_get_end(upm)); + ATF_CHECK_EQ(VALID_AVAIL_START_PFN_2, uvm_physseg_get_avail_start(upm)); + ATF_CHECK_EQ(VALID_AVAIL_END_PFN_2, uvm_physseg_get_avail_end(upm)); +} + +ATF_TC(uvm_page_physunload_invalid); +ATF_TC_HEAD(uvm_page_physunload_invalid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the uvm_page_physunload() \ + fails when then Free list does not match."); +} +ATF_TC_BODY(uvm_page_physunload_invalid, tc) +{ + psize_t npages = (VALID_END_PFN_2 - VALID_START_PFN_2); + + struct vm_page *pgs = malloc(sizeof(struct vm_page) * npages); + + paddr_t p = 0; + + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + uvm_physseg_init_seg(upm, pgs); + + ATF_CHECK_EQ(false, uvm_page_physunload(upm, VM_FREELIST_FIRST4G, &p)); +} + +ATF_TC(uvm_page_physunload_force); +ATF_TC_HEAD(uvm_page_physunload_force, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the basic \ + uvm_page_physunload_force() including delete works without."); +} +ATF_TC_BODY(uvm_page_physunload_force, tc) +{ + /* + * Would uvmexp.npages reduce everytime an uvm_page_physunload is called? + */ + paddr_t p = 0; + + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_1, VALID_END_PFN_1, + VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + /* Insert more than one segment iff VM_PHYSSEG_MAX > 1 */ +#if VM_PHYSSEG_MAX > 1 + /* + * We have couple of physloads done this is bacause of the fact that if + * we physunload all the PFs from a given range and we have only one + * segment in total a panic() is called + */ + uvm_page_physload(VALID_START_PFN_2, VALID_END_PFN_2, + VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); +#endif + +#if VM_PHYSSEG_MAX == 1 + atf_tc_expect_signal(SIGABRT, + "cannot uvm_page_physunload() the last segment"); +#endif + + ATF_REQUIRE_EQ(VALID_AVAIL_START_PFN_1, + uvm_physseg_get_avail_start(upm)); + + for(paddr_t i = VALID_AVAIL_START_PFN_1; + i < VALID_AVAIL_END_PFN_1; i++) { + ATF_CHECK_EQ(true, + uvm_page_physunload_force(upm, VM_FREELIST_DEFAULT, &p)); + ATF_CHECK_EQ(i, atop(p)); + + if(i + 1 < VALID_AVAIL_END_PFN_1) + ATF_CHECK_EQ(i + 1, uvm_physseg_get_avail_start(upm)); + } + + /* + * Now we try to retrieve the segment, which has been removed + * from the system through force unloading all the pages inside it. + */ + upm = uvm_physseg_find(VALID_AVAIL_END_PFN_1 - 1, NULL); + + /* It should no longer exist */ + ATF_CHECK_EQ(NULL, upm); + + ATF_CHECK_EQ(1, uvm_physseg_get_entries()); +} + +ATF_TC(uvm_page_physunload_force_invalid); +ATF_TC_HEAD(uvm_page_physunload_force_invalid, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests if the invalid conditions for \ + uvm_page_physunload_force_invalid()."); +} +ATF_TC_BODY(uvm_page_physunload_force_invalid, tc) +{ + paddr_t p = 0; + + uvm_physseg_t upm; + + setup(); + upm = uvm_page_physload(VALID_START_PFN_2, VALID_START_PFN_2+ 1, + VALID_START_PFN_2, VALID_START_PFN_2, VM_FREELIST_DEFAULT); + + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + ATF_REQUIRE_EQ(0, uvmexp.npages); + + ATF_CHECK_EQ(false, + uvm_page_physunload_force(upm, VM_FREELIST_DEFAULT, &p)); + + ATF_CHECK_EQ(0, p); +} + +ATF_TP_ADD_TCS(tp) +{ +#if defined(UVM_HOTPLUG) + /* Internal */ + ATF_TP_ADD_TC(tp, uvm_physseg_alloc_atboot_mismatch); + ATF_TP_ADD_TC(tp, uvm_physseg_alloc_atboot_overrun); + ATF_TP_ADD_TC(tp, uvm_physseg_alloc_sanity); + ATF_TP_ADD_TC(tp, uvm_physseg_free_atboot_mismatch); + ATF_TP_ADD_TC(tp, uvm_physseg_free_sanity); +#if VM_PHYSSEG_MAX > 1 + ATF_TP_ADD_TC(tp, uvm_physseg_atboot_free_leak); +#endif +#endif /* UVM_HOTPLUG */ + + ATF_TP_ADD_TC(tp, uvm_physseg_plug); + ATF_TP_ADD_TC(tp, uvm_physseg_unplug); + + /* Exported */ + ATF_TP_ADD_TC(tp, uvm_physseg_init); + ATF_TP_ADD_TC(tp, uvm_page_physload_preload); + ATF_TP_ADD_TC(tp, uvm_page_physload_postboot); + ATF_TP_ADD_TC(tp, uvm_physseg_handle_immutable); + ATF_TP_ADD_TC(tp, uvm_physseg_seg_chomp_slab); + ATF_TP_ADD_TC(tp, uvm_physseg_alloc_from_slab); + ATF_TP_ADD_TC(tp, uvm_physseg_init_seg); + ATF_TP_ADD_TC(tp, uvm_physseg_get_start); + ATF_TP_ADD_TC(tp, uvm_physseg_get_start_invalid); + ATF_TP_ADD_TC(tp, uvm_physseg_get_end); + ATF_TP_ADD_TC(tp, uvm_physseg_get_end_invalid); + ATF_TP_ADD_TC(tp, uvm_physseg_get_avail_start); + ATF_TP_ADD_TC(tp, uvm_physseg_get_avail_start_invalid); + ATF_TP_ADD_TC(tp, uvm_physseg_get_avail_end); + ATF_TP_ADD_TC(tp, uvm_physseg_get_avail_end_invalid); + ATF_TP_ADD_TC(tp, uvm_physseg_get_next); + ATF_TP_ADD_TC(tp, uvm_physseg_get_next_invalid); + ATF_TP_ADD_TC(tp, uvm_physseg_get_prev); + ATF_TP_ADD_TC(tp, uvm_physseg_get_prev_invalid); + ATF_TP_ADD_TC(tp, uvm_physseg_get_first); + ATF_TP_ADD_TC(tp, uvm_physseg_get_last); + ATF_TP_ADD_TC(tp, uvm_physseg_valid); + ATF_TP_ADD_TC(tp, uvm_physseg_valid_invalid); + ATF_TP_ADD_TC(tp, uvm_physseg_get_highest); + ATF_TP_ADD_TC(tp, uvm_physseg_get_free_list); + ATF_TP_ADD_TC(tp, uvm_physseg_get_start_hint); + ATF_TP_ADD_TC(tp, uvm_physseg_set_start_hint); + ATF_TP_ADD_TC(tp, uvm_physseg_set_start_hint_invalid); + ATF_TP_ADD_TC(tp, uvm_physseg_get_pg); + +#ifdef __HAVE_PMAP_PHYSSEG + ATF_TP_ADD_TC(tp, uvm_physseg_get_pmseg); +#endif + ATF_TP_ADD_TC(tp, vm_physseg_find); + ATF_TP_ADD_TC(tp, vm_physseg_find_invalid); + + ATF_TP_ADD_TC(tp, uvm_page_physunload_start); + ATF_TP_ADD_TC(tp, uvm_page_physunload_end); + ATF_TP_ADD_TC(tp, uvm_page_physunload_none); + ATF_TP_ADD_TC(tp, uvm_page_physunload_delete_start); + ATF_TP_ADD_TC(tp, uvm_page_physunload_delete_end); + ATF_TP_ADD_TC(tp, uvm_page_physunload_invalid); + ATF_TP_ADD_TC(tp, uvm_page_physunload_force); + ATF_TP_ADD_TC(tp, uvm_page_physunload_force_invalid); + + return atf_no_error(); +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/sys/uvm/t_uvm_physseg.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/sys/uvm/t_uvm_physseg_load.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/sys/uvm/t_uvm_physseg_load.c (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/sys/uvm/t_uvm_physseg_load.c (revision 312126) @@ -0,0 +1,740 @@ +/* $NetBSD: t_uvm_physseg_load.c,v 1.2 2016/12/22 08:15:20 cherry Exp $ */ + +/*- + * Copyright (c) 2015, 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Santhosh N. Raju and + * by Cherry G. Mathew + * + * 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 +__RCSID("$NetBSD: t_uvm_physseg_load.c,v 1.2 2016/12/22 08:15:20 cherry Exp $"); + +/* + * If this line is commented out tests related touvm_physseg_get_pmseg() + * wont run. + * + * Have a look at machine/uvm_physseg.h for more details. + */ +#define __HAVE_PMAP_PHYSSEG + +/* + * This is a dummy struct used for testing purposes + * + * In reality this struct would exist in the MD part of the code residing in + * machines/vmparam.h + */ + +#ifdef __HAVE_PMAP_PHYSSEG +struct pmap_physseg { + int dummy_variable; /* Dummy variable use for testing */ +}; +#endif + +/* Testing API - assumes userland */ +/* Provide Kernel API equivalents */ +#include +#include +#include /* memset(3) et. al */ +#include /* printf(3) */ +#include /* malloc(3) */ +#include +#include +#include + +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" + +#define UVM_HOTPLUG /* Enable hotplug with rbtree. */ +#define PMAP_STEAL_MEMORY +#define DEBUG /* Enable debug functionality. */ + +typedef unsigned long vaddr_t; +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long vsize_t; + +#include +#include + +#ifndef DIAGNOSTIC +#define KASSERTMSG(e, msg, ...) /* NOTHING */ +#define KASSERT(e) /* NOTHING */ +#else +#define KASSERT(a) assert(a) +#define KASSERTMSG(exp, ...) printf(__VA_ARGS__); assert((exp)) +#endif + +#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH + +#define VM_NFREELIST 4 +#define VM_FREELIST_DEFAULT 0 +#define VM_FREELIST_FIRST16 3 +#define VM_FREELIST_FIRST1G 2 +#define VM_FREELIST_FIRST4G 1 + +/* + * Used in tests when Array implementation is tested + */ +#if !defined(VM_PHYSSEG_MAX) +#define VM_PHYSSEG_MAX 32 +#endif + +#define PAGE_SIZE 4096 +#define PAGE_SHIFT 12 +#define atop(x) (((paddr_t)(x)) >> PAGE_SHIFT) + +#define mutex_enter(l) +#define mutex_exit(l) + +#define _SYS_KMEM_H_ /* Disallow the real kmem API (see below) */ +/* free(p) XXX: pgs management need more thought */ +#define kmem_alloc(size, flags) malloc(size) +#define kmem_zalloc(size, flags) malloc(size) +#define kmem_free(p, size) free(p) + +psize_t physmem; + +struct uvmexp uvmexp; /* decl */ + +/* + * uvm structure borrowed from uvm.h + * + * Remember this is a dummy structure used within the ATF Tests and + * uses only necessary fields from the original uvm struct. + * See uvm/uvm.h for the full struct. + */ + +struct uvm { + /* vm_page related parameters */ + + bool page_init_done; /* TRUE if uvm_page_init() finished */ +} uvm; + +static void +panic(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vprintf(fmt, ap); + printf("\n"); + va_end(ap); + KASSERT(false); + + /*NOTREACHED*/ +} + +static void +uvm_pagefree(struct vm_page *pg) +{ + return; +} + +#if defined(UVM_HOTPLUG) +static void +uvmpdpol_reinit(void) +{ + return; +} +#endif /* UVM_HOTPLUG */ + +/* end - Provide Kernel API equivalents */ + +#include "uvm/uvm_physseg.c" + +#include + +#define ONE_MEGABYTE 1024 * 1024 + +/* Sample Page Frame Numbers */ +#define VALID_START_PFN_1 atop(0) +#define VALID_END_PFN_1 atop(ONE_MEGABYTE) +#define VALID_AVAIL_START_PFN_1 atop(0) +#define VALID_AVAIL_END_PFN_1 atop(ONE_MEGABYTE) + +#define VALID_START_PFN_2 atop(ONE_MEGABYTE + 1) +#define VALID_END_PFN_2 atop(ONE_MEGABYTE * 2) +#define VALID_AVAIL_START_PFN_2 atop(ONE_MEGABYTE + 1) +#define VALID_AVAIL_END_PFN_2 atop(ONE_MEGABYTE * 2) + +#define VALID_START_PFN_3 atop((ONE_MEGABYTE * 2) + 1) +#define VALID_END_PFN_3 atop(ONE_MEGABYTE * 3) +#define VALID_AVAIL_START_PFN_3 atop((ONE_MEGABYTE * 2) + 1) +#define VALID_AVAIL_END_PFN_3 atop(ONE_MEGABYTE * 3) + +#define VALID_START_PFN_4 atop(ONE_MEGABYTE + 1) +#define VALID_END_PFN_4 atop(ONE_MEGABYTE * 128) +#define VALID_AVAIL_START_PFN_4 atop(ONE_MEGABYTE + 1) +#define VALID_AVAIL_END_PFN_4 atop(ONE_MEGABYTE * 128) + +#define VALID_START_PFN_5 atop(ONE_MEGABYTE + 1) +#define VALID_END_PFN_5 atop(ONE_MEGABYTE * 256) +#define VALID_AVAIL_START_PFN_5 atop(ONE_MEGABYTE + 1) +#define VALID_AVAIL_END_PFN_5 atop(ONE_MEGABYTE * 256) + +/* + * Total number of pages (of 4K size each) should be 256 for 1MB of memory. + */ +#define PAGE_COUNT_1M 256 + +/* + * The number of Page Frames to allot per segment + */ +#define PF_STEP 8 + +/* + * A debug fucntion to print the content of upm. + */ + static inline void + uvm_physseg_dump_seg(uvm_physseg_t upm) + { +#if defined(DEBUG) + printf("%s: seg->start == %ld\n", __func__, + uvm_physseg_get_start(upm)); + printf("%s: seg->end == %ld\n", __func__, + uvm_physseg_get_end(upm)); + printf("%s: seg->avail_start == %ld\n", __func__, + uvm_physseg_get_avail_start(upm)); + printf("%s: seg->avail_end == %ld\n", __func__, + uvm_physseg_get_avail_end(upm)); + + printf("====\n\n"); +#else + return; +#endif /* DEBUG */ + } + +/* + * Private accessor that gets the value of vm_physmem.nentries + */ +static int +uvm_physseg_get_entries(void) +{ +#if defined(UVM_HOTPLUG) + return uvm_physseg_graph.nentries; +#else + return vm_nphysmem; +#endif /* UVM_HOTPLUG */ +} + +/* + * Note: This function replicates verbatim what happens in + * uvm_page.c:uvm_page_init(). + * + * Please track any changes that happen there. + */ +static void +uvm_page_init_fake(struct vm_page *pagearray, psize_t pagecount) +{ + uvm_physseg_t bank; + size_t n; + + for (bank = uvm_physseg_get_first(), + uvm_physseg_seg_chomp_slab(bank, pagearray, pagecount); + uvm_physseg_valid_p(bank); + bank = uvm_physseg_get_next(bank)) { + + n = uvm_physseg_get_end(bank) - uvm_physseg_get_start(bank); + uvm_physseg_seg_alloc_from_slab(bank, n); + uvm_physseg_init_seg(bank, pagearray); + + /* set up page array pointers */ + pagearray += n; + pagecount -= n; + } + + uvm.page_init_done = true; +} + +/* + * PHYS_TO_VM_PAGE: find vm_page for a PA. used by MI code to get vm_pages + * back from an I/O mapping (ugh!). used in some MD code as well. + */ +static struct vm_page * +uvm_phys_to_vm_page(paddr_t pa) +{ + paddr_t pf = atop(pa); + paddr_t off; + uvm_physseg_t psi; + + psi = uvm_physseg_find(pf, &off); + if (psi != UVM_PHYSSEG_TYPE_INVALID) + return uvm_physseg_get_pg(psi, off); + return(NULL); +} + +//static paddr_t +//uvm_vm_page_to_phys(const struct vm_page *pg) +//{ +// +// return pg->phys_addr; +//} + +/* + * XXX: To do, write control test cases for uvm_vm_page_to_phys(). + */ + +/* #define VM_PAGE_TO_PHYS(entry) uvm_vm_page_to_phys(entry) */ + +#define PHYS_TO_VM_PAGE(pa) uvm_phys_to_vm_page(pa) + +/* + * Test Fixture SetUp(). + */ +static void +setup(void) +{ + /* Prerequisites for running certain calls in uvm_physseg */ + uvmexp.pagesize = PAGE_SIZE; + uvmexp.npages = 0; + uvm.page_init_done = false; + uvm_physseg_init(); +} + +ATF_TC(uvm_physseg_100); +ATF_TC_HEAD(uvm_physseg_100, tc) +{ + atf_tc_set_md_var(tc, "descr", "Load test uvm_phys_to_vm_page() with \ + 100 calls, VM_PHYSSEG_MAX is 32."); +} +ATF_TC_BODY(uvm_physseg_100, tc) +{ + paddr_t pa; + + setup(); + + for(paddr_t i = VALID_START_PFN_1; + i < VALID_END_PFN_1; i += PF_STEP) { + uvm_page_physload(i, i + PF_STEP, i, i + PF_STEP, + VM_FREELIST_DEFAULT); + } + + ATF_REQUIRE_EQ(VM_PHYSSEG_MAX, uvm_physseg_get_entries()); + + srandom((unsigned)time(NULL)); + for(int i = 0; i < 100; i++) { + pa = (paddr_t) random() % (paddr_t) ctob(VALID_END_PFN_1); + PHYS_TO_VM_PAGE(pa); + } + + ATF_CHECK_EQ(true, true); +} + +ATF_TC(uvm_physseg_1K); +ATF_TC_HEAD(uvm_physseg_1K, tc) +{ + atf_tc_set_md_var(tc, "descr", "Load test uvm_phys_to_vm_page() with \ + 1000 calls, VM_PHYSSEG_MAX is 32."); +} +ATF_TC_BODY(uvm_physseg_1K, tc) +{ + paddr_t pa; + + setup(); + + for(paddr_t i = VALID_START_PFN_1; + i < VALID_END_PFN_1; i += PF_STEP) { + uvm_page_physload(i, i + PF_STEP, i, i + PF_STEP, + VM_FREELIST_DEFAULT); + } + + ATF_REQUIRE_EQ(VM_PHYSSEG_MAX, uvm_physseg_get_entries()); + + srandom((unsigned)time(NULL)); + for(int i = 0; i < 1000; i++) { + pa = (paddr_t) random() % (paddr_t) ctob(VALID_END_PFN_1); + PHYS_TO_VM_PAGE(pa); + } + + ATF_CHECK_EQ(true, true); +} + +ATF_TC(uvm_physseg_10K); +ATF_TC_HEAD(uvm_physseg_10K, tc) +{ + atf_tc_set_md_var(tc, "descr", "Load test uvm_phys_to_vm_page() with \ + 10,000 calls, VM_PHYSSEG_MAX is 32."); +} +ATF_TC_BODY(uvm_physseg_10K, tc) +{ + paddr_t pa; + + setup(); + + for(paddr_t i = VALID_START_PFN_1; + i < VALID_END_PFN_1; i += PF_STEP) { + uvm_page_physload(i, i + PF_STEP, i, i + PF_STEP, + VM_FREELIST_DEFAULT); + } + + ATF_REQUIRE_EQ(VM_PHYSSEG_MAX, uvm_physseg_get_entries()); + + srandom((unsigned)time(NULL)); + for(int i = 0; i < 10000; i++) { + pa = (paddr_t) random() % (paddr_t) ctob(VALID_END_PFN_1); + PHYS_TO_VM_PAGE(pa); + } + + ATF_CHECK_EQ(true, true); +} + +ATF_TC(uvm_physseg_100K); +ATF_TC_HEAD(uvm_physseg_100K, tc) +{ + atf_tc_set_md_var(tc, "descr", "Load test uvm_phys_to_vm_page() with \ + 100,000 calls, VM_PHYSSEG_MAX is 32."); +} +ATF_TC_BODY(uvm_physseg_100K, tc) +{ + paddr_t pa; + + setup(); + + for(paddr_t i = VALID_START_PFN_1; + i < VALID_END_PFN_1; i += PF_STEP) { + uvm_page_physload(i, i + PF_STEP, i, i + PF_STEP, + VM_FREELIST_DEFAULT); + } + + ATF_REQUIRE_EQ(VM_PHYSSEG_MAX, uvm_physseg_get_entries()); + + srandom((unsigned)time(NULL)); + for(int i = 0; i < 100000; i++) { + pa = (paddr_t) random() % (paddr_t) ctob(VALID_END_PFN_1); + PHYS_TO_VM_PAGE(pa); + } + + ATF_CHECK_EQ(true, true); +} + +ATF_TC(uvm_physseg_1M); +ATF_TC_HEAD(uvm_physseg_1M, tc) +{ + atf_tc_set_md_var(tc, "descr", "Load test uvm_phys_to_vm_page() with \ + 1,000,000 calls, VM_PHYSSEG_MAX is 32."); +} +ATF_TC_BODY(uvm_physseg_1M, tc) +{ + paddr_t pa; + + setup(); + + for(paddr_t i = VALID_START_PFN_1; + i < VALID_END_PFN_1; i += PF_STEP) { + uvm_page_physload(i, i + PF_STEP, i, i + PF_STEP, + VM_FREELIST_DEFAULT); + } + + ATF_REQUIRE_EQ(VM_PHYSSEG_MAX, uvm_physseg_get_entries()); + + srandom((unsigned)time(NULL)); + for(int i = 0; i < 1000000; i++) { + pa = (paddr_t) random() % (paddr_t) ctob(VALID_END_PFN_1); + PHYS_TO_VM_PAGE(pa); + } + + ATF_CHECK_EQ(true, true); +} + +ATF_TC(uvm_physseg_10M); +ATF_TC_HEAD(uvm_physseg_10M, tc) +{ + atf_tc_set_md_var(tc, "descr", "Load test uvm_phys_to_vm_page() with \ + 10,000,000 calls, VM_PHYSSEG_MAX is 32."); +} +ATF_TC_BODY(uvm_physseg_10M, tc) +{ + paddr_t pa; + + setup(); + + for(paddr_t i = VALID_START_PFN_1; + i < VALID_END_PFN_1; i += PF_STEP) { + uvm_page_physload(i, i + PF_STEP, i, i + PF_STEP, + VM_FREELIST_DEFAULT); + } + + ATF_REQUIRE_EQ(VM_PHYSSEG_MAX, uvm_physseg_get_entries()); + + srandom((unsigned)time(NULL)); + for(int i = 0; i < 10000000; i++) { + pa = (paddr_t) random() % (paddr_t) ctob(VALID_END_PFN_1); + PHYS_TO_VM_PAGE(pa); + } + + ATF_CHECK_EQ(true, true); +} + +ATF_TC(uvm_physseg_100M); +ATF_TC_HEAD(uvm_physseg_100M, tc) +{ + atf_tc_set_md_var(tc, "descr", "Load test uvm_phys_to_vm_page() with \ + 100,000,000 calls, VM_PHYSSEG_MAX is 32."); +} +ATF_TC_BODY(uvm_physseg_100M, tc) +{ + paddr_t pa; + + setup(); + + for(paddr_t i = VALID_START_PFN_1; + i < VALID_END_PFN_1; i += PF_STEP) { + uvm_page_physload(i, i + PF_STEP, i, i + PF_STEP, + VM_FREELIST_DEFAULT); + } + + ATF_REQUIRE_EQ(VM_PHYSSEG_MAX, uvm_physseg_get_entries()); + + srandom((unsigned)time(NULL)); + for(int i = 0; i < 100000000; i++) { + pa = (paddr_t) random() % (paddr_t) ctob(VALID_END_PFN_1); + PHYS_TO_VM_PAGE(pa); + } + + ATF_CHECK_EQ(true, true); +} + +ATF_TC(uvm_physseg_1MB); +ATF_TC_HEAD(uvm_physseg_1MB, tc) +{ + atf_tc_set_md_var(tc, "descr", "Load test uvm_phys_to_vm_page() with \ + 10,000,000 calls, VM_PHYSSEG_MAX is 32 on 1 MB Segment."); +} +ATF_TC_BODY(uvm_physseg_1MB, t) +{ + paddr_t pa = 0; + + paddr_t pf = 0; + + psize_t pf_chunk_size = 0; + + psize_t npages1 = (VALID_END_PFN_1 - VALID_START_PFN_1); + + psize_t npages2 = (VALID_END_PFN_2 - VALID_START_PFN_2); + + struct vm_page *slab = malloc(sizeof(struct vm_page) * + (npages1 + npages2)); + + setup(); + + /* We start with zero segments */ + ATF_REQUIRE_EQ(true, uvm_physseg_plug(VALID_START_PFN_1, npages1, NULL)); + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + /* Post boot: Fake all segments and pages accounted for. */ + uvm_page_init_fake(slab, npages1 + npages2); + + ATF_REQUIRE_EQ(true, uvm_physseg_plug(VALID_START_PFN_2, npages2, NULL)); + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + srandom((unsigned)time(NULL)); + for(pf = VALID_START_PFN_2; pf < VALID_END_PFN_2; pf += PF_STEP) { + pf_chunk_size = (psize_t) random() % (psize_t) (PF_STEP - 1) + 1; + uvm_physseg_unplug(pf, pf_chunk_size); + } + + for(int i = 0; i < 10000000; i++) { + pa = (paddr_t) random() % (paddr_t) ctob(VALID_END_PFN_2); + if(pa < ctob(VALID_START_PFN_2)) + pa += ctob(VALID_START_PFN_2); + PHYS_TO_VM_PAGE(pa); + } + + ATF_CHECK_EQ(true, true); +} + +ATF_TC(uvm_physseg_64MB); +ATF_TC_HEAD(uvm_physseg_64MB, tc) +{ + atf_tc_set_md_var(tc, "descr", "Load test uvm_phys_to_vm_page() with \ + 10,000,000 calls, VM_PHYSSEG_MAX is 32 on 64 MB Segment."); +} +ATF_TC_BODY(uvm_physseg_64MB, t) +{ + paddr_t pa = 0; + + paddr_t pf = 0; + + psize_t pf_chunk_size = 0; + + psize_t npages1 = (VALID_END_PFN_1 - VALID_START_PFN_1); + + psize_t npages2 = (VALID_END_PFN_3 - VALID_START_PFN_3); + + struct vm_page *slab = malloc(sizeof(struct vm_page) * + (npages1 + npages2)); + + setup(); + + /* We start with zero segments */ + ATF_REQUIRE_EQ(true, uvm_physseg_plug(VALID_START_PFN_1, npages1, NULL)); + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + /* Post boot: Fake all segments and pages accounted for. */ + uvm_page_init_fake(slab, npages1 + npages2); + + ATF_REQUIRE_EQ(true, uvm_physseg_plug(VALID_START_PFN_3, npages2, NULL)); + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + srandom((unsigned)time(NULL)); + for(pf = VALID_START_PFN_3; pf < VALID_END_PFN_3; pf += PF_STEP) { + pf_chunk_size = (psize_t) random() % (psize_t) (PF_STEP - 1) + 1; + uvm_physseg_unplug(pf, pf_chunk_size); + } + + for(int i = 0; i < 10000000; i++) { + pa = (paddr_t) random() % (paddr_t) ctob(VALID_END_PFN_3); + if(pa < ctob(VALID_START_PFN_3)) + pa += ctob(VALID_START_PFN_3); + PHYS_TO_VM_PAGE(pa); + } + + ATF_CHECK_EQ(true, true); +} + +ATF_TC(uvm_physseg_128MB); +ATF_TC_HEAD(uvm_physseg_128MB, tc) +{ + atf_tc_set_md_var(tc, "descr", "Load test uvm_phys_to_vm_page() with \ + 10,000,000 calls, VM_PHYSSEG_MAX is 32 on 128 MB Segment."); +} +ATF_TC_BODY(uvm_physseg_128MB, t) +{ + paddr_t pa = 0; + + paddr_t pf = 0; + + psize_t pf_chunk_size = 0; + + psize_t npages1 = (VALID_END_PFN_1 - VALID_START_PFN_1); + + psize_t npages2 = (VALID_END_PFN_4 - VALID_START_PFN_4); + + struct vm_page *slab = malloc(sizeof(struct vm_page) + * (npages1 + npages2)); + + setup(); + + /* We start with zero segments */ + ATF_REQUIRE_EQ(true, uvm_physseg_plug(VALID_START_PFN_1, npages1, NULL)); + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + /* Post boot: Fake all segments and pages accounted for. */ + uvm_page_init_fake(slab, npages1 + npages2); + + ATF_REQUIRE_EQ(true, uvm_physseg_plug(VALID_START_PFN_2, npages2, NULL)); + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + srandom((unsigned)time(NULL)); + for(pf = VALID_START_PFN_4; pf < VALID_END_PFN_4; pf += PF_STEP) { + pf_chunk_size = (psize_t) random() % (psize_t) (PF_STEP - 1) + 1; + uvm_physseg_unplug(pf, pf_chunk_size); + } + + for(int i = 0; i < 10000000; i++) { + pa = (paddr_t) random() % (paddr_t) ctob(VALID_END_PFN_4); + if(pa < ctob(VALID_START_PFN_4)) + pa += ctob(VALID_START_PFN_4); + PHYS_TO_VM_PAGE(pa); + } + + ATF_CHECK_EQ(true, true); +} + +ATF_TC(uvm_physseg_256MB); +ATF_TC_HEAD(uvm_physseg_256MB, tc) +{ + atf_tc_set_md_var(tc, "descr", "Load test uvm_phys_to_vm_page() with \ + 10,000,000 calls, VM_PHYSSEG_MAX is 32 on 256 MB Segment."); +} +ATF_TC_BODY(uvm_physseg_256MB, t) +{ + paddr_t pa = 0; + + paddr_t pf = 0; + + psize_t pf_chunk_size = 0; + + psize_t npages1 = (VALID_END_PFN_1 - VALID_START_PFN_1); + + psize_t npages2 = (VALID_END_PFN_5 - VALID_START_PFN_5); + + struct vm_page *slab = malloc(sizeof(struct vm_page) * (npages1 + npages2)); + + setup(); + + /* We start with zero segments */ + ATF_REQUIRE_EQ(true, uvm_physseg_plug(VALID_START_PFN_1, npages1, NULL)); + ATF_REQUIRE_EQ(1, uvm_physseg_get_entries()); + + /* Post boot: Fake all segments and pages accounted for. */ + uvm_page_init_fake(slab, npages1 + npages2); + + ATF_REQUIRE_EQ(true, uvm_physseg_plug(VALID_START_PFN_2, npages2, NULL)); + ATF_REQUIRE_EQ(2, uvm_physseg_get_entries()); + + srandom((unsigned)time(NULL)); + for(pf = VALID_START_PFN_5; pf < VALID_END_PFN_5; pf += PF_STEP) { + pf_chunk_size = (psize_t) random() % (psize_t) (PF_STEP - 1) + 1; + uvm_physseg_unplug(pf, pf_chunk_size); + } + + for(int i = 0; i < 10000000; i++) { + pa = (paddr_t) random() % (paddr_t) ctob(VALID_END_PFN_5); + if(pa < ctob(VALID_END_PFN_5)) + pa += ctob(VALID_START_PFN_5); + PHYS_TO_VM_PAGE(pa); + } + + ATF_CHECK_EQ(true, true); +} + +ATF_TP_ADD_TCS(tp) +{ + /* Fixed memory size tests. */ + ATF_TP_ADD_TC(tp, uvm_physseg_100); + ATF_TP_ADD_TC(tp, uvm_physseg_1K); + ATF_TP_ADD_TC(tp, uvm_physseg_10K); + ATF_TP_ADD_TC(tp, uvm_physseg_100K); + ATF_TP_ADD_TC(tp, uvm_physseg_1M); + ATF_TP_ADD_TC(tp, uvm_physseg_10M); + ATF_TP_ADD_TC(tp, uvm_physseg_100M); + +#if defined(UVM_HOTPLUG) + /* Variable memory size tests. */ + ATF_TP_ADD_TC(tp, uvm_physseg_1MB); + ATF_TP_ADD_TC(tp, uvm_physseg_64MB); + ATF_TP_ADD_TC(tp, uvm_physseg_128MB); + ATF_TP_ADD_TC(tp, uvm_physseg_256MB); +#endif /* UVM_HOTPLUG */ + + return atf_no_error(); +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/sys/uvm/t_uvm_physseg_load.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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/mixerctl/t_mixerctl.sh =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/mixerctl/t_mixerctl.sh (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/mixerctl/t_mixerctl.sh (revision 312126) @@ -0,0 +1,51 @@ +# $NetBSD: t_mixerctl.sh,v 1.1 2017/01/02 15:40:09 christos Exp $ + +atf_test_case noargs_usage +noargs_usage_head() { + atf_set "descr" "Ensure mixerctl(1) with no args prints a usage message" +} +noargs_usage_body() { + atf_check -s exit:0 -o not-empty -e ignore \ + mixerctl +} + +atf_test_case showvalue +showvalue_head() { + atf_set "descr" "Ensure mixerctl(1) can print the value for all variables" +} +showvalue_body() { + for var in $(mixerctl -a | awk -F= '{print $1}'); do + atf_check -s exit:0 -e ignore -o match:"^${var}=" \ + mixerctl ${var} + done +} + +atf_test_case nflag +nflag_head() { + atf_set "descr" "Ensure 'mixerctl -n' actually suppresses some output" +} +nflag_body() { + varname="$(mixerctl -a | head -1 | awk -F= '{print $1}')" + + atf_check -s exit:0 -o match:"${varname}" -e ignore \ + mixerctl ${varname} + + atf_check -s exit:0 -o not-match:"${varname}" -e ignore \ + mixerctl -n ${varname} +} + +atf_test_case nonexistant_device +nonexistant_device_head() { + atf_set "descr" "Ensure mixerctl(1) complains if provided a nonexistant mixer device" +} +nonexistant_device_body() { + atf_check -s not-exit:0 -o ignore -e match:"No such file" \ + mixerctl -d /a/b/c/d/e +} + +atf_init_test_cases() { + atf_add_test_case noargs_usage + atf_add_test_case showvalue + atf_add_test_case nflag + atf_add_test_case nonexistant_device +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/mixerctl/t_mixerctl.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ 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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_basic.in =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_basic.in (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_basic.in (revision 312126) @@ -0,0 +1,4 @@ +1 +12 +1 +1 Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_basic.in ___________________________________________________________________ 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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_basic.out =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_basic.out (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_basic.out (revision 312126) @@ -0,0 +1,3 @@ +1 +12 +1 Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_counts.out =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_counts.out (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_counts.out (revision 312126) @@ -0,0 +1,6 @@ + 1 #01 foo0 bar0 foo1 bar1 + 1 #02 bar0 foo1 bar1 foo1 + 1 #03 foo0 bar0 foo1 bar1 + 1 #04 + 2 #05 foo0 bar0 foo1 bar1 + 1 #07 bar0 foo1 bar1 foo0 Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_input.in =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_input.in (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_input.in (revision 312126) @@ -0,0 +1,7 @@ +#01 foo0 bar0 foo1 bar1 +#02 bar0 foo1 bar1 foo1 +#03 foo0 bar0 foo1 bar1 +#04 +#05 foo0 bar0 foo1 bar1 +#06 foo0 bar0 foo1 bar1 +#07 bar0 foo1 bar1 foo0 Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_input.in ___________________________________________________________________ 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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_show_duplicates.out =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_show_duplicates.out (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_show_duplicates.out (revision 312126) @@ -0,0 +1 @@ +#05 foo0 bar0 foo1 bar1 Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_show_uniques.out =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_show_uniques.out (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/d_show_uniques.out (revision 312126) @@ -0,0 +1,5 @@ +#01 foo0 bar0 foo1 bar1 +#02 bar0 foo1 bar1 foo1 +#03 foo0 bar0 foo1 bar1 +#04 +#07 bar0 foo1 bar1 foo0 Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/t_uniq.sh =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/t_uniq.sh (nonexistent) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/t_uniq.sh (revision 312126) @@ -0,0 +1,97 @@ +# $NetBSD: t_uniq.sh,v 1.1 2016/10/22 14:13:39 abhinav Exp $ +# +# Copyright (c) 2016 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Abhinav Upadhyay +# +# 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. +# + +atf_test_case basic +basic_head() +{ + atf_set "descr" "Checks the basic functionality" +} +basic_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_basic.out uniq \ + $(atf_get_srcdir)/d_basic.in +} + +atf_test_case test_counts +test_counts_head() +{ + atf_set "descr" "Tests the -c option, comparing each line of the input" \ + "file data starting from the second field" +} +test_counts_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_counts.out uniq -c -f 1 \ + $(atf_get_srcdir)/d_input.in +} + +atf_test_case show_duplicates +show_duplicates_head() +{ + atf_set "descr" "Checks the -d option, comparing each line of the input" \ + "file data starting from the second field" +} +show_duplicates_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_show_duplicates.out uniq -d -f 1 \ + $(atf_get_srcdir)/d_input.in +} + +atf_test_case show_uniques +show_uniques_head() +{ + atf_set "descr" "Checks the -u option, comparing each line of the input" \ + "file data starting from the second field" +} +show_uniques_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_show_uniques.out uniq -u -f 1 \ + $(atf_get_srcdir)/d_input.in +} + +atf_test_case show_duplicates_from_third_character +show_duplicates_from_third_character_head() +{ + atf_set "descr" "Checks the -d option, comparing each line of the input" \ + "file data starting from the third character (-s option)" +} +show_duplicates_from_third_character_body() +{ + atf_check -o empty uniq -d -s 2 $(atf_get_srcdir)/d_input.in + +} + +atf_init_test_cases() +{ + atf_add_test_case basic + atf_add_test_case test_counts + atf_add_test_case show_duplicates + atf_add_test_case show_uniques + atf_add_test_case show_duplicates_from_third_character +} Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/usr.bin/uniq/t_uniq.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ 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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests (revision 312125) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests (revision 312126) Property changes on: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /vendor/NetBSD/tests/dist:r311967-311969,311971-312123