Index: head/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue =================================================================== --- head/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue (revision 313438) +++ head/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue (revision 313439) @@ -1,1040 +1,1035 @@ begin 644 t_pad_output.bz2 -M0EIH.3%!629360S39&D`>;SS,K;%2@`2::%N=I -MVR86:*KOO>O99MMM-XP&76N]W/6T=[SW@<[G'3H:Z'K1F?=WON]WO>]S=WN^ -ML]W>^WN[[W;V\VW>[OMN^WW;;3+3/=TK*Y5E4LVE#-E5H:"S530#1IB5LS:V -MJHK6!JVA2M9LR*V:MFUJ55JBM:Q4*EL,5$`50)L6M11:P55:V%+55:U5C!I3 -M1L,BU5-5JV-%F55-5EL;:@5:K+%5:S--;5-;:M5MJVZZ[:V]>[:7NTN>][;> -M[O/MO-M[NYOM]WN^[K69ON\^][WO(Q/N8ZZ![N''=O3VP[V/>RCRX[0VJ7FW -M-FQJ%7-G0R;9MB*N\G'>PTM*5H%``-LF2NKF=-LQFU*50444`446P`&FV06V -MUE17-HDJB[#--!MBC$-1L#;!MF@JALFIM-IE3-30"JH#2D`$`!,F$R83(830 -M--,AD!H&AH`R#$9`:&AHR`Q-`,":8)D8C`3)@FF":8@P"9,$,"&)D#0)@$&D -MD$TPF@`)@```````-`"8`)@"8F$R8`F3$`)@`:&F@),R83":8$Q---,"8"8( -M,:1D#!,H--)2:$$VF##`"#329,1A-!,Q$:F)A-#$-3TT4>F4]">IZ0&U#3:@ -MVC4#`-(/4#3T@#30&@/1/1#0#1D``#$-!HR:-!)I2E$H&3TVPVH\BE/QIHC1 -M3,34T4]IE-I0WD4?IJ33T0`R:&T0`9!IM0&CRC(`!HT&AZ@`&@`````````` -M``TI$#1IHIFU,F`T:F*>"G@$F:3TP"-3T9&"&FT*/3"3R,33)I/":&C(T&(T -M4\T-`GIDR-,$T:GIJ>1B831II/(&D\C4S(::8F)HU-02:E)*!#5/%/>V,B-H -MB&"-#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G+GQMN[@ +M\N+3J.*ZC%Y,Y"!M8G7@`M=J\;M9&E_/&A[[/LWC,1#I;I9;G`XA`KVLS/:7 +M+WJ,2-3%!F+4@6`P:ETZ*-&ZL"]2-B0H+3K4H`!)+VO[BDGHZ$5RPUGIHQEF +MY504K%*A$.=J\C)R4-I,^B$_!X.4'MN#[V`3"I:[D)=O^_19RW;8%6E55&3E:\"H4GNR3=("`V%YKL?J_+H +M%+O\X_IU%@]B4!#6E![8_&@A+;Y)B=Y3_+D`+9HNUI(3Y)?WY8H@4)9\3#D?1 +ME0HX7U@GG=GN>YD"%P_W6DC^W0[CPOFE:5H[3-12VMKJFO[EK8`"G=AT[Z2SPX,E9?G4#KR&08@0H5]\U8GT'Q\>UV[ +M*"(9J/D)1WDZL;[+[[FL,#D]$[I8%A^,KX>O2+K``0VKJXS-/!G$U/#XG(0O +M"OJ_&SOB`$`QJDECIERVTTTSVI6G-&2C?GU8O)+ #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, 0x93, 0xba, 0x09, 0x4b, 0x20, 0xf3, 0xe6, 0x44, 0x30, 0x5e, 0x9e, 0xfc, 0x7a, 0x3c, 0x7d, 0x11, 0x63, 0xea, 0x40, 0x94, 0xaa, 0xd0, 0xa9, 0xf6, 0xc7, 0x1e, 0x8f, 0xc8, 0xa6, 0x2c, 0xf7, 0xeb, 0x51, 0x26, 0xdc, 0xf8, 0x73, 0xf9, 0xb4, 0xa8, 0x80, 0x4a, 0xe5, 0x6f, 0xb6, 0x33, 0x13, 0x6b, 0x1b, 0x7d, 0x00, 0xde, 0x44, 0x7e, 0x26, 0xa2, 0x82, 0xa7, 0x80, 0x16, 0x34, 0xde, 0xb9, 0x82, 0x4c, 0x42, 0x8e, 0x0d, 0x48, 0x7e, 0x38, 0xbd, 0x1d, 0x7d, 0x98, 0xbb, 0x11, 0x8a, 0x72, 0x14, 0x4e, 0xaa, 0xd0, 0xef, 0x4d, 0x7f, 0xa3, 0xa6, 0xfc, 0x85, 0x9d, 0x74, 0x63, 0x9d, 0xe4, 0x5c, 0xf7, 0xa8, 0xd0, 0xd7, 0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a, 0xae, 0x71, 0x7a, 0x07, 0xd7, 0xec, 0x75, 0x2f, 0x8a, 0x99, 0x59, 0x13, 0xd0, 0x8d, 0x18, 0x69, 0x0d, 0xd9, 0x39, 0x73, 0x2b, 0xd0, 0xa3, 0xbc, 0x9e, 0x29, 0x4d, 0x88, 0xff, 0x98, 0x02, 0xb4, 0xcf, 0xa1, 0xf9, 0x2a, 0xa6, 0xef, 0x7c, 0x72, 0x26, 0x4e, 0xd7, 0xdf, 0xec, 0x3a, 0xbc, 0x8e, 0xe6, 0xb3, 0x2b, 0x43, 0xcd, 0x67, 0x8b, 0x72, 0x00, 0x6f, 0xe5, 0x85, 0xe2, 0x2a, 0x4c, 0x8d, 0x02, 0x44, 0x6b, 0x7a, 0x89, 0x7a, 0x18, 0x3b, 0xc8, 0x9c, 0x8d, 0x60, 0xec, 0x79, 0x58, 0x15, 0x98, 0x71, 0x4b, 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, 0x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 0x1f, 0x4f, 0x55, 0x2c, 0x1d, 0x26, 0x7f, 0xc9, 0x27, 0x00, 0x88, 0x7d, 0x45, 0x4e, 0xe1, 0x36, 0xf6, 0xf5, 0xa8, 0xd4, 0xef, 0x8b, 0x26, 0x76, 0x41, 0x28, 0x87, 0xf4, 0x51, 0x14, 0x36, 0xad, 0x60, 0x8d, 0xe9, 0xe2, 0x9d, 0x3c, 0xea, 0x09, 0x51, 0x3c, 0x81, 0xdf, 0x1a, 0xc2, 0xc2, 0xf6, 0x45, 0xe1, 0x73, 0xac, 0xae, 0x85, 0x74, 0x83, 0x8f, 0x56, 0x3c, 0x36, 0x1c, 0xe0, 0x07, 0xc6, 0x6a, 0x48, 0xe4, 0x34, 0xe9, 0x81, 0x53, 0xb7, 0x53, 0x95, 0xa7, 0x94, 0x21, 0x7e, 0x32, 0x53, 0xda, 0x83, 0xd8, 0x57, 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,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xaf, 0x40, 0x17, 0xed, 0x2b, 0x60, 0x73, 0x7d, 0x99, 0x95, 0x3f, 0xd6, 0x6c, 0xca, 0x1e, 0xf3, 0xb0, 0xcd, 0xd5, 0x1d, 0x53, 0xe0, 0xd2, 0x8b, 0x57, 0x7b, 0xac, 0x67, 0x5a, 0x5a, 0x0a, 0x64, 0x82, 0xab, 0x8f, 0x5a, 0x36, 0xe2, 0x45, 0x50, 0xec, 0x3e, 0x14, 0x80, 0x7c, 0xfd, 0x0c, 0xa9, 0x94, 0xfb, 0xfe, 0x72, 0xec, 0x47, 0x71, 0x2e, 0x90, 0x97, 0xf6, 0x33, 0xbd, 0x7d, 0x7e, 0x77, 0x8f, 0xad, 0xd4, 0x1d, 0x1d, 0x53, 0x0f, 0x28, 0x39, 0x77, 0x06, 0x1a, 0x75, 0xfc, 0x12, 0xe6, 0x45, 0xfc, 0x87, 0xe1, 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, 0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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, 0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8, 0x93, 0x57, 0x6b, 0xd5, 0xa4, 0xad, 0x9a, 0x97, 0xeb, 0x97, 0xe7, 0x60, 0x01, 0x89, 0x3f, 0x88, 0xf2, 0xee, 0xf3, 0x79, 0xd6, 0x5a, 0x03, 0x94, 0x07, 0xd3, 0x33, 0xc8, 0xda, 0x15, 0x17, 0x0a, 0x8f, 0xbd, 0x58, 0x1b, 0xfe, 0x3d, 0x77, 0x5d, 0x8f, 0x4e, 0x0e, 0x98, 0x7d, 0x02, 0x63, 0x94, 0x73, 0x4a, 0x58, 0x47, 0xed, 0x52, 0xfc, 0x85, 0x19, 0x5d, 0x2f, 0xfa, 0x07, 0x44, 0xbd, 0x8e, 0xcb, 0x20, 0x63, 0x9d, 0x2b, 0x61, 0x5c, 0x19, 0x71, 0x80, 0xe5, 0x25, 0x5b, 0x2e, 0xc5, 0xfe, 0x1a, }; /* * IV method encblkno8, 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, 0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, 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, 0xd2, 0xd8, 0xa7, 0x7f, 0x41, 0x98, 0x24, 0xa8, 0x28, 0x0c, 0x88, 0x55, 0x91, 0xdb, 0x29, 0x17, 0x70, 0xd7, 0x03, 0xff, 0xbd, 0x0e, 0xbf, 0xf8, 0x73, 0x92, 0x19, 0xe9, 0x92, 0x67, 0xdb, 0x08, 0x94, 0x77, 0x71, 0x2d, 0x00, 0xad, 0x26, 0x42, 0x2d, 0xac, 0x8c, 0x67, 0x6f, 0xb3, 0x8e, 0x36, 0x22, 0xeb, 0x1f, 0x8c, 0xd4, 0x9b, 0x9f, 0xa6, 0xa9, 0xb1, 0x52, 0x65, 0x9a, 0xfe, 0xcc, 0x92, 0x48, 0x75, 0xf6, 0xb8, 0x59, 0xfe, 0x0e, 0x67, 0x93, 0xce, 0x3b, 0x7e, 0x51, 0x74, 0xe5, 0x24, 0x35, 0x08, 0x68, 0x21, 0x6a, 0x7f, 0xdd, 0x8c, 0xfd, 0xcd, 0x6d, 0x90, 0xc5, 0x3b, 0x26, 0x9e, 0x00, 0xf4, 0x1e, 0x70, 0xd3, 0xe7, 0xe8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, 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, 0x2c, 0x0b, 0x95, 0x3a, 0xaf, 0xc0, 0xf3, 0x1f, 0x0e, 0x07, 0x01, 0xa6, 0x35, 0x19, 0x79, 0x91, 0x24, 0xaa, 0x0d, 0xf0, 0x53, 0x27, 0x7d, 0xbb, 0xa6, 0xb6, 0x44, 0x31, 0x4b, 0xd4, 0xcf, 0xf6, 0x6d, 0x18, 0xa2, 0x28, 0x8a, 0xc1, 0x0a, 0xbe, 0x57, 0x0c, 0x61, 0x5f, 0xd9, 0x12, 0x14, 0xfe, 0xe2, 0xc7, 0x10, 0x72, 0xee, 0x19, 0xb8, 0x16, 0x0b, 0x88, 0x87, 0xce, 0xf3, 0xfe, 0x57, 0x37, 0xd1, 0xa2, 0xf7, 0xd0, 0x5e, 0x73, 0xde, 0x39, 0x35, 0xbc, 0xde, 0xed, 0x61, 0x4b, 0x31, 0xdc, 0xfe, 0x3c, 0x4d, 0x98, 0xa9, 0x36, 0xb0, 0x34, 0x5b, 0xb4, 0xb7, 0x79, 0x25, 0x6e, 0x24, 0x7e, 0x10, 0xfe, 0x20, 0xd5, 0x16, 0x86, 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, 0xd2, 0x37, 0xd6, 0xca, 0x5d, 0xb9, 0xf4, 0x51, 0x31, 0x8a, 0x1a, 0x82, 0xbd, 0x6f, 0x6d, 0x88, 0x2b, 0x63, 0x0f, 0xe1, 0xf0, 0xcf, 0x13, 0x79, 0x1d, 0x78, 0x82, 0x66, 0xa1, 0xef, 0xdb, 0x34, 0x50, 0xd2, 0x71, 0x47, 0x49, 0x41, 0x74, 0xd9, 0x0b, 0x14, 0x38, 0x1f, 0xc3, 0x09, 0x4d, 0xb3, 0xa6, 0x03, 0x3f, 0x56, 0x67, 0xd7, 0x51, 0x4c, 0x8a, 0x1d, 0x37, 0x99, 0xfb, 0xe1, 0x84, 0x57, 0x55, 0x9b, 0xf8, 0x73, 0x63, 0x68, 0x73, 0x89, 0x52, 0x06, 0xe7, 0x34, 0xe7, 0x1a, 0x15, 0x7e, 0xd9, 0x84, 0xa3, 0x0e, 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: head/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c =================================================================== --- head/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c (revision 313438) +++ head/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c (revision 313439) @@ -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, 0xa7, 0x56, 0x95, 0xa0, 0xa7, 0x35, 0x77, 0xf4, 0xdd, 0xdc, 0x37, 0xc0, 0x28, 0x20, 0x00, 0x79, 0xa0, 0x35, 0xe0, 0x83, 0x23, 0x95, 0x4e, 0xea, 0x8d, 0xa2, 0x11, 0xbf, 0x9a, 0xd5, 0x21, 0x1e, 0x15, 0xb9, 0xd1, 0x2e, 0xd2, 0xd9, 0xa5, 0xcc, 0x26, 0x75, 0xba, 0x3e, 0x30, 0x11, 0xb2, 0x40, 0xdd, 0x1d, 0x07, 0x3b, 0xe6, 0x00, 0xa7, 0x31, 0x9e, 0x58, 0x41, 0xf3, 0x02, 0xf5, 0xad, 0x35, 0x79, 0x9a, 0x9e, 0x03, 0xc8, 0x7a, 0x9d, 0x1d, 0x58, 0x9f, 0x98, 0x67, 0xe2, 0x49, 0x81, 0x0c, 0x23, 0x90, 0xd8, 0xc6, 0xf0, 0xc5, 0x73, 0x46, 0xd5, 0x14, 0x1d, 0x78, 0x24, 0x7c, 0x9f, 0x5c, 0x8c, 0xe6, 0x5d, 0x85, 0x7a, 0x5f, 0x76, 0xcc, 0xd8, 0xe9, 0x03, 0xff, 0xfd, 0xd4, 0x12, 0x3f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x5c, 0xc7, 0x38, 0xe9, 0x92, 0xcd, 0x35, 0xfd, 0x1c, 0xcc, 0x3c, 0x28, 0x75, 0x6f, 0xff, 0xd5, 0xe8, 0xbf, 0x90, 0x92, 0x34, 0x13, 0x11, 0x89, 0xe0, 0xa2, 0x25, 0xeb, 0x82, 0x63, 0x31, 0x80, 0x50, 0x6c, 0x99, 0xaa, 0x97, 0x0e, 0x59, 0x45, 0x64, 0xb8, 0x77, 0x78, 0x6b, 0x24, 0xac, 0xc0, 0xc9, 0xa9, 0xbc, 0x13, 0xd1, 0x5e, 0x50, 0x9a, 0x91, 0x1a, 0x08, 0xf7, 0xc5, 0x18, 0x9f, 0x87, 0x97, 0x9c, 0x0a, 0x27, 0xf1, 0x66, 0xf8, 0x09, 0x52, 0x09, 0x41, 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, 0x26, 0xeb, 0x91, 0xc6, 0x4b, 0xf0, 0x38, 0xdf, 0x9f, 0x9d, 0x6c, 0xd8, 0x49, 0x83, 0x88, 0xbe, 0x62, 0x2d, 0x5e, 0x88, 0xc0, 0x35, 0xe4, 0xc3, 0xc9, 0x9f, 0x62, 0x59, 0x16, 0xa7, 0x2e, 0xc0, 0xda, 0x3c, 0x2e, 0x10, 0x53, 0xf0, 0x84, 0x27, 0x38, 0xd0, 0xf4, 0xb5, 0x7c, 0x4a, 0x63, 0x04, 0x51, 0x22, 0xae, 0xf3, 0xe7, 0x97, 0x53, 0xee, 0xe6, 0xaf, 0xc3, 0x49, 0x3a, 0x5a, 0x74, 0x83, 0x18, 0xa3, 0x6b, 0xf3, 0x6a, 0x3b, 0xe2, 0x1b, 0xd4, 0x64, 0x41, 0xdf, 0xd1, 0xd2, 0xdd, 0x22, 0xa8, 0x66, 0xbd, 0x8e, 0xc4, 0x9a, 0x6d, 0x15, 0x38, 0x5b, 0x50, 0x9a, 0x65, 0x48, 0x97, 0xf1, 0x04, 0x85, 0x8b, 0x5c, 0x44, 0x32, 0x15, 0xea, 0x28, 0x5f, 0x98, 0x53, 0xb4, 0x80, 0xd0, 0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, 0x95, 0x44, 0x52, 0x3b, 0x59, 0x9d, 0x0b, 0x77, 0xa0, 0x39, 0x40, 0xea, 0x33, 0x25, 0xc8, 0xc5, 0x90, 0x47, 0x23, 0xe3, 0x03, 0x8c, 0x6a, 0xe0, 0x4f, 0x76, 0xe7, 0x72, 0x82, 0xcc, 0xb2, 0xfd, 0xfb, 0x82, 0x1a, 0x28, 0x30, 0x89, 0x0e, 0x25, 0xa7, 0x63, 0x85, 0x2e, 0x9b, 0xa6, 0x0b, 0xa0, 0xb5, 0x34, 0xa2, 0x2e, 0x7f, 0xd4, 0xe5, 0xd6, 0x95, 0xe8, 0x09, 0x3d, 0x4d, 0xdf, 0xd9, 0xc0, 0x63, 0x17, 0xa5, 0x9c, 0xf6, 0xa3, 0x59, 0x17, 0xc0, 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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f2, 0x5e, 0xe6, 0x13, 0x86, 0xfa, 0xc6, 0xde, 0xd8, 0xe1, 0x70, 0xb4, 0xf7, 0x5b, 0x9f, 0x79, 0x55, 0x22, 0x7a, 0xe1, 0x54, 0x40, 0x39, 0x11, 0xe1, 0x78, 0x01, 0x01, 0xc0, 0x44, 0xeb, 0x92, 0xb9, 0x01, 0xdd, 0x56, 0xb9, 0x7e, 0xa0, 0x50, 0x41, 0x58, 0xb2, 0x13, 0x12, 0x44, 0xd2, 0x39, 0xf2, 0x76, 0x3c, 0x53, 0x36, 0xfe, 0x17, 0x74, 0x91, 0x8d, 0xbe, 0xc5, 0x40, 0xf7, 0xa2, 0xe9, 0x65, 0xd9, 0xdf, 0x80, 0x7b, 0xd9, 0xc3, 0x1f, 0xb4, 0xfc, 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, 0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62, 0x5f, 0x7a, 0x2a, 0x37, 0x88, 0xea, 0x57, 0x99, 0x64, 0x50, 0x2d, 0xd3, 0x6a, 0x09, 0x4b, 0xd6, 0x61, 0xf2, 0x22, 0x53, 0x36, 0xf7, 0x42, 0x21, 0xde, 0xda, 0xcb, 0x8b, 0x6f, 0xf3, 0x4e, 0x2c, 0x16, 0xfb, 0xfc, 0x13, 0xa7, 0xd1, 0xd8, 0xfd, 0x16, 0x39, 0x20, 0xe0, 0xb2, 0xb4, 0xd5, 0x40, 0x93, 0x30, 0xf3, 0xab, 0x88, 0xe3, 0xfb, 0xbe, 0xb8, 0x02, 0x3a, 0x78, 0x2d, 0x56, 0x4b, 0x92, 0x5b, 0x0a, 0x8d, 0x18, 0xa4, 0x5b, 0x11, 0x60, 0x0b, 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,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0, 0xb9, 0x5e, 0x1f, 0x88, 0x0e, 0x08, 0x2c, 0xf3, 0xb4, 0x3a, 0x15, 0xc5, 0xf9, 0x5b, 0x85, 0x92, 0x94, 0xa8, 0x8f, 0x2c, 0x3a, 0x7e, 0x22, 0x86, 0x88, 0x51, 0x03, 0xee, 0xf9, 0x2e, 0x83, 0xce, 0x39, 0x0c, 0x76, 0x64, 0xe5, 0x5a, 0x88, 0xef, 0xc5, 0x06, 0xb2, 0xe4, 0x13, 0x82, 0xc9, 0xee, 0xba, 0x6d, 0x56, 0xa8, 0x87, 0x51, 0x69, 0x3b, 0x86, 0x29, 0x8e, 0xe8, 0xb4, 0x44, 0x42, 0x07, 0x5b, 0xff, 0x0e, 0x1e, 0x9f, 0x42, 0xb1, 0xc8, 0x5f, 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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, 0x93, 0x5b, 0x60, 0x2f, 0xb5, 0xfe, 0x82, 0xaf, 0x85, 0xb7, 0x79, 0x7c, 0xee, 0xad, 0xea, 0xfa, 0x9b, 0xad, 0xca, 0x38, 0x21, 0x3d, 0x46, 0x8a, 0x5b, 0xa7, 0x55, 0x3d, 0x88, 0x4a, 0x52, 0xdb, 0xf2, 0x07, 0xed, 0xd6, 0x3c, 0x9f, 0x1b, 0x42, 0xb4, 0x14, 0x12, 0xb7, 0x00, 0xfc, 0x6a, 0x79, 0x61, 0x0b, 0x43, 0xaa, 0x44, 0x48, 0x30, 0x15, 0x48, 0x76, 0x27, 0x32, 0x7a, 0x2e, 0x25, 0x6a, 0x8c, 0x8c, 0x64, 0x67, 0x86, 0x54, 0x4a, 0x93, 0x14, 0xfe, 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, 0x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f, 0x21, 0x5e, 0xf2, 0x77, 0x5a, 0x42, 0xfd, 0xd3, 0xc4, 0x31, 0xaf, 0xd6, 0x6c, 0x6c, 0xde, 0x8c, 0x50, 0x01, 0x8f, 0x57, 0x90, 0x88, 0x43, 0xf9, 0x44, 0x09, 0x4d, 0x27, 0x58, 0x9f, 0xae, 0x50, 0x28, 0x12, 0x47, 0x20, 0x79, 0x2b, 0xe4, 0x02, 0x97, 0xcd, 0xab, 0x53, 0x28, 0x8f, 0x8f, 0xe3, 0x3b, 0xd6, 0xc9, 0xc8, 0xff, 0xbf, 0x18, 0x3b, 0x75, 0xdb, 0xcf, 0x07, 0x8c, 0xfe, 0x58, 0xee, 0x75, 0x01, 0x98, 0x98, 0xe4, 0x60, 0xfe, 0xe6, 0x7f, }; /* * 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, 0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 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, 0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b, 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_ctxt[SECSIZE] = { 0xe6, 0x41, 0x75, 0xd6, 0x80, 0xdf, 0x44, 0x37, 0xa7, 0xa2, 0xb2, 0x29, 0x0d, 0xf0, 0x02, 0x78, 0x92, 0xb2, 0x06, 0x5f, 0x86, 0xd3, 0x9c, 0xa3, 0xd0, 0xc5, 0x08, 0x03, 0x6d, 0x41, 0x9d, 0x61, 0xb4, 0xb9, 0xa1, 0x69, 0x6e, 0x3a, 0x78, 0xd7, 0x04, 0x94, 0xf2, 0x53, 0xed, 0xd1, 0xf6, 0xd8, 0x98, 0xe2, 0x49, 0x75, 0x15, 0x85, 0xe0, 0x78, 0x5b, 0x28, 0x5e, 0xe6, 0xfa, 0x60, 0x3d, 0x4b, 0x8c, 0xf1, 0x1a, 0xfd, 0x1f, 0xe8, 0xad, 0xb4, 0xa1, 0xe7, 0xd3, 0x71, 0x16, 0xdf, 0xc6, 0x95, 0xd4, 0x43, 0xaf, 0x92, 0xab, 0x74, 0x0f, 0x77, 0x75, 0x4d, 0xd7, 0x13, 0x97, 0x18, 0xea, 0x43, 0x92, 0x0d, 0x88, 0xc8, 0x41, 0xf7, 0x15, 0x34, 0x0f, 0x63, 0xbf, 0x50, 0x18, 0xb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, 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, 0xf8, 0xf5, 0x5a, 0x39, 0x30, 0xad, 0x64, 0x42, 0x06, 0xa3, 0xce, 0x3f, 0x67, 0xd6, 0x6e, 0xcd, 0x3b, 0xf5, 0x03, 0x2b, 0x07, 0x83, 0x18, 0x1a, 0x4f, 0x4c, 0xe7, 0x6b, 0xe8, 0xf9, 0x19, 0xa5, 0x23, 0x8f, 0x46, 0x35, 0x13, 0x7b, 0x61, 0x05, 0xfc, 0x7d, 0x17, 0x39, 0x03, 0xa8, 0xec, 0x7a, 0xd2, 0x5f, 0x91, 0xa7, 0x26, 0x07, 0x9d, 0xd7, 0x0c, 0xd7, 0xd4, 0x8e, 0x37, 0xf3, 0x1a, 0x3c, 0x04, 0x83, 0x04, 0x71, 0x06, 0xa6, 0x5f, 0x82, 0xe0, 0x6d, 0x87, 0x5c, 0x7c, 0x03, 0x25, 0x03, 0x4b, 0x24, 0x07, 0x40, 0xad, 0xe4, 0x1d, 0x1d, 0xcb, 0x34, 0xc2, 0x53, 0x1d, 0x13, 0xc5, 0x87, 0xab, 0xa7, 0x95, 0x11, 0x8b, 0xbb, 0xf0, 0xc3, 0x00, 0xeb, 0xe5, 0xb0, 0x9e, 0x88, 0x8b, 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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, 0x61, 0x35, 0x8d, 0x55, 0x06, 0xeb, 0x96, 0xe7, 0xf5, 0x4b, 0x95, 0x5f, 0x9b, 0xb2, 0x18, 0x0d, 0x13, 0xc2, 0x96, 0x79, 0x50, 0x78, 0x98, 0x50, 0x88, 0x2b, 0xab, 0x05, 0x66, 0xa1, 0x3a, 0x25, 0x85, 0xe2, 0xd0, 0xe2, 0xac, 0xb5, 0x26, 0xde, 0x95, 0x04, 0x45, 0xe7, 0x22, 0x71, 0x02, 0xb3, 0x84, 0x4c, 0xb5, 0xad, 0x64, 0x5c, 0x27, 0x5c, 0x71, 0xcd, 0x0b, 0x62, 0x91, 0xd6, 0x84, 0x00, 0x62, 0x52, 0x54, 0xbd, 0x22, 0xc8, 0x57, 0xa7, 0x41, 0xac, 0xc7, 0xa8, 0x56, 0x6f, 0x1b, 0x7e, 0xce, 0x02, 0x29, 0x3b, 0xc0, 0x5d, 0x8e, 0x11, 0xa9, 0x54, 0xc2, 0xf2, 0xf0, 0x81, 0x6c, 0x9a, 0x24, 0x5b, 0x81, 0x7d, 0xf3, 0x84, 0x93, 0xc6, 0x2a, 0xd4, 0xd3, 0x1a, 0x2f, 0x97, 0x2e, 0x31, 0x8a, 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, 0x7b, 0x5a, 0xb9, 0x11, 0xa0, 0xc7, 0x75, 0x60, 0xc5, 0x54, 0x7d, 0xb0, 0xb4, 0xd0, 0x95, 0x01, 0xff, 0x07, 0x49, 0x56, 0xfb, 0xec, 0xa9, 0x4c, 0x68, 0x28, 0x41, 0x81, 0x80, 0x05, 0x88, 0x58, 0xf5, 0xdc, 0x42, 0x99, 0xd8, 0xb7, 0x47, 0xd9, 0xf7, 0x0e, 0x2c, 0x0f, 0x95, 0x04, 0xb3, 0xc8, 0x8a, 0xe2, 0x21, 0x57, 0x8d, 0x64, 0x54, 0x40, 0xf6, 0xd0, 0x3c, 0x97, 0xcf, 0x22, 0xce, 0xcd, 0xbf, 0x05, 0x15, 0xaa, 0x89, 0xd9, 0x2b, 0x48, 0xaf, 0x34, 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, 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, 0x82, 0xbe, 0x24, 0x7f, 0xb7, 0x46, 0xa8, 0x70, 0x10, 0x33, 0xb6, 0x3f, 0xbf, 0xa8, 0xa8, 0x85, 0xab, 0x1d, 0xb4, 0x3f, 0x84, 0x06, 0x91, 0xd6, 0x18, 0x3d, 0xeb, 0x8b, 0x3f, 0x9b, 0x37, 0x9e, 0x2e, 0xd2, 0xec, 0xe5, 0x2d, 0xf0, 0x3f, 0x45, 0xd5, 0x9d, 0xb9, 0x28, 0x89, 0xe4, 0x0c, 0xa9, 0x38, 0xca, 0x22, 0x56, 0x53, 0xdf, 0x49, 0xba, 0x5d, 0x99, 0xd6, 0x4b, 0x1d, 0x0d, 0x6d, 0xee, 0x7c, 0xf2, 0x6f, 0x50, 0x04, 0xf1, 0xf8, 0x49, 0xd1, 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,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0xda, 0xb4, 0xff, 0x2a, 0x85, 0x8b, 0x1a, 0xbf, 0xb5, 0xe4, 0x7f, 0x27, 0xee, 0xf3, 0x25, 0xe6, 0x52, 0x2a, 0x83, 0xbe, 0xe4, 0x64, 0xc3, 0x67, 0x0c, 0x9e, 0x0f, 0xba, 0xb4, 0x67, 0xd1, 0x1b, 0x4a, 0xb0, 0xb2, 0xb4, 0xf2, 0x8a, 0x1b, 0x21, 0x34, 0x3c, 0x97, 0x5a, 0xdb, 0x92, 0x8b, 0x2d, 0xe9, 0x94, 0x4e, 0x11, 0xfb, 0xd4, 0x2e, 0xc2, 0xed, 0xf9, 0x75, 0xfd, 0x1a, 0xef, 0x3b, 0x98, 0x5d, 0xa9, 0x75, 0xd5, 0x14, 0x0a, 0xe3, 0xda, 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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 0xf5, 0x8a, 0x11, 0x3b, 0xab, 0xce, 0x7a, 0xb0, 0xb4, 0x4c, 0xba, 0xc0, 0x91, 0x7f, 0x3c, 0x27, 0xe9, 0xc0, 0x58, 0x92, 0x70, 0x67, 0xf4, 0x80, 0x40, 0x92, 0x51, 0x80, 0x8e, 0x9d, 0x2d, 0x87, 0x89, 0x8e, 0xe7, 0xd1, 0xb5, 0xc5, 0x4f, 0xd0, 0x86, 0x31, 0x7f, 0x90, 0x77, 0x05, 0x35, 0xfe, 0xa7, 0xcb, 0x9d, 0x94, 0xf3, 0xf8, 0xbb, 0x4f, 0xe1, 0xb3, 0x48, 0x57, 0xbf, 0xd1, 0x77, 0xe8, 0x72, 0x31, 0x4d, 0x2f, 0xe8, 0xa0, 0xf4, 0x7c, 0x25, 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, 0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, 0xa4, 0x0b, 0x30, 0x87, 0x23, 0x62, 0xed, 0xf3, 0x7b, 0x80, 0x7e, 0x4f, 0xc2, 0xb3, 0xe8, 0xba, 0x25, 0x3e, 0xd3, 0x12, 0x7e, 0x27, 0xd5, 0x72, 0x3b, 0x02, 0xf4, 0xfd, 0x2f, 0x8b, 0xc2, 0x5f, 0x44, 0x40, 0x31, 0x88, 0x73, 0x81, 0xa3, 0xcc, 0xc4, 0x78, 0x2b, 0xfc, 0x41, 0x2e, 0xb2, 0xd0, 0xb4, 0x00, 0x29, 0xc1, 0x46, 0xdf, 0xc1, 0xbd, 0x15, 0x59, 0xa3, 0x6a, 0xc8, 0x2f, 0x29, 0x28, 0x12, 0x9b, 0x1e, 0xea, 0x4e, 0xa9, 0x80, 0xa1, 0xb8, 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,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 0xf0, 0x1f, 0xb8, 0x85, 0x90, 0x9c, 0x79, 0xde, 0xcb, 0x50, 0xba, 0xa9, 0x56, 0x66, 0xd1, 0x1e, 0x78, 0xa8, 0x6a, 0xd5, 0xa5, 0x83, 0x73, 0xe2, 0x88, 0xf2, 0x04, 0x33, 0x61, 0xdf, 0x89, 0xd5, 0x3d, 0x03, 0x4e, 0x94, 0xb0, 0x0f, 0x8d, 0x4d, 0xb4, 0x09, 0xb2, 0xf1, 0xb0, 0xe7, 0xfe, 0xb0, 0x18, 0xe2, 0xfc, 0x92, 0xeb, 0x2d, 0x7d, 0x56, 0x29, 0xbd, 0x34, 0x20, 0x7c, 0xb6, 0xe7, 0x7b, 0xd7, 0x95, 0xa5, 0x0d, 0x10, 0xbc, 0x7d, 0x9d, 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, 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d6, 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[SECSIZE] = { 0x1d, 0x65, 0xb2, 0x4e, 0xfa, 0x3f, 0xdb, 0xab, 0x34, 0x9d, 0x37, 0x03, 0x17, 0x44, 0xed, 0x5b, 0xf7, 0x1b, 0x6b, 0xc0, 0x5c, 0xfe, 0x5b, 0xcd, 0xf0, 0xaf, 0x26, 0x82, 0x97, 0x12, 0xb8, 0x4f, 0x76, 0x3d, 0x07, 0xd8, 0x29, 0x56, 0x3c, 0xbd, 0x0e, 0xac, 0xd1, 0x8f, 0x53, 0x1a, 0x8f, 0xcd, 0x04, 0x5b, 0x49, 0xe0, 0xf0, 0xea, 0xc9, 0x8a, 0x08, 0x3d, 0x1f, 0x2d, 0x8c, 0xec, 0xb8, 0xea, 0xe9, 0x24, 0xd1, 0x93, 0xd7, 0x9a, 0x0f, 0xd7, 0x0f, 0x6b, 0xa0, 0x08, 0x58, 0x81, 0x68, 0x2f, 0xde, 0x36, 0xb5, 0x87, 0xd9, 0xcd, 0x82, 0x13, 0x36, 0x16, 0x6a, 0x9a, 0x02, 0xca, 0xda, 0x6f, 0x51, 0x87, 0x75, 0x47, 0x89, 0xa4, 0x10, 0x60, 0xfb, 0x1a, 0x74, 0x55, 0x6d, 0x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 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, 0x47, 0x04, 0x4e, 0x8b, 0x73, 0xa6, 0x02, 0x3a, 0xc1, 0xa3, 0xfa, 0x1a, 0xd0, 0x03, 0xf7, 0x26, 0x9f, 0xad, 0x06, 0x8f, 0x86, 0xdc, 0xb8, 0x73, 0x87, 0xa2, 0x82, 0xc6, 0x80, 0xe1, 0xac, 0x3d, 0x16, 0x4c, 0xc3, 0x7c, 0x86, 0x01, 0xa5, 0x7a, 0x1c, 0x4b, 0x56, 0x68, 0xf6, 0x06, 0x99, 0x32, 0x42, 0x40, 0xf1, 0xb7, 0x44, 0x4b, 0xd1, 0xdb, 0xad, 0x4e, 0xa6, 0xc2, 0x5f, 0xee, 0x21, 0x1d, 0x58, 0xc6, 0xd5, 0x02, 0xef, 0xb2, 0x38, 0xef, 0x29, 0x25, 0xfd, 0x28, 0x8a, 0x5b, 0x8b, 0x36, 0x1a, 0xd6, 0x68, 0xf8, 0x77, 0xed, 0xba, 0xb3, 0xa5, 0x6f, 0x76, 0x5e, 0xb5, 0xd4, 0xc3, 0xb8, 0xf9, 0x67, 0x7a, 0x18, 0x43, 0xb6, 0x65, 0x07, 0x48, 0x1d, 0x56, 0x20, 0x11, 0xe1, 0x62, 0x6b,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0, 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, 0x27, 0xd2, 0xb2, 0x73, 0xe4, 0x0a, 0x85, 0xb5, 0x3c, 0x79, 0x78, 0xd6, 0x35, 0x3d, 0x46, 0xac, 0xa3, 0x81, 0x55, 0x76, 0x86, 0xfc, 0x37, 0xa0, 0x95, 0xc2, 0x30, 0xc9, 0x19, 0xc2, 0x5f, 0xb0, 0x13, 0xa2, 0xa8, 0xe1, 0xc7, 0xb7, 0x61, 0x54, 0xd8, 0xe6, 0xca, 0x94, 0x6f, 0x47, 0x87, 0x33, 0x58, 0xd9, 0xd5, 0xd2, 0x95, 0x73, 0x87, 0x9a, 0x31, 0xe5, 0x2e, 0x95, 0x83, 0x7d, 0xdc, 0x0f, 0xc5, 0x2f, 0x14, 0xbc, 0x80, 0xac, 0x47, 0xd6, 0xd8, 0x17, 0x9e, 0xf7, 0xff, 0x5b, 0x85, 0x05, 0x91, 0xe0, 0x73, 0xd2, 0x5c, 0xa7, 0x41, 0xf8, 0xcb, 0x3d, 0x38, 0x14, 0x28, 0x3e, 0x89, 0x6f, 0xd4, 0xac, 0xb6, 0x11, 0x35, 0x67, 0x7b, 0xef, 0x0d, 0xd8, 0x4d, 0xdd, 0x7e, 0x73, 0xcd, 0x58, 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 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, 0x24, 0xa8, 0xe8, 0xb4, 0xa7, 0xa0, 0x87, 0xa8, 0x43, 0x01, 0x21, 0x29, 0x70, 0x39, 0x2d, 0x0b, 0x2a, 0xe9, 0x11, 0x57, 0x86, 0x13, 0xd4, 0x1c, 0x1b, 0x59, 0x19, 0xc4, 0x7d, 0x2c, 0x94, 0xc7, 0x01, 0xb8, 0x96, 0x01, 0xd2, 0x01, 0x17, 0x97, 0x41, 0x68, 0xab, 0xba, 0x9c, 0xc8, 0xad, 0x4e, 0xd7, 0xa8, 0x4c, 0x96, 0x3f, 0xf9, 0xfc, 0x7e, 0xd7, 0x59, 0xe8, 0x25, 0x51, 0x4d, 0x1d, 0x99, 0xfd, 0x0b, 0xe9, 0x88, 0x23, 0xd1, 0x4b, 0x30, 0x6e, 0x18, 0x7c, 0xe3, 0x7a, 0x54, 0x2a, 0x4f, 0x2a, 0x99, 0x8f, 0xaf, 0xd7, 0x5e, 0x25, 0xfe, 0x9c, 0x47, 0x09, 0x63, 0x38, 0x0d, 0x5f, 0xb3, 0x43, 0xa6, 0x66, 0x9b, 0xc5, 0x3d, 0x88, 0x5e, 0xc7, 0x60, 0x99, 0x8e, 0xcb, 0x6a, 0x65, 0x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0xb3, 0x9a, 0x60, 0xb3, 0xcd, 0x6b, 0x43, 0x96, 0x21, 0xa0, 0x65, 0x43, 0xde, 0x4f, 0x6e, 0xb5, 0x81, 0x50, 0x7e, 0xca, 0x4b, 0xdb, 0x30, 0xf2, 0xcb, 0x28, 0x3b, 0x19, 0x6a, 0x0a, 0xfa, 0x05, 0x5e, 0x61, 0xde, 0x76, 0x7e, 0xdf, 0xd9, 0xa9, 0x1b, 0xd0, 0x8a, 0xb5, 0x04, 0x51, 0xf5, 0x66, 0xa2, 0x32, 0x21, 0xb2, 0xa9, 0x40, 0x78, 0x60, 0x9d, 0xdc, 0x45, 0xbe, 0xb4, 0x3a, 0xba, 0xd1, 0xec, 0x31, 0x53, 0x24, 0x22, 0x70, 0x99, 0xda, 0xc8, 0x17, 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, 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17, 0xb1, 0xb8, 0xd4, 0x52, 0x1e, 0x67, 0xeb, 0xac, 0xe0, 0x87, 0x6c, 0xe4, 0x7a, 0x03, 0x73, 0xe4, 0x43, 0xeb, 0x3b, 0x57, 0x3f, 0x56, 0x4b, 0x6c, 0x26, 0x81, 0x27, 0xbf, 0x7e, 0x59, 0xcd, 0xab, 0x67, 0x8c, 0x4b, 0x6f, 0xa5, 0x47, 0x2c, 0x45, 0x28, 0x5a, 0x3d, 0x88, 0x53, 0xf9, 0x25, 0xdf, 0x5d, 0xba, 0xf7, 0x18, 0xa7, 0x3d, 0x79, 0xb4, 0x43, 0x59, 0x77, 0xf9, 0xd5, 0x5d, 0x4f, 0x31, 0x56, 0x8c, 0x21, 0xb5, 0xc0, 0xa2, 0xca, 0x04, 0x62, 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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4, 0x91, 0xbb, 0xb9, 0x05, 0x8d, 0xcf, 0xb9, 0xcb, 0x36, 0x97, 0xb2, 0x6a, 0x31, 0x8f, 0xcb, 0xf8, 0x5a, 0x2f, 0x9e, 0xa1, 0xf9, 0x7a, 0xf4, 0x10, 0x0e, 0xe7, 0x7f, 0x4c, 0xcb, 0xe3, 0x83, 0x17, 0x39, 0x34, 0xef, 0x49, 0x35, 0x68, 0x50, 0x80, 0xf9, 0xcd, 0x3a, 0x10, 0xf6, 0x71, 0x1a, 0x94, 0xc3, 0xec, 0xb9, 0x36, 0x84, 0x36, 0xe7, 0x3f, 0x6f, 0x9b, 0xa9, 0x2b, 0x5c, 0x96, 0x49, 0x26, 0xda, 0xb3, 0x08, 0x3d, 0x5e, 0x9e, 0x59, 0xdf, 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, 0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 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, 0xfa, 0x7f, 0x56, 0x00, 0x00, 0x05, 0x27, 0x9f, 0xa5, 0xd8, 0xb5, 0xe4, 0xad, 0x40, 0xe7, 0x36, 0xdd, 0xb4, 0xd3, 0x54, 0x12, 0x32, 0x80, 0x63, 0xfd, 0x2a, 0xab, 0x53, 0xe5, 0xea, 0x1e, 0x0a, 0x9f, 0x33, 0x25, 0x00, 0xa5, 0xdf, 0x94, 0x87, 0xd0, 0x7a, 0x5c, 0x92, 0xcc, 0x51, 0x2c, 0x88, 0x66, 0xc7, 0xe8, 0x60, 0xce, 0x93, 0xfd, 0xf1, 0x66, 0xa2, 0x49, 0x12, 0xb4, 0x22, 0x97, 0x61, 0x46, 0xae, 0x20, 0xce, 0x84, 0x6b, 0xb7, 0xdc, 0x9b, 0xa9, 0x4a, 0x76, 0x7a, 0xae, 0xf2, 0x0c, 0x0d, 0x61, 0xad, 0x02, 0x65, 0x5e, 0xa9, 0x2d, 0xc4, 0xc4, 0xe4, 0x1a, 0x89, 0x52, 0xc6, 0x51, 0xd3, 0x31, 0x74, 0xbe, 0x51, 0xa1, 0x0c, 0x42, 0x11, 0x10, 0xe6, 0xd8, 0x15, 0x88, 0xed, 0xe8, 0x21, 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, 0x89, 0x9b, 0x32, 0x91, 0x98, 0xeb, 0x61, 0xc1, 0x93, 0xfb, 0x62, 0x75, 0xaa, 0x8c, 0xa3, 0x40, 0x34, 0x4a, 0x75, 0xa8, 0x62, 0xae, 0xbe, 0x92, 0xee, 0xe1, 0xce, 0x03, 0x2f, 0xd9, 0x50, 0xb4, 0x7d, 0x77, 0x04, 0xa3, 0x87, 0x69, 0x23, 0xb4, 0xad, 0x62, 0x84, 0x4b, 0xf4, 0xa0, 0x9c, 0x4d, 0xbe, 0x8b, 0x43, 0x97, 0x18, 0x4b, 0x74, 0x71, 0x36, 0x0c, 0x95, 0x64, 0x88, 0x0a, 0xed, 0xdd, 0xb9, 0xba, 0xa4, 0xaf, 0x2e, 0x75, 0x39, 0x4b, 0x08, 0xcd, 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,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 0xd9, 0x50, 0xb4, 0x7d, 0x77, 0x04, 0xa3, 0x87, 0x69, 0x23, 0xb4, 0xad, 0x62, 0x84, 0x4b, 0xf4, 0xa0, 0x9c, 0x4d, 0xbe, 0x8b, 0x43, 0x97, 0x18, 0x4b, 0x74, 0x71, 0x36, 0x0c, 0x95, 0x64, 0x88, 0x0a, 0xed, 0xdd, 0xb9, 0xba, 0xa4, 0xaf, 0x2e, 0x75, 0x39, 0x4b, 0x08, 0xcd, 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, }; 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, 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x91, 0xec, 0xa0, 0x4d, 0x66, 0x52, 0x0d, 0x22, 0x9e, 0x60, 0x40, 0x1e, 0x72, 0x82, 0xbe, 0xf4, 0x86, 0xae, 0x05, 0x9a, 0xa7, 0x06, 0x96, 0xe0, 0xe3, 0x05, 0xd7, 0x77, 0x14, 0x0a, 0x7a, 0x88, 0x3e, 0xcd, 0xcb, 0x69, 0xb9, 0xff, 0x93, 0x8e, 0x8a, 0x42, 0x31, 0x86, 0x4c, 0x69, 0xca, 0x2c, 0x20, 0x43, 0xbe, 0xd0, 0x07, 0xff, 0x3e, 0x60, 0x5e, 0x01, 0x4b, 0xcf, 0x51, 0x81, 0x38, 0xdc, 0x3a, 0x25, 0xc5, 0xe2, 0x36, 0x17, 0x1a, 0x2d, 0x01, 0xd6, }; /* * 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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 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, 0x8c, 0xc6, 0x08, 0xc2, 0xc2, 0x6c, 0x19, 0xa2, 0xe2, 0xfe, 0x22, 0xf9, 0x87, 0x32, 0xc2, 0xb5, 0xcb, 0x84, 0x4c, 0xc6, 0xc0, 0x70, 0x2d, 0x91, 0xe1, 0xd5, 0x0f, 0xc4, 0x38, 0x2a, 0x7e, 0xba, 0x56, 0x35, 0xcd, 0x60, 0x24, 0x32, 0xa2, 0x30, 0x6a, 0xc4, 0xce, 0x82, 0xf8, 0xd7, 0x0c, 0x8d, 0x9b, 0xc1, 0x5f, 0x91, 0x8f, 0xe7, 0x1e, 0x74, 0xc6, 0x22, 0xd5, 0xcf, 0x71, 0x17, 0x8b, 0xf6, 0xe0, 0xb9, 0xcc, 0x9f, 0x2b, 0x41, 0xdd, 0x8d, 0xbe, 0x44, 0x1c, 0x41, 0xcd, 0x0c, 0x73, 0xa6, 0xdc, 0x47, 0xa3, 0x48, 0xf6, 0x70, 0x2f, 0x9d, 0x0e, 0x9b, 0x1b, 0x14, 0x31, 0xe9, 0x48, 0xe2, 0x99, 0xb9, 0xec, 0x22, 0x72, 0xab, 0x2c, 0x5f, 0x0c, 0x7b, 0xe8, 0x6a, 0xff, 0xa5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 0x12, 0x99, 0xfa, 0xae, 0xec, 0xae, 0x35, 0xc6, 0xea, 0xac, 0xa7, 0x53, 0xb0, 0x41, 0xb5, 0xe5, 0xf0, 0x93, 0xbf, 0x83, 0x39, 0x7f, 0xd2, 0x1d, 0xd6, 0xb3, 0x01, 0x20, 0x66, 0xfc, 0xc0, 0x58, 0xcc, 0x32, 0xc3, 0xb0, 0x9d, 0x75, 0x62, 0xde, 0xe2, 0x95, 0x09, 0xb5, 0x83, 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, }; static const uint8_t aes_xts_256_vec8_ctxt[SECSIZE] = { 0x72, 0xef, 0xc1, 0xeb, 0xfe, 0x1e, 0xe2, 0x59, 0x75, 0xa6, 0xeb, 0x3a, 0xa8, 0x58, 0x9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, 0x3a, 0x4d, 0x8b, 0xc3, 0xec, 0x38, 0x81, 0x3e, 0xca, 0x30, 0xa1, 0x3c, 0xf1, 0xbb, 0x18, 0xd5, 0x24, 0xf1, 0x99, 0x2d, 0x44, 0xd8, 0xb1, 0xa4, 0x2e, 0xa3, 0x0b, 0x22, 0xe6, 0xc9, 0x5b, 0x19, 0x9d, 0x8d, 0x18, 0x2f, 0x88, 0x40, 0xb0, 0x9d, 0x05, 0x95, 0x85, 0xc3, 0x1a, 0xd6, 0x91, 0xfa, 0x06, 0x19, 0xff, 0x03, 0x8a, 0xca, 0x2c, 0x39, 0xa9, 0x43, 0x42, 0x11, 0x57, 0x36, 0x17, 0x17, 0xc4, 0x9d, 0x32, 0x20, 0x28, 0xa7, 0x46, 0x48, 0x11, 0x3b, 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, 0x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6, 0xc9, 0x5b, 0x19, 0x9d, 0x8d, 0x18, 0x2f, 0x88, 0x40, 0xb0, 0x9d, 0x05, 0x95, 0x85, 0xc3, 0x1a, 0xd6, 0x91, 0xfa, 0x06, 0x19, 0xff, 0x03, 0x8a, 0xca, 0x2c, 0x39, 0xa9, 0x43, 0x42, 0x11, 0x57, 0x36, 0x17, 0x17, 0xc4, 0x9d, 0x32, 0x20, 0x28, 0xa7, 0x46, 0x48, 0x11, 0x3b, 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, }; static const uint8_t aes_xts_256_vec9_ctxt[SECSIZE] = { 0x32, 0x60, 0xae, 0x8d, 0xad, 0x1f, 0x4a, 0x32, 0xc5, 0xca, 0xfe, 0x3a, 0xb0, 0xeb, 0x95, 0x54, 0x9d, 0x46, 0x1a, 0x67, 0xce, 0xb9, 0xe5, 0xaa, 0x2d, 0x3a, 0xfb, 0x62, 0xde, 0xce, 0x05, 0x53, 0x19, 0x3b, 0xa5, 0x0c, 0x75, 0xbe, 0x25, 0x1e, 0x08, 0xd1, 0xd0, 0x8f, 0x10, 0x88, 0x57, 0x6c, 0x7e, 0xfd, 0xfa, 0xaf, 0x3f, 0x45, 0x95, 0x59, 0x57, 0x1e, 0x12, 0x51, 0x17, 0x53, 0xb0, 0x7a, 0xf0, 0x73, 0xf3, 0x5d, 0xa0, 0x6a, 0xf0, 0xce, 0x0b, 0xbf, 0x6b, 0x8f, 0x5c, 0xcc, 0x5c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 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, 0x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, 0xe0, 0xe1, 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, 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, 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0x8f, 0x84, 0x25, 0x20, 0x70, 0xc1, 0x3e, 0x9f, 0x1f, 0x28, 0x9b, 0xe5, 0x4f, 0xbc, 0x48, 0x14, 0x57, 0x77, 0x8f, 0x61, 0x60, 0x15, 0xe1, 0x32, 0x7a, 0x02, 0xb1, 0x40, 0xf1, 0x50, 0x5e, 0xb3, 0x09, 0x32, 0x6d, 0x68, 0x37, 0x8f, 0x83, 0x74, 0x59, 0x5c, 0x84, 0x9d, 0x84, 0xf4, 0xc3, 0x33, 0xec, 0x44, 0x23, 0x88, 0x51, 0x43, 0xcb, 0x47, 0xbd, 0x71, 0xc5, 0xed, 0xae, 0x9b, 0xe6, 0x9a, 0x2f, 0xfe, 0xce, 0xb1, 0xbe, 0xc9, 0xde, 0x24, 0x4f, 0xbe, 0x15, 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, 0x6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, 0x53, 0x1f, 0x3d, 0x16, 0x19, 0xe7, 0x85, 0xf1, 0xad, 0xa4, 0x37, 0xca, 0xb9, 0x2e, 0x98, 0x05, 0x58, 0xb3, 0xdc, 0xe1, 0x47, 0x4a, 0xfb, 0x75, 0xbf, 0xed, 0xbf, 0x8f, 0xf5, 0x4c, 0xb2, 0x61, 0x8e, 0x02, 0x44, 0xc9, 0xac, 0x0d, 0x3c, 0x66, 0xfb, 0x51, 0x59, 0x8c, 0xd2, 0xdb, 0x11, 0xf9, 0xbe, 0x39, 0x79, 0x1a, 0xbe, 0x44, 0x7c, 0x63, 0x09, 0x4f, 0x7c, 0x45, 0x3b, 0x7f, 0xf8, 0x7c, 0xb5, 0xbb, 0x36, 0xb7, 0xc7, 0x9e, 0xfb, 0x08, 0x72, 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: head/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c =================================================================== --- head/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c (revision 313438) +++ head/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c (revision 313439) @@ -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, 0xd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xeb, 0x54, 0x39, 0x5a, 0x91, 0xfe, 0x86, 0x18, 0xea, 0x8c, 0xd6, 0x66, 0xd5, 0x85, 0x02, 0x2b, 0x00, 0x5d, 0x7e, 0x13, 0xa0, 0x1f, 0x73, 0x46, 0x6d, 0x5e, 0xcd, 0xe0, 0x82, 0x02, 0x28, 0x88, 0xbf, 0x17, 0xfd, 0x9b, 0x83, 0x2c, 0xa2, 0xf7, 0xde, 0x51, 0x98, 0x3f, 0xe2, 0x80, 0x66, 0x14, 0x17, 0xce, 0x8e, 0x30, 0x2d, 0xe2, 0x24, 0x68, 0x4b, 0xe5, 0xd1, 0x09, 0xfb, 0x6e, }; /* * IV method encblkno1, 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, 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, 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, 0xaa, 0x82, 0xb6, 0x1d, 0xf7, 0x12, 0x9e, 0x73, 0xfe, 0xac, 0x2f, 0x1e, 0x2b, 0xea, 0x3a, 0x4f, 0xc3, 0x0a, 0x59, 0x80, 0x0d, 0x3d, 0xbc, 0x62, 0x8d, 0x70, 0xef, 0x1b, 0xfb, 0xdc, 0x4e, 0xc4, 0x97, 0xf4, 0x77, 0xb7, 0x25, 0x94, 0x13, 0x48, 0xf2, 0x3d, 0x4c, 0xa7, 0xb8, 0x8c, 0xf5, 0x26, 0xa4, 0x35, 0xeb, 0xa0, 0xe7, 0x68, 0xb0, 0x69, 0xf4, 0xf6, 0x13, 0x3a, 0x57, 0xa3, 0xd2, 0x26, 0xe6, 0x70, 0xd8, 0xd4, 0x05, 0xb5, 0x01, 0xda, 0xc7, 0x4a, 0x79, 0x1a, 0x6d, 0xb6, 0xf6, 0xb5, 0x7d, 0x9a, 0x5c, 0xf1, 0x6a, 0xf8, 0xd1, 0x0a, 0xbc, 0xe7, 0xea, 0xb4, 0x99, 0x72, 0x19, 0x97, 0x41, 0x4f, 0x14, 0x5f, 0xa3, 0xb3, 0x9b, 0x36, 0x00, 0x08, 0x88, 0x8c, 0xce, 0x7f, 0x3a, 0x9b, 0xb0, 0x24, 0x17, 0x95, 0xc4, 0x59, 0x30, 0x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x0d, 0x6f, 0x67, 0xce, 0x5e, 0xa0, 0x04, 0x7e, 0x93, 0x1d, 0x17, 0x1c, 0x32, 0x82, 0xf4, 0x54, 0xb9, 0x80, 0xdd, 0x82, 0xae, 0xf5, 0xc5, 0x1e, 0x15, 0xab, 0xc2, 0x5c, 0x60, 0xd2, 0x08, 0xc2, 0xa1, 0x1f, 0x89, 0x0b, 0x59, 0x36, 0x07, 0xdc, 0x57, 0xd3, 0xa0, 0x32, 0x42, 0xac, 0xa6, 0x90, 0x0b, 0xc0, 0xe4, 0x91, 0x45, 0x85, 0x27, 0xb9, 0x48, 0x2a, 0x88, 0x0a, 0xbf, 0xf6, 0x2d, 0xef, 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, 0xd6, 0xa0, 0x44, 0xd3, 0x05, 0x4e, 0xf4, 0xfe, 0x6a, 0x57, 0x69, 0x01, 0xaa, 0x91, 0x9c, 0x6e, 0x4f, 0x79, 0xc9, 0x8f, 0x4c, 0xdf, 0x5b, 0x9c, 0xc4, 0xf7, 0x63, 0x16, 0x20, 0x09, 0x07, 0x3f, 0x5e, 0x31, 0xcc, 0x81, 0x71, 0xe3, 0x7b, 0xb5, 0xea, 0x2c, 0xb5, 0x14, 0x1e, 0xf9, 0x0d, 0xe0, 0x45, 0xbc, 0x9f, 0x92, 0x6c, 0xc9, 0x0a, 0x85, 0x62, 0x42, 0xf1, 0x4b, 0xac, 0xe2, 0xfa, 0xad, 0x97, 0x7a, 0x43, 0x3d, 0xb6, 0x5f, 0xcb, 0xe7, 0x17, 0x23, 0x28, 0xde, 0x4e, 0xf8, 0xa1, 0x3c, 0x22, 0x63, 0x49, 0x31, 0xa7, 0xbe, 0xbf, 0xfe, 0xee, 0xd9, 0x1f, 0xa0, 0x2a, 0x0e, 0xf2, 0x4f, 0x3e, 0xf8, 0xbb, 0xae, 0x9e, 0x0d, 0x2c, 0xaa, 0x2a, 0x2c, 0xf0, 0x6c, 0x37, 0x2a, 0x5d, 0x96, 0x70, 0x9c, 0x87, 0xcc, 0x2b, 0xca, 0x95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x26, 0x79, 0x77, 0xc5, 0x96, 0xd3, 0xbf, 0x38, 0xda, 0x0f, 0xe1, 0x26, 0x9a, 0x38, 0xfc, 0x43, 0x82, 0xd1, 0x4d, 0xf2, 0xae, 0x98, 0x1e, 0xb0, 0x0d, 0xec, 0x7b, 0x56, 0x66, 0xcb, 0x30, 0x57, 0x4f, 0xe7, 0x03, 0xe3, 0xa6, 0x4a, 0x4a, 0xf9, 0xa3, 0xbf, 0x44, 0xac, 0x1a, 0xe7, 0x4b, 0xc1, 0x5b, 0x03, 0x25, 0x4e, 0xc6, 0x1f, 0x96, 0x4d, 0xf7, 0xbe, 0xa7, 0x5d, 0x60, 0x20, 0x62, 0x10, 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, 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, 0x82, 0x59, 0x2c, 0xe2, 0x8d, 0xba, 0x08, 0x01, 0x67, 0x1f, 0x2a, 0x9e, 0x4d, 0x53, 0x57, 0x2d, 0x6e, 0x35, 0x38, 0xd5, 0x50, 0xa7, 0x0c, 0xe6, 0x77, 0x71, 0xbe, 0x45, 0x2e, 0xf4, 0x7a, 0x3a, 0x51, 0x03, 0x04, 0x2b, 0xd7, 0x42, 0x6c, 0x5b, 0x82, 0xba, 0xb4, 0x09, 0xee, 0x9d, 0xea, 0x8f, 0xf0, 0xb3, 0xb2, 0x9d, 0x0e, 0x09, 0x72, 0x8c, 0xd9, 0x1e, 0x6d, 0x78, 0x57, 0x10, 0x1f, 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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, 0xd5, 0x7b, 0xbb, 0x4e, 0xe1, 0xa9, 0x2a, 0xc6, 0x42, 0xf5, 0x21, 0x9c, 0x15, 0xae, 0xb9, 0x08, 0x3a, 0xc4, 0x50, 0x7e, 0x0e, 0xb6, 0xc3, 0xfe, 0xf4, 0xd9, 0x1a, 0x97, 0x30, 0x9f, 0x51, 0x2c, 0xac, 0xd2, 0x13, 0x93, 0x62, 0x56, 0xcb, 0x34, 0xf3, 0xca, 0x26, 0xc6, 0x32, 0xbe, 0xf6, 0xd5, 0x1e, 0x5b, 0x3a, 0x5c, 0x31, 0x08, 0xa1, 0x47, 0x6b, 0x75, 0x95, 0x8e, 0x3d, 0xbf, 0x2e, 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, 0x6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x73, 0xb0, 0xb3, 0xd7, 0x6d, 0x3e, 0x4d, 0x6b, 0x9e, 0x42, 0x8e, 0xbb, 0xd7, 0xb5, 0x26, 0xa9, 0x19, 0xf5, 0x68, 0xf3, 0x8d, 0x35, 0x91, 0x06, 0x48, 0xfa, 0x0e, 0x7d, 0xe2, 0xd3, 0x71, 0x75, 0x44, 0xbd, 0xe6, 0xe6, 0xd6, 0x36, 0x43, 0x64, 0x3a, 0xd5, 0x97, 0xfa, 0xc0, 0x10, 0xf7, 0x6c, 0x26, 0xf1, 0xb4, 0xbc, 0xf5, 0xf6, 0xa3, 0xec, 0x0a, 0xb5, 0x34, 0x55, 0x1a, 0x67, 0xcb, 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, 0x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 0x56, 0x6a, 0x0f, 0xeb, 0x4d, 0x00, 0xdf, 0xe0, 0xf3, 0x7c, 0xd3, 0x2c, 0x5a, 0x48, 0x39, 0xa1, 0xc1, 0xfa, 0x34, 0x5f, 0xf9, 0x0b, 0xcd, 0x1f, 0x21, 0xc6, 0x46, 0xb3, 0xd8, 0x45, 0xc5, 0x37, 0xf7, 0xd0, 0xda, 0x27, 0x0f, 0xec, 0xec, 0x05, 0x81, 0x6f, 0x97, 0xca, 0x6d, 0xfa, 0x71, 0xc9, 0x59, 0x84, 0xc3, 0x0d, 0x55, 0x12, 0xbf, 0xe1, 0xd2, 0x7c, 0x51, 0x65, 0x8c, 0xc3, 0x8a, 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, 0x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 0xf1, 0x5b, 0x91, 0x7e, 0x93, 0xea, 0x94, 0xf1, 0xcf, 0x0e, 0x10, 0xf8, 0xc2, 0x55, 0x87, 0x68, 0xf9, 0x49, 0xfa, 0xeb, 0x0f, 0x2c, 0xd7, 0xd8, 0x26, 0x1a, 0x5b, 0x1a, 0x42, 0x06, 0xea, 0x8a, 0xb6, 0xec, 0x6e, 0xb0, 0x00, 0xb9, 0x3b, 0x50, 0xe8, 0x9e, 0xc2, 0x51, 0x4f, 0x03, 0xcd, 0x9f, 0x36, 0x27, 0xca, 0xa2, 0x98, 0x87, 0x5a, 0xae, 0xd8, 0x87, 0x76, 0xb6, 0xb6, 0x19, 0x7d, 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,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b, 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, 0x16, 0xfc, 0x2f, 0x27, 0xb3, 0xc6, 0x3c, 0x38, 0x31, 0x11, 0xe1, 0x3b, 0x72, 0x22, 0x1c, 0x01, 0xc5, 0xa6, 0x70, 0x16, 0x4d, 0xd2, 0xbd, 0xcb, 0x15, 0x00, 0x22, 0xab, 0x65, 0x6a, 0x96, 0x5e, 0x45, 0x7f, 0xfd, 0x76, 0x18, 0x43, 0x25, 0x75, 0x73, 0xa4, 0x24, 0xe4, 0x5b, 0xca, 0xf7, 0x6f, 0xfe, 0xc6, 0x4c, 0x81, 0x77, 0xe5, 0x1b, 0xb4, 0x7b, 0x64, 0xc2, 0x0d, 0x2b, 0xa9, 0x76, 0xae, 0x5d, 0xab, 0x81, 0x77, 0xa6, 0x48, 0xe9, 0x0c, 0x6d, 0x93, 0xbd, 0x7e, 0xdc, 0x39, 0x89, 0x72, 0xd2, 0x07, 0x87, 0x44, 0xa6, 0x7d, 0x08, 0x54, 0xc6, 0x90, 0x1d, 0xa2, 0xd7, 0xfd, 0xd5, 0x59, 0x67, 0xd9, 0x5f, 0x5c, 0xbc, 0x60, 0xc7, 0xf6, 0x98, 0xad, 0x21, 0xdf, 0xde, 0x27, 0xca, 0x73, 0x2f, 0x56, 0xb7, 0xd7, 0x54, 0x6e, 0xc3, 0x09, 0x6f, 0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84, 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, 0xd2, 0xc0, 0xd3, 0x75, 0xe8, 0x04, 0x34, 0x66, 0x76, 0x25, 0x70, 0xde, 0x41, 0xf1, 0x35, 0x63, 0x5c, 0xac, 0x8f, 0x28, 0x17, 0xd3, 0xae, 0x43, 0xfd, 0x8a, 0xb8, 0xc2, 0xd3, 0x88, 0xef, 0xfa, 0x21, 0xeb, 0xb4, 0x33, 0x75, 0x69, 0x7d, 0xe9, 0x27, 0x1c, 0x03, 0xcf, 0x90, 0xcf, 0xf0, 0xaa, 0x3e, 0x01, 0x41, 0x24, 0xdc, 0x01, 0x5a, 0xe8, 0x92, 0xea, 0xde, 0x87, 0xbf, 0x75, 0xe4, 0x0b, 0xf7, 0xa3, 0x42, 0x27, 0xc4, 0xde, 0x01, 0x6f, 0x5c, 0xec, 0x6d, 0x37, 0x38, 0xd7, 0x4f, 0x85, 0xc0, 0xc2, 0x3a, 0xa7, 0x2d, 0x15, 0xd5, 0x1c, 0xee, 0x15, 0x13, 0x7a, 0x4e, 0x33, 0xc7, 0x59, 0x93, 0x73, 0xe9, 0xf5, 0x39, 0xb0, 0xad, 0x8b, 0x61, 0xca, 0x4d, 0x31, 0xaa, 0x44, 0xf6, 0x5c, 0xb7, 0x99, 0xe5, 0x92, 0x3d, 0x47, 0x79, 0x9b, 0x29, 0x16, 0xe1,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x2f, 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, 0xaa, 0xa7, 0x2f, 0x48, 0x2c, 0x39, 0x88, 0x2d, 0xc6, 0xb1, 0xf7, 0xc7, 0x2d, 0xda, 0xe9, 0xfb, 0x4f, 0x9b, 0x1f, 0xe1, 0x0c, 0x24, 0x89, 0xfe, 0x70, 0xe0, 0xb2, 0x51, 0x89, 0x51, 0xa9, 0xae, 0xd1, 0x92, 0x4f, 0x56, 0x5c, 0x2a, 0xf4, 0xbc, 0x4e, 0x77, 0x4a, 0xb8, 0xab, 0x02, 0x76, 0xef, 0x69, 0xfb, 0x5e, 0x06, 0xb5, 0xff, 0x31, 0xce, 0x2b, 0xfc, 0x48, 0x4c, 0x82, 0xe9, 0x3c, 0x61, 0x69, 0x68, 0x1d, 0xb1, 0xc6, 0x40, 0x10, 0xd7, 0x0e, 0xd2, 0x26, 0x33, 0x5b, 0x0b, 0xe7, 0xc2, 0xbe, 0xf4, 0x24, 0x1a, 0xa6, 0x70, 0x31, 0xa7, 0x15, 0x76, 0xc7, 0x90, 0x8d, 0x60, 0xe0, 0xee, 0x5b, 0x73, 0xa9, 0xe1, 0xe1, 0xaf, 0xf0, 0x5e, 0x6f, 0x32, 0x98, 0x92, 0xbe, 0x24, 0x81, 0x26, 0x9f, 0xb8, 0x67, 0xd0, 0xca, 0x9d, 0x8f, 0x14, 0x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81, 0x3a, 0x50, 0x3c, 0x5c, 0x7c, 0x86, 0x17, 0x22, 0xe7, 0xa3, 0xff, 0x73, 0x5e, 0x91, 0xbf, 0xb3, 0x59, 0x07, 0xb7, 0xa4, 0xd5, 0x1b, 0x5c, 0xce, 0x56, 0xde, 0x5f, 0xae, 0x89, 0xcb, 0x6a, 0xfe, 0xaf, 0xe7, 0xd4, 0x34, 0x8d, 0x18, 0x22, 0x4d, 0xd9, 0x91, 0xa6, 0xec, 0x97, 0x0e, 0x29, 0x4d, 0xf6, 0xd8, 0xb3, 0x50, 0x1c, 0xc9, 0x66, 0x9d, 0x2e, 0x5e, 0x27, 0xce, 0x36, 0xcb, 0x47, 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_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e2, 0x1a, 0x92, 0x1f, 0xfe, 0x20, 0x81, 0xe5, 0x83, 0x97, 0xfb, 0xaf, 0xeb, 0x31, 0x6c, 0x81, 0xf2, 0x2f, 0xf4, 0x41, 0xf1, 0xd9, 0x61, 0xfb, 0x36, 0x4e, 0xab, 0xc5, 0x8b, 0x9c, 0x37, 0xea, 0x88, 0xeb, 0x1e, 0x4c, 0x84, 0x1a, 0xac, 0x4c, 0x19, 0x39, 0x51, 0x53, 0xe0, 0x50, 0xb0, 0xdf, 0xe6, 0xc5, 0xbb, 0x80, 0x06, 0x30, 0x14, 0xf5, 0x0e, 0x73, 0xd2, 0xdb, 0x19, 0x45, 0x30, 0xdc, 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, 0x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e, 0x5e, 0x74, 0xc7, 0xe6, 0x62, 0xb1, 0x5a, 0xec, 0x6a, 0xc1, 0x71, 0x19, 0xf3, 0xf1, 0xe7, 0x46, 0x13, 0xd6, 0xb6, 0x5a, 0xf4, 0xca, 0x3f, 0xe3, 0xa1, 0x1f, 0xe4, 0xda, 0xd6, 0x0c, 0x62, 0x6a, 0x33, 0x42, 0x99, 0x6f, 0x5d, 0x3a, 0xe0, 0xe7, 0xfa, 0x2d, 0x47, 0x4a, 0xec, 0xaa, 0x71, 0xb5, 0xeb, 0x62, 0xb8, 0x31, 0x34, 0x07, 0x44, 0xa2, 0x18, 0xec, 0x76, 0xf7, 0x77, 0x56, 0x86, 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,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, 0x11, 0xe7, 0x0e, 0xfd, 0x08, 0x5e, 0x64, 0x8b, 0x5b, 0x9f, 0x94, 0x8b, 0x0d, 0x83, 0x7e, 0xef, 0x89, 0x30, 0x4a, 0x55, 0xce, 0x10, 0x5f, 0x15, 0xd2, 0xe7, 0x07, 0x0c, 0x34, 0x92, 0xda, 0xae, 0x84, 0x26, 0x28, 0x36, 0x1a, 0x96, 0xc6, 0xf1, 0x41, 0x2b, 0xb6, 0x01, 0xfe, 0x20, 0x05, 0x43, 0x80, 0x45, 0xdf, 0x5c, 0xc2, 0x96, 0xc8, 0x41, 0x68, 0x87, 0x78, 0xbc, 0xf8, 0x34, 0xfb, 0x19, 0x61, 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, 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, 0x5d, 0x25, 0x3c, 0x2d, 0x8c, 0xa8, 0xa1, 0xb1, 0x79, 0x8e, 0x60, 0xa2, 0x3e, 0x04, 0xfa, 0x3f, 0xb4, 0x43, 0xde, 0x0a, 0xde, 0xf4, 0x58, 0xe7, 0xd1, 0x04, 0x1d, 0xb7, 0x1d, 0xa6, 0xcb, 0x49, 0x41, 0x30, 0xb5, 0x41, 0xb5, 0x14, 0x19, 0xe4, 0xeb, 0x2c, 0xe2, 0xf0, 0x66, 0x59, 0xe3, 0xc6, 0xb0, 0xd0, 0x1e, 0xaa, 0x9f, 0xa5, 0x0b, 0xb8, 0xfd, 0xae, 0x62, 0xcf, 0x3e, 0xe2, 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, 0x65, 0x06, 0xee, 0x14, 0x88, 0xb5, 0x58, 0xc8, 0x4d, 0x6e, 0xd8, 0x44, 0x76, 0x21, 0x16, 0xa4, 0xdf, 0x68, 0x4b, 0xff, 0x69, 0x23, 0x66, 0x18, 0x75, 0xe6, 0x29, 0xea, 0x95, 0x87, 0x1c, 0xed, 0x2d, 0xbd, 0xbf, 0x22, 0x56, 0x11, 0xd5, 0x59, 0x90, 0x24, 0xd7, 0xae, 0xda, 0x99, 0x49, 0xe3, 0x23, 0x03, 0x24, 0x3b, 0x02, 0x49, 0x1d, 0xa5, 0x57, 0x2f, 0xea, 0xd1, 0x6a, 0x17, 0x53, 0x0f, 0xb3, 0xa9, 0x64, 0x8a, 0xdb, 0x62, 0x17, 0xad, 0x5c, 0x7d, 0x56, 0x14, 0x0f, 0xfb, 0x14, 0xbe, 0x7e, 0xa1, 0xa8, 0x27, 0xf0, 0xf0, 0x3a, 0xe7, 0xc5, 0x26, 0x98, 0x9d, 0x29, 0xf7, 0xfd, 0x43, 0x13, 0x34, 0xe2, 0xb8, 0x0b, 0x14, 0xe9, 0x79, 0x66, 0x7a, 0xf2, 0xed, 0x79, 0x37, 0x16, 0x75, 0x2b, 0xf2, 0x99, 0xa1, 0xba, 0xf1, 0xc1, 0x61, 0x8d, 0x78, 0x46, 0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0xcf, 0x79, 0x05, 0xbd, 0xe0, 0x44, 0x39, 0xf0, 0x35, 0x2d, 0x7a, 0x31, 0x3b, 0x24, 0xb3, 0xb4, 0xa5, 0x08, 0xf5, 0xac, 0x51, 0xf1, 0x09, 0x52, 0x14, 0xc7, 0xb5, 0xe0, 0x65, 0x47, 0x30, 0xdd, 0xa4, 0xfd, 0x71, 0x68, 0xa5, 0x4b, 0x00, 0x72, 0xe2, 0xc4, 0xa9, 0x5d, 0x21, 0x6d, 0x83, 0x4e, 0x88, 0xaa, 0x76, 0x07, 0xf0, 0xf7, 0x36, 0xa2, 0x5e, 0xd5, 0x4c, 0x7f, 0x9b, 0x74, 0x89, 0x0a, 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, 0x9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e, 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,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9c, 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_vec1_ctxt[SECSIZE] = { 0x90, 0x3d, 0xee, 0x58, 0xf7, 0xe3, 0xc4, 0x18, 0xaf, 0xfa, 0xaf, 0xed, 0x9a, 0x45, 0xe7, 0xa8, 0xbe, 0xcd, 0x0f, 0xb9, 0x53, 0x18, 0xc6, 0x14, 0xbe, 0xbb, 0x90, 0x1c, 0x5c, 0x60, 0x93, 0xcb, 0x62, 0xb3, 0xdb, 0x31, 0x19, 0x39, 0xce, 0x3f, 0xe4, 0x8f, 0x44, 0xc1, 0x10, 0x80, 0x05, 0x6b, 0x77, 0xe3, 0xe1, 0xe5, 0xd2, 0x6d, 0x93, 0xf2, 0xb3, 0x81, 0x03, 0xf8, 0xbc, 0x7b, 0x5a, 0x71, 0x15, 0x16, 0x3a, 0x2f, 0x03, 0xbb, 0x67, 0x6a, 0xd9, 0xf5, 0x63, 0x6f, 0x3d, 0x75, 0x1b, 0x0a, 0x4b, 0x9d, 0x04, 0x11, 0x7e, 0xe8, 0x3e, 0x2d, 0x04, 0x8f, 0xbf, 0x8a, 0xb2, 0x35, 0x76, 0xc5, 0xcc, 0x6d, 0x9e, 0x99, 0x71, 0x13, 0xf6, 0x5e, 0xeb, 0x74, 0x96, 0x8a, 0x29, 0x38, 0x0b, 0x25, 0x4b, 0x89, 0xa9, 0x43, 0x3c, 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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, 0xd4, 0x84, 0xaa, 0x01, 0x85, 0x13, 0xe8, 0xab, 0xaa, 0xb6, 0x81, 0x82, 0xd6, 0x32, 0xd6, 0x9f, 0x63, 0x69, 0x55, 0x10, 0x5f, 0x2e, 0xb3, 0x51, 0x74, 0x80, 0x5c, 0xe9, 0x8d, 0x27, 0xd8, 0x41, 0x2d, 0x27, 0x07, 0xb4, 0x13, 0xcd, 0xc0, 0xb3, 0x96, 0xaa, 0x59, 0x9c, 0x3e, 0x16, 0x9e, 0x18, 0xa5, 0x92, 0x52, 0x59, 0x19, 0x19, 0x62, 0xeb, 0xd9, 0xdf, 0x9d, 0x10, 0x77, 0xfb, 0x3c, 0xf1, 0xeb, 0x70, 0xf6, 0x6a, 0x9b, 0xad, 0x99, 0x35, 0xd7, 0xf8, 0xde, 0x2b, 0x52, 0x85, 0xdd, 0x36, 0x07, 0x3a, 0x88, 0xa6, 0xbb, 0x98, 0x7a, 0xe3, 0xb0, 0xe6, 0xae, 0x33, 0x5d, 0x47, 0x0c, 0x6c, 0xd4, 0x84, 0x33, 0x7e, 0xf4, 0xea, 0xfd, 0xf1, 0x1c, 0xdb, 0x8b, 0xfe, 0x01, 0x77, 0xa3, 0x07, 0x21, 0x09, 0xac, 0x0c, 0xe4, 0x63, 0xaa, 0x3d, 0xb3, 0x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0x4d, 0x40, 0x6c, 0xc2, 0x99, 0xc2, 0xe9, 0x0e, 0xcf, 0x06, 0x82, 0x61, 0x5c, 0x76, 0xca, 0xef, 0x8f, 0xd3, 0x78, 0x2a, 0xae, 0x39, 0x29, 0x4e, 0xc1, 0x2c, 0xb1, 0xbc, 0xcd, 0x76, 0x4f, 0x25, 0xf0, 0x5b, 0x78, 0x3a, 0xa4, 0x39, 0x52, 0x5a, 0xc7, 0xcf, 0x17, 0x3d, 0xb0, 0x39, 0x63, 0xf9, 0xf9, 0xfb, 0x6f, 0x35, 0xb7, 0xf1, 0x49, 0x10, 0xd8, 0x12, 0x8d, 0xa2, 0xdf, 0xc5, 0x26, 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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x61, 0x8e, 0x6c, 0xc5, 0x34, 0xab, 0x03, 0x3e, 0x8a, 0xe5, 0x2b, 0xa2, 0xa4, 0x04, 0xa2, 0x01, 0x81, 0x79, 0x72, 0xfc, 0x19, 0xbd, 0x38, 0x39, 0xee, 0xb3, 0x95, 0xc5, 0x6f, 0xed, 0xaa, 0x6e, 0xca, 0xeb, 0xc6, 0xaf, 0xeb, 0x76, 0xb4, 0xd7, 0xc3, 0x1b, 0x65, 0x99, 0xc6, 0xa3, 0xe8, 0x96, 0x5e, 0xc1, 0x0c, 0xd2, 0xf8, 0x65, 0xcf, 0x42, 0xc5, 0x8f, 0x52, 0x5d, 0x90, 0x21, 0x55, 0xec, 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: head/contrib/netbsd-tests/dev/clock_subr/clock_subr_test_data_gen.sh =================================================================== --- head/contrib/netbsd-tests/dev/clock_subr/clock_subr_test_data_gen.sh (nonexistent) +++ head/contrib/netbsd-tests/dev/clock_subr/clock_subr_test_data_gen.sh (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/dev/clock_subr/t_clock_subr.c =================================================================== --- head/contrib/netbsd-tests/dev/clock_subr/t_clock_subr.c (nonexistent) +++ head/contrib/netbsd-tests/dev/clock_subr/t_clock_subr.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/dev/scsipi/t_cd.c =================================================================== --- head/contrib/netbsd-tests/dev/scsipi/t_cd.c (revision 313438) +++ head/contrib/netbsd-tests/dev/scsipi/t_cd.c (revision 313439) @@ -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: head/contrib/netbsd-tests/dev/sysmon/t_swwdog.c =================================================================== --- head/contrib/netbsd-tests/dev/sysmon/t_swwdog.c (revision 313438) +++ head/contrib/netbsd-tests/dev/sysmon/t_swwdog.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/common/h_fsmacros.h =================================================================== --- head/contrib/netbsd-tests/fs/common/h_fsmacros.h (revision 313438) +++ head/contrib/netbsd-tests/fs/common/h_fsmacros.h (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c =================================================================== --- head/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c (revision 313438) +++ head/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/ffs/t_fifos.c =================================================================== --- head/contrib/netbsd-tests/fs/ffs/t_fifos.c (revision 313438) +++ head/contrib/netbsd-tests/fs/ffs/t_fifos.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/ffs/t_mount.c =================================================================== --- head/contrib/netbsd-tests/fs/ffs/t_mount.c (revision 313438) +++ head/contrib/netbsd-tests/fs/ffs/t_mount.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/ffs/t_quota2_1.c =================================================================== --- head/contrib/netbsd-tests/fs/ffs/t_quota2_1.c (revision 313438) +++ head/contrib/netbsd-tests/fs/ffs/t_quota2_1.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c =================================================================== --- head/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c (revision 313438) +++ head/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/ffs/t_snapshot.c =================================================================== --- head/contrib/netbsd-tests/fs/ffs/t_snapshot.c (revision 313438) +++ head/contrib/netbsd-tests/fs/ffs/t_snapshot.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c =================================================================== --- head/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c (revision 313438) +++ head/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c =================================================================== --- head/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c (revision 313438) +++ head/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/hfs/t_pathconvert.c =================================================================== --- head/contrib/netbsd-tests/fs/hfs/t_pathconvert.c (revision 313438) +++ head/contrib/netbsd-tests/fs/hfs/t_pathconvert.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/kernfs/t_basic.c =================================================================== --- head/contrib/netbsd-tests/fs/kernfs/t_basic.c (revision 313438) +++ head/contrib/netbsd-tests/fs/kernfs/t_basic.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/lfs/t_pr.c =================================================================== --- head/contrib/netbsd-tests/fs/lfs/t_pr.c (revision 313438) +++ head/contrib/netbsd-tests/fs/lfs/t_pr.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c =================================================================== --- head/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c (revision 313438) +++ head/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/nfs/t_mountd.c =================================================================== --- head/contrib/netbsd-tests/fs/nfs/t_mountd.c (revision 313438) +++ head/contrib/netbsd-tests/fs/nfs/t_mountd.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/nullfs/t_basic.c =================================================================== --- head/contrib/netbsd-tests/fs/nullfs/t_basic.c (revision 313438) +++ head/contrib/netbsd-tests/fs/nullfs/t_basic.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/ptyfs/t_nullpts.c =================================================================== --- head/contrib/netbsd-tests/fs/ptyfs/t_nullpts.c (revision 313438) +++ head/contrib/netbsd-tests/fs/ptyfs/t_nullpts.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/ptyfs/t_ptyfs.c =================================================================== --- head/contrib/netbsd-tests/fs/ptyfs/t_ptyfs.c (revision 313438) +++ head/contrib/netbsd-tests/fs/ptyfs/t_ptyfs.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/puffs/t_basic.c =================================================================== --- head/contrib/netbsd-tests/fs/puffs/t_basic.c (revision 313438) +++ head/contrib/netbsd-tests/fs/puffs/t_basic.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/puffs/t_fuzz.c =================================================================== --- head/contrib/netbsd-tests/fs/puffs/t_fuzz.c (revision 313438) +++ head/contrib/netbsd-tests/fs/puffs/t_fuzz.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/puffs/t_io.c =================================================================== --- head/contrib/netbsd-tests/fs/puffs/t_io.c (revision 313438) +++ head/contrib/netbsd-tests/fs/puffs/t_io.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh =================================================================== --- head/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh (revision 313438) +++ head/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh (revision 313439) @@ -1,159 +1,143 @@ # $NetBSD: t_mknod.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $ # # Copyright (c) 2005, 2006, 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. # # # Verifies that the mknod operation works. # atf_test_case block block_head() { atf_set "descr" "Tests that block devices can be created" atf_set "require.user" "root" } block_body() { test_mount umask 022 atf_check -s eq:0 -o empty -e empty mknod fd0a b 2 0 eval $(stat -s fd0a) [ ${st_mode} = 060644 ] || atf_fail "Invalid mode" [ ${st_rdev} -eq 512 ] || atf_fail "Invalid device" test_unmount } atf_test_case block_kqueue block_kqueue_head() { atf_set "descr" "Tests that creating a block device raises the" \ "appropriate kqueue events" atf_set "require.user" "root" } block_kqueue_body() { test_mount umask 022 atf_check -s eq:0 -o empty -e empty mkdir dir echo 'mknod dir/fd0a b 2 0' | kqueue_monitor 1 dir kqueue_check dir NOTE_WRITE test_unmount } atf_test_case char char_head() { atf_set "descr" "Tests that character devices can be created" atf_set "require.user" "root" } char_body() { test_mount umask 022 atf_check -s eq:0 -o empty -e empty mknod null c 2 2 eval $(stat -s null) [ ${st_mode} = 020644 ] || atf_fail "Invalid mode" [ ${st_rdev} -eq 514 ] || atf_fail "Invalid device" test_unmount } atf_test_case char_kqueue char_kqueue_head() { atf_set "descr" "Tests that creating a character device raises the" \ "appropriate kqueue events" atf_set "require.user" "root" } char_kqueue_body() { test_mount umask 022 atf_check -s eq:0 -o empty -e empty mkdir dir echo 'mknod dir/null c 2 2' | kqueue_monitor 1 dir kqueue_check dir NOTE_WRITE test_unmount } atf_test_case pipe pipe_head() { atf_set "descr" "Tests that named pipes can be created" atf_set "require.user" "root" } pipe_body() { test_mount umask 022 - # Begin FreeBSD - if true; then - atf_check -s eq:0 -o empty -e empty mkfifo pipe - else - # End FreeBSD atf_check -s eq:0 -o empty -e empty mknod pipe p - # Begin FreeBSD - fi - # End FreeBSD eval $(stat -s pipe) [ ${st_mode} = 010644 ] || atf_fail "Invalid mode" test_unmount } atf_test_case pipe_kqueue pipe_kqueue_head() { atf_set "descr" "Tests that creating a named pipe raises the" \ "appropriate kqueue events" atf_set "require.user" "root" } pipe_kqueue_body() { test_mount umask 022 atf_check -s eq:0 -o empty -e empty mkdir dir - # Begin FreeBSD - if true; then - echo 'mkfifo dir/pipe' | kqueue_monitor 1 dir - else - # End FreeBSD echo 'mknod dir/pipe p' | kqueue_monitor 1 dir - # Begin FreeBSD - fi - # End FreeBSD kqueue_check dir NOTE_WRITE test_unmount } atf_init_test_cases() { . $(atf_get_srcdir)/../h_funcs.subr . $(atf_get_srcdir)/h_funcs.subr atf_add_test_case block atf_add_test_case block_kqueue atf_add_test_case char atf_add_test_case char_kqueue atf_add_test_case pipe atf_add_test_case pipe_kqueue } Index: head/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh =================================================================== --- head/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh (revision 313438) +++ head/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh (revision 313439) @@ -1,124 +1,116 @@ # $NetBSD: t_readdir.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $ # # Copyright (c) 2005, 2006, 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. # # # Verifies that the readdir operation works. # atf_test_case dots dots_head() { atf_set "descr" "Verifies that readdir returns the '.' and '..'" \ "entries" atf_set "require.user" "root" } dots_body() { test_mount atf_check -s eq:0 -o save:stdout -e empty /bin/ls -a atf_check -s eq:0 -o ignore -e empty grep '^\.$' stdout atf_check -s eq:0 -o ignore -e empty grep '^\..$' stdout test_unmount } atf_test_case types types_head() { atf_set "descr" "Verifies that readdir works for all different" \ "file types" atf_set "require.user" "root" } types_body() { test_mount atf_check -s eq:0 -o empty -e empty mkdir dir atf_check -s eq:0 -o empty -e empty touch reg atf_check -s eq:0 -o empty -e empty ln -s reg lnk atf_check -s eq:0 -o empty -e empty mknod blk b 0 0 atf_check -s eq:0 -o empty -e empty mknod chr c 0 0 - # Begin FreeBSD - if true; then - atf_check -s eq:0 -o empty -e empty mkfifo fifo - else - # End FreeBSD atf_check -s eq:0 -o empty -e empty mknod fifo p - # Begin FreeBSD - fi - # End FreeBSD atf_check -s eq:0 -o empty -e empty \ $(atf_get_srcdir)/h_tools sockets sock atf_check -s eq:0 -o ignore -e empty ls atf_check -s eq:0 -o empty -e empty rm -rf * test_unmount } atf_test_case caching caching_head() { atf_set "descr" "Catch a bug caused by incorrect invalidation of" \ "readdir caching variables" atf_set "require.user" "root" } caching_body() { test_mount atf_check -s eq:0 -o empty -e empty touch $(jot 10) atf_check -s eq:0 -o empty -e empty rm * atf_check -s eq:0 -o empty -e empty touch $(jot 20) atf_check -s eq:0 -o empty -e empty -x "ls >/dev/null" test_unmount } atf_test_case many many_head() { atf_set "descr" "Verifies that readdir works with many files" atf_set "require.user" "root" } many_body() { test_mount atf_check -s eq:0 -o empty -e empty mkdir a echo "Creating 500 files" for f in $(jot 500); do touch a/$f done atf_check -s eq:0 -o empty -e empty rm a/* atf_check -s eq:0 -o empty -e empty rmdir a test_unmount } atf_init_test_cases() { . $(atf_get_srcdir)/../h_funcs.subr . $(atf_get_srcdir)/h_funcs.subr atf_add_test_case dots atf_add_test_case types atf_add_test_case caching atf_add_test_case many } Index: head/contrib/netbsd-tests/fs/tmpfs/t_renamerace.c =================================================================== --- head/contrib/netbsd-tests/fs/tmpfs/t_renamerace.c (revision 313438) +++ head/contrib/netbsd-tests/fs/tmpfs/t_renamerace.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/umapfs/t_basic.c =================================================================== --- head/contrib/netbsd-tests/fs/umapfs/t_basic.c (revision 313438) +++ head/contrib/netbsd-tests/fs/umapfs/t_basic.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/union/t_pr.c =================================================================== --- head/contrib/netbsd-tests/fs/union/t_pr.c (revision 313438) +++ head/contrib/netbsd-tests/fs/union/t_pr.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/vfs/t_full.c =================================================================== --- head/contrib/netbsd-tests/fs/vfs/t_full.c (revision 313438) +++ head/contrib/netbsd-tests/fs/vfs/t_full.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/vfs/t_io.c =================================================================== --- head/contrib/netbsd-tests/fs/vfs/t_io.c (revision 313438) +++ head/contrib/netbsd-tests/fs/vfs/t_io.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/vfs/t_mtime_otrunc.c =================================================================== --- head/contrib/netbsd-tests/fs/vfs/t_mtime_otrunc.c (nonexistent) +++ head/contrib/netbsd-tests/fs/vfs/t_mtime_otrunc.c (revision 313439) @@ -0,0 +1,86 @@ +/*- + * Copyright (c) 2017 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) 2013\ + The NetBSD Foundation, inc. All rights reserved."); +__RCSID("$NetBSD: t_mtime_otrunc.c,v 1.1 2017/02/02 22:07:05 martin Exp $"); + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "../common/h_fsmacros.h" + +#define LOCKFILE "lock" + +static time_t +lock_it(void) +{ + struct stat st; + + if (rump_sys_stat(LOCKFILE, &st) != 0) + st.st_mtime = 0; + + int f = rump_sys_open(LOCKFILE, O_WRONLY|O_CREAT|O_TRUNC, 0666); + if (f == -1) return 0; + rump_sys_close(f); + + return st.st_mtime; +} + +static void +otrunc_mtime_update(const atf_tc_t *tc, const char *path) +{ + time_t last_ts = 0; + int res; + + /* atf_tc_expect_fail("PR kern/51762"); */ + + res = rump_sys_chdir(path); + if (res == -1) + atf_tc_fail("chdir failed"); + + for (int i = 0; i < 5; i++) { + time_t l = lock_it(); + printf("last lock: %ld\n", (long)l); + ATF_REQUIRE_MSG(i == 0 || l > last_ts, + "iteration %d: lock time did not increase, old time %lu, " + "new time %lu", i, + (unsigned long)last_ts, (unsigned long)l); + last_ts = l; + sleep(2); + } + rump_sys_chdir("/"); +} + +ATF_FSAPPLY(otrunc_mtime_update, "Checks for mtime updates by open(O_TRUNC) (PR kern/51762)"); Property changes on: head/contrib/netbsd-tests/fs/vfs/t_mtime_otrunc.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/contrib/netbsd-tests/fs/vfs/t_renamerace.c =================================================================== --- head/contrib/netbsd-tests/fs/vfs/t_renamerace.c (revision 313438) +++ head/contrib/netbsd-tests/fs/vfs/t_renamerace.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/vfs/t_ro.c =================================================================== --- head/contrib/netbsd-tests/fs/vfs/t_ro.c (revision 313438) +++ head/contrib/netbsd-tests/fs/vfs/t_ro.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/vfs/t_rwtoro.c =================================================================== --- head/contrib/netbsd-tests/fs/vfs/t_rwtoro.c (nonexistent) +++ head/contrib/netbsd-tests/fs/vfs/t_rwtoro.c (revision 313439) @@ -0,0 +1,233 @@ +/* $NetBSD: t_rwtoro.c,v 1.1 2017/01/27 10:45:11 hannken Exp $ */ + +/*- + * Copyright (c) 2017 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" + +static const char *unsupported = "fs does not support r/o remount"; +static char file_path[MAXPATHLEN]; +static int file_fd; + +/* + * Remount the filesystem read-only and test errno. + * Skip filesystems that don't implement read-write -> read-only. + */ +static void +remount_ro(const atf_tc_t *tc, const char *mp, int expected_errno) +{ + int error; + union { + struct tmpfs_args tmpfs; + char data[4095]; + } mount_args; + int mount_args_length; + struct statvfs sbuf; + + if (FSTYPE_ZFS(tc)) + atf_tc_skip("%s", unsupported); + + /* Prepare mount arguments. */ + RL(rump_sys_statvfs1(mp, &sbuf, ST_WAIT)); + mount_args_length = sizeof(mount_args); + memset(&mount_args, 0, mount_args_length); + if (FSTYPE_TMPFS(tc)) + mount_args.tmpfs.ta_version = TMPFS_ARGS_VERSION; + mount_args_length = rump_sys_mount(sbuf.f_fstypename, mp, MNT_GETARGS, + &mount_args, mount_args_length); + ATF_CHECK(mount_args_length >= 0); + + /* Remount and test result. */ + error = rump_sys_mount(sbuf.f_fstypename, mp, MNT_UPDATE | MNT_RDONLY, + &mount_args, mount_args_length); + if (errno == EOPNOTSUPP) + atf_tc_skip("%s", unsupported); + if (expected_errno == 0) + ATF_CHECK(error == 0); + else + ATF_CHECK_ERRNO(expected_errno, error == -1); +} + +static void +open_file_ro(const char *prefix) +{ + + snprintf(file_path, sizeof(file_path), "%s/file", prefix); + RL(file_fd = rump_sys_open(file_path, O_CREAT | O_RDWR, 0777)); + RL(rump_sys_close(file_fd)); + RL(file_fd = rump_sys_open(file_path, O_RDONLY)); +} + +static void +open_file_ro_unlink(const char *prefix) +{ + + snprintf(file_path, sizeof(file_path), "%s/file", prefix); + RL(file_fd = rump_sys_open(file_path, O_CREAT | O_RDWR, 0777)); + RL(rump_sys_close(file_fd)); + RL(file_fd = rump_sys_open(file_path, O_RDONLY)); + RL(rump_sys_unlink(file_path)); +} + +static void +open_file_rw(const char *prefix) +{ + + snprintf(file_path, sizeof(file_path), "%s/file", prefix); + RL(file_fd = rump_sys_open(file_path, O_CREAT | O_RDWR, 0777)); +} + +static void +close_file(const char *unused) +{ + + RL(rump_sys_close(file_fd)); +} + +static void +basic_test(const atf_tc_t *tc, const char *mp, int expected_errno, + bool use_layer, void (*pre)(const char *), void (*post)(const char *)) +{ + const char *null_mount = "/nullm"; + struct null_args nargs; + + if (use_layer) { + RL(rump_sys_mkdir(null_mount, 0777)); + memset(&nargs, 0, sizeof(nargs)); + nargs.nulla_target = __UNCONST(mp);; + RL(rump_sys_mount(MOUNT_NULL, null_mount, 0, + &nargs, sizeof(nargs))); + } + if (pre) + (*pre)(use_layer ? null_mount : mp); + remount_ro(tc, mp, expected_errno); + if (post) + (*post)(use_layer ? null_mount : mp); + if (use_layer) + RL(rump_sys_unmount(null_mount, 0)); +} + +static void +noneopen(const atf_tc_t *tc, const char *mp) +{ + + basic_test(tc, mp, 0, false, NULL, NULL); +} + +static void +readopen(const atf_tc_t *tc, const char *mp) +{ + + basic_test(tc, mp, 0, false, open_file_ro, close_file); +} + +static void +writeopen(const atf_tc_t *tc, const char *mp) +{ + + basic_test(tc, mp, EBUSY, false, open_file_rw, close_file); +} + +static void +read_unlinked(const atf_tc_t *tc, const char *mp) +{ + + basic_test(tc, mp, EBUSY, false, open_file_ro_unlink, close_file); +} + +static void +layer_noneopen(const atf_tc_t *tc, const char *mp) +{ + + basic_test(tc, mp, 0, true, NULL, NULL); +} + +static void +layer_readopen(const atf_tc_t *tc, const char *mp) +{ + + basic_test(tc, mp, 0, true, open_file_ro, close_file); +} + +static void +layer_writeopen(const atf_tc_t *tc, const char *mp) +{ + + basic_test(tc, mp, EBUSY, true, open_file_rw, close_file); +} + +static void +layer_read_unlinked(const atf_tc_t *tc, const char *mp) +{ + + basic_test(tc, mp, EBUSY, true, open_file_ro_unlink, close_file); +} + +ATF_TC_FSAPPLY(noneopen, "remount r/o with no file open"); +ATF_TC_FSAPPLY(readopen, "remount r/o with file open for reading"); +ATF_TC_FSAPPLY(writeopen, "remount r/o with file open for writing"); +ATF_TC_FSAPPLY(read_unlinked, + "remount r/o with unlinked file open for reading"); +ATF_TC_FSAPPLY(layer_noneopen, "remount r/o with no file open on layer"); +ATF_TC_FSAPPLY(layer_readopen, + "remount r/o with file open for reading on layer"); +ATF_TC_FSAPPLY(layer_writeopen, + "remount r/o with file open for writing on layer"); +ATF_TC_FSAPPLY(layer_read_unlinked, + "remount r/o with unlinked file open for reading on layer"); + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_FSAPPLY(noneopen); + ATF_TP_FSAPPLY(readopen); + ATF_TP_FSAPPLY(writeopen); + ATF_TP_FSAPPLY(read_unlinked); + ATF_TP_FSAPPLY(layer_noneopen); + ATF_TP_FSAPPLY(layer_readopen); + ATF_TP_FSAPPLY(layer_writeopen); + ATF_TP_FSAPPLY(layer_read_unlinked); + + return atf_no_error(); +} Property changes on: head/contrib/netbsd-tests/fs/vfs/t_rwtoro.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/contrib/netbsd-tests/fs/vfs/t_union.c =================================================================== --- head/contrib/netbsd-tests/fs/vfs/t_union.c (revision 313438) +++ head/contrib/netbsd-tests/fs/vfs/t_union.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/vfs/t_unpriv.c =================================================================== --- head/contrib/netbsd-tests/fs/vfs/t_unpriv.c (revision 313438) +++ head/contrib/netbsd-tests/fs/vfs/t_unpriv.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/vfs/t_vfsops.c =================================================================== --- head/contrib/netbsd-tests/fs/vfs/t_vfsops.c (revision 313438) +++ head/contrib/netbsd-tests/fs/vfs/t_vfsops.c (revision 313439) @@ -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: head/contrib/netbsd-tests/fs/vfs/t_vnops.c =================================================================== --- head/contrib/netbsd-tests/fs/vfs/t_vnops.c (revision 313438) +++ head/contrib/netbsd-tests/fs/vfs/t_vnops.c (revision 313439) @@ -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: head/contrib/netbsd-tests/include/sys/t_socket.c =================================================================== --- head/contrib/netbsd-tests/include/sys/t_socket.c (revision 313438) +++ head/contrib/netbsd-tests/include/sys/t_socket.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait.c (revision 313439) @@ -0,0 +1,1606 @@ +/* $NetBSD: t_ptrace_wait.c,v 1.11 2017/01/18 05:14:34 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.11 2017/01/18 05:14:34 kamil 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_type=%#x\n", pw.pw_type); + 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_type=%#x\n", pw.pw_type); + 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; + 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("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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%#x\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 0); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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; + 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("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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%d\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 1); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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; + 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("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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%#x\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 2); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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; + 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("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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%#x\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 3); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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; + 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); + + ++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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%#x\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 0); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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; + 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); + + ++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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%#x\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 1); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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; + 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); + + ++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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%#x\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 2); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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; + 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); + + ++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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%#x\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 3); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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; + 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("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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%#x\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 0); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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; + 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("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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%#x\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 1); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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; + 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("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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%#x\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 2); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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; + 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("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_type = PTRACE_PW_TYPE_DBREGS; + 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_type=%#x\n", pw.pw_type); + 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 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 checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 3); + ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED); + + 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: head/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: head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait3.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait3.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait3.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait4.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait4.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait4.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait6.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait6.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_wait6.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitid.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitid.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitid.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitpid.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitpid.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/amd64/t_ptrace_waitpid.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait3.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait3.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait3.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait4.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait4.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait4.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait6.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait6.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_wait6.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitid.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitid.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitid.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitpid.c =================================================================== --- head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitpid.c (nonexistent) +++ head/contrib/netbsd-tests/kernel/arch/i386/t_ptrace_waitpid.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/kqueue/read/t_file.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/read/t_file.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/read/t_file.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/kqueue/read/t_file2.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/read/t_file2.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/read/t_file2.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/kqueue/t_ioctl.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/t_ioctl.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/t_ioctl.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/kqueue/t_proc1.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/t_proc1.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/t_proc1.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/kqueue/t_proc2.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/t_proc2.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/t_proc2.c (revision 313439) @@ -1,142 +1,139 @@ -/* $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: head/contrib/netbsd-tests/kernel/kqueue/t_proc3.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/t_proc3.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/t_proc3.c (revision 313439) @@ -1,102 +1,99 @@ -/* $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: head/contrib/netbsd-tests/kernel/kqueue/t_sig.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/t_sig.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/t_sig.c (revision 313439) @@ -1,150 +1,147 @@ -/* $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: head/contrib/netbsd-tests/kernel/kqueue/t_vnode.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/t_vnode.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/t_vnode.c (revision 313439) @@ -1,536 +1,533 @@ -#ifdef __FreeBSD__ -#include -#endif #include #include #include #include #include #include #include /* * Test cases for events triggered by manipulating a target directory * content. Using EVFILT_VNODE filter on the target directory descriptor. * */ static const char *dir_target = "foo"; static const char *dir_inside1 = "foo/bar1"; static const char *dir_inside2 = "foo/bar2"; static const char *dir_outside = "bar"; static const char *file_inside1 = "foo/baz1"; static const char *file_inside2 = "foo/baz2"; static const char *file_outside = "qux"; static const struct timespec ts = {0, 0}; static int kq = -1; static int target = -1; int init_target(void); int init_kqueue(void); int create_file(const char *); void cleanup(void); int init_target(void) { if (mkdir(dir_target, S_IRWXU) < 0) { return -1; } target = open(dir_target, O_RDONLY, 0); return target; } int init_kqueue(void) { struct kevent eventlist[1]; kq = kqueue(); if (kq < 0) { return -1; } EV_SET(&eventlist[0], (uintptr_t)target, EVFILT_VNODE, EV_ADD | EV_ONESHOT, NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_LINK | NOTE_RENAME | NOTE_REVOKE, 0, 0); return kevent(kq, eventlist, 1, NULL, 0, NULL); } int create_file(const char *file) { int fd; fd = open(file, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); if (fd < 0) { return -1; } return close(fd); } void cleanup(void) { (void)unlink(file_inside1); (void)unlink(file_inside2); (void)unlink(file_outside); (void)rmdir(dir_inside1); (void)rmdir(dir_inside2); (void)rmdir(dir_outside); (void)rmdir(dir_target); (void)close(kq); (void)close(target); } ATF_TC_WITH_CLEANUP(dir_no_note_link_create_file_in); ATF_TC_HEAD(dir_no_note_link_create_file_in, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) does not return NOTE_LINK for the directory " "'foo' if a file 'foo/baz' is created."); } ATF_TC_BODY(dir_no_note_link_create_file_in, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(create_file(file_inside1) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, 0); } ATF_TC_CLEANUP(dir_no_note_link_create_file_in, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_no_note_link_delete_file_in); ATF_TC_HEAD(dir_no_note_link_delete_file_in, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) does not return NOTE_LINK for the directory " "'foo' if a file 'foo/baz' is deleted."); } ATF_TC_BODY(dir_no_note_link_delete_file_in, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(create_file(file_inside1) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(unlink(file_inside1) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, 0); } ATF_TC_CLEANUP(dir_no_note_link_delete_file_in, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_no_note_link_mv_dir_within); ATF_TC_HEAD(dir_no_note_link_mv_dir_within, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) does not return NOTE_LINK for the directory " "'foo' if a directory 'foo/bar' is renamed to 'foo/baz'."); } ATF_TC_BODY(dir_no_note_link_mv_dir_within, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rename(dir_inside1, dir_inside2) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, 0); } ATF_TC_CLEANUP(dir_no_note_link_mv_dir_within, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_no_note_link_mv_file_within); ATF_TC_HEAD(dir_no_note_link_mv_file_within, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) does not return NOTE_LINK for the directory " "'foo' if a file 'foo/baz' is renamed to 'foo/qux'."); } ATF_TC_BODY(dir_no_note_link_mv_file_within, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(create_file(file_inside1) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rename(file_inside1, file_inside2) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, 0); } ATF_TC_CLEANUP(dir_no_note_link_mv_file_within, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_link_create_dir_in); ATF_TC_HEAD(dir_note_link_create_dir_in, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_LINK for the directory " "'foo' if a directory 'foo/bar' is created."); } ATF_TC_BODY(dir_note_link_create_dir_in, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, NOTE_LINK); } ATF_TC_CLEANUP(dir_note_link_create_dir_in, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_link_delete_dir_in); ATF_TC_HEAD(dir_note_link_delete_dir_in, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_LINK for the directory " "'foo' if a directory 'foo/bar' is deleted."); } ATF_TC_BODY(dir_note_link_delete_dir_in, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rmdir(dir_inside1) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, NOTE_LINK); } ATF_TC_CLEANUP(dir_note_link_delete_dir_in, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_link_mv_dir_in); ATF_TC_HEAD(dir_note_link_mv_dir_in, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_LINK for the directory " "'foo' if a directory 'bar' is renamed to 'foo/bar'."); } ATF_TC_BODY(dir_note_link_mv_dir_in, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(mkdir(dir_outside, S_IRWXU) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rename(dir_outside, dir_inside1) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, NOTE_LINK); } ATF_TC_CLEANUP(dir_note_link_mv_dir_in, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_link_mv_dir_out); ATF_TC_HEAD(dir_note_link_mv_dir_out, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_LINK for the directory " "'foo' if a directory 'foo/bar' is renamed to 'bar'."); } ATF_TC_BODY(dir_note_link_mv_dir_out, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rename(dir_inside1, dir_outside) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, NOTE_LINK); } ATF_TC_CLEANUP(dir_note_link_mv_dir_out, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_write_create_dir_in); ATF_TC_HEAD(dir_note_write_create_dir_in, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_WRITE for the directory " "'foo' if a directory 'foo/bar' is created."); } ATF_TC_BODY(dir_note_write_create_dir_in, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); } ATF_TC_CLEANUP(dir_note_write_create_dir_in, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_write_create_file_in); ATF_TC_HEAD(dir_note_write_create_file_in, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_WRITE for the directory " "'foo' if a file 'foo/baz' is created."); } ATF_TC_BODY(dir_note_write_create_file_in, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(create_file(file_inside1) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); } ATF_TC_CLEANUP(dir_note_write_create_file_in, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_write_delete_dir_in); ATF_TC_HEAD(dir_note_write_delete_dir_in, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_WRITE for the directory " "'foo' if a directory 'foo/bar' is deleted."); } ATF_TC_BODY(dir_note_write_delete_dir_in, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rmdir(dir_inside1) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); } ATF_TC_CLEANUP(dir_note_write_delete_dir_in, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_write_delete_file_in); ATF_TC_HEAD(dir_note_write_delete_file_in, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_WRITE for the directory " "'foo' if a file 'foo/baz' is deleted."); } ATF_TC_BODY(dir_note_write_delete_file_in, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(create_file(file_inside1) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(unlink(file_inside1) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); } ATF_TC_CLEANUP(dir_note_write_delete_file_in, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_write_mv_dir_in); ATF_TC_HEAD(dir_note_write_mv_dir_in, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_WRITE for the directory " "'foo' if a directory 'bar' is renamed to 'foo/bar'."); } ATF_TC_BODY(dir_note_write_mv_dir_in, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(mkdir(dir_outside, S_IRWXU) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rename(dir_outside, dir_inside1) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); } ATF_TC_CLEANUP(dir_note_write_mv_dir_in, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_write_mv_dir_out); ATF_TC_HEAD(dir_note_write_mv_dir_out, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_WRITE for the directory " "'foo' if a directory 'foo/bar' is renamed to 'bar'."); } ATF_TC_BODY(dir_note_write_mv_dir_out, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rename(dir_inside1, dir_outside) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); } ATF_TC_CLEANUP(dir_note_write_mv_dir_out, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_write_mv_dir_within); ATF_TC_HEAD(dir_note_write_mv_dir_within, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_WRITE for the directory " "'foo' if a directory 'foo/bar' is renamed to 'foo/baz'."); } ATF_TC_BODY(dir_note_write_mv_dir_within, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rename(dir_inside1, dir_inside2) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); } ATF_TC_CLEANUP(dir_note_write_mv_dir_within, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_write_mv_file_in); ATF_TC_HEAD(dir_note_write_mv_file_in, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_WRITE for the directory " "'foo' if a file 'qux' is renamed to 'foo/baz'."); } ATF_TC_BODY(dir_note_write_mv_file_in, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(create_file(file_outside) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rename(file_outside, file_inside1) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); } ATF_TC_CLEANUP(dir_note_write_mv_file_in, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_write_mv_file_out); ATF_TC_HEAD(dir_note_write_mv_file_out, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_WRITE for the directory " "'foo' if a file 'foo/baz' is renamed to 'qux'."); } ATF_TC_BODY(dir_note_write_mv_file_out, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(create_file(file_inside1) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rename(file_inside1, file_outside) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); } ATF_TC_CLEANUP(dir_note_write_mv_file_out, tc) { cleanup(); } ATF_TC_WITH_CLEANUP(dir_note_write_mv_file_within); ATF_TC_HEAD(dir_note_write_mv_file_within, tc) { atf_tc_set_md_var(tc, "descr", "This test case ensures " "that kevent(2) returns NOTE_WRITE for the directory " "'foo' if a file 'foo/baz' is renamed to 'foo/qux'."); } ATF_TC_BODY(dir_note_write_mv_file_within, tc) { struct kevent changelist[1]; ATF_REQUIRE(init_target() != -1); ATF_REQUIRE(create_file(file_inside1) != -1); ATF_REQUIRE(init_kqueue() != -1); ATF_REQUIRE(rename(file_inside1, file_inside2) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); } ATF_TC_CLEANUP(dir_note_write_mv_file_within, tc) { cleanup(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, dir_no_note_link_create_file_in); ATF_TP_ADD_TC(tp, dir_no_note_link_delete_file_in); ATF_TP_ADD_TC(tp, dir_no_note_link_mv_dir_within); ATF_TP_ADD_TC(tp, dir_no_note_link_mv_file_within); ATF_TP_ADD_TC(tp, dir_note_link_create_dir_in); ATF_TP_ADD_TC(tp, dir_note_link_delete_dir_in); ATF_TP_ADD_TC(tp, dir_note_link_mv_dir_in); ATF_TP_ADD_TC(tp, dir_note_link_mv_dir_out); ATF_TP_ADD_TC(tp, dir_note_write_create_dir_in); ATF_TP_ADD_TC(tp, dir_note_write_create_file_in); ATF_TP_ADD_TC(tp, dir_note_write_delete_dir_in); ATF_TP_ADD_TC(tp, dir_note_write_delete_file_in); ATF_TP_ADD_TC(tp, dir_note_write_mv_dir_in); ATF_TP_ADD_TC(tp, dir_note_write_mv_dir_out); ATF_TP_ADD_TC(tp, dir_note_write_mv_dir_within); ATF_TP_ADD_TC(tp, dir_note_write_mv_file_in); ATF_TP_ADD_TC(tp, dir_note_write_mv_file_out); ATF_TP_ADD_TC(tp, dir_note_write_mv_file_within); return atf_no_error(); } Index: head/contrib/netbsd-tests/kernel/kqueue/write/t_fifo.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/write/t_fifo.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/write/t_fifo.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/kqueue/write/t_pipe.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/write/t_pipe.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/write/t_pipe.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/kqueue/write/t_ttypty.c =================================================================== --- head/contrib/netbsd-tests/kernel/kqueue/write/t_ttypty.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/kqueue/write/t_ttypty.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/t_extent.c =================================================================== --- head/contrib/netbsd-tests/kernel/t_extent.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/t_extent.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/t_filedesc.c =================================================================== --- head/contrib/netbsd-tests/kernel/t_filedesc.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/t_filedesc.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/t_lock.c =================================================================== --- head/contrib/netbsd-tests/kernel/t_lock.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/t_lock.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/t_mqueue.c =================================================================== --- head/contrib/netbsd-tests/kernel/t_mqueue.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/t_mqueue.c (revision 313439) @@ -1,157 +1,154 @@ -/* $NetBSD: t_mqueue.c,v 1.5 2017/01/10 22:10:22 christos Exp $ */ +/* $NetBSD: t_mqueue.c,v 1.6 2017/01/14 20:57:24 christos Exp $ */ /* * Test for POSIX message queue priority handling. * * This file is in the Public Domain. */ -#ifdef __FreeBSD__ #include -#include -#include "freebsd_test_suite/macros.h" -#endif - #include -#include - +#include +#include +#include #include #include #include -#include #include -#include +#ifdef __FreeBSD__ +#include "freebsd_test_suite/macros.h" +#endif #define MQ_PRIO_BASE 24 static void send_msgs(mqd_t mqfd) { char msg[2]; msg[1] = '\0'; msg[0] = 'a'; ATF_REQUIRE_MSG(mq_send(mqfd, msg, sizeof(msg), MQ_PRIO_BASE) != -1, "mq_send 1 failed: %d", errno); msg[0] = 'b'; ATF_REQUIRE_MSG(mq_send(mqfd, msg, sizeof(msg), MQ_PRIO_BASE + 1) != -1, "mq_send 2 failed: %d", errno); msg[0] = 'c'; ATF_REQUIRE_MSG(mq_send(mqfd, msg, sizeof(msg), MQ_PRIO_BASE) != -1, "mq_send 3 failed: %d", errno); msg[0] = 'd'; ATF_REQUIRE_MSG(mq_send(mqfd, msg, sizeof(msg), MQ_PRIO_BASE - 1) != -1, "mq_send 4 failed: %d", errno); msg[0] = 'e'; ATF_REQUIRE_MSG(mq_send(mqfd, msg, sizeof(msg), 0) != -1, "mq_send 5 failed: %d", errno); msg[0] = 'f'; ATF_REQUIRE_MSG(mq_send(mqfd, msg, sizeof(msg), MQ_PRIO_BASE + 1) != -1, "mq_send 6 failed: %d", errno); } static void receive_msgs(mqd_t mqfd) { struct mq_attr mqa; char *m; unsigned p; int len; ATF_REQUIRE_MSG(mq_getattr(mqfd, &mqa) != -1, "mq_getattr failed %d", errno); len = mqa.mq_msgsize; m = calloc(1, len); ATF_REQUIRE_MSG(m != NULL, "calloc failed"); ATF_REQUIRE_MSG(mq_receive(mqfd, m, len, &p) != -1, "mq_receive 1 failed: %d", errno); ATF_REQUIRE_MSG(p == (MQ_PRIO_BASE + 1) && m[0] == 'b', "mq_receive 1 prio/data mismatch"); ATF_REQUIRE_MSG(mq_receive(mqfd, m, len, &p) != -1, "mq_receive 2 failed: %d", errno); ATF_REQUIRE_MSG(p == (MQ_PRIO_BASE + 1) && m[0] == 'f', "mq_receive 2 prio/data mismatch"); ATF_REQUIRE_MSG(mq_receive(mqfd, m, len, &p) != -1, "mq_receive 3 failed: %d", errno); ATF_REQUIRE_MSG(p == MQ_PRIO_BASE && m[0] == 'a', "mq_receive 3 prio/data mismatch"); ATF_REQUIRE_MSG(mq_receive(mqfd, m, len, &p) != -1, "mq_receive 4 failed: %d", errno); ATF_REQUIRE_MSG(p == MQ_PRIO_BASE && m[0] == 'c', "mq_receive 4 prio/data mismatch"); ATF_REQUIRE_MSG(mq_receive(mqfd, m, len, &p) != -1, "mq_receive 5 failed: %d", errno); ATF_REQUIRE_MSG(p == (MQ_PRIO_BASE - 1) && m[0] == 'd', "mq_receive 5 prio/data mismatch"); ATF_REQUIRE_MSG(mq_receive(mqfd, m, len, &p) != -1, "mq_receive 6 failed: %d", errno); ATF_REQUIRE_MSG(p == 0 && m[0] == 'e', "mq_receive 6 prio/data mismatch"); } ATF_TC(mqueue); ATF_TC_HEAD(mqueue, tc) { atf_tc_set_md_var(tc, "timeout", "3"); atf_tc_set_md_var(tc, "descr", "Checks mqueue send/receive"); } ATF_TC_BODY(mqueue, tc) { int status; char *tmpdir; char template[32]; char mq_name[64]; #ifdef __FreeBSD__ ATF_REQUIRE_KERNEL_MODULE("mqueuefs"); #endif strlcpy(template, "./t_mqueue.XXXXXX", sizeof(template)); tmpdir = mkdtemp(template); ATF_REQUIRE_MSG(tmpdir != NULL, "mkdtemp failed: %d", errno); #ifdef __FreeBSD__ snprintf(mq_name, sizeof(mq_name), "/t_mqueue"); #else snprintf(mq_name, sizeof(mq_name), "%s/mq", tmpdir); #endif mqd_t mqfd; mqfd = mq_open(mq_name, O_RDWR | O_CREAT, S_IRUSR | S_IRWXG | S_IROTH, NULL); #ifdef __FreeBSD__ ATF_REQUIRE_MSG(mqfd != (mqd_t)-1, "mq_open failed: %d", errno); #else ATF_REQUIRE_MSG(mqfd != -1, "mq_open failed: %d", errno); #endif send_msgs(mqfd); receive_msgs(mqfd); status = mq_close(mqfd); ATF_REQUIRE_MSG(status == 0, "mq_close failed: %d", errno); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, mqueue); return atf_no_error(); } Index: head/contrib/netbsd-tests/kernel/t_ptrace.c =================================================================== --- head/contrib/netbsd-tests/kernel/t_ptrace.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/t_ptrace.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/t_ptrace_wait.c =================================================================== --- head/contrib/netbsd-tests/kernel/t_ptrace_wait.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/t_ptrace_wait.c (revision 313439) @@ -1,5082 +1,6700 @@ -/* $NetBSD: t_ptrace_wait.c,v 1.53 2017/01/10 05:08:24 kamil Exp $ */ +/* $NetBSD: t_ptrace_wait.c,v 1.69 2017/01/27 16:43:07 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.69 2017/01/27 16:43:07 kamil 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 "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)); +} + +ATF_TC(eventmask5); +ATF_TC_HEAD(eventmask5, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that PTRACE_LWP_CREATE in EVENT_MASK is preserved"); +} + +ATF_TC_BODY(eventmask5, 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_LWP_CREATE; + 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(eventmask6); +ATF_TC_HEAD(eventmask6, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that PTRACE_LWP_EXIT in EVENT_MASK is preserved"); +} + +ATF_TC_BODY(eventmask6, 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_LWP_EXIT; + 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_DONE 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(io_read_auxv1); +ATF_TC_HEAD(io_read_auxv1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_READ_AUXV called for tracee"); +} + +ATF_TC_BODY(io_read_auxv1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + AuxInfo ai[100], *aip; + struct ptrace_io_desc io = { + .piod_op = PIOD_READ_AUXV, + .piod_offs = 0, + .piod_addr = ai, + .piod_len = sizeof(ai) + }; + + 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 AUXV from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + printf("Asserting that AUXV length (%zu) is > 0\n", io.piod_len); + ATF_REQUIRE(io.piod_len > 0); + + for (aip = ai; aip->a_type != AT_NULL; aip++) + printf("a_type=%#llx a_v=%#llx\n", + (long long int)aip->a_type, (long long int)aip->a_v); + + 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 +volatile lwpid_t the_lwp_id = 0; + +static void +lwp_main_func(void *arg) +{ + the_lwp_id = _lwp_self(); + _lwp_exit(); +} + +ATF_TC(lwp_create1); +ATF_TC_HEAD(lwp_create1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that 1 LWP creation is intercepted by ptrace(2) with " + "EVENT_MASK set to PTRACE_LWP_CREATE"); +} + +ATF_TC_BODY(lwp_create1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, 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); + ucontext_t uc; + lwpid_t lid; + static const size_t ssize = 16*1024; + void *stack; + + 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 allocating memory for stack in child\n"); + FORKEE_ASSERT((stack = malloc(ssize)) != NULL); + + printf("Before making context for new lwp in child\n"); + _lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize); + + printf("Before creating new in child\n"); + FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0); + + printf("Before waiting for lwp %d to exit\n", lid); + FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0); + + printf("Before verifying that reported %d and running lid %d " + "are the same\n", lid, the_lwp_id); + FORKEE_ASSERT_EQ(lid, the_lwp_id); + + 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 = PTRACE_LWP_CREATE; + 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 " + "SIGTRAP\n", TWAIT_FNAME); + 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_LWP_CREATE); + + lid = state.pe_lwp; + printf("Reported PTRACE_LWP_CREATE event with lid %d\n", lid); + + 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(lwp_exit1); +ATF_TC_HEAD(lwp_exit1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that 1 LWP creation is intercepted by ptrace(2) with " + "EVENT_MASK set to PTRACE_LWP_EXIT"); +} + +ATF_TC_BODY(lwp_exit1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, 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); + ucontext_t uc; + lwpid_t lid; + static const size_t ssize = 16*1024; + void *stack; + + 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 allocating memory for stack in child\n"); + FORKEE_ASSERT((stack = malloc(ssize)) != NULL); + + printf("Before making context for new lwp in child\n"); + _lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize); + + printf("Before creating new in child\n"); + FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0); + + printf("Before waiting for lwp %d to exit\n", lid); + FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0); + + printf("Before verifying that reported %d and running lid %d " + "are the same\n", lid, the_lwp_id); + FORKEE_ASSERT_EQ(lid, the_lwp_id); + + 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 = PTRACE_LWP_EXIT; + 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 " + "SIGTRAP\n", TWAIT_FNAME); + 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_LWP_EXIT); + + lid = state.pe_lwp; + printf("Reported PTRACE_LWP_EXIT event with lid %d\n", lid); + + 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(signal1); +ATF_TC_HEAD(signal1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that masking single unrelated signal does not stop tracer " + "from catching other signals"); +} + +ATF_TC_BODY(signal1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + const int sigmasked = SIGTRAP; + const int signotmasked = SIGINT; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + sigset_t intmask; + + 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); + + sigemptyset(&intmask); + sigaddset(&intmask, sigmasked); + sigprocmask(SIG_BLOCK, &intmask, NULL); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before raising %s from child\n", + strsignal(signotmasked)); + FORKEE_ASSERT(raise(signotmasked) == 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, signotmasked); + + 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(signal2); +ATF_TC_HEAD(signal2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that masking SIGTRAP in tracee stops tracer from " + "catching this raised signal"); +} + +ATF_TC_BODY(signal2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + const int sigmasked = SIGTRAP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + sigset_t intmask; + + 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); + + sigemptyset(&intmask); + sigaddset(&intmask, sigmasked); + sigprocmask(SIG_BLOCK, &intmask, NULL); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before raising %s breakpoint from child\n", + strsignal(sigmasked)); + FORKEE_ASSERT(raise(sigmasked) == 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(signal3); +ATF_TC_HEAD(signal3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that masking SIGTRAP in tracee does not stop tracer from " + "catching software breakpoints"); +} + +ATF_TC_BODY(signal3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + const int sigmasked = SIGTRAP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + sigset_t intmask; + + atf_tc_expect_fail("PR kern/51918"); + + 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); + + sigemptyset(&intmask); + sigaddset(&intmask, sigmasked); + sigprocmask(SIG_BLOCK, &intmask, NULL); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before raising software breakpoint from child\n"); +#if defined(__x86_64__) + __asm__ __volatile__ ("int3\n;"); +#else + /* port me */ +#endif + + 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, sigmasked); + + 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(PT_STEP) +ATF_TC(signal4); +ATF_TC_HEAD(signal4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that masking SIGTRAP in tracee does not stop tracer from " + "catching single step trap"); +} + +ATF_TC_BODY(signal4, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + const int sigmasked = SIGTRAP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + sigset_t intmask; + int happy; + + atf_tc_expect_fail("PR kern/51918"); + + 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); + + sigemptyset(&intmask); + sigaddset(&intmask, sigmasked); + sigprocmask(SIG_BLOCK, &intmask, NULL); + + 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\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, sigmasked); + + 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(signal5); +ATF_TC_HEAD(signal5, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that masking SIGTRAP in tracee does not stop tracer from " + "catching exec() breakpoint"); +} + +ATF_TC_BODY(signal5, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + const int sigmasked = SIGTRAP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + sigset_t intmask; + + atf_tc_expect_fail("PR kern/51918"); + + 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); + + sigemptyset(&intmask); + sigaddset(&intmask, sigmasked); + sigprocmask(SIG_BLOCK, &intmask, NULL); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before calling execve(2) from child\n"); + execlp("/bin/echo", "/bin/echo", NULL); + + 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, sigmasked); + + 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(signal6); +ATF_TC_HEAD(signal6, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that masking SIGTRAP in tracee does not stop tracer from " + "catching PTRACE_FORK breakpoint"); +} + +ATF_TC_BODY(signal6, tc) +{ + const int exitval = 5; + const int exitval2 = 15; + const int sigval = SIGSTOP; + const int sigmasked = SIGTRAP; + pid_t child, child2, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + sigset_t intmask; + ptrace_state_t state; + const int slen = sizeof(state); + ptrace_event_t event; + const int elen = sizeof(event); + + atf_tc_expect_fail("PR kern/51918"); + + 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); + + sigemptyset(&intmask); + sigaddset(&intmask, sigmasked); + sigprocmask(SIG_BLOCK, &intmask, NULL); + + 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\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigmasked); + + 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 child2\n", TWAIT_FNAME); + 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 + +#if defined(TWAIT_HAVE_PID) +ATF_TC(signal7); +ATF_TC_HEAD(signal7, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that masking SIGTRAP in tracee does not stop tracer from " + "catching PTRACE_VFORK breakpoint"); +} + +ATF_TC_BODY(signal7, tc) +{ + const int exitval = 5; + const int exitval2 = 15; + const int sigval = SIGSTOP; + const int sigmasked = SIGTRAP; + pid_t child, child2, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + sigset_t intmask; + ptrace_state_t state; + const int slen = sizeof(state); + ptrace_event_t event; + const int elen = sizeof(event); + + atf_tc_expect_fail("PR kern/51918 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); + + sigemptyset(&intmask); + sigaddset(&intmask, sigmasked); + sigprocmask(SIG_BLOCK, &intmask, NULL); + + 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_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\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigmasked); + + 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 child2\n", TWAIT_FNAME); + 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(signal8); +ATF_TC_HEAD(signal8, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that masking SIGTRAP in tracee does not stop tracer from " + "catching PTRACE_VFORK_DONE breakpoint"); +} + +ATF_TC_BODY(signal8, tc) +{ + const int exitval = 5; + const int exitval2 = 15; + const int sigval = SIGSTOP; + const int sigmasked = SIGTRAP; + pid_t child, child2, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + sigset_t intmask; + ptrace_state_t state; + const int slen = sizeof(state); + ptrace_event_t event; + const int elen = sizeof(event); + + atf_tc_expect_fail("PR kern/51918"); + + 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); + + sigemptyset(&intmask); + sigaddset(&intmask, sigmasked); + sigprocmask(SIG_BLOCK, &intmask, NULL); + + 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_DONE 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\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigmasked); + + 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(signal9); +ATF_TC_HEAD(signal9, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that masking SIGTRAP in tracee does not stop tracer from " + "catching PTRACE_LWP_CREATE breakpoint"); +} + +ATF_TC_BODY(signal9, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + const int sigmasked = SIGTRAP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + sigset_t intmask; + ptrace_state_t state; + const int slen = sizeof(state); + ptrace_event_t event; + const int elen = sizeof(event); + ucontext_t uc; + lwpid_t lid; + static const size_t ssize = 16*1024; + void *stack; + + atf_tc_expect_fail("PR kern/51918"); + + 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); + + sigemptyset(&intmask); + sigaddset(&intmask, sigmasked); + sigprocmask(SIG_BLOCK, &intmask, NULL); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before allocating memory for stack in child\n"); + FORKEE_ASSERT((stack = malloc(ssize)) != NULL); + + printf("Before making context for new lwp in child\n"); + _lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize); + + printf("Before creating new in child\n"); + FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0); + + printf("Before waiting for lwp %d to exit\n", lid); + FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0); + + printf("Before verifying that reported %d and running lid %d " + "are the same\n", lid, the_lwp_id); + FORKEE_ASSERT_EQ(lid, the_lwp_id); + + 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 = PTRACE_LWP_CREATE; + 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 " + "SIGTRAP\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigmasked); + + ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1); + + ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_LWP_CREATE); + + lid = state.pe_lwp; + printf("Reported PTRACE_LWP_CREATE event with lid %d\n", lid); + + 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(signal10); +ATF_TC_HEAD(signal10, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that masking SIGTRAP in tracee does not stop tracer from " + "catching PTRACE_LWP_EXIT breakpoint"); +} + +ATF_TC_BODY(signal10, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + const int sigmasked = SIGTRAP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + sigset_t intmask; + ptrace_state_t state; + const int slen = sizeof(state); + ptrace_event_t event; + const int elen = sizeof(event); + ucontext_t uc; + lwpid_t lid; + static const size_t ssize = 16*1024; + void *stack; + + atf_tc_expect_fail("PR kern/51918"); + + 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); + + sigemptyset(&intmask); + sigaddset(&intmask, sigmasked); + sigprocmask(SIG_BLOCK, &intmask, NULL); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before allocating memory for stack in child\n"); + FORKEE_ASSERT((stack = malloc(ssize)) != NULL); + + printf("Before making context for new lwp in child\n"); + _lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize); + + printf("Before creating new in child\n"); + FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0); + + printf("Before waiting for lwp %d to exit\n", lid); + FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0); + + printf("Before verifying that reported %d and running lid %d " + "are the same\n", lid, the_lwp_id); + FORKEE_ASSERT_EQ(lid, the_lwp_id); + + 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 = PTRACE_LWP_EXIT; + 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 " + "SIGTRAP\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigmasked); + + ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1); + + ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_LWP_EXIT); + + lid = state.pe_lwp; + printf("Reported PTRACE_LWP_EXIT event with lid %d\n", lid); + + 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_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(tp, eventmask5); + ATF_TP_ADD_TC(tp, eventmask6); 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(tp, io_read_auxv1); + 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); + + ATF_TP_ADD_TC(tp, lwp_create1); + + ATF_TP_ADD_TC(tp, lwp_exit1); + + ATF_TP_ADD_TC(tp, signal1); + ATF_TP_ADD_TC(tp, signal2); + ATF_TP_ADD_TC(tp, signal3); + ATF_TP_ADD_TC_PT_STEP(tp, signal4); + ATF_TP_ADD_TC(tp, signal5); + ATF_TP_ADD_TC_HAVE_PID(tp, signal6); + ATF_TP_ADD_TC_HAVE_PID(tp, signal7); + ATF_TP_ADD_TC(tp, signal8); + ATF_TP_ADD_TC(tp, signal9); + ATF_TP_ADD_TC(tp, signal10); return atf_no_error(); } Index: head/contrib/netbsd-tests/kernel/t_pty.c =================================================================== --- head/contrib/netbsd-tests/kernel/t_pty.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/t_pty.c (revision 313439) @@ -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: head/contrib/netbsd-tests/kernel/t_rnd.c =================================================================== --- head/contrib/netbsd-tests/kernel/t_rnd.c (revision 313438) +++ head/contrib/netbsd-tests/kernel/t_rnd.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c (revision 313439) @@ -1,125 +1,120 @@ -/* $NetBSD: t_mkfifoat.c,v 1.3 2017/01/10 15:15:09 christos Exp $ */ +/* $NetBSD: t_mkfifoat.c,v 1.4 2017/01/14 20:55:26 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Emmanuel Dreyfus. * * 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_mkfifoat.c,v 1.3 2017/01/10 15:15:09 christos Exp $"); +__RCSID("$NetBSD: t_mkfifoat.c,v 1.4 2017/01/14 20:55:26 christos Exp $"); #include #include #include #include #include #include #include #include #include #include #define DIR "dir" #define FIFO "dir/openat" #define BASEFIFO "openat" #define FIFOERR "dir/openaterr" ATF_TC(mkfifoat_fd); ATF_TC_HEAD(mkfifoat_fd, tc) { atf_tc_set_md_var(tc, "descr", "See that mkfifoat works with fd"); } ATF_TC_BODY(mkfifoat_fd, tc) { int dfd; - int fd; mode_t mode = 0600; ATF_REQUIRE(mkdir(DIR, 0755) == 0); ATF_REQUIRE((dfd = open(DIR, O_RDONLY, 0)) != -1); - ATF_REQUIRE((fd = mkfifoat(dfd, BASEFIFO, mode)) != -1); - ATF_REQUIRE(close(fd) == 0); + ATF_REQUIRE(mkfifoat(dfd, BASEFIFO, mode) != -1); ATF_REQUIRE(access(FIFO, F_OK) == 0); (void)close(dfd); } ATF_TC(mkfifoat_fdcwd); ATF_TC_HEAD(mkfifoat_fdcwd, tc) { atf_tc_set_md_var(tc, "descr", "See that mkfifoat works with fd as AT_FDCWD"); } ATF_TC_BODY(mkfifoat_fdcwd, tc) { - int fd; mode_t mode = 0600; ATF_REQUIRE(mkdir(DIR, 0755) == 0); - ATF_REQUIRE((fd = mkfifoat(AT_FDCWD, FIFO, mode)) != -1); - ATF_REQUIRE(close(fd) == 0); + ATF_REQUIRE(mkfifoat(AT_FDCWD, FIFO, mode) != -1); ATF_REQUIRE(access(FIFO, F_OK) == 0); } ATF_TC(mkfifoat_fdcwderr); ATF_TC_HEAD(mkfifoat_fdcwderr, tc) { atf_tc_set_md_var(tc, "descr", "See that mkfifoat fails with fd as AT_FDCWD and bad path"); } ATF_TC_BODY(mkfifoat_fdcwderr, tc) { - int fd; mode_t mode = 0600; - ATF_REQUIRE((fd = mkfifoat(AT_FDCWD, FIFOERR, mode)) == -1); + ATF_REQUIRE(mkfifoat(AT_FDCWD, FIFOERR, mode) == -1); } ATF_TC(mkfifoat_fderr); ATF_TC_HEAD(mkfifoat_fderr, tc) { atf_tc_set_md_var(tc, "descr", "See that mkfifoat fails with fd as -1"); } ATF_TC_BODY(mkfifoat_fderr, tc) { int fd; mode_t mode = 0600; ATF_REQUIRE(mkdir(DIR, 0755) == 0); ATF_REQUIRE((fd = open(FIFO, O_CREAT|O_RDWR, 0644)) != -1); ATF_REQUIRE(close(fd) == 0); - ATF_REQUIRE((fd = mkfifoat(-1, FIFO, mode)) == -1); + ATF_REQUIRE(mkfifoat(-1, FIFO, mode) == -1); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, mkfifoat_fd); ATF_TP_ADD_TC(tp, mkfifoat_fdcwd); ATF_TP_ADD_TC(tp, mkfifoat_fdcwderr); ATF_TP_ADD_TC(tp, mkfifoat_fderr); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/db/t_db.sh =================================================================== --- head/contrib/netbsd-tests/lib/libc/db/t_db.sh (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/db/t_db.sh (revision 313439) @@ -1,1310 +1,1302 @@ # $NetBSD: t_db.sh,v 1.7 2016/09/24 20:12:33 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. # prog_db() { echo $(atf_get_srcdir)/h_db } prog_lfsr() { echo $(atf_get_srcdir)/h_lfsr } dict() { if [ -f /usr/share/dict/words ]; then echo /usr/share/dict/words elif [ -f /usr/dict/words ]; then echo /usr/dict/words else - echo "" atf_fail "no dictionary found" fi } - -# Begin FreeBSD -dict() -{ - echo /usr/share/dict/words -} -# End FreeBSD SEVEN_SEVEN="abcdefg|abcdefg|abcdefg|abcdefg|abcdefg|abcdefg|abcdefg" atf_test_case small_btree small_btree_head() { atf_set "descr" \ "Checks btree database using small keys and small data" \ "pairs: takes the first hundred entries in the dictionary," \ "and makes them be key/data pairs." # Begin FreeBSD atf_set "require.files" /usr/share/dict/words # End FreeBSD } small_btree_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} sed 200q $(dict) >exp for i in `sed 200q $(dict)`; do echo p echo k$i echo d$i echo g echo k$i done >in atf_check -o file:exp "$(prog_db)" btree in } atf_test_case small_hash small_hash_head() { atf_set "descr" \ "Checks hash database using small keys and small data" \ "pairs: takes the first hundred entries in the dictionary," \ "and makes them be key/data pairs." # Begin FreeBSD atf_set "require.files" /usr/share/dict/words # End FreeBSD } small_hash_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} sed 200q $(dict) >exp for i in `sed 200q $(dict)`; do echo p echo k$i echo d$i echo g echo k$i done >in atf_check -o file:exp "$(prog_db)" hash in } atf_test_case small_recno small_recno_head() { atf_set "descr" \ "Checks recno database using small keys and small data" \ "pairs: takes the first hundred entries in the dictionary," \ "and makes them be key/data pairs." # Begin FreeBSD atf_set "require.files" /usr/share/dict/words # End FreeBSD } small_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} sed 200q $(dict) >exp sed 200q $(dict) | awk '{ ++i; printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); }' >in atf_check -o file:exp "$(prog_db)" recno in } atf_test_case medium_btree medium_btree_head() { atf_set "descr" \ "Checks btree database using small keys and medium" \ "data pairs: takes the first 200 entries in the" \ "dictionary, and gives them each a medium size data entry." # Begin FreeBSD atf_set "require.files" /usr/share/dict/words # End FreeBSD } medium_btree_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz echo $mdata | awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp for i in $(sed 200q $(dict)); do echo p echo k$i echo d$mdata echo g echo k$i done >in atf_check -o file:exp "$(prog_db)" btree in } atf_test_case medium_hash medium_hash_head() { atf_set "descr" \ "Checks hash database using small keys and medium" \ "data pairs: takes the first 200 entries in the" \ "dictionary, and gives them each a medium size data entry." # Begin FreeBSD atf_set "require.files" /usr/share/dict/words # End FreeBSD } medium_hash_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz echo $mdata | awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp for i in $(sed 200q $(dict)); do echo p echo k$i echo d$mdata echo g echo k$i done >in atf_check -o file:exp "$(prog_db)" hash in } atf_test_case medium_recno medium_recno_head() { atf_set "descr" \ "Checks recno database using small keys and medium" \ "data pairs: takes the first 200 entries in the" \ "dictionary, and gives them each a medium size data entry." } medium_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz echo $mdata | awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp echo $mdata | awk '{ for (i = 1; i < 201; ++i) printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); }' >in atf_check -o file:exp "$(prog_db)" recno in } atf_test_case big_btree big_btree_head() { atf_set "descr" \ "Checks btree database using small keys and big data" \ "pairs: inserts the programs in /bin with their paths" \ "as their keys." } big_btree_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} (find /bin -type f -print | xargs cat) >exp for psize in 512 16384 65536; do echo "checking page size: $psize" for i in `find /bin -type f -print`; do echo p echo k$i echo D$i echo g echo k$i done >in atf_check "$(prog_db)" -o out btree in cmp -s exp out || atf_fail "test failed for page size: $psize" done } atf_test_case big_hash big_hash_head() { atf_set "descr" \ "Checks hash database using small keys and big data" \ "pairs: inserts the programs in /bin with their paths" \ "as their keys." } big_hash_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} (find /bin -type f -print | xargs cat) >exp for i in `find /bin -type f -print`; do echo p echo k$i echo D$i echo g echo k$i done >in atf_check "$(prog_db)" -o out hash in cmp -s exp out || atf_fail "test failed" } atf_test_case big_recno big_recno_head() { atf_set "descr" \ "Checks recno database using small keys and big data" \ "pairs: inserts the programs in /bin with their paths" \ "as their keys." } big_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} (find /bin -type f -print | xargs cat) >exp find /bin -type f -print | awk '{ ++i; printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i); }' >in for psize in 512 16384 65536; do echo "checking page size: $psize" atf_check "$(prog_db)" -o out recno in cmp -s exp out || atf_fail "test failed for page size: $psize" done } atf_test_case random_recno random_recno_head() { atf_set "descr" "Checks recno database using random entries" } random_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk '{ for (i = 37; i <= 37 + 88 * 17; i += 17) { if (i % 41) s = substr($0, 1, i % 41); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } for (i = 1; i <= 15; ++i) { if (i % 41) s = substr($0, 1, i % 41); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } for (i = 19234; i <= 19234 + 61 * 27; i += 27) { if (i % 41) s = substr($0, 1, i % 41); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } exit }' >exp cat exp | awk 'BEGIN { i = 37; incr = 17; } { printf("p\nk%d\nd%s\n", i, $0); if (i == 19234 + 61 * 27) exit; if (i == 37 + 88 * 17) { i = 1; incr = 1; } else if (i == 15) { i = 19234; incr = 27; } else i += incr; } END { for (i = 37; i <= 37 + 88 * 17; i += 17) printf("g\nk%d\n", i); for (i = 1; i <= 15; ++i) printf("g\nk%d\n", i); for (i = 19234; i <= 19234 + 61 * 27; i += 27) printf("g\nk%d\n", i); }' >in atf_check -o file:exp "$(prog_db)" recno in } atf_test_case reverse_recno reverse_recno_head() { atf_set "descr" "Checks recno database using reverse order entries" } reverse_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk ' { for (i = 1500; i; --i) { if (i % 34) s = substr($0, 1, i % 34); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } exit; }' >exp cat exp | awk 'BEGIN { i = 1500; } { printf("p\nk%d\nd%s\n", i, $0); --i; } END { for (i = 1500; i; --i) printf("g\nk%d\n", i); }' >in atf_check -o file:exp "$(prog_db)" recno in } atf_test_case alternate_recno alternate_recno_head() { atf_set "descr" "Checks recno database using alternating order entries" } alternate_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk ' { for (i = 1; i < 1200; i += 2) { if (i % 34) s = substr($0, 1, i % 34); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } for (i = 2; i < 1200; i += 2) { if (i % 34) s = substr($0, 1, i % 34); else s = substr($0, 1); printf("input key %d: %s\n", i, s); } exit; }' >exp cat exp | awk 'BEGIN { i = 1; even = 0; } { printf("p\nk%d\nd%s\n", i, $0); i += 2; if (i >= 1200) { if (even == 1) exit; even = 1; i = 2; } } END { for (i = 1; i < 1200; ++i) printf("g\nk%d\n", i); }' >in atf_check "$(prog_db)" -o out recno in sort -o exp exp sort -o out out cmp -s exp out || atf_fail "test failed" } h_delete() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} type=$1 echo $SEVEN_SEVEN | awk '{ for (i = 1; i <= 120; ++i) printf("%05d: input key %d: %s\n", i, i, $0); }' >exp cat exp | awk '{ printf("p\nk%d\nd%s\n", ++i, $0); } END { printf("fR_NEXT\n"); for (i = 1; i <= 120; ++i) printf("s\n"); printf("fR_CURSOR\ns\nkXX\n"); printf("r\n"); printf("fR_NEXT\ns\n"); printf("fR_CURSOR\ns\nk1\n"); printf("r\n"); printf("fR_FIRST\ns\n"); }' >in # For btree, the records are ordered by the string representation # of the key value. So sort the expected output file accordingly, # and set the seek_last key to the last expected key value. if [ "$type" = "btree" ] ; then sed -e 's/kXX/k99/' < in > tmp mv tmp in sort -d -k4 < exp > tmp mv tmp exp echo $SEVEN_SEVEN | awk '{ printf("%05d: input key %d: %s\n", 99, 99, $0); printf("seq failed, no such key\n"); printf("%05d: input key %d: %s\n", 1, 1, $0); printf("%05d: input key %d: %s\n", 10, 10, $0); exit; }' >> exp else # For recno, records are ordered by numerical key value. No sort # is needed, but still need to set proper seek_last key value. sed -e 's/kXX/k120/' < in > tmp mv tmp in echo $SEVEN_SEVEN | awk '{ printf("%05d: input key %d: %s\n", 120, 120, $0); printf("seq failed, no such key\n"); printf("%05d: input key %d: %s\n", 1, 1, $0); printf("%05d: input key %d: %s\n", 2, 2, $0); exit; }' >> exp fi atf_check "$(prog_db)" -o out $type in atf_check -o file:exp cat out } atf_test_case delete_btree delete_btree_head() { atf_set "descr" "Checks removing records in btree database" } delete_btree_body() { h_delete btree } atf_test_case delete_recno delete_recno_head() { atf_set "descr" "Checks removing records in recno database" } delete_recno_body() { h_delete recno } h_repeated() { local type="$1" TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo "" | awk 'BEGIN { for (i = 1; i <= 10; ++i) { printf("p\nkkey1\nD/bin/sh\n"); printf("p\nkkey2\nD/bin/csh\n"); if (i % 8 == 0) { printf("c\nkkey2\nD/bin/csh\n"); printf("c\nkkey1\nD/bin/sh\n"); printf("e\t%d of 10 (comparison)\n", i); } else printf("e\t%d of 10 \n", i); printf("r\nkkey1\nr\nkkey2\n"); } }' >in $(prog_db) $type in } atf_test_case repeated_btree repeated_btree_head() { atf_set "descr" \ "Checks btree database with repeated small keys and" \ "big data pairs. Makes sure that overflow pages are reused" } repeated_btree_body() { h_repeated btree } atf_test_case repeated_hash repeated_hash_head() { atf_set "descr" \ "Checks hash database with repeated small keys and" \ "big data pairs. Makes sure that overflow pages are reused" } repeated_hash_body() { h_repeated hash } atf_test_case duplicate_btree duplicate_btree_head() { atf_set "descr" "Checks btree database with duplicate keys" } duplicate_btree_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk '{ for (i = 1; i <= 543; ++i) printf("%05d: input key %d: %s\n", i, i, $0); exit; }' >exp cat exp | awk '{ if (i++ % 2) printf("p\nkduplicatekey\nd%s\n", $0); else printf("p\nkunique%dkey\nd%s\n", i, $0); } END { printf("o\n"); }' >in atf_check -o file:exp -x "$(prog_db) -iflags=1 btree in | sort" } h_cursor_flags() { local type=$1 TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk '{ for (i = 1; i <= 20; ++i) printf("%05d: input key %d: %s\n", i, i, $0); exit; }' >exp # Test that R_CURSOR doesn't succeed before cursor initialized cat exp | awk '{ if (i == 10) exit; printf("p\nk%d\nd%s\n", ++i, $0); } END { printf("fR_CURSOR\nr\n"); printf("eR_CURSOR SHOULD HAVE FAILED\n"); }' >in atf_check -o ignore -e ignore -s ne:0 "$(prog_db)" -o out $type in atf_check -s ne:0 test -s out cat exp | awk '{ if (i == 10) exit; printf("p\nk%d\nd%s\n", ++i, $0); } END { printf("fR_CURSOR\np\nk1\ndsome data\n"); printf("eR_CURSOR SHOULD HAVE FAILED\n"); }' >in atf_check -o ignore -e ignore -s ne:0 "$(prog_db)" -o out $type in atf_check -s ne:0 test -s out } atf_test_case cursor_flags_btree cursor_flags_btree_head() { atf_set "descr" \ "Checks use of cursor flags without initialization in btree database" } cursor_flags_btree_body() { h_cursor_flags btree } atf_test_case cursor_flags_recno cursor_flags_recno_head() { atf_set "descr" \ "Checks use of cursor flags without initialization in recno database" } cursor_flags_recno_body() { h_cursor_flags recno } atf_test_case reverse_order_recno reverse_order_recno_head() { atf_set "descr" "Checks reverse order inserts in recno database" } reverse_order_recno_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk '{ for (i = 1; i <= 779; ++i) printf("%05d: input key %d: %s\n", i, i, $0); exit; }' >exp cat exp | awk '{ if (i == 0) { i = 1; printf("p\nk1\nd%s\n", $0); printf("%s\n", "fR_IBEFORE"); } else printf("p\nk1\nd%s\n", $0); } END { printf("or\n"); }' >in atf_check -o file:exp "$(prog_db)" recno in } atf_test_case small_page_btree small_page_btree_head() { atf_set "descr" \ "Checks btree database with lots of keys and small page" \ "size: takes the first 20000 entries in the dictionary," \ "reverses them, and gives them each a small size data" \ "entry. Uses a small page size to make sure the btree" \ "split code gets hammered." # Begin FreeBSD atf_set "require.files" /usr/share/dict/words # End FreeBSD } small_page_btree_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} mdata=abcdefghijklmnopqrstuvwxy echo $mdata | awk '{ for (i = 1; i < 20001; ++i) print $0 }' >exp for i in `sed 20000q $(dict) | rev`; do echo p echo k$i echo d$mdata echo g echo k$i done >in atf_check -o file:exp "$(prog_db)" -i psize=512 btree in } h_byte_orders() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} type=$1 sed 50q $(dict) >exp for order in 1234 4321; do for i in `sed 50q $(dict)`; do echo p echo k$i echo d$i echo S echo g echo k$i done >in atf_check -o file:exp "$(prog_db)" -ilorder=$order -f byte.file $type in for i in `sed 50q $(dict)`; do echo g echo k$i done >in atf_check -o file:exp "$(prog_db)" -s -ilorder=$order -f byte.file $type in done } atf_test_case byte_orders_btree byte_orders_btree_head() { atf_set "descr" "Checks btree database using differing byte orders" # Begin FreeBSD atf_set "require.files" /usr/share/dict/words # End FreeBSD } byte_orders_btree_body() { h_byte_orders btree } atf_test_case byte_orders_hash byte_orders_hash_head() { atf_set "descr" "Checks hash database using differing byte orders" } byte_orders_hash_body() { h_byte_orders hash } h_bsize_ffactor() { bsize=$1 ffactor=$2 echo "bucketsize $bsize, fill factor $ffactor" atf_check -o file:exp "$(prog_db)" "-ibsize=$bsize,\ ffactor=$ffactor,nelem=25000,cachesize=65536" hash in } atf_test_case bsize_ffactor bsize_ffactor_head() { atf_set "timeout" "1800" atf_set "descr" "Checks hash database with various" \ "bucketsizes and fill factors" # Begin FreeBSD atf_set "require.files" /usr/share/dict/words # End FreeBSD } bsize_ffactor_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} echo $SEVEN_SEVEN | awk '{ for (i = 1; i <= 10000; ++i) { if (i % 34) s = substr($0, 1, i % 34); else s = substr($0, 1); printf("%s\n", s); } exit; }' >exp sed 10000q $(dict) | awk 'BEGIN { ds="'$SEVEN_SEVEN'" } { if (++i % 34) s = substr(ds, 1, i % 34); else s = substr(ds, 1); printf("p\nk%s\nd%s\n", $0, s); }' >in sed 10000q $(dict) | awk '{ ++i; printf("g\nk%s\n", $0); }' >>in h_bsize_ffactor 256 11 h_bsize_ffactor 256 14 h_bsize_ffactor 256 21 h_bsize_ffactor 512 21 h_bsize_ffactor 512 28 h_bsize_ffactor 512 43 h_bsize_ffactor 1024 43 h_bsize_ffactor 1024 57 h_bsize_ffactor 1024 85 h_bsize_ffactor 2048 85 h_bsize_ffactor 2048 114 h_bsize_ffactor 2048 171 h_bsize_ffactor 4096 171 h_bsize_ffactor 4096 228 h_bsize_ffactor 4096 341 h_bsize_ffactor 8192 341 h_bsize_ffactor 8192 455 h_bsize_ffactor 8192 683 h_bsize_ffactor 16384 341 h_bsize_ffactor 16384 455 h_bsize_ffactor 16384 683 h_bsize_ffactor 32768 341 h_bsize_ffactor 32768 455 h_bsize_ffactor 32768 683 # Begin FreeBSD if false; then # End FreeBSD h_bsize_ffactor 65536 341 h_bsize_ffactor 65536 455 h_bsize_ffactor 65536 683 # Begin FreeBSD fi # End FreeBSD } # This tests 64K block size addition/removal atf_test_case four_char_hash four_char_hash_head() { atf_set "descr" \ "Checks hash database with 4 char key and" \ "value insert on a 65536 bucket size" } four_char_hash_body() { TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} cat >in < 0; ) { s = sprintf("a%03d:%09d", i, kdsize); for (j = 0; j < kdsize-20; j++) { s = s "x"; } printf("p\nka%03d\nd%s\n", i, s); } print "o"; }' /dev/null > in sed -n 's/^d//p' in | sort > exp atf_check -o file:exp \ "$(prog_db)" -i psize=$psize btree in done done } # Extremely tricky test attempting to replicate some unusual database # corruption seen in the field: pieces of the database becoming # inaccessible to random access, sequential access, or both. The # hypothesis is that at least some of these are triggered by the bug # in page splits on index 0 with a particular exact keylen+datalen. # (See Test 40.) For psize=4096, this size is exactly 2024. # The order of operations here relies on very specific knowledge of # the internals of the btree access method in order to place records # at specific offsets in a page and to create certain keys on internal # pages. The to-be-split page immediately prior to the bug-triggering # split has the following properties: # # * is not the leftmost leaf page # * key on the parent page is compares less than the key of the item # on index 0 # * triggering record's key also compares greater than the key on the # parent page # Additionally, we prime the mpool LRU chain so that the head page on # the chain has the following properties: # # * record at index 0 is located where it will not get overwritten by # items written to the right-hand page during the split # * key of the record at index 0 compares less than the key of the # bug-triggering record # If the page-split bug exists, this test appears to create a database # where some records are inaccessible to a search, but still remain in # the file and are accessible by sequential traversal. At least one # record gets duplicated out of sequence. atf_test_case btree_tricky_page_split btree_tricky_page_split_head() { atf_set "descr" \ "btree: no unsearchables due to page split on index 0" } btree_tricky_page_split_body() { list=`(for i in a b c d; do for j in 990 998 999; do echo g ${i}${j} 1024 done done; echo g y997 2014 for i in y z; do for j in 998 999; do echo g ${i}${j} 1024 done done)` # Exact number for trigger condition accounts for newlines # retained by dbtest with -ofile but not without; we use # -ofile, so count newlines. keylen=5,datalen=5+2014 for # psize=4096 here. (cat - < in (echo "$list"; echo "$list") | awk '{ s = $2; for (i = 0; i < $3; i++) { s = s "x"; } print s; }' > exp atf_check -o file:exp \ "$(prog_db)" -i psize=4096 btree in } # Begin FreeBSD if false; then # End FreeBSD atf_test_case btree_recursive_traversal btree_recursive_traversal_head() { atf_set "descr" \ "btree: Test for recursive traversal successfully " \ "retrieving records that are inaccessible to normal " \ "sequential 'sibling-link' traversal. This works by " \ "unlinking a few leaf pages but leaving their parent " \ "links intact. To verify that the unlink actually makes " \ "records inaccessible, the test first uses 'o' to do a " \ "normal sequential traversal, followed by 'O' to do a " \ "recursive traversal." } btree_recursive_traversal_body() { fill="abcdefghijklmnopqrstuvwxyzy" script='{ for (i = 0; i < 20000; i++) { printf("p\nkAA%05d\nd%05d%s\n", i, i, $0); } print "u"; print "u"; print "u"; print "u"; }' (echo $fill | awk "$script"; echo o) > in1 echo $fill | awk '{ for (i = 0; i < 20000; i++) { if (i >= 5 && i <= 40) continue; printf("%05d%s\n", i, $0); } }' > exp1 atf_check -o file:exp1 \ "$(prog_db)" -i psize=512 btree in1 echo $fill | awk '{ for (i = 0; i < 20000; i++) { printf("%05d%s\n", i, $0); } }' > exp2 (echo $fill | awk "$script"; echo O) > in2 atf_check -o file:exp2 \ "$(prog_db)" -i psize=512 btree in2 } # Begin FreeBSD fi # End FreeBSD atf_test_case btree_byteswap_unaligned_access_bksd btree_byteswap_unaligned_access_bksd_head() { atf_set "descr" \ "btree: big key, small data, byteswap unaligned access" } btree_byteswap_unaligned_access_bksd_body() { (echo foo; echo bar) | awk '{ s = $0 for (i = 0; i < 488; i++) { s = s "x"; } printf("p\nk%s\ndx\n", s); }' > in for order in 1234 4321; do atf_check \ "$(prog_db)" -o out -i psize=512,lorder=$order btree in done } atf_test_case btree_byteswap_unaligned_access_skbd btree_byteswap_unaligned_access_skbd_head() { atf_set "descr" \ "btree: small key, big data, byteswap unaligned access" } btree_byteswap_unaligned_access_skbd_body() { # 484 = 512 - 20 (header) - 7 ("foo1234") - 1 (newline) (echo foo1234; echo bar1234) | awk '{ s = $0 for (i = 0; i < 484; i++) { s = s "x"; } printf("p\nk%s\nd%s\n", $0, s); }' > in for order in 1234 4321; do atf_check \ "$(prog_db)" -o out -i psize=512,lorder=$order btree in done } atf_test_case btree_known_byte_order btree_known_byte_order_head() { atf_set "descr" \ "btree: small key, big data, known byte order" } btree_known_byte_order_body() { local a="-i psize=512,lorder=" (echo foo1234; echo bar1234) | awk '{ s = $0 for (i = 0; i < 484; i++) { s = s "x"; } printf("%s\n", s); }' > exp (echo foo1234; echo bar1234) | awk '{ s = $0 for (i = 0; i < 484; i++) { s = s "x"; } printf("p\nk%s\nd%s\n", $0, s); }' > in1 for order in 1234 4321; do atf_check \ "$(prog_db)" -f out.$order $a$order btree in1 done (echo g; echo kfoo1234; echo g; echo kbar1234) > in2 for order in 1234 4321; do atf_check -o file:exp \ "$(prog_db)" -s -f out.$order $a$order btree in2 done } atf_init_test_cases() { atf_add_test_case small_btree atf_add_test_case small_hash atf_add_test_case small_recno atf_add_test_case medium_btree atf_add_test_case medium_hash atf_add_test_case medium_recno atf_add_test_case big_btree atf_add_test_case big_hash atf_add_test_case big_recno atf_add_test_case random_recno atf_add_test_case reverse_recno atf_add_test_case alternate_recno atf_add_test_case delete_btree atf_add_test_case delete_recno atf_add_test_case repeated_btree atf_add_test_case repeated_hash atf_add_test_case duplicate_btree atf_add_test_case cursor_flags_btree atf_add_test_case cursor_flags_recno atf_add_test_case reverse_order_recno atf_add_test_case small_page_btree atf_add_test_case byte_orders_btree atf_add_test_case byte_orders_hash atf_add_test_case bsize_ffactor atf_add_test_case four_char_hash atf_add_test_case bsize_torture atf_add_test_case btree_weird_page_split atf_add_test_case btree_tricky_page_split # Begin FreeBSD if false; then # End FreeBSD atf_add_test_case btree_recursive_traversal # Begin FreeBSD fi # End FreeBSD atf_add_test_case btree_byteswap_unaligned_access_bksd atf_add_test_case btree_byteswap_unaligned_access_skbd atf_add_test_case btree_known_byte_order } Index: head/contrib/netbsd-tests/lib/libc/gen/exect/t_exect.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/gen/exect/t_exect.c (nonexistent) +++ head/contrib/netbsd-tests/lib/libc/gen/exect/t_exect.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c (revision 313439) @@ -1,178 +1,177 @@ /* $NetBSD: t_spawnattr.c,v 1.1 2012/02/13 21:03:08 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Charles Zhang and * Martin Husemann . * * 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 static int get_different_scheduler(void); static int get_different_priority(int scheduler); static const int schedulers[] = { SCHED_OTHER, SCHED_FIFO, SCHED_RR }; static int get_different_scheduler(void) { u_int i; int scheduler; /* get current schedule policy */ scheduler = sched_getscheduler(0); for (i = 0; i < __arraycount(schedulers); i++) { if (schedulers[i] == scheduler) break; } ATF_REQUIRE_MSG(i < __arraycount(schedulers), "Unknown current scheduler %d", scheduler); /* new scheduler */ i++; if (i >= __arraycount(schedulers)) i = 0; return schedulers[i]; } static int get_different_priority(int scheduler) { int max, min, new, priority; struct sched_param param; max = sched_get_priority_max(scheduler); min = sched_get_priority_min(scheduler); sched_getparam(0, ¶m); priority = param.sched_priority; /* * Change numerical value of the priority, to ensure that it * was set for the spawned child. */ new = priority + 1; if (new > max) new = min; return new; } ATF_TC(t_spawnattr); ATF_TC_HEAD(t_spawnattr, tc) { atf_tc_set_md_var(tc, "require.user", "root"); atf_tc_set_md_var(tc, "descr", "Tests posix_spawn with scheduler attributes"); } ATF_TC_BODY(t_spawnattr, tc) { int pid, scheduler, child_scheduler, priority, status, err, pfd[2]; char helper_arg[128]; char * const args[] = { __UNCONST("h_spawnattr"), helper_arg, NULL }; struct sched_param sp, child_sp; sigset_t sig; posix_spawnattr_t attr; char helper[FILENAME_MAX]; /* * create a pipe to controll the child */ err = pipe(pfd); ATF_REQUIRE_MSG(err == 0, "could not create pipe, errno %d", errno); sprintf(helper_arg, "%d", pfd[0]); posix_spawnattr_init(&attr); scheduler = get_different_scheduler(); priority = get_different_priority(scheduler); sp.sched_priority = priority; sigemptyset(&sig); sigaddset(&sig, SIGUSR1); posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSCHEDULER | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF); posix_spawnattr_setpgroup(&attr, 0); posix_spawnattr_setschedparam(&attr, &sp); posix_spawnattr_setschedpolicy(&attr, scheduler); posix_spawnattr_setsigmask(&attr, &sig); posix_spawnattr_setsigdefault(&attr, &sig); sprintf(helper, "%s/h_spawnattr", atf_tc_get_config_var(tc, "srcdir")); err = posix_spawn(&pid, helper, NULL, &attr, args, NULL); ATF_REQUIRE_MSG(err == 0, "error %d", err); child_scheduler = sched_getscheduler(pid); ATF_REQUIRE_MSG(scheduler == child_scheduler, "scheduler = %d, child_scheduler = %d, pid %d, errno %d", scheduler, child_scheduler, pid, errno); sched_getparam(pid, &child_sp); ATF_REQUIRE_MSG(child_sp.sched_priority == sp.sched_priority, "priority is: %d, but we requested: %d", child_sp.sched_priority, sp.sched_priority); ATF_REQUIRE_MSG(pid == getpgid(pid), "child pid: %d, child pgid: %d", pid, getpgid(pid)); /* ready, let child go */ write(pfd[1], "q", 1); close(pfd[0]); close(pfd[1]); /* wait and check result from child */ waitpid(pid, &status, 0); ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS); posix_spawnattr_destroy(&attr); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, t_spawnattr); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/gen/t_glob.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/gen/t_glob.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/gen/t_glob.c (revision 313439) @@ -1,289 +1,283 @@ -/* $NetBSD: t_glob.c,v 1.3 2013/01/02 11:28:48 martin Exp $ */ +/* $NetBSD: t_glob.c,v 1.5 2017/01/14 20:47: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.5 2017/01/14 20:47:41 christos Exp $"); #include #include #include #include #include #include #include #include #include -#ifdef __FreeBSD__ #include "h_macros.h" -#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__ +#ifdef GLOB_STAR 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; + 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__ +#ifdef GLOB_STAR 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__ +#ifdef GLOB_STAR 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: head/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c (revision 313439) @@ -1,319 +1,315 @@ /* $NetBSD: t_humanize_number.c,v 1.9 2017/01/10 15:20:44 christos Exp $ */ /*- * Copyright (c) 2010, 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 -#ifdef __FreeBSD__ -#include -#else #include -#endif const struct hnopts { size_t ho_len; int64_t ho_num; const char *ho_suffix; int ho_scale; int ho_flags; int ho_retval; /* expected return value */ const char *ho_retstr; /* expected string in buffer */ } hnopts[] = { /* * Rev. 1.6 produces "10.0". */ { 5, 10737418236ULL * 1024, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 3, "10T" }, { 5, 10450000, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 3, "10M" }, { 5, 10500000, "", /* just for reference */ HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 3, "10M" }, /* * Trailing space. Rev. 1.7 produces "1 ". */ { 5, 1, "", 0, HN_NOSPACE, 1, "1" }, { 5, 1, "", 0, 0, 2, "1 " }, /* just for reference */ { 5, 1, "", 0, HN_B, 3, "1 B" }, /* and more ... */ { 5, 1, "", 0, HN_DECIMAL, 2, "1 " }, { 5, 1, "", 0, HN_NOSPACE | HN_B, 2, "1B" }, { 5, 1, "", 0, HN_B | HN_DECIMAL, 3, "1 B" }, { 5, 1, "", 0, HN_NOSPACE | HN_B | HN_DECIMAL, 2, "1B" }, /* * Space and HN_B. Rev. 1.7 produces "1B". */ { 5, 1, "", HN_AUTOSCALE, HN_B, 3, "1 B" }, { 5, 1000, "", /* just for reference */ HN_AUTOSCALE, HN_B, 3, "1 K" }, /* * Truncated output. Rev. 1.7 produces "1.0 K". */ #ifndef __FreeBSD__ { 6, 1000, "A", HN_AUTOSCALE, HN_DECIMAL, -1, "" }, /* * Failure case reported by Greg Troxel . * Rev. 1.11 incorrectly returns 5 with filling the buffer * with "1000". */ { 5, 1048258238, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 4, "1.0G" }, /* Similar case it prints 1000 where it shouldn't */ { 5, 1023488, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 4, "1.0M" }, #endif { 5, 1023999, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 4, "1.0M" }, }; struct hnflags { int hf_flags; const char *hf_name; }; const struct hnflags scale_flags[] = { { HN_GETSCALE, "HN_GETSCALE" }, { HN_AUTOSCALE, "HN_AUTOSCALE" }, }; const struct hnflags normal_flags[] = { { HN_DECIMAL, "HN_DECIMAL" }, { HN_NOSPACE, "HN_NOSPACE" }, { HN_B, "HN_B" }, { HN_DIVISOR_1000, "HN_DIVISOR_1000" }, }; const char *formatflags(char *, size_t, const struct hnflags *, size_t, int); void newline(void); void w_printf(const char *, ...) __printflike(1, 2); int main(int, char *[]); const char * formatflags(char *buf, size_t buflen, const struct hnflags *hfs, size_t hfslen, int flags) { const struct hnflags *hf; char *p = buf; ssize_t len = buflen; unsigned int i, found; int n; if (flags == 0) { snprintf(buf, buflen, "0"); return (buf); } for (i = found = 0; i < hfslen && flags & ~found; i++) { hf = &hfs[i]; if (flags & hf->hf_flags) { found |= hf->hf_flags; n = snprintf(p, len, "|%s", hf->hf_name); if (n >= len) { p = buf; len = buflen; /* Print `flags' as number */ goto bad; } p += n; len -= n; } } flags &= ~found; if (flags) bad: snprintf(p, len, "|0x%x", flags); return (*buf == '|' ? buf + 1 : buf); } static int col, bol = 1; void newline(void) { fprintf(stderr, "\n"); col = 0; bol = 1; } void w_printf(const char *fmt, ...) { char buf[80]; va_list ap; int n; va_start(ap, fmt); if (col >= 0) { n = vsnprintf(buf, sizeof(buf), fmt, ap); if (n >= (int)sizeof(buf)) { col = -1; goto overflow; } else if (n == 0) goto out; if (!bol) { if (col + n > 75) fprintf(stderr, "\n "), col = 4; else fprintf(stderr, " "), col++; } fprintf(stderr, "%s", buf); col += n; bol = 0; } else { overflow: vfprintf(stderr, fmt, ap); } out: va_end(ap); } ATF_TC(humanize_number_basic); ATF_TC_HEAD(humanize_number_basic, tc) { atf_tc_set_md_var(tc, "descr", "Test humanize_number(3)"); } ATF_TC_BODY(humanize_number_basic, tc) { char fbuf[128]; const struct hnopts *ho; char *buf = NULL; size_t buflen = 0; unsigned int i; int rv = 0; for (i = 0; i < __arraycount(hnopts); i++) { ho = &hnopts[i]; if (buflen < ho->ho_len) { buflen = ho->ho_len; buf = realloc(buf, buflen); if (buf == NULL) atf_tc_fail("realloc(..., %zu) failed", buflen); } rv = humanize_number(buf, ho->ho_len, ho->ho_num, ho->ho_suffix, ho->ho_scale, ho->ho_flags); if (rv == ho->ho_retval && (rv == -1 || strcmp(buf, ho->ho_retstr) == 0)) continue; w_printf("humanize_number(\"%s\", %zu, %" PRId64 ",", ho->ho_retstr, ho->ho_len, ho->ho_num); w_printf("\"%s\",", ho->ho_suffix); w_printf("%s,", formatflags(fbuf, sizeof(fbuf), scale_flags, sizeof(scale_flags) / sizeof(scale_flags[0]), ho->ho_scale)); w_printf("%s)", formatflags(fbuf, sizeof(fbuf), normal_flags, sizeof(normal_flags) / sizeof(normal_flags[0]), ho->ho_flags)); w_printf("= %d,", ho->ho_retval); w_printf("but got"); w_printf("%d/[%s]", rv, rv == -1 ? "" : buf); newline(); atf_tc_fail_nonfatal("Failed for table entry %d", i); } free(buf); } ATF_TC(humanize_number_big); ATF_TC_HEAD(humanize_number_big, tc) { atf_tc_set_md_var(tc, "descr", "Test humanize " "big numbers (PR lib/44097)"); } ATF_TC_BODY(humanize_number_big, tc) { char buf[1024]; int rv; /* * Seems to work. */ (void)memset(buf, 0, sizeof(buf)); rv = humanize_number(buf, 10, 10000, "", HN_AUTOSCALE, HN_NOSPACE); ATF_REQUIRE(rv != -1); ATF_CHECK_STREQ(buf, "10000"); /* * A bogus value with large number. */ (void)memset(buf, 0, sizeof(buf)); rv = humanize_number(buf, 10, INT64_MAX, "", HN_AUTOSCALE, HN_NOSPACE); ATF_REQUIRE(rv != -1); ATF_REQUIRE(strcmp(buf, "0") != 0); /* * Large buffer with HN_AUTOSCALE. Entirely bogus. */ (void)memset(buf, 0, sizeof(buf)); rv = humanize_number(buf, sizeof(buf), 10000, "", HN_AUTOSCALE, HN_NOSPACE); ATF_REQUIRE(rv != -1); ATF_REQUIRE(strcmp(buf, "0%d%s%d%s%s%s") != 0); /* * Tight buffer. * * The man page says that len must be at least 4. * 3 works, but anything less that will not. This * is because baselen starts with 2 for positive * numbers. */ (void)memset(buf, 0, sizeof(buf)); rv = humanize_number(buf, 3, 1, "", HN_AUTOSCALE, HN_NOSPACE); ATF_REQUIRE(rv != -1); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, humanize_number_basic); ATF_TP_ADD_TC(tp, humanize_number_big); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/gen/t_sleep.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/gen/t_sleep.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/gen/t_sleep.c (revision 313439) @@ -1,352 +1,348 @@ /* $NetBSD: t_sleep.c,v 1.11 2017/01/10 15:43:59 maya Exp $ */ /*- * 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. */ -#ifdef __FreeBSD__ -/* kqueue(2) on FreeBSD requires sys/types.h for uintptr_t; NetBSD doesn't. */ -#include -#endif #include #include #include #include /* for TIMESPEC_TO_TIMEVAL on FreeBSD */ #include #include #include #include #include #include #include #include #include #include "isqemu.h" #define BILLION 1000000000LL /* nano-seconds per second */ #define MILLION 1000000LL /* nano-seconds per milli-second */ #define ALARM 6 /* SIGALRM after this many seconds */ #define MAXSLEEP 22 /* Maximum delay in seconds */ #define KEVNT_TIMEOUT 10300 /* measured in milli-seconds */ #define FUZZ (40 * MILLION) /* scheduling fuzz accepted - 40 ms */ /* * Timer notes * * Most tests use FUZZ as their initial delay value, but 'sleep' * starts at 1sec (since it cannot handle sub-second intervals). * Subsequent passes double the previous interval, up to MAXSLEEP. * * The current values result in 5 passes for the 'sleep' test (at 1, * 2, 4, 8, and 16 seconds) and 10 passes for the other tests (at * 0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56, 5.12, 10.24, and 20.48 * seconds). * * The ALARM is only set if the current pass's delay is longer, and * only if the ALARM has not already been triggered. * * The 'kevent' test needs the ALARM to be set on a different pass * from when the KEVNT_TIMEOUT fires. So set ALARM to fire on the * penultimate pass, and the KEVNT_TIMEOUT on the final pass. We * set KEVNT_TIMEOUT just barely long enough to put it into the * last test pass, and set MAXSLEEP a couple seconds longer than * necessary, in order to avoid a QEMU bug which nearly doubles * some timers. */ static volatile int sig; int sleeptest(int (*)(struct timespec *, struct timespec *), bool, bool); int do_nanosleep(struct timespec *, struct timespec *); int do_select(struct timespec *, struct timespec *); #ifdef __NetBSD__ int do_poll(struct timespec *, struct timespec *); #endif int do_sleep(struct timespec *, struct timespec *); int do_kevent(struct timespec *, struct timespec *); void sigalrm(int); void sigalrm(int s) { sig++; } int do_nanosleep(struct timespec *delay, struct timespec *remain) { int ret; if (nanosleep(delay, remain) == -1) ret = (errno == EINTR ? 0 : errno); else ret = 0; return ret; } int do_select(struct timespec *delay, struct timespec *remain) { int ret; struct timeval tv; TIMESPEC_TO_TIMEVAL(&tv, delay); if (select(0, NULL, NULL, NULL, &tv) == -1) ret = (errno == EINTR ? 0 : errno); else ret = 0; return ret; } #ifdef __NetBSD__ int do_poll(struct timespec *delay, struct timespec *remain) { int ret; struct timeval tv; TIMESPEC_TO_TIMEVAL(&tv, delay); if (pollts(NULL, 0, delay, NULL) == -1) ret = (errno == EINTR ? 0 : errno); else ret = 0; return ret; } #endif int do_sleep(struct timespec *delay, struct timespec *remain) { struct timeval tv; TIMESPEC_TO_TIMEVAL(&tv, delay); remain->tv_sec = sleep(delay->tv_sec); remain->tv_nsec = 0; return 0; } int do_kevent(struct timespec *delay, struct timespec *remain) { struct kevent ktimer; struct kevent kresult; int rtc, kq, kerrno; int tmo; ATF_REQUIRE_MSG((kq = kqueue()) != -1, "kqueue: %s", strerror(errno)); tmo = KEVNT_TIMEOUT; /* * If we expect the KEVNT_TIMEOUT to fire, and we're running * under QEMU, make sure the delay is long enough to account * for the effects of PR kern/43997 ! */ if (isQEMU() && tmo/1000 < delay->tv_sec && tmo/500 > delay->tv_sec) delay->tv_sec = MAXSLEEP; EV_SET(&ktimer, 1, EVFILT_TIMER, EV_ADD, 0, tmo, 0); rtc = kevent(kq, &ktimer, 1, &kresult, 1, delay); kerrno = errno; (void)close(kq); if (rtc == -1) { ATF_REQUIRE_MSG(kerrno == EINTR, "kevent: %s", strerror(kerrno)); return 0; } if (delay->tv_sec * BILLION + delay->tv_nsec > tmo * MILLION) ATF_REQUIRE_MSG(rtc > 0, "kevent: KEVNT_TIMEOUT did not cause EVFILT_TIMER event"); return 0; } ATF_TC(nanosleep); ATF_TC_HEAD(nanosleep, tc) { atf_tc_set_md_var(tc, "descr", "Test nanosleep(2) timing"); atf_tc_set_md_var(tc, "timeout", "65"); } ATF_TC_BODY(nanosleep, tc) { sleeptest(do_nanosleep, true, false); } ATF_TC(select); ATF_TC_HEAD(select, tc) { atf_tc_set_md_var(tc, "descr", "Test select(2) timing"); atf_tc_set_md_var(tc, "timeout", "65"); } ATF_TC_BODY(select, tc) { sleeptest(do_select, true, true); } #ifdef __NetBSD__ ATF_TC(poll); ATF_TC_HEAD(poll, tc) { atf_tc_set_md_var(tc, "descr", "Test poll(2) timing"); atf_tc_set_md_var(tc, "timeout", "65"); } ATF_TC_BODY(poll, tc) { sleeptest(do_poll, true, true); } #endif ATF_TC(sleep); ATF_TC_HEAD(sleep, tc) { atf_tc_set_md_var(tc, "descr", "Test sleep(3) timing"); atf_tc_set_md_var(tc, "timeout", "65"); } ATF_TC_BODY(sleep, tc) { sleeptest(do_sleep, false, false); } ATF_TC(kevent); ATF_TC_HEAD(kevent, tc) { atf_tc_set_md_var(tc, "descr", "Test kevent(2) timing"); atf_tc_set_md_var(tc, "timeout", "65"); } ATF_TC_BODY(kevent, tc) { sleeptest(do_kevent, true, true); } int sleeptest(int (*test)(struct timespec *, struct timespec *), bool subsec, bool sim_remain) { struct timespec tsa, tsb, tslp, tremain; int64_t delta1, delta2, delta3, round; sig = 0; signal(SIGALRM, sigalrm); if (subsec) { round = 1; delta3 = FUZZ; } else { round = 1000000000; delta3 = round; } tslp.tv_sec = delta3 / 1000000000; tslp.tv_nsec = delta3 % 1000000000; while (tslp.tv_sec <= MAXSLEEP) { /* * disturb sleep by signal on purpose */ if (tslp.tv_sec > ALARM && sig == 0) alarm(ALARM); clock_gettime(CLOCK_REALTIME, &tsa); (*test)(&tslp, &tremain); clock_gettime(CLOCK_REALTIME, &tsb); if (sim_remain) { timespecsub(&tsb, &tsa, &tremain); timespecsub(&tslp, &tremain, &tremain); } delta1 = (int64_t)tsb.tv_sec - (int64_t)tsa.tv_sec; delta1 *= BILLION; delta1 += (int64_t)tsb.tv_nsec - (int64_t)tsa.tv_nsec; delta2 = (int64_t)tremain.tv_sec * BILLION; delta2 += (int64_t)tremain.tv_nsec; delta3 = (int64_t)tslp.tv_sec * BILLION; delta3 += (int64_t)tslp.tv_nsec - delta1 - delta2; delta3 /= round; delta3 *= round; if (delta3 > FUZZ || delta3 < -FUZZ) { if (!sim_remain) atf_tc_expect_fail("Long reschedule latency " "due to PR kern/43997"); atf_tc_fail("Reschedule latency %"PRId64" exceeds " "allowable fuzz %lld", delta3, FUZZ); } delta3 = (int64_t)tslp.tv_sec * 2 * BILLION; delta3 += (int64_t)tslp.tv_nsec * 2; delta3 /= round; delta3 *= round; if (delta3 < FUZZ) break; tslp.tv_sec = delta3 / BILLION; tslp.tv_nsec = delta3 % BILLION; } ATF_REQUIRE_MSG(sig == 1, "Alarm did not fire!"); atf_tc_pass(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, nanosleep); ATF_TP_ADD_TC(tp, select); #ifdef __NetBSD__ ATF_TP_ADD_TC(tp, poll); #endif ATF_TP_ADD_TC(tp, sleep); ATF_TP_ADD_TC(tp, kevent); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/hash/h_hash.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/hash/h_hash.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/hash/h_hash.c (revision 313439) @@ -1,187 +1,167 @@ /* $NetBSD: h_hash.c,v 1.1 2011/01/02 22:03:25 pgoyette Exp $ */ /*- * Copyright (c) 2000 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. */ /* * Combined MD5/SHA1 time and regression test. */ #include #include #include #include #include -#ifdef __NetBSD__ #include -#endif -#ifdef __FreeBSD__ -#include -#endif int mflag, rflag, sflag, tflag; static void usage(void) { (void)fprintf(stderr, "Usage:\t%s -r[ms] < test-file\n" "\t%s -t[ms]\n", getprogname(), getprogname()); exit(1); /* NOTREACHED */ } static void hexdump (unsigned char *buf, int len) { int i; for (i=0; i 0) && \ (buf[len-1] == '\n')) { \ buf[len-1] = '\0'; \ len--; \ last = 1; \ } static void regress(void) { unsigned char buf[1024]; unsigned char out[20]; int len, outlen, last; while (fgets((char *)buf, sizeof(buf), stdin) != NULL) { last = 0; len = strlen((char *)buf); CHOMP(buf, len, last); if (mflag) { MD5_CTX ctx; MD5Init(&ctx); MD5Update(&ctx, buf, len); while (!last && fgets((char *)buf, sizeof(buf), stdin) != NULL) { len = strlen((char *)buf); CHOMP(buf, len, last); MD5Update(&ctx, buf, len); } MD5Final(out, &ctx); outlen = 16; } else { -#ifdef __FreeBSD__ - SHA_CTX ctx; - - SHA1_Init(&ctx); - SHA1_Update(&ctx, buf, len); -#else SHA1_CTX ctx; SHA1Init(&ctx); SHA1Update(&ctx, buf, len); -#endif while (!last && fgets((char *)buf, sizeof(buf), stdin) != NULL) { len = strlen((char *)buf); CHOMP(buf, len, last); -#ifdef __FreeBSD__ - SHA1_Update(&ctx, buf, len); -#else SHA1Update(&ctx, buf, len); -#endif } -#ifdef __FreeBSD__ - SHA1_Final(out, &ctx); -#else SHA1Final(out, &ctx); -#endif outlen = 20; } hexdump(out, outlen); } } int main(int argc, char **argv) { int ch; while ((ch = getopt(argc, argv, "mrst")) != -1) switch (ch) { case 'm': mflag = 1; break; case 'r': rflag = 1; break; case 's': sflag = 1; break; case 't': tflag = 1; break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc > 0) usage(); if (!(mflag || sflag)) mflag = 1; if ((mflag ^ sflag) != 1) usage(); if ((tflag ^ rflag) != 1) usage(); if (tflag) timetest(); if (rflag) regress(); exit(0); } Index: head/contrib/netbsd-tests/lib/libc/hash/t_hmac.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/hash/t_hmac.c (nonexistent) +++ head/contrib/netbsd-tests/lib/libc/hash/t_hmac.c (revision 313439) @@ -0,0 +1,127 @@ +/* $NetBSD: t_hmac.c,v 1.1 2016/07/02 14:52:09 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_hmac.c,v 1.1 2016/07/02 14:52:09 christos Exp $"); + +#include +#include +#include +#include +#include + +static void +test(void) +{ + uint8_t tmp1[EVP_MAX_MD_SIZE]; + uint8_t tmp2[EVP_MAX_MD_SIZE]; + uint8_t key[256]; + uint8_t data[4096]; + unsigned int tmp1len; + size_t tmp2len; + int stop; + void *e1; + const void *evps[] = { + EVP_md2(), + EVP_md4(), + EVP_md5(), + EVP_ripemd160(), + EVP_sha1(), + EVP_sha224(), + EVP_sha256(), + EVP_sha384(), + EVP_sha512(), + }; + const char *names[] = { + "md2", + "md4", + "md5", + "rmd160", + "sha1", + "sha224", + "sha256", + "sha384", + "sha512", + }; + + for (size_t k = 0; k < sizeof(key); k++) + key[k] = k; + for (size_t d = 0; d < sizeof(data); d++) + data[d] = d % 256; + + for (size_t t = 0; t < __arraycount(names); t++) + for (size_t i = 1; i < sizeof(key); i += 9) + for (size_t j = 3; j < sizeof(data); j += 111) { + stop = 0; +#ifdef DEBUG + printf("%s: keysize = %zu datasize = %zu\n", names[t], + i, j); +#endif + memset(tmp1, 0, sizeof(tmp1)); + memset(tmp2, 0, sizeof(tmp2)); + e1 = HMAC(evps[t], key, i, data, j, tmp1, &tmp1len); + ATF_REQUIRE(e1 != NULL); + tmp2len = hmac(names[t], key, i, data, j, tmp2, + sizeof(tmp2)); + ATF_REQUIRE_MSG(tmp1len == tmp2len, "hash %s len %u " + "!= %zu", names[t], tmp1len, tmp2len); + for (size_t k = 0; k < tmp2len; k++) + if (tmp1[k] != tmp2[k]) { +#ifdef DEBUG + printf("%zu %.2x %.2x\n", + k, tmp1[k], tmp2[k]); +#endif + stop = 1; + break; + } + ATF_REQUIRE_MSG(!stop, "hash %s failed for " + "keylen=%zu, datalen=%zu", names[t], i, j); + } +} + +ATF_TC(t_hmac); + +ATF_TC_HEAD(t_hmac, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test hmac functions for consistent results"); +} + +ATF_TC_BODY(t_hmac, tc) +{ + test(); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, t_hmac); + return atf_no_error(); +} + Property changes on: head/contrib/netbsd-tests/lib/libc/hash/t_hmac.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/contrib/netbsd-tests/lib/libc/hash/t_sha2.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/hash/t_sha2.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/hash/t_sha2.c (revision 313439) @@ -1,257 +1,243 @@ /* $NetBSD: t_sha2.c,v 1.3 2012/09/26 22:23:30 joerg Exp $ */ /*- * Copyright (c) 2010 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 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_sha2.c,v 1.3 2012/09/26 22:23:30 joerg Exp $"); #include #include -#ifdef __NetBSD__ #include -#endif #include - -#ifdef __FreeBSD__ -#include -typedef SHA512_CTX SHA384_CTX; -/* From /usr/src/crypto/openssh/openbsd-compat/sha2.h */ -#define SHA256_DIGEST_LENGTH 32 -#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) -#define SHA384_DIGEST_LENGTH 48 -#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) -#define SHA512_DIGEST_LENGTH 64 -#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) -#endif ATF_TC(t_sha256); ATF_TC(t_sha384); ATF_TC(t_sha512); ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, t_sha256); ATF_TP_ADD_TC(tp, t_sha384); ATF_TP_ADD_TC(tp, t_sha512); return atf_no_error(); } struct testvector { const char *vector; const char *hash; }; static const struct testvector test256[] = { { "hello, world", "09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b" }, { "", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" }, { "a", "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb" }, { "ab", "fb8e20fc2e4c3f248c60c39bd652f3c1347298bb977b8b4d5903b85055620603" }, { "abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" }, { "abcd", "88d4266fd4e6338d13b845fcf289579d209c897823b9217da3e161936f031589" }, { "abcde", "36bbe50ed96841d10443bcb670d6554f0a34b761be67ec9c4a8ad2c0c44ca42c" }, { "abcdef", "bef57ec7f53a6d40beb640a780a639c83bc29ac8a9816f1fc6c5c6dcd93c4721" }, { "abcdefg", "7d1a54127b222502f5b79b5fb0803061152a44f92b37e23c6527baf665d4da9a" }, { "abcdefgh", "9c56cc51b374c3ba189210d5b6d4bf57790d351c96c47c02190ecf1e430635ab" }, { "abcdefghi", "19cc02f26df43cc571bc9ed7b0c4d29224a3ec229529221725ef76d021c8326f" }, { "abcdefghij", "72399361da6a7754fec986dca5b7cbaf1c810a28ded4abaf56b2106d06cb78b0" }, { "abcdefghijk", "ca2f2069ea0c6e4658222e06f8dd639659cbb5e67cbbba6734bc334a3799bc68" }, { "abcdefghijkl", "d682ed4ca4d989c134ec94f1551e1ec580dd6d5a6ecde9f3d35e6e4a717fbde4" }, { "abcdefghijklm", "ff10304f1af23606ede1e2d8abcdc94c229047a61458d809d8bbd53ede1f6598" }, { "abcdefghijklmn", "0653c7e992d7aad40cb2635738b870e4c154afb346340d02c797d490dd52d5f9" }, { "abcdefghijklmno", "41c7760c50efde99bf574ed8fffc7a6dd3405d546d3da929b214c8945acf8a97" }, { "abcdefghijklmnop", "f39dac6cbaba535e2c207cd0cd8f154974223c848f727f98b3564cea569b41cf" }, { "abcdefghijklmnopq", "918a954ac4dfb54ac39f068d9868227f69ab39bc362e2c9b0083bf6a109d6ad7" }, { "abcdefghijklmnopqr", "2d1222692afaf56e95a8ab00879ed023a00db3e26fa14236e542748579285efa" }, { "abcdefghijklmnopqrs", "e250f886728b77ba63722c7e65fc73e203101a84281b32332fd67cc6a1ae3e22" }, { "abcdefghijklmnopqrst", "dd65eea0329dcb94b17187af9dff28c31a1d78026737a16af75979a1fa4618e5" }, { "abcdefghijklmnopqrstu", "25f62a5a3d414ec6e20907df7f367f2b72625aade552db64c07933f6044fc49a" }, { "abcdefghijklmnopqrstuv", "f69f9b70d1c9a5442258ca76f8b0a7a45fcb4e31c36141b6357ec591328b0624" }, { "abcdefghijklmnopqrstuvw", "7f07818e14d08944ce145629ca54332f5cfad148c590efbcb5c377f4d336e5f4" }, { "abcdefghijklmnopqrstuvwq", "063132d7fbec0acb79b2f228777eec8885e7f09bc1896b3ce5aa1843e83de048" }, }; static const struct testvector test384[] = { { "hello, world", "1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f00418a70cdb7e" }, { "", "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" }, { "a", "54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31" }, { "ab", "c7be03ba5bcaa384727076db0018e99248e1a6e8bd1b9ef58a9ec9dd4eeebb3f48b836201221175befa74ddc3d35afdd" }, { "abc", "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7" }, { "abcd", "1165b3406ff0b52a3d24721f785462ca2276c9f454a116c2b2ba20171a7905ea5a026682eb659c4d5f115c363aa3c79b" }, { "abcde", "4c525cbeac729eaf4b4665815bc5db0c84fe6300068a727cf74e2813521565abc0ec57a37ee4d8be89d097c0d2ad52f0" }, { "abcdef", "c6a4c65b227e7387b9c3e839d44869c4cfca3ef583dea64117859b808c1e3d8ae689e1e314eeef52a6ffe22681aa11f5" }, { "abcdefg", "9f11fc131123f844c1226f429b6a0a6af0525d9f40f056c7fc16cdf1b06bda08e302554417a59fa7dcf6247421959d22" }, { "abcdefgh", "9000cd7cada59d1d2eb82912f7f24e5e69cc5517f68283b005fa27c285b61e05edf1ad1a8a9bded6fd29eb87d75ad806" }, { "abcdefghi", "ef54915b60cf062b8dd0c29ae3cad69abe6310de63ac081f46ef019c5c90897caefd79b796cfa81139788a260ded52df" }, { "abcdefghij", "a12070030a02d86b0ddacd0d3a5b598344513d0a051e7355053e556a0055489c1555399b03342845c4adde2dc44ff66c" }, { "abcdefghijk", "2440d0e751fe5b8b1aba067e20be00b9deecc5e218b0b4b37202de824bcd04294d67c8d0b73e393afa844fa9ca25fa51" }, { "abcdefghijkl", "103ca96c06a1ce798f08f8eff0dfb0ccdb567d48b285b23d0cd773454667a3c2fa5f1b58d9cdf2329bd9979730bfaaff" }, { "abcdefghijklm", "89a7179df195462f047393c36e4843183eb38404bdfbacfd0b0f9c2556632a2799f19c3ecf48bdb7c9bdf95d3f6c3704" }, { "abcdefghijklmn", "3bc463b0a5614d39fd207cbfd108534bce68d5438235c6c577b34b70fe219954adceaf8808d1fad4a44fc9c420ea8ff1" }, { "abcdefghijklmno", "5149860ee76dd6666308189e60090d615e36ce0c0ef753a610cca0524a022900489d70167a47cc74c4dd9f9f340066af" }, { "abcdefghijklmnop", "96d3c1b54b1938600abe5b57232e185df1c5856f74656b8f9837c5317cf5b22ac38226fafc8c946b9d20aca1b0c53a98" }, { "abcdefghijklmnopq", "dae0d8c29d8f1137df3afb8f502dc474d3bbb56de0c10fc219547826f23f38f37ec29e4ed203908e6e7955c83a138129" }, { "abcdefghijklmnopqr", "5cfa62716d985d3b1efab0ed3460e7b7f6af9439ae8ee5c58b20e68607eeec3e8c6df8481f5f36e726eaa56512acea6e" }, { "abcdefghijklmnopqrs", "c5d404fc93b0e59ecb5f40446da201876faf18a0af46e577ae2f7a4fe56dc4c419afff7edec90ff3de160d0c5e7a5ec1" }, { "abcdefghijklmnopqrst", "bc1511cd8b813544cb60b13d1ceb63e81f46aa3ca114a23fc5c3aba54f9965cdf9afa68e2dc2a680934e429dff5aa7f2" }, { "abcdefghijklmnopqrstu", "8f18622d37e0aceabba191e3836b30e8970aca202ce6e811f586ec5f950edb7bf799cc88a18468a3effb063397242d95" }, { "abcdefghijklmnopqrstuv", "c8a4f46e609626543ce6c1362721fcbe95c8e7405aaee61da4f2da1740f0351172c98a66530f8607bf8609e387ff8456" }, { "abcdefghijklmnopqrstuvw", "2daff33b3bd67de61550070696b431d54b1397b40d053912b07a94260812185907726e3efbe9ae9fc078659cd2ce36db" }, { "abcdefghijklmnopqrstuvwq", "87dc70a2eaa0dd0b687f91f26383866161026e41bb310a9e32b7a17c99284db85b9743476a30caeedf3fbb3c8072bc5e" }, }; static const struct testvector test512[] = { { "hello, world", "8710339dcb6814d0d9d2290ef422285c9322b7163951f9a0ca8f883d3305286f44139aa374848e4174f5aada663027e4548637b6d19894aec4fb6c46a139fbf9" }, { "", "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" }, { "a", "1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75" }, { "ab", "2d408a0717ec188158278a796c689044361dc6fdde28d6f04973b80896e1823975cdbf12eb63f9e0591328ee235d80e9b5bf1aa6a44f4617ff3caf6400eb172d" }, { "abc", "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f" }, { "abcd", "d8022f2060ad6efd297ab73dcc5355c9b214054b0d1776a136a669d26a7d3b14f73aa0d0ebff19ee333368f0164b6419a96da49e3e481753e7e96b716bdccb6f" }, { "abcde", "878ae65a92e86cac011a570d4c30a7eaec442b85ce8eca0c2952b5e3cc0628c2e79d889ad4d5c7c626986d452dd86374b6ffaa7cd8b67665bef2289a5c70b0a1" }, { "abcdef", "e32ef19623e8ed9d267f657a81944b3d07adbb768518068e88435745564e8d4150a0a703be2a7d88b61e3d390c2bb97e2d4c311fdc69d6b1267f05f59aa920e7" }, { "abcdefg", "d716a4188569b68ab1b6dfac178e570114cdf0ea3a1cc0e31486c3e41241bc6a76424e8c37ab26f096fc85ef9886c8cb634187f4fddff645fb099f1ff54c6b8c" }, { "abcdefgh", "a3a8c81bc97c2560010d7389bc88aac974a104e0e2381220c6e084c4dccd1d2d17d4f86db31c2a851dc80e6681d74733c55dcd03dd96f6062cdda12a291ae6ce" }, { "abcdefghi", "f22d51d25292ca1d0f68f69aedc7897019308cc9db46efb75a03dd494fc7f126c010e8ade6a00a0c1a5f1b75d81e0ed5a93ce98dc9b833db7839247b1d9c24fe" }, { "abcdefghij", "ef6b97321f34b1fea2169a7db9e1960b471aa13302a988087357c520be957ca119c3ba68e6b4982c019ec89de3865ccf6a3cda1fe11e59f98d99f1502c8b9745" }, { "abcdefghijk", "2798fd001ee8800e3da09ee99ae9600de2d0ccf464ab782c92fcc06ce3847cef0743365f1d49c2c8b4426db1635433f937d508672a9d0cb673b84f368eca1b23" }, { "abcdefghijkl", "17807c728ee3ba35e7cf7af823116d26e41e5d4d6c2ff1f3720d3d96aacb6f69de642e63d5b73fc396c12be38b2bd5d884257c32c8f6d0854ae6b540f86dda2e" }, { "abcdefghijklm", "e11a66f7b9a2acda5663e9434377137d73ea560a32782230412642a463c8558123bfb7c0dbf17851e9aa58cc9587c3b4f5e3f7f38dcb6f890702e5bed4d5b54a" }, { "abcdefghijklmn", "8334134081070bf7fcc8bf1c242d24bb3182a5119e5fb19d8bbf6b9d0cdb7fed5336e83415fce93094c0e55123cf69e14d7ae41b22289232699824e31125b6d9" }, { "abcdefghijklmno", "db723f341a042d8de1aa813efd5e02fc1745ccbe259486257514804e2ec4bcebb2a46f1e4ad442154943f9e97e1bc47c3ae0eddab7de0c01a9c51f15342a5b19" }, { "abcdefghijklmnop", "d0cadd6834fa0c157b36cca30ee8b0b1435d841aa5b5ac850c11ae80a1440f51743e98fb1f1e7376c70f2f65404f088c28bcb4a511df2e64111f8f7424364b60" }, { "abcdefghijklmnopq", "6196942a8495b721f82bbc385c74c1f10eeadf35db8adc9cf1a05ddeed19351228279644cd5d686ee48a31631ebb64747a2b68b733dd6015e3d27750878fa875" }, { "abcdefghijklmnopqr", "fb3bd1fc157ea6f7a6728986a59b271b766fb723f6b7cf2b4194437435f2c497f33b6a56ae7eb3830fa9e04d5ebb4cb5e3f4d4bd812c498bdf0167e125de3fba" }, { "abcdefghijklmnopqrs", "836f9ecf2aa02f522a94f1370af45a9fd538ac3c70e3b709d614b2f8981881d6b0070fc6387b74ee371fc2549309f82926e78084b401deb61a106c399089bee8" }, { "abcdefghijklmnopqrst", "8cd9c137651425fb32d193d99b281735ec68eb5fd296f16459d1b33eac7badcfce0dca22eadaa5f209fa4ac3bbecd41342bac8b8a5dc3626e7f22cdc96e17cb4" }, { "abcdefghijklmnopqrstu", "7079853a3e36241a8d83639f168ef38e883d7f72851a84ef3ed4d91c6a3896cf542b8b4518c2816fb19d4692a4b9aae65cb857e3642ce0a3936e20363bcbd4ca" }, { "abcdefghijklmnopqrstuv", "a4e8a90b7058fb078e6cdcfd0c6a33c366437eb9084eac657830356804c9f9b53f121496d8e972d8707a4cf02615e6f58ed1a770c28ac79ffd845401fe18a928" }, { "abcdefghijklmnopqrstuvw", "d91b1fd7c7785975493826719f333d090b214ff42351c84d8f8b2538509a28d2d59a36d0ac798d99d3908083b072a4be606ae391def5daa74156350fec71dd24" }, { "abcdefghijklmnopqrstuvwq", "404eb5652173323320cac6bf8d9714aef0747693a8ab4570700c6262268d367f30e31c44fa66860568ff058fe39c9aa8dac76bc78566c691a884cb9052c4aa0a" }, }; static void digest2string(const uint8_t *digest, char *string, size_t len) { while (len--) { if (*digest / 16 < 10) *string++ = '0' + *digest / 16; else *string++ = 'a' + *digest / 16 - 10; if (*digest % 16 < 10) *string++ = '0' + *digest % 16; else *string++ = 'a' + *digest % 16 - 10; ++digest; } *string = '\0'; } ATF_TC_HEAD(t_sha256, tc) { atf_tc_set_md_var(tc, "descr", "Test SHA256 functions for consistent results"); } ATF_TC_BODY(t_sha256, tc) { size_t i, j, len; SHA256_CTX ctx; unsigned char buf[256]; unsigned char digest[8 + SHA256_DIGEST_LENGTH]; char output[SHA256_DIGEST_STRING_LENGTH]; for (i = 0; i < sizeof(test256) / sizeof(test256[0]); ++i) { len = strlen(test256[i].vector); for (j = 0; j < 8; ++j) { SHA256_Init(&ctx); memcpy(buf + j, test256[i].vector, len); SHA256_Update(&ctx, buf + j, len); SHA256_Final(digest + j, &ctx); digest2string(digest + j, output, SHA256_DIGEST_LENGTH); ATF_CHECK_STREQ(test256[i].hash, output); } } } ATF_TC_HEAD(t_sha384, tc) { atf_tc_set_md_var(tc, "descr", "Test SHA384 functions for consistent results"); } ATF_TC_BODY(t_sha384, tc) { size_t i, j, len; SHA384_CTX ctx; unsigned char buf[384]; unsigned char digest[8 + SHA384_DIGEST_LENGTH]; char output[SHA384_DIGEST_STRING_LENGTH]; for (i = 0; i < sizeof(test384) / sizeof(test384[0]); ++i) { len = strlen(test384[i].vector); for (j = 0; j < 8; ++j) { SHA384_Init(&ctx); memcpy(buf + j, test384[i].vector, len); SHA384_Update(&ctx, buf + j, len); SHA384_Final(digest + j, &ctx); digest2string(digest + j, output, SHA384_DIGEST_LENGTH); ATF_CHECK_STREQ(test384[i].hash, output); } } } ATF_TC_HEAD(t_sha512, tc) { atf_tc_set_md_var(tc, "descr", "Test SHA512 functions for consistent results"); } ATF_TC_BODY(t_sha512, tc) { size_t i, j, len; SHA512_CTX ctx; unsigned char buf[512]; unsigned char digest[8 + SHA512_DIGEST_LENGTH]; char output[SHA512_DIGEST_STRING_LENGTH]; for (i = 0; i < sizeof(test512) / sizeof(test512[0]); ++i) { len = strlen(test512[i].vector); for (j = 0; j < 8; ++j) { SHA512_Init(&ctx); memcpy(buf + j, test512[i].vector, len); SHA512_Update(&ctx, buf + j, len); SHA512_Final(digest + j, &ctx); digest2string(digest + j, output, SHA512_DIGEST_LENGTH); ATF_CHECK_STREQ(test512[i].hash, output); } } } Index: head/contrib/netbsd-tests/lib/libc/locale/t_io.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/locale/t_io.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/locale/t_io.c (revision 313439) @@ -1,193 +1,189 @@ /* $NetBSD: t_io.c,v 1.4 2014/01/21 00:32:16 yamt Exp $ */ /*- * Copyright (c) 2013 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 __COPYRIGHT("@(#) Copyright (c) 2011\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_io.c,v 1.4 2014/01/21 00:32:16 yamt Exp $"); #include #include #include #include #include #include #include #include ATF_TC(bad_big5_wprintf); ATF_TC_HEAD(bad_big5_wprintf, tc) { atf_tc_set_md_var(tc, "descr", "Test bad big5 wchar wprintf"); } ATF_TC_BODY(bad_big5_wprintf, tc) { #ifdef __FreeBSD__ atf_tc_skip("does not fail as expected (may be implementation " "specific issue with the test)"); #endif - /* XXX implementation detail knowledge (wchar_t encoding) */ wchar_t ibuf[] = { 0xcf10, 0 }; setlocale(LC_CTYPE, "zh_TW.Big5"); - ATF_REQUIRE_ERRNO(EILSEQ, wprintf(L"%ls\n", ibuf) < 0); ATF_REQUIRE(ferror(stdout)); } ATF_TC(bad_big5_swprintf); ATF_TC_HEAD(bad_big5_swprintf, tc) { atf_tc_set_md_var(tc, "descr", "Test bad big5 wchar swprintf"); } ATF_TC_BODY(bad_big5_swprintf, tc) { #ifdef __FreeBSD__ atf_tc_skip("does not fail as expected (may be implementation " "specific issue with the test)"); #endif - /* XXX implementation detail knowledge (wchar_t encoding) */ wchar_t ibuf[] = { 0xcf10, 0 }; wchar_t obuf[20]; setlocale(LC_CTYPE, "zh_TW.Big5"); - ATF_REQUIRE_ERRNO(EILSEQ, swprintf(obuf, sizeof(obuf), L"%ls\n", ibuf) < 0); } ATF_TC(good_big5_wprintf); ATF_TC_HEAD(good_big5_wprintf, tc) { atf_tc_set_md_var(tc, "descr", "Test good big5 wchar wprintf"); } ATF_TC_BODY(good_big5_wprintf, tc) { /* XXX implementation detail knowledge (wchar_t encoding) */ wchar_t ibuf[] = { 0xcf40, 0 }; setlocale(LC_CTYPE, "zh_TW.Big5"); ATF_REQUIRE_EQ(wprintf(L"%ls\n", ibuf), 2); } ATF_TC(good_big5_swprintf); ATF_TC_HEAD(good_big5_swprintf, tc) { atf_tc_set_md_var(tc, "descr", "Test good big5 wchar swprintf"); } ATF_TC_BODY(good_big5_swprintf, tc) { /* XXX implementation detail knowledge (wchar_t encoding) */ wchar_t ibuf[] = { 0xcf40, 0 }; wchar_t obuf[20]; setlocale(LC_CTYPE, "zh_TW.Big5"); ATF_REQUIRE_EQ(swprintf(obuf, sizeof(obuf), L"%ls\n", ibuf), 2); } struct ibuf { off_t off; size_t buflen; const char *buf; }; static int readfn(void *vp, char *buf, int len) { struct ibuf *ib = vp; size_t todo = MIN((size_t)len, ib->buflen - ib->off); memcpy(buf, ib->buf + ib->off, todo); ib->off += todo; return todo; } ATF_TC(good_big5_getwc); ATF_TC_HEAD(good_big5_getwc, tc) { atf_tc_set_md_var(tc, "descr", "Test good big5 wchar getwc"); } ATF_TC_BODY(good_big5_getwc, tc) { const char buf[] = { 0xcf, 0x40 }; struct ibuf ib = { .buf = buf, .buflen = sizeof(buf), }; FILE *fp = funopen(&ib, readfn, NULL, NULL, NULL); ATF_REQUIRE(fp != NULL); setlocale(LC_CTYPE, "zh_TW.Big5"); /* XXX implementation detail knowledge (wchar_t encoding) */ ATF_REQUIRE_EQ(getwc(fp), 0xcf40); fclose(fp); } ATF_TC(bad_big5_getwc); ATF_TC_HEAD(bad_big5_getwc, tc) { atf_tc_set_md_var(tc, "descr", "Test bad big5 wchar getwc"); } ATF_TC_BODY(bad_big5_getwc, tc) { const char buf[] = { 0xcf, 0x20 }; struct ibuf ib = { .buf = buf, .buflen = sizeof(buf), }; FILE *fp = funopen(&ib, readfn, NULL, NULL, NULL); ATF_REQUIRE(fp != NULL); setlocale(LC_CTYPE, "zh_TW.Big5"); #ifdef __FreeBSD__ atf_tc_expect_fail("does not return WEOF as expected"); #endif ATF_REQUIRE_EQ(getwc(fp), WEOF); fclose(fp); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, bad_big5_wprintf); ATF_TP_ADD_TC(tp, bad_big5_swprintf); ATF_TP_ADD_TC(tp, good_big5_wprintf); ATF_TP_ADD_TC(tp, good_big5_swprintf); ATF_TP_ADD_TC(tp, good_big5_getwc); ATF_TP_ADD_TC(tp, bad_big5_getwc); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c (revision 313439) @@ -1,151 +1,150 @@ /* $NetBSD: t_mbtowc.c,v 1.1 2011/04/09 17:45:25 pgoyette 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. */ /*- * Copyright (c)2007 Citrus Project, * 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) 2011\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_mbtowc.c,v 1.1 2011/04/09 17:45:25 pgoyette Exp $"); #include #include #include #include #include #include #include #include static void h_mbtowc(const char *locale, const char *illegal, const char *legal) { char buf[64]; size_t stateful, ret; char *str; ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C"); #ifdef __NetBSD__ ATF_REQUIRE(setlocale(LC_CTYPE, locale) != NULL); #else if (setlocale(LC_CTYPE, locale) == NULL) { fprintf(stderr, "Locale %s not found.\n", locale); return; } #endif ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL); (void)printf("Using locale: %s\n", str); stateful = wctomb(NULL, L'\0'); (void)printf("Locale is state-%sdependent\n", stateful ? "in" : ""); /* initialize internal state */ ret = mbtowc(NULL, NULL, 0); ATF_REQUIRE(stateful ? ret : !ret); (void)strvis(buf, illegal, VIS_WHITE | VIS_OCTAL); (void)printf("Checking illegal sequence: \"%s\"\n", buf); ret = mbtowc(NULL, illegal, strlen(illegal)); (void)printf("mbtowc() returned: %zd\n", ret); ATF_REQUIRE_EQ(ret, (size_t)-1); (void)printf("errno: %s\n", strerror(errno)); ATF_REQUIRE_EQ(errno, EILSEQ); /* if this is stateless encoding, this re-initialization is not required. */ if (stateful) { /* re-initialize internal state */ ret = mbtowc(NULL, NULL, 0); ATF_REQUIRE(stateful ? ret : !ret); } /* valid multibyte sequence case */ (void)strvis(buf, legal, VIS_WHITE | VIS_OCTAL); (void)printf("Checking legal sequence: \"%s\"\n", buf); errno = 0; ret = mbtowc(NULL, legal, strlen(legal)); (void)printf("mbtowc() returned: %zd\n", ret); ATF_REQUIRE(ret != (size_t)-1); (void)printf("errno: %s\n", strerror(errno)); ATF_REQUIRE_EQ(errno, 0); (void)printf("Ok.\n"); } ATF_TC(mbtowc); ATF_TC_HEAD(mbtowc, tc) { atf_tc_set_md_var(tc, "descr", "Checks mbtowc(3)"); } ATF_TC_BODY(mbtowc, tc) { h_mbtowc("en_US.UTF-8", "\240", "\302\240"); h_mbtowc("ja_JP.ISO2022-JP", "\033$B", "\033$B$\"\033(B"); h_mbtowc("ja_JP.SJIS", "\202", "\202\240"); h_mbtowc("ja_JP.eucJP", "\244", "\244\242"); - /* Moved last as it fails */ h_mbtowc("zh_CN.GB18030", "\241", "\241\241"); h_mbtowc("zh_TW.Big5", "\241", "\241@"); h_mbtowc("zh_TW.eucTW", "\241", "\241\241"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, mbtowc); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/regex/debug.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/regex/debug.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/regex/debug.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c (revision 313439) @@ -1,639 +1,630 @@ -/* $NetBSD: t_regex_att.c,v 1.1 2012/08/24 20:24:40 jmmv Exp $ */ +/* $NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 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.3 2017/01/14 20:59:23 christos Exp $"); #include -#include +#include +#include #include -#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: head/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c (revision 313439) @@ -1,416 +1,409 @@ /* $NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos Exp $ */ #include __RCSID("$NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos Exp $"); #include #include #include #include #include #include #include #include #include #include #ifndef TEST #include #define ERRX(ev, msg, ...) ATF_REQUIRE_MSG(0, msg, __VA_ARGS__) #define SKIPX(ev, msg, ...) do { \ atf_tc_skip(msg, __VA_ARGS__); \ return ev; \ } while(/*CONSTCOND*/0) -#ifdef __FreeBSD__ -#define SKIPXI(ev, msg, ...) do { \ - atf_tc_skip(msg, __VA_ARGS__); \ - return ev; \ -} while(/*CONSTCOND*/0) -#endif - #else #define ERRX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__) #define SKIPX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__) #endif #ifdef DEBUG #define DPRINTF(...) printf(__VA_ARGS__) #else #define DPRINTF(...) #endif #define RPCBPROC_NULL 0 static int reply(caddr_t replyp, struct netbuf * raddrp, struct netconfig * nconf) { char host[NI_MAXHOST]; struct sockaddr *sock = raddrp->buf; int error; error = getnameinfo(sock, sock->sa_len, host, sizeof(host), NULL, 0, 0); if (error) warnx("Cannot resolve address (%s)", gai_strerror(error)); else printf("response from: %s\n", host); return 0; } #ifdef __FreeBSD__ #define __rpc_control rpc_control #endif extern bool_t __rpc_control(int, void *); static void onehost(const char *host, const char *transp) { CLIENT *clnt; struct netbuf addr; struct timeval tv; /* * Magic! */ tv.tv_sec = 0; tv.tv_usec = 500000; #define CLCR_SET_RPCB_TIMEOUT 2 __rpc_control(CLCR_SET_RPCB_TIMEOUT, &tv); if ((clnt = clnt_create(host, RPCBPROG, RPCBVERS, transp)) == NULL) SKIPX(, "clnt_create (%s)", clnt_spcreateerror("")); tv.tv_sec = 1; tv.tv_usec = 0; #ifdef __FreeBSD__ if (clnt_call(clnt, RPCBPROC_NULL, (xdrproc_t)xdr_void, NULL, (xdrproc_t)xdr_void, NULL, tv) != RPC_SUCCESS) #else if (clnt_call(clnt, RPCBPROC_NULL, xdr_void, NULL, xdr_void, NULL, tv) != RPC_SUCCESS) #endif ERRX(, "clnt_call (%s)", clnt_sperror(clnt, "")); clnt_control(clnt, CLGET_SVC_ADDR, (char *) &addr); reply(NULL, &addr, NULL); } #define PROGNUM 0x81 #define VERSNUM 0x01 #define PLUSONE 1 #define DESTROY 2 static struct timeval tout = {1, 0}; static void server(struct svc_req *rqstp, SVCXPRT *transp) { int num; DPRINTF("Starting server\n"); switch (rqstp->rq_proc) { case NULLPROC: if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) ERRX(, "svc_sendreply failed %d", 0); return; case PLUSONE: break; case DESTROY: if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) ERRX(, "svc_sendreply failed %d", 0); svc_destroy(transp); exit(0); default: svcerr_noproc(transp); return; } if (!svc_getargs(transp, (xdrproc_t)xdr_int, (void *)&num)) { svcerr_decode(transp); return; } DPRINTF("About to increment\n"); num++; if (!svc_sendreply(transp, (xdrproc_t)xdr_int, (void *)&num)) ERRX(, "svc_sendreply failed %d", 1); DPRINTF("Leaving server procedure.\n"); } static int rawtest(const char *arg) { CLIENT *clnt; SVCXPRT *svc; int num, resp; enum clnt_stat rv; if (arg) num = atoi(arg); else num = 0; svc = svc_raw_create(); if (svc == NULL) ERRX(EXIT_FAILURE, "Cannot create server %d", num); if (!svc_reg(svc, PROGNUM, VERSNUM, server, NULL)) ERRX(EXIT_FAILURE, "Cannot register server %d", num); clnt = clnt_raw_create(PROGNUM, VERSNUM); if (clnt == NULL) ERRX(EXIT_FAILURE, "%s", clnt_spcreateerror("clnt_raw_create")); rv = clnt_call(clnt, PLUSONE, (xdrproc_t)xdr_int, (void *)&num, (xdrproc_t)xdr_int, (void *)&resp, tout); if (rv != RPC_SUCCESS) ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); DPRINTF("Got %d\n", resp); clnt_destroy(clnt); svc_destroy(svc); if (++num != resp) ERRX(EXIT_FAILURE, "expected %d got %d", num, resp); return EXIT_SUCCESS; } static int regtest(const char *hostname, const char *transp, const char *arg, int p) { CLIENT *clnt; int num, resp; enum clnt_stat rv; pid_t pid; if (arg) num = atoi(arg); else num = 0; #ifdef __NetBSD__ svc_fdset_init(p ? SVC_FDSET_POLL : 0); #endif if (!svc_create(server, PROGNUM, VERSNUM, transp)) { - SKIPXI(EXIT_FAILURE, "Cannot create server %d", num); + SKIPX(EXIT_FAILURE, "Cannot create server %d", num); } switch ((pid = fork())) { case 0: DPRINTF("Calling svc_run\n"); svc_run(); ERRX(EXIT_FAILURE, "svc_run returned %d!", num); case -1: ERRX(EXIT_FAILURE, "Fork failed (%s)", strerror(errno)); default: sleep(1); break; } DPRINTF("Initializing client\n"); clnt = clnt_create(hostname, PROGNUM, VERSNUM, transp); if (clnt == NULL) ERRX(EXIT_FAILURE, "%s", clnt_spcreateerror("clnt_raw_create")); rv = clnt_call(clnt, PLUSONE, (xdrproc_t)xdr_int, (void *)&num, (xdrproc_t)xdr_int, (void *)&resp, tout); if (rv != RPC_SUCCESS) ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); DPRINTF("Got %d\n", resp); if (++num != resp) ERRX(EXIT_FAILURE, "expected %d got %d", num, resp); rv = clnt_call(clnt, DESTROY, (xdrproc_t)xdr_void, NULL, (xdrproc_t)xdr_void, NULL, tout); if (rv != RPC_SUCCESS) ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); clnt_destroy(clnt); return EXIT_SUCCESS; } #ifdef TEST static void allhosts(const char *transp) { enum clnt_stat clnt_stat; clnt_stat = rpc_broadcast(RPCBPROG, RPCBVERS, RPCBPROC_NULL, (xdrproc_t)xdr_void, NULL, (xdrproc_t)xdr_void, NULL, (resultproc_t)reply, transp); if (clnt_stat != RPC_SUCCESS && clnt_stat != RPC_TIMEDOUT) ERRX(EXIT_FAILURE, "%s", clnt_sperrno(clnt_stat)); } int main(int argc, char *argv[]) { int ch; int s, p; const char *transp = "udp"; p = s = 0; while ((ch = getopt(argc, argv, "prstu")) != -1) switch (ch) { case 'p': p = 1; break; case 's': s = 1; break; case 't': transp = "tcp"; break; case 'u': transp = "udp"; break; case 'r': transp = NULL; break; default: fprintf(stderr, "Usage: %s -[r|s|t|u] [...]\n", getprogname()); return EXIT_FAILURE; } if (argc == optind) { if (transp) allhosts(transp); else rawtest(NULL); } else { for (; optind < argc; optind++) { if (transp) s == 0 ? onehost(argv[optind], transp) : regtest(argv[optind], transp, "1", p); else rawtest(argv[optind]); } } return EXIT_SUCCESS; } #else ATF_TC(get_svc_addr_tcp); ATF_TC_HEAD(get_svc_addr_tcp, tc) { atf_tc_set_md_var(tc, "descr", "Checks CLGET_SVC_ADDR for tcp"); } ATF_TC_BODY(get_svc_addr_tcp, tc) { onehost("localhost", "tcp"); } ATF_TC(get_svc_addr_udp); ATF_TC_HEAD(get_svc_addr_udp, tc) { atf_tc_set_md_var(tc, "descr", "Checks CLGET_SVC_ADDR for udp"); } ATF_TC_BODY(get_svc_addr_udp, tc) { onehost("localhost", "udp"); } ATF_TC(raw); ATF_TC_HEAD(raw, tc) { atf_tc_set_md_var(tc, "descr", "Checks svc raw"); } ATF_TC_BODY(raw, tc) { #ifdef __FreeBSD__ atf_tc_expect_fail("fails with: clnt_call: " "RPC: Can't decode result -- PR # 211804"); #endif rawtest(NULL); } ATF_TC(tcp); ATF_TC_HEAD(tcp, tc) { atf_tc_set_md_var(tc, "descr", "Checks svc tcp (select)"); #ifdef __FreeBSD__ atf_tc_set_md_var(tc, "require.user", "root"); #endif } ATF_TC_BODY(tcp, tc) { regtest("localhost", "tcp", "1", 0); } ATF_TC(udp); ATF_TC_HEAD(udp, tc) { atf_tc_set_md_var(tc, "descr", "Checks svc udp (select)"); #ifdef __FreeBSD__ atf_tc_set_md_var(tc, "require.user", "root"); #endif } ATF_TC_BODY(udp, tc) { regtest("localhost", "udp", "1", 0); } ATF_TC(tcp_poll); ATF_TC_HEAD(tcp_poll, tc) { atf_tc_set_md_var(tc, "descr", "Checks svc tcp (poll)"); #ifdef __FreeBSD__ atf_tc_set_md_var(tc, "require.user", "root"); #endif } ATF_TC_BODY(tcp_poll, tc) { regtest("localhost", "tcp", "1", 1); } ATF_TC(udp_poll); ATF_TC_HEAD(udp_poll, tc) { atf_tc_set_md_var(tc, "descr", "Checks svc udp (poll)"); #ifdef __FreeBSD__ atf_tc_set_md_var(tc, "require.user", "root"); #endif } ATF_TC_BODY(udp_poll, tc) { regtest("localhost", "udp", "1", 1); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, get_svc_addr_udp); ATF_TP_ADD_TC(tp, get_svc_addr_tcp); ATF_TP_ADD_TC(tp, raw); ATF_TP_ADD_TC(tp, tcp); ATF_TP_ADD_TC(tp, udp); ATF_TP_ADD_TC(tp, tcp_poll); ATF_TP_ADD_TC(tp, udp_poll); return atf_no_error(); } #endif Index: head/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c (revision 313439) @@ -1,196 +1,196 @@ -/* $NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $ */ +/* $NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 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. */ /* * Copyright (c) 1994 Christopher G. Demetriou * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed for the * NetBSD Project. See http://www.NetBSD.org/ for * information about NetBSD. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * <> */ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $"); +__RCSID("$NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $"); #include #include #include #include #include #include #include #include #include #define REQUIRE_ERRNO(x) ATF_REQUIRE_MSG(x, "%s", strerror(errno)) #define TEST_SETJMP 0 #define TEST_U_SETJMP 1 #define TEST_SIGSETJMP_SAVE 2 #define TEST_SIGSETJMP_NOSAVE 3 static int expectsignal; static void aborthandler(int signo __unused) { ATF_REQUIRE_MSG(expectsignal, "kill(SIGABRT) succeeded"); atf_tc_pass(); } static void h_check(int test) { struct sigaction sa; jmp_buf jb; sigjmp_buf sjb; sigset_t ss; int i, x; i = getpid(); if (test == TEST_SETJMP || test == TEST_SIGSETJMP_SAVE) expectsignal = 0; else if (test == TEST_U_SETJMP || test == TEST_SIGSETJMP_NOSAVE) expectsignal = 1; else atf_tc_fail("unknown test"); sa.sa_handler = aborthandler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; REQUIRE_ERRNO(sigaction(SIGABRT, &sa, NULL) != -1); REQUIRE_ERRNO(sigemptyset(&ss) != -1); REQUIRE_ERRNO(sigaddset(&ss, SIGABRT) != -1); REQUIRE_ERRNO(sigprocmask(SIG_BLOCK, &ss, NULL) != -1); if (test == TEST_SETJMP) x = setjmp(jb); else if (test == TEST_U_SETJMP) x = _setjmp(jb); else x = sigsetjmp(sjb, !expectsignal); if (x != 0) { ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value"); kill(i, SIGABRT); ATF_REQUIRE_MSG(!expectsignal, "kill(SIGABRT) failed"); atf_tc_pass(); } REQUIRE_ERRNO(sigprocmask(SIG_UNBLOCK, &ss, NULL) != -1); if (test == TEST_SETJMP) longjmp(jb, i); else if (test == TEST_U_SETJMP) _longjmp(jb, i); else siglongjmp(sjb, i); atf_tc_fail("jmp failed"); } ATF_TC(setjmp); ATF_TC_HEAD(setjmp, tc) { atf_tc_set_md_var(tc, "descr", "Checks setjmp(3)"); } ATF_TC_BODY(setjmp, tc) { h_check(TEST_SETJMP); } ATF_TC(_setjmp); ATF_TC_HEAD(_setjmp, tc) { atf_tc_set_md_var(tc, "descr", "Checks _setjmp(3)"); } ATF_TC_BODY(_setjmp, tc) { h_check(TEST_U_SETJMP); } ATF_TC(sigsetjmp_save); ATF_TC_HEAD(sigsetjmp_save, tc) { atf_tc_set_md_var(tc, "descr", "Checks sigsetjmp(3) with savemask enabled"); } ATF_TC_BODY(sigsetjmp_save, tc) { h_check(TEST_SIGSETJMP_SAVE); } ATF_TC(sigsetjmp_nosave); ATF_TC_HEAD(sigsetjmp_nosave, tc) { atf_tc_set_md_var(tc, "descr", "Checks sigsetjmp(3) with savemask disabled"); } ATF_TC_BODY(sigsetjmp_nosave, tc) { h_check(TEST_SIGSETJMP_NOSAVE); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, setjmp); ATF_TP_ADD_TC(tp, _setjmp); ATF_TP_ADD_TC(tp, sigsetjmp_save); ATF_TP_ADD_TC(tp, sigsetjmp_nosave); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c (revision 313439) @@ -1,218 +1,218 @@ -/* $NetBSD: t_threadjmp.c,v 1.1 2011/04/21 18:58:20 martin Exp $ */ +/* $NetBSD: t_threadjmp.c,v 1.2 2017/01/14 21:08:17 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. */ /* * Copyright (c) 1994 Christopher G. Demetriou * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed for the * NetBSD Project. See http://www.NetBSD.org/ for * information about NetBSD. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * <> */ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_threadjmp.c,v 1.1 2011/04/21 18:58:20 martin Exp $"); +__RCSID("$NetBSD: t_threadjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $"); #include #include #include #include #include #include #include #include #include #include #define REQUIRE_ERRNO(x) ATF_REQUIRE_MSG(x, "%s", strerror(errno)) #define TEST_SETJMP 0 #define TEST_U_SETJMP 1 #define TEST_SIGSETJMP_SAVE 2 #define TEST_SIGSETJMP_NOSAVE 3 static pthread_t myself = NULL; static int expectsignal; static void aborthandler(int signo __unused) { ATF_REQUIRE(myself == pthread_self()); ATF_REQUIRE_MSG(expectsignal, "kill(SIGABRT) succeeded"); atf_tc_pass(); } static void h_check(int test) { struct sigaction sa; jmp_buf jb; sigjmp_buf sjb; sigset_t ss; int i, x; myself = pthread_self(); i = getpid(); if (test == TEST_SETJMP || test == TEST_SIGSETJMP_SAVE) expectsignal = 0; else if (test == TEST_U_SETJMP || test == TEST_SIGSETJMP_NOSAVE) expectsignal = 1; else atf_tc_fail("unknown test"); sa.sa_handler = aborthandler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; REQUIRE_ERRNO(sigaction(SIGABRT, &sa, NULL) != -1); REQUIRE_ERRNO(sigemptyset(&ss) != -1); REQUIRE_ERRNO(sigaddset(&ss, SIGABRT) != -1); REQUIRE_ERRNO(sigprocmask(SIG_BLOCK, &ss, NULL) != -1); ATF_REQUIRE(myself == pthread_self()); if (test == TEST_SETJMP) x = setjmp(jb); else if (test == TEST_U_SETJMP) x = _setjmp(jb); else x = sigsetjmp(sjb, !expectsignal); if (x != 0) { ATF_REQUIRE(myself == pthread_self()); ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value"); kill(i, SIGABRT); ATF_REQUIRE_MSG(!expectsignal, "kill(SIGABRT) failed"); ATF_REQUIRE(myself == pthread_self()); atf_tc_pass(); } ATF_REQUIRE(myself == pthread_self()); REQUIRE_ERRNO(sigprocmask(SIG_UNBLOCK, &ss, NULL) != -1); if (test == TEST_SETJMP) longjmp(jb, i); else if (test == TEST_U_SETJMP) _longjmp(jb, i); else siglongjmp(sjb, i); atf_tc_fail("jmp failed"); } ATF_TC(setjmp); ATF_TC_HEAD(setjmp, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_self() and setjmp(3)"); } ATF_TC_BODY(setjmp, tc) { h_check(TEST_SETJMP); } ATF_TC(_setjmp); ATF_TC_HEAD(_setjmp, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_self() and _setjmp(3)"); } ATF_TC_BODY(_setjmp, tc) { h_check(TEST_U_SETJMP); } ATF_TC(sigsetjmp_save); ATF_TC_HEAD(sigsetjmp_save, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_self() and sigsetjmp(3) with savemask enabled"); } ATF_TC_BODY(sigsetjmp_save, tc) { h_check(TEST_SIGSETJMP_SAVE); } ATF_TC(sigsetjmp_nosave); ATF_TC_HEAD(sigsetjmp_nosave, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_self() and sigsetjmp(3) with savemask disabled"); } ATF_TC_BODY(sigsetjmp_nosave, tc) { h_check(TEST_SIGSETJMP_NOSAVE); } ATF_TP_ADD_TCS(tp) { /* * These test cases try to verify setjmp and friends in a program * linked with pthreads, and verify that pthread_self() stays * consistent throughout the program. A setcontext() call invoked * by *setjmp() might clobber the TLS special register used to * implement pthread_self(). */ ATF_TP_ADD_TC(tp, setjmp); ATF_TP_ADD_TC(tp, _setjmp); ATF_TP_ADD_TC(tp, sigsetjmp_save); ATF_TP_ADD_TC(tp, sigsetjmp_nosave); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/ssp/h_memset.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/ssp/h_memset.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/ssp/h_memset.c (revision 313439) @@ -1,49 +1,45 @@ -/* $NetBSD: h_memset.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */ +/* $NetBSD: h_memset.c,v 1.2 2017/01/16 16:34:24 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: h_memset.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $"); +__RCSID("$NetBSD: h_memset.c,v 1.2 2017/01/16 16:34:24 christos Exp $"); #include #include #include int main(int argc, char *argv[]) { char b[10]; size_t len = atoi(argv[1]); (void)memset(b, 0, len); -#ifdef __FreeBSD__ return b[0]; /* keeps optimizer from zapping the call to memset() */ -#else - return 0; -#endif } Index: head/contrib/netbsd-tests/lib/libc/ssp/h_read.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/ssp/h_read.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/ssp/h_read.c (revision 313439) @@ -1,67 +1,54 @@ -/* $NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */ +/* $NetBSD: h_read.c,v 1.2 2017/01/16 16:35:57 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: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $"); +__RCSID("$NetBSD: h_read.c,v 1.2 2017/01/16 16:35:57 christos Exp $"); #include +#include +#include #include #include #include -#ifdef __FreeBSD__ -#include -#include - int main(int argc, char *argv[]) { char b[MAXPATHLEN]; int fd, n; size_t len = atoi(argv[1]); if ((fd = open(_PATH_DEVZERO, O_RDONLY)) == -1) abort(); if ((n = read(fd, b, len)) == -1) abort(); (void)printf("%s\n", b); return (0); } -#else -int -main(int argc, char *argv[]) -{ - char b[MAXPATHLEN]; - size_t len = atoi(argv[1]); - - (void)printf("%s\n", b); - return 0; -} -#endif Index: head/contrib/netbsd-tests/lib/libc/stdlib/h_getopt.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/stdlib/h_getopt.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/stdlib/h_getopt.c (revision 313439) @@ -1,130 +1,134 @@ /* $NetBSD: h_getopt.c,v 1.1 2011/01/01 23:56:49 pgoyette Exp $ */ /*- * Copyright (c) 2002 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 #include #include #include #include #ifdef __FreeBSD__ +/* + * Needed to avoid libutil.h pollution in stdio.h, which causes grief with + * with hexdump(3) in lib/libc/db/h_hash.c + */ #include #endif #define WS "\t\n " #define debug 0 int main(int argc, char *argv[]) { size_t len, lineno = 0; char *line, *ptr, *optstring = NULL, *result = NULL; char buf[1024]; char *args[100]; char arg[100]; int nargs = -1; int c; while ((line = fparseln(stdin, &len, &lineno, NULL, 0)) != NULL) { if (strncmp(line, "load:", 5) == 0) { if (optstring) free(optstring); optstring = strtok(&line[6], WS); if (optstring == NULL) errx(1, "missing optstring at line %ld", (unsigned long)lineno); optstring = strdup(optstring); if (debug) fprintf(stderr, "optstring = %s\n", optstring); } else if (strncmp(line, "args:", 5) == 0) { for (; nargs >= 0; nargs--) { if (args[nargs] != NULL) free(args[nargs]); } args[nargs = 0] = strtok(&line[6], WS); if (args[nargs] == NULL) errx(1, "missing args at line %ld", (unsigned long)lineno); args[nargs] = strdup(args[nargs]); while ((args[++nargs] = strtok(NULL, WS)) != NULL) args[nargs] = strdup(args[nargs]); if (debug) { int i = 0; for (i = 0; i < nargs; i++) fprintf(stderr, "argv[%d] = %s\n", i, args[i]); } } else if (strncmp(line, "result:", 7) == 0) { buf[0] = '\0'; optind = optreset = 1; if (result) free(result); result = strtok(&line[8], WS); if (result == NULL) errx(1, "missing result at line %ld", (unsigned long)lineno); result = strdup(result); if (nargs == -1) errx(1, "result: without args:"); if (debug) fprintf(stderr, "result = %s\n", result); while ((c = getopt(nargs, args, optstring)) != -1) { if (c == ':') err(1, "`:' found as argument char"); if ((ptr = strchr(optstring, c)) == NULL) { snprintf(arg, sizeof(arg), "!%c,", c); strcat(buf, arg); continue; } if (ptr[1] != ':') snprintf(arg, sizeof(arg), "%c,", c); else snprintf(arg, sizeof(arg), "%c=%s,", c, optarg); strcat(buf, arg); } len = strlen(buf); if (len > 0) { buf[len - 1] = '|'; buf[len] = '\0'; } else { buf[0] = '|'; buf[1] = '\0'; } snprintf(arg, sizeof(arg), "%d", nargs - optind); strcat(buf, arg); if (strcmp(buf, result) != 0) errx(1, "`%s' != `%s'", buf, result); } free(line); } return 0; } Index: head/contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c (revision 313439) @@ -1,242 +1,246 @@ /* $NetBSD: h_getopt_long.c,v 1.1 2011/01/01 23:56:49 pgoyette Exp $ */ /*- * Copyright (c) 2007 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 #include #include #include #include #include #include #ifdef __FreeBSD__ +/* + * Needed to avoid libutil.h pollution in stdio.h, which causes grief with + * with hexdump(3) in lib/libc/db/h_hash.c + */ #include #endif #define SKIPWS(p) while (isspace((int)(*p))) p++ #define WS "\t\n " int main(int argc, char *argv[]) { size_t len, lineno = 0; char *line, *eptr, *longopt, *ptr, *optstring = NULL, *result = NULL; char buf[1024]; char *args[128]; char arg[256]; int nargs = -1; int c; int nlongopts = 0; int maxnlongopts = 0; int *longopt_flags = NULL; struct option *longopts = NULL; while ((line = fparseln(stdin, &len, &lineno, NULL, 0)) != NULL) { if (strncmp(line, "optstring:", 10) == 0) { if (optstring) free(optstring); optstring = strtok(&line[11], WS); if (optstring == NULL) errx(1, "missing optstring at line %ld", (unsigned long)lineno); optstring = strdup(optstring); } else if (strncmp(line, "longopts:", 9) == 0) { if (longopts) { int i; for (i = 0; i < nlongopts; i++) if (longopts[i].name != NULL) free(__UNCONST(longopts[i].name)); free(longopts); } if (longopt_flags) free(longopt_flags); nlongopts = 0; ptr = strtok(&line[10], WS); if (ptr == NULL) errx(1, "missing longopts at line %ld", (unsigned long)lineno); maxnlongopts = strtoul(ptr, &eptr, 10); if (*eptr != '\0') warnx("garbage in longopts at line %ld", (unsigned long)lineno); maxnlongopts++; /* space for trailer */ longopts = (struct option *)calloc(sizeof(struct option), maxnlongopts); if (longopts == NULL) err(1, "calloc"); longopt_flags = (int *)calloc(sizeof(int), maxnlongopts); if (longopt_flags == NULL) err(1, "calloc"); } else if (strncmp(line, "longopt:", 8) == 0) { if (longopts == NULL) errx(1, "longopt: without longopts at line %ld", (unsigned long)lineno); if (nlongopts >= maxnlongopts) errx(1, "longopt: too many options at line %ld", (unsigned long)lineno); /* name */ ptr = &line[9]; SKIPWS(ptr); longopt = strsep(&ptr, ","); if (longopt == NULL) errx(1, "missing longopt at line %ld", (unsigned long)lineno); longopts[nlongopts].name = strdup(longopt); /* has_arg */ SKIPWS(ptr); longopt = strsep(&ptr, ","); if (*longopt != '\0') { if (strncmp(longopt, "0", 1) == 0 || strncmp(longopt, "no_argument", 2) == 0) longopts[nlongopts].has_arg = no_argument; else if (strncmp(longopt, "1", 1) == 0 || strncmp(longopt, "required_argument", 8) == 0) longopts[nlongopts].has_arg = required_argument; else if (strncmp(longopt, "2", 1) == 0 || strncmp(longopt, "optional_argument", 8) == 0) longopts[nlongopts].has_arg = optional_argument; else errx(1, "unknown has_arg %s at line %ld", longopt, (unsigned long)lineno); } /* flag */ SKIPWS(ptr); longopt = strsep(&ptr, ","); if (*longopt != '\0' && strncmp(longopt, "NULL", 4) != 0) longopts[nlongopts].flag = &longopt_flags[nlongopts]; /* val */ SKIPWS(ptr); longopt = strsep(&ptr, ","); if (*longopt == '\0') errx(1, "missing val at line %ld", (unsigned long)lineno); if (*longopt != '\'') { longopts[nlongopts].val = (int)strtoul(longopt, &eptr, 10); if (*eptr != '\0') errx(1, "invalid val at line %ld", (unsigned long)lineno); } else longopts[nlongopts].val = (int)longopt[1]; nlongopts++; } else if (strncmp(line, "args:", 5) == 0) { for (; nargs >= 0; nargs--) { if (args[nargs] != NULL) free(args[nargs]); } args[nargs = 0] = strtok(&line[6], WS); if (args[nargs] == NULL) errx(1, "Missing args"); args[nargs] = strdup(args[nargs]); while ((args[++nargs] = strtok(NULL, WS)) != NULL) args[nargs] = strdup(args[nargs]); } else if (strncmp(line, "result:", 7) == 0) { int li; buf[0] = '\0'; optind = optreset = 1; if (result) free(result); result = strtok(&line[8], WS); if (result == NULL) errx(1, "missing result at line %ld", (unsigned long)lineno); if (optstring == NULL) errx(1, "result: without optstring"); if (longopts == NULL || nlongopts == 0) errx(1, "result: without longopts"); result = strdup(result); if (nargs == -1) errx(1, "result: without args"); li = -2; while ((c = getopt_long(nargs, args, optstring, longopts, &li)) != -1) { if (c == ':') errx(1, "`:' found as argument char"); if (li == -2) { ptr = strchr(optstring, c); if (ptr == NULL) { snprintf(arg, sizeof(arg), "!%c,", c); strcat(buf, arg); continue; } if (ptr[1] != ':') snprintf(arg, sizeof(arg), "%c,", c); else snprintf(arg, sizeof(arg), "%c=%s,", c, optarg); } else { switch (longopts[li].has_arg) { case no_argument: snprintf(arg, sizeof(arg), "-%s,", longopts[li].name); break; case required_argument: snprintf(arg, sizeof(arg), "-%s=%s,", longopts[li].name, optarg); break; case optional_argument: snprintf(arg, sizeof(arg), "-%s%s%s,", longopts[li].name, (optarg)? "=" : "", (optarg)? optarg : ""); break; default: errx(1, "internal error"); } } strcat(buf, arg); li = -2; } len = strlen(buf); if (len > 0) { buf[len - 1] = '|'; buf[len] = '\0'; } else { buf[0] = '|'; buf[1] = '\0'; } snprintf(arg, sizeof(arg), "%d", nargs - optind); strcat(buf, arg); if (strcmp(buf, result) != 0) errx(1, "`%s' != `%s'", buf, result); } else errx(1, "unknown directive at line %ld", (unsigned long)lineno); free(line); } return 0; } Index: head/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c (revision 313439) @@ -1,411 +1,414 @@ /* $NetBSD: t_hsearch.c,v 1.4 2014/07/20 20:17:21 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. */ /* * Copyright (c) 2001 Christopher G. Demetriou * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed for the * NetBSD Project. See http://www.NetBSD.org/ for * information about NetBSD. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * <> */ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_hsearch.c,v 1.4 2014/07/20 20:17:21 christos Exp $"); #include #include #include #include #include #include #define REQUIRE_ERRNO(x) ATF_REQUIRE_MSG(x, "%s", strerror(errno)) -#ifdef __NetBSD__ ATF_TC(hsearch_basic); ATF_TC_HEAD(hsearch_basic, tc) { atf_tc_set_md_var(tc, "descr", "Checks basic insertions and searching"); } ATF_TC_BODY(hsearch_basic, tc) { ENTRY e, *ep; char ch[2]; int i; REQUIRE_ERRNO(hcreate(16) != 0); /* ch[1] should be constant from here on down. */ ch[1] = '\0'; /* Basic insertions. Check enough that there'll be collisions. */ for (i = 0; i < 26; i++) { ch[0] = 'a' + i; e.key = strdup(ch); /* ptr to provided key is kept! */ ATF_REQUIRE(e.key != NULL); e.data = (void *)(intptr_t)i; ep = hsearch(e, ENTER); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, ch); ATF_REQUIRE_EQ((intptr_t)ep->data, i); } /* e.key should be constant from here on down. */ e.key = ch; /* Basic lookups. */ for (i = 0; i < 26; i++) { ch[0] = 'a' + i; ep = hsearch(e, FIND); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, ch); ATF_REQUIRE_EQ((intptr_t)ep->data, i); } +#ifdef __NetBSD__ hdestroy1(free, NULL); -} +#else + hdestroy(); #endif +} ATF_TC(hsearch_duplicate); ATF_TC_HEAD(hsearch_duplicate, tc) { atf_tc_set_md_var(tc, "descr", "Checks that inserting duplicate " "doesn't overwrite existing data"); } ATF_TC_BODY(hsearch_duplicate, tc) { ENTRY e, *ep; REQUIRE_ERRNO(hcreate(16)); e.key = __UNCONST("a"); e.data = (void *)(intptr_t) 0; ep = hsearch(e, ENTER); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, "a"); ATF_REQUIRE_EQ((intptr_t)ep->data, 0); e.data = (void *)(intptr_t)12345; ep = hsearch(e, ENTER); ep = hsearch(e, FIND); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, "a"); ATF_REQUIRE_EQ((intptr_t)ep->data, 0); hdestroy(); } ATF_TC(hsearch_nonexistent); ATF_TC_HEAD(hsearch_nonexistent, tc) { atf_tc_set_md_var(tc, "descr", "Checks searching for non-existent entry"); } ATF_TC_BODY(hsearch_nonexistent, tc) { ENTRY e, *ep; REQUIRE_ERRNO(hcreate(16)); e.key = __UNCONST("A"); ep = hsearch(e, FIND); ATF_REQUIRE_EQ(ep, NULL); hdestroy(); } ATF_TC(hsearch_two); ATF_TC_HEAD(hsearch_two, tc) { atf_tc_set_md_var(tc, "descr", "Checks that searching doesn't overwrite previous search results"); } ATF_TC_BODY(hsearch_two, tc) { ENTRY e, *ep, *ep2; REQUIRE_ERRNO(hcreate(16)); e.key = __UNCONST("a"); e.data = (void*)(intptr_t)0; ep = hsearch(e, ENTER); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, "a"); ATF_REQUIRE_EQ((intptr_t)ep->data, 0); e.key = __UNCONST("b"); e.data = (void*)(intptr_t)1; ep = hsearch(e, ENTER); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, "b"); ATF_REQUIRE_EQ((intptr_t)ep->data, 1); e.key = __UNCONST("a"); ep = hsearch(e, FIND); e.key = __UNCONST("b"); ep2 = hsearch(e, FIND); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, "a"); ATF_REQUIRE_EQ((intptr_t)ep->data, 0); ATF_REQUIRE(ep2 != NULL); ATF_REQUIRE_STREQ(ep2->key, "b"); ATF_REQUIRE_EQ((intptr_t)ep2->data, 1); hdestroy(); } #if defined(__FreeBSD__) && 1100027 <= __FreeBSD_version -#ifdef __NetBSD__ ATF_TC(hsearch_r_basic); ATF_TC_HEAD(hsearch_r_basic, tc) { atf_tc_set_md_var(tc, "descr", "Checks basic insertions and searching"); } ATF_TC_BODY(hsearch_r_basic, tc) { ENTRY e, *ep; char ch[2]; int i; struct hsearch_data t; REQUIRE_ERRNO(hcreate_r(16, &t) != 0); /* ch[1] should be constant from here on down. */ ch[1] = '\0'; /* Basic insertions. Check enough that there'll be collisions. */ for (i = 0; i < 26; i++) { ch[0] = 'a' + i; e.key = strdup(ch); /* ptr to provided key is kept! */ ATF_REQUIRE(e.key != NULL); e.data = (void *)(intptr_t)i; ATF_REQUIRE(hsearch_r(e, ENTER, &ep, &t) == 1); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, ch); ATF_REQUIRE_EQ((intptr_t)ep->data, i); } /* e.key should be constant from here on down. */ e.key = ch; /* Basic lookups. */ for (i = 0; i < 26; i++) { ch[0] = 'a' + i; ATF_REQUIRE(hsearch_r(e, FIND, &ep, &t) == 1); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, ch); ATF_REQUIRE_EQ((intptr_t)ep->data, i); } +#ifdef __NetBSD__ hdestroy1_r(&t, free, NULL); +#else + hdestroy_r(&t); +#endif } #endif ATF_TC(hsearch_r_duplicate); ATF_TC_HEAD(hsearch_r_duplicate, tc) { atf_tc_set_md_var(tc, "descr", "Checks that inserting duplicate " "doesn't overwrite existing data"); } ATF_TC_BODY(hsearch_r_duplicate, tc) { ENTRY e, *ep; struct hsearch_data t; REQUIRE_ERRNO(hcreate_r(16, &t)); e.key = __UNCONST("a"); e.data = (void *)(intptr_t) 0; ATF_REQUIRE(hsearch_r(e, ENTER, &ep, &t) == 1); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, "a"); ATF_REQUIRE_EQ((intptr_t)ep->data, 0); e.data = (void *)(intptr_t)12345; ATF_REQUIRE(hsearch_r(e, ENTER, &ep, &t) == 1); ATF_REQUIRE(hsearch_r(e, FIND, &ep, &t) == 1); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, "a"); ATF_REQUIRE_EQ((intptr_t)ep->data, 0); hdestroy_r(&t); } ATF_TC(hsearch_r_nonexistent); ATF_TC_HEAD(hsearch_r_nonexistent, tc) { atf_tc_set_md_var(tc, "descr", "Checks searching for non-existent entry"); } ATF_TC_BODY(hsearch_r_nonexistent, tc) { ENTRY e, *ep; struct hsearch_data t; REQUIRE_ERRNO(hcreate_r(16, &t)); +#ifdef __FreeBSD__ + atf_tc_expect_fail("behavior doesn't match docs; see bug # 216872"); +#endif e.key = __UNCONST("A"); ATF_REQUIRE(hsearch_r(e, FIND, &ep, &t) == 1); ATF_REQUIRE_EQ(ep, NULL); hdestroy_r(&t); } ATF_TC(hsearch_r_two); ATF_TC_HEAD(hsearch_r_two, tc) { atf_tc_set_md_var(tc, "descr", "Checks that searching doesn't overwrite previous search results"); } ATF_TC_BODY(hsearch_r_two, tc) { ENTRY e, *ep, *ep2; struct hsearch_data t; REQUIRE_ERRNO(hcreate_r(16, &t)); e.key = __UNCONST("a"); e.data = (void*)(intptr_t)0; ATF_REQUIRE(hsearch_r(e, ENTER, &ep, &t) == 1); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, "a"); ATF_REQUIRE_EQ((intptr_t)ep->data, 0); e.key = __UNCONST("b"); e.data = (void*)(intptr_t)1; ATF_REQUIRE(hsearch_r(e, ENTER, &ep, &t) == 1); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, "b"); ATF_REQUIRE_EQ((intptr_t)ep->data, 1); e.key = __UNCONST("a"); ATF_REQUIRE(hsearch_r(e, FIND, &ep, &t) == 1); e.key = __UNCONST("b"); ATF_REQUIRE(hsearch_r(e, FIND, &ep2, &t) == 1); ATF_REQUIRE(ep != NULL); ATF_REQUIRE_STREQ(ep->key, "a"); ATF_REQUIRE_EQ((intptr_t)ep->data, 0); ATF_REQUIRE(ep2 != NULL); ATF_REQUIRE_STREQ(ep2->key, "b"); ATF_REQUIRE_EQ((intptr_t)ep2->data, 1); hdestroy_r(&t); } -#endif ATF_TP_ADD_TCS(tp) { -#ifdef __NetBSD__ ATF_TP_ADD_TC(tp, hsearch_basic); -#endif ATF_TP_ADD_TC(tp, hsearch_duplicate); ATF_TP_ADD_TC(tp, hsearch_nonexistent); ATF_TP_ADD_TC(tp, hsearch_two); - + #if defined(__FreeBSD__) && 1100027 <= __FreeBSD_version -#ifdef __NetBSD__ ATF_TP_ADD_TC(tp, hsearch_r_basic); -#endif ATF_TP_ADD_TC(tp, hsearch_r_duplicate); ATF_TP_ADD_TC(tp, hsearch_r_nonexistent); ATF_TP_ADD_TC(tp, hsearch_r_two); #endif return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c (revision 313439) @@ -1,336 +1,334 @@ /* $NetBSD: t_strtod.c,v 1.34 2015/12/22 14:19:25 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. */ /* Public domain, Otto Moerbeek , 2006. */ #include __RCSID("$NetBSD: t_strtod.c,v 1.34 2015/12/22 14:19:25 christos Exp $"); #include #include #include #include #include #include #include #if !defined(__vax__) static const char * const inf_strings[] = { "Inf", "INF", "-Inf", "-INF", "Infinity", "+Infinity", "INFINITY", "-INFINITY", "InFiNiTy", "+InFiNiTy" }; const char *nan_string = "NaN(x)y"; #endif ATF_TC(strtod_basic); ATF_TC_HEAD(strtod_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtod(3)"); } ATF_TC_BODY(strtod_basic, tc) { static const size_t n = 1024 * 1000; for (size_t i = 1; i < n; i = i + 1024) { char buf[512]; (void)snprintf(buf, sizeof(buf), "%zu.%zu", i, i + 1); errno = 0; double d = strtod(buf, NULL); ATF_REQUIRE(d > 0.0); ATF_REQUIRE(errno == 0); } } ATF_TC(strtod_hex); ATF_TC_HEAD(strtod_hex, tc) { atf_tc_set_md_var(tc, "descr", "A strtod(3) with hexadecimals"); } #ifdef __vax__ #define SMALL_NUM 1.0e-38 #else #define SMALL_NUM 1.0e-40 #endif ATF_TC_BODY(strtod_hex, tc) { const char *str; char *end; volatile double d; str = "-0x0"; d = strtod(str, &end); /* -0.0 */ ATF_REQUIRE(end == str + 4); ATF_REQUIRE(signbit(d) != 0); ATF_REQUIRE(fabs(d) < SMALL_NUM); str = "-0x"; d = strtod(str, &end); /* -0.0 */ ATF_REQUIRE(end == str + 2); ATF_REQUIRE(signbit(d) != 0); ATF_REQUIRE(fabs(d) < SMALL_NUM); } ATF_TC(strtod_inf); ATF_TC_HEAD(strtod_inf, tc) { atf_tc_set_md_var(tc, "descr", "A strtod(3) with INF (PR lib/33262)"); } ATF_TC_BODY(strtod_inf, tc) { #ifndef __vax__ for (size_t i = 0; i < __arraycount(inf_strings); i++) { volatile double d = strtod(inf_strings[i], NULL); ATF_REQUIRE(isinf(d) != 0); } #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtof_inf); ATF_TC_HEAD(strtof_inf, tc) { atf_tc_set_md_var(tc, "descr", "A strtof(3) with INF (PR lib/33262)"); } ATF_TC_BODY(strtof_inf, tc) { #ifndef __vax__ for (size_t i = 0; i < __arraycount(inf_strings); i++) { volatile float f = strtof(inf_strings[i], NULL); ATF_REQUIRE(isinf(f) != 0); } #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtold_inf); ATF_TC_HEAD(strtold_inf, tc) { atf_tc_set_md_var(tc, "descr", "A strtold(3) with INF (PR lib/33262)"); } ATF_TC_BODY(strtold_inf, tc) { #ifndef __vax__ # ifdef __HAVE_LONG_DOUBLE for (size_t i = 0; i < __arraycount(inf_strings); i++) { volatile long double ld = strtold(inf_strings[i], NULL); ATF_REQUIRE(isinf(ld) != 0); } # else atf_tc_skip("Requires long double support"); # endif #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtod_nan); ATF_TC_HEAD(strtod_nan, tc) { atf_tc_set_md_var(tc, "descr", "A strtod(3) with NaN"); } ATF_TC_BODY(strtod_nan, tc) { #ifndef __vax__ char *end; volatile double d = strtod(nan_string, &end); ATF_REQUIRE(isnan(d) != 0); ATF_REQUIRE(strcmp(end, "y") == 0); #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtof_nan); ATF_TC_HEAD(strtof_nan, tc) { atf_tc_set_md_var(tc, "descr", "A strtof(3) with NaN"); } ATF_TC_BODY(strtof_nan, tc) { #ifndef __vax__ char *end; volatile float f = strtof(nan_string, &end); ATF_REQUIRE(isnanf(f) != 0); ATF_REQUIRE(strcmp(end, "y") == 0); #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtold_nan); ATF_TC_HEAD(strtold_nan, tc) { atf_tc_set_md_var(tc, "descr", "A strtold(3) with NaN (PR lib/45020)"); } ATF_TC_BODY(strtold_nan, tc) { #ifndef __vax__ # ifdef __HAVE_LONG_DOUBLE char *end; volatile long double ld = strtold(nan_string, &end); ATF_REQUIRE(isnan(ld) != 0); -#ifdef __FreeBSD__ - ATF_REQUIRE(strcmp(end, "y") == 0); -#else +#ifndef __FreeBSD__ ATF_REQUIRE(__isnanl(ld) != 0); #endif ATF_REQUIRE(strcmp(end, "y") == 0); # else atf_tc_skip("Requires long double support"); # endif #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtod_round); ATF_TC_HEAD(strtod_round, tc) { atf_tc_set_md_var(tc, "descr", "Test rouding in strtod(3)"); } ATF_TC_BODY(strtod_round, tc) { #ifdef __HAVE_FENV /* * Test that strtod(3) honors the current rounding mode. * The used value is somewhere near 1 + DBL_EPSILON + FLT_EPSILON. */ const char *val = "1.00000011920928977282585492503130808472633361816406"; (void)fesetround(FE_UPWARD); volatile double d1 = strtod(val, NULL); (void)fesetround(FE_DOWNWARD); volatile double d2 = strtod(val, NULL); if (fabs(d1 - d2) > 0.0) return; else { atf_tc_expect_fail("PR misc/44767"); atf_tc_fail("strtod(3) did not honor fesetround(3)"); } #else atf_tc_skip("Requires support"); #endif } ATF_TC(strtod_underflow); ATF_TC_HEAD(strtod_underflow, tc) { atf_tc_set_md_var(tc, "descr", "Test underflow in strtod(3)"); } ATF_TC_BODY(strtod_underflow, tc) { const char *tmp = "0.0000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000002"; errno = 0; volatile double d = strtod(tmp, NULL); if (d != 0 || errno != ERANGE) atf_tc_fail("strtod(3) did not detect underflow"); } /* * Bug found by Geza Herman. * See * http://www.exploringbinary.com/a-bug-in-the-bigcomp-function-of-david-gays-strtod/ */ ATF_TC(strtod_gherman_bug); ATF_TC_HEAD(strtod_gherman_bug, tc) { atf_tc_set_md_var(tc, "descr", "Test a bug found by Geza Herman"); } ATF_TC_BODY(strtod_gherman_bug, tc) { const char *str = "1.8254370818746402660437411213933955878019332885742187"; errno = 0; volatile double d = strtod(str, NULL); ATF_CHECK(d == 0x1.d34fd8378ea83p+0); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtod_basic); ATF_TP_ADD_TC(tp, strtod_hex); ATF_TP_ADD_TC(tp, strtod_inf); ATF_TP_ADD_TC(tp, strtof_inf); ATF_TP_ADD_TC(tp, strtold_inf); ATF_TP_ADD_TC(tp, strtod_nan); ATF_TP_ADD_TC(tp, strtof_nan); ATF_TP_ADD_TC(tp, strtold_nan); ATF_TP_ADD_TC(tp, strtod_round); ATF_TP_ADD_TC(tp, strtod_underflow); ATF_TP_ADD_TC(tp, strtod_gherman_bug); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/string/t_strlen.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/string/t_strlen.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/string/t_strlen.c (revision 313439) @@ -1,210 +1,202 @@ -/* $NetBSD: t_strlen.c,v 1.5 2011/07/14 07:33:20 jruoho Exp $ */ +/* $NetBSD: t_strlen.c,v 1.6 2017/01/14 20:49:24 christos Exp $ */ /* * Written by J.T. Conklin * Public domain. */ #include #include #include #include #include #include #include static void write_num(int); static void write_num(int val) { char buf[20]; int i; for (i = sizeof buf; --i >= 0;) { buf[i] = '0' + val % 10; val /= 10; if (val == 0) { write(2, buf + i, sizeof buf - i); return; } } write(2, "overflow", 8); } ATF_TC(strlen_basic); ATF_TC_HEAD(strlen_basic, tc) { atf_tc_set_md_var(tc, "descr", "Test strlen(3) results"); } ATF_TC_BODY(strlen_basic, tc) { -#ifdef __FreeBSD__ void *dl_handle; -#endif /* try to trick the compiler */ size_t (*strlen_fn)(const char *); unsigned int a, t; size_t len; char buf[64]; struct tab { const char* val; size_t len; }; const struct tab tab[] = { /* * patterns that check for all combinations of leading and * trailing unaligned characters (on a 64 bit processor) */ { "", 0 }, { "a", 1 }, { "ab", 2 }, { "abc", 3 }, { "abcd", 4 }, { "abcde", 5 }, { "abcdef", 6 }, { "abcdefg", 7 }, { "abcdefgh", 8 }, { "abcdefghi", 9 }, { "abcdefghij", 10 }, { "abcdefghijk", 11 }, { "abcdefghijkl", 12 }, { "abcdefghijklm", 13 }, { "abcdefghijklmn", 14 }, { "abcdefghijklmno", 15 }, { "abcdefghijklmnop", 16 }, { "abcdefghijklmnopq", 17 }, { "abcdefghijklmnopqr", 18 }, { "abcdefghijklmnopqrs", 19 }, { "abcdefghijklmnopqrst", 20 }, { "abcdefghijklmnopqrstu", 21 }, { "abcdefghijklmnopqrstuv", 22 }, { "abcdefghijklmnopqrstuvw", 23 }, /* * patterns that check for the cases where the expression: * * ((word - 0x7f7f..7f) & 0x8080..80) * * returns non-zero even though there are no zero bytes in * the word. */ { "" "\xff\xff\xff\xff\xff\xff\xff\xff" "abcdefgh", 16 }, { "a" "\xff\xff\xff\xff\xff\xff\xff\xff" "bcdefgh", 16 }, { "ab" "\xff\xff\xff\xff\xff\xff\xff\xff" "cdefgh", 16 }, { "abc" "\xff\xff\xff\xff\xff\xff\xff\xff" "defgh", 16 }, { "abcd" "\xff\xff\xff\xff\xff\xff\xff\xff" "efgh", 16 }, { "abcde" "\xff\xff\xff\xff\xff\xff\xff\xff" "fgh", 16 }, { "abcdef" "\xff\xff\xff\xff\xff\xff\xff\xff" "gh", 16 }, { "abcdefg" "\xff\xff\xff\xff\xff\xff\xff\xff" "h", 16 }, { "abcdefgh" "\xff\xff\xff\xff\xff\xff\xff\xff" "", 16 }, }; /* * During testing it is useful have the rest of the program * use a known good version! */ -#ifdef __FreeBSD__ dl_handle = dlopen(NULL, RTLD_LAZY); strlen_fn = dlsym(dl_handle, "test_strlen"); -#else - strlen_fn = dlsym(dlopen(NULL, RTLD_LAZY), "test_strlen"); -#endif if (!strlen_fn) strlen_fn = strlen; for (a = 0; a < sizeof(long); ++a) { for (t = 0; t < (sizeof(tab) / sizeof(tab[0])); ++t) { memcpy(&buf[a], tab[t].val, tab[t].len + 1); len = strlen_fn(&buf[a]); if (len != tab[t].len) { /* Write error without using printf / strlen */ write(2, "alignment ", 10); write_num(a); write(2, ", test ", 7); write_num(t); write(2, ", got len ", 10); write_num(len); write(2, ", not ", 6); write_num(tab[t].len); write(2, ", for '", 7); write(2, tab[t].val, tab[t].len); write(2, "'\n", 2); atf_tc_fail("See stderr for details"); } } } -#ifdef __FreeBSD__ (void)dlclose(dl_handle); -#endif } ATF_TC(strlen_huge); ATF_TC_HEAD(strlen_huge, tc) { atf_tc_set_md_var(tc, "descr", "Test strlen(3) with huge strings"); } ATF_TC_BODY(strlen_huge, tc) { long page; char *str; size_t i; page = sysconf(_SC_PAGESIZE); ATF_REQUIRE(page >= 0); for (i = 1; i < 1000; i = i + 100) { str = malloc(i * page + 1); if (str == NULL) continue; (void)memset(str, 'x', i * page); str[i * page] = '\0'; ATF_REQUIRE(strlen(str) == i * page); free(str); } } ATF_TC(strnlen_basic); ATF_TC_HEAD(strnlen_basic, tc) { atf_tc_set_md_var(tc, "descr", "A naive test of strnlen(3)"); } ATF_TC_BODY(strnlen_basic, tc) { char buf[1]; buf[0] = '\0'; ATF_CHECK(strnlen(buf, 000) == 0); ATF_CHECK(strnlen(buf, 111) == 0); ATF_CHECK(strnlen("xxx", 0) == 0); ATF_CHECK(strnlen("xxx", 1) == 1); ATF_CHECK(strnlen("xxx", 2) == 2); ATF_CHECK(strnlen("xxx", 3) == 3); ATF_CHECK(strnlen("xxx", 9) == 3); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strlen_basic); ATF_TP_ADD_TC(tp, strlen_huge); ATF_TP_ADD_TC(tp, strnlen_basic); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/sys/t_clock_gettime.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_clock_gettime.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_clock_gettime.c (revision 313439) @@ -1,220 +1,213 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_connect.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_connect.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_connect.c (revision 313439) @@ -1,140 +1,133 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_dup.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_dup.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_dup.c (revision 313439) @@ -1,405 +1,402 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c (revision 313439) @@ -1,151 +1,160 @@ /* $NetBSD: t_getcontext.c,v 1.3 2011/07/14 04:59:14 jruoho Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_getcontext.c,v 1.3 2011/07/14 04:59:14 jruoho Exp $"); #include #include #include #include #include #define STACKSZ (10*1024) #define DEPTH 3 static int calls; static void run(int n, ...) { va_list va; int i, ia; ATF_REQUIRE_EQ(n, DEPTH - calls - 1); va_start(va, n); -#if defined(__FreeBSD__) && defined(__amd64__) +#ifdef __FreeBSD__ +#if defined(__amd64__) for (i = 0; i < 5; i++) { -#elif defined(__FreeBSD__) && defined(__aarch64__) +#elif defined(__aarch64__) for (i = 0; i < 7; i++) { -#elif defined(__FreeBSD__) && defined(__mips__) +#elif defined(__mips__) for (i = 0; i < 5; i++) { #else for (i = 0; i < 9; i++) { #endif +#else + for (i = 0; i < 9; i++) { +#endif ia = va_arg(va, int); ATF_REQUIRE_EQ(i, ia); } va_end(va); calls++; } ATF_TC(getcontext_err); ATF_TC_HEAD(getcontext_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from getcontext(2)"); } ATF_TC_BODY(getcontext_err, tc) { errno = 0; ATF_REQUIRE_ERRNO(EFAULT, getcontext((void *)-1) == -1); } ATF_TC(setcontext_err); ATF_TC_HEAD(setcontext_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from setcontext(2)"); } ATF_TC_BODY(setcontext_err, tc) { errno = 0; ATF_REQUIRE_ERRNO(EFAULT, setcontext((void *)-1) == -1); } ATF_TC(setcontext_link); ATF_TC_HEAD(setcontext_link, tc) { atf_tc_set_md_var(tc, "descr", "Checks get/make/setcontext(), context linking via uc_link(), " "and argument passing to the new context"); } ATF_TC_BODY(setcontext_link, tc) { ucontext_t uc[DEPTH]; ucontext_t save; volatile int i = 0; /* avoid longjmp clobbering */ for (i = 0; i < DEPTH; ++i) { ATF_REQUIRE_EQ(getcontext(&uc[i]), 0); uc[i].uc_stack.ss_sp = malloc(STACKSZ); uc[i].uc_stack.ss_size = STACKSZ; uc[i].uc_link = (i > 0) ? &uc[i - 1] : &save; -#if defined(__FreeBSD__) && defined(__amd64__) +#ifdef __FreeBSD__ +#if defined(__amd64__) /* FreeBSD/amd64 only permits up to 6 arguments. */ makecontext(&uc[i], (void *)run, 6, i, 0, 1, 2, 3, 4); -#elif defined(__FreeBSD__) && defined(__aarch64__) +#elif defined(__aarch64__) /* FreeBSD/arm64 only permits up to 8 arguments. */ makecontext(&uc[i], (void *)run, 8, i, 0, 1, 2, 3, 4, 5, 6); -#elif defined(__FreeBSD__) && defined(__mips__) +#elif defined(__mips__) /* FreeBSD/mips only permits up to 6 arguments. */ makecontext(&uc[i], (void *)run, 6, i, 0, 1, 2, 3, 4); +#else + makecontext(&uc[i], (void *)run, 10, i, + 0, 1, 2, 3, 4, 5, 6, 7, 8); +#endif #else makecontext(&uc[i], (void *)run, 10, i, 0, 1, 2, 3, 4, 5, 6, 7, 8); #endif } ATF_REQUIRE_EQ(getcontext(&save), 0); if (calls == 0) ATF_REQUIRE_EQ(setcontext(&uc[DEPTH-1]), 0); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, getcontext_err); ATF_TP_ADD_TC(tp, setcontext_err); ATF_TP_ADD_TC(tp, setcontext_link); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/sys/t_kevent.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_kevent.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_kevent.c (revision 313439) @@ -1,215 +1,198 @@ /* $NetBSD: t_kevent.c,v 1.7 2015/02/05 13:55:37 isaki 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 __RCSID("$NetBSD: t_kevent.c,v 1.7 2015/02/05 13:55:37 isaki Exp $"); #include #include #include #include #include #include #include #include #include #include #include #ifdef __NetBSD__ #include +#else +#define DRVCTLDEV "/nonexistent" #endif #include #include #include #include -#ifdef __FreeBSD__ -#define DRVCTLDEV "/nonexistent" -#endif - ATF_TC(kevent_zerotimer); ATF_TC_HEAD(kevent_zerotimer, tc) { atf_tc_set_md_var(tc, "descr", "Checks that kevent with a 0 timer " "does not crash the system (PR lib/45618)"); } ATF_TC_BODY(kevent_zerotimer, tc) { struct kevent ev; int kq; ATF_REQUIRE((kq = kqueue()) != -1); EV_SET(&ev, 1, EVFILT_TIMER, EV_ADD|EV_ENABLE, 0, 1, 0); ATF_REQUIRE(kevent(kq, &ev, 1, NULL, 0, NULL) != -1); ATF_REQUIRE(kevent(kq, NULL, 0, &ev, 1, NULL) == 1); } ATF_TC(kqueue_desc_passing); ATF_TC_HEAD(kqueue_desc_passing, tc) { atf_tc_set_md_var(tc, "descr", "Checks that passing a kqueue to " "another process does not crash the kernel (PR 46463)"); } ATF_TC_BODY(kqueue_desc_passing, tc) { pid_t child; int s[2], storage, status, kq; struct cmsghdr *msg; struct iovec iov; struct msghdr m; struct kevent ev; ATF_REQUIRE((kq = kqueue()) != -1); // atf_tc_skip("crashes kernel (PR 46463)"); ATF_REQUIRE(socketpair(AF_LOCAL, SOCK_STREAM, 0, s) != -1); msg = malloc(CMSG_SPACE(sizeof(int))); m.msg_iov = &iov; m.msg_iovlen = 1; m.msg_name = NULL; m.msg_namelen = 0; m.msg_control = msg; m.msg_controllen = CMSG_SPACE(sizeof(int)); #ifdef __FreeBSD__ m.msg_flags = 0; #endif child = fork(); if (child == 0) { close(s[0]); iov.iov_base = &storage; iov.iov_len = sizeof(int); m.msg_iov = &iov; m.msg_iovlen = 1; if (recvmsg(s[1], &m, 0) == -1) err(1, "child: could not recvmsg"); -#ifdef __FreeBSD__ - bcopy(CMSG_DATA(msg), &kq, sizeof(kq)); - printf("child (pid %d): received kq fd %d\n", getpid(), kq); - _exit(0); -#else kq = *(int *)CMSG_DATA(msg); printf("child (pid %d): received kq fd %d\n", getpid(), kq); exit(0); -#endif } close(s[1]); iov.iov_base = &storage; iov.iov_len = sizeof(int); +#ifdef __FreeBSD__ + msg = CMSG_FIRSTHDR(&m); +#endif msg->cmsg_level = SOL_SOCKET; msg->cmsg_type = SCM_RIGHTS; msg->cmsg_len = CMSG_LEN(sizeof(int)); -#ifdef __FreeBSD__ - /* - * What is should have been - * bcopy(&s[0], CMSG_DATA(msg), sizeof(kq)); - */ - bcopy(&kq, CMSG_DATA(msg), sizeof(kq)); -#else +#ifdef __NetBSD__ *(int *)CMSG_DATA(msg) = kq; #endif EV_SET(&ev, 1, EVFILT_TIMER, EV_ADD|EV_ENABLE, 0, 1, 0); ATF_CHECK(kevent(kq, &ev, 1, NULL, 0, NULL) != -1); printf("parent (pid %d): sending kq fd %d\n", getpid(), kq); if (sendmsg(s[0], &m, 0) == -1) { -#ifdef __NetBSD__ ATF_REQUIRE_EQ_MSG(errno, EBADF, "errno is %d", errno); atf_tc_skip("PR kern/46523"); -#endif -#ifdef __FreeBSD__ - ATF_REQUIRE_EQ_MSG(errno, EOPNOTSUPP, "errno is %d", errno); - close(s[0]); -#endif } close(kq); waitpid(child, &status, 0); ATF_CHECK(WIFEXITED(status) && WEXITSTATUS(status)==0); } ATF_TC(kqueue_unsupported_fd); ATF_TC_HEAD(kqueue_unsupported_fd, tc) { atf_tc_set_md_var(tc, "descr", "Checks that watching an fd whose" " type is not supported does not crash the kernel"); } ATF_TC_BODY(kqueue_unsupported_fd, tc) { /* mqueue and semaphore use fnullop_kqueue also */ int fd, kq; struct kevent ev; fd = open(DRVCTLDEV, O_RDONLY); if (fd == -1) { switch (errno) { case ENOENT: case ENXIO: atf_tc_skip("no " DRVCTLDEV " available for testing"); break; } } ATF_REQUIRE(fd != -1); ATF_REQUIRE((kq = kqueue()) != -1); EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND|NOTE_ATTRIB|NOTE_LINK| NOTE_RENAME|NOTE_REVOKE, 0, 0); ATF_REQUIRE(kevent(kq, &ev, 1, NULL, 0, NULL) == -1); ATF_REQUIRE_ERRNO(EOPNOTSUPP, true); (void)close(fd); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, kevent_zerotimer); ATF_TP_ADD_TC(tp, kqueue_desc_passing); ATF_TP_ADD_TC(tp, kqueue_unsupported_fd); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/sys/t_link.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_link.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_link.c (revision 313439) @@ -1,233 +1,230 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_listen.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_listen.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_listen.c (revision 313439) @@ -1,141 +1,136 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_mincore.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_mincore.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_mincore.c (revision 313439) @@ -1,348 +1,342 @@ -/* $NetBSD: t_mincore.c,v 1.9 2017/01/10 22:36:29 christos Exp $ */ +/* $NetBSD: t_mincore.c,v 1.10 2017/01/14 20:51:13 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) 1999 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, * NASA Ames Research Center. * * 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_mincore.c,v 1.9 2017/01/10 22:36:29 christos Exp $"); +__RCSID("$NetBSD: t_mincore.c,v 1.10 2017/01/14 20:51:13 christos Exp $"); #include #include #include #include #include #include #include #include #include #include #include #include static long page = 0; static const char path[] = "mincore"; static size_t check_residency(void *, size_t); static size_t check_residency(void *addr, size_t npgs) { size_t i, resident; char *vec; vec = malloc(npgs); ATF_REQUIRE(vec != NULL); ATF_REQUIRE(mincore(addr, npgs * page, vec) == 0); for (i = resident = 0; i < npgs; i++) { if (vec[i] != 0) resident++; #if 0 (void)fprintf(stderr, "page 0x%p is %sresident\n", (char *)addr + (i * page), vec[i] ? "" : "not "); #endif } free(vec); return resident; } ATF_TC(mincore_err); ATF_TC_HEAD(mincore_err, tc) { atf_tc_set_md_var(tc, "descr", "Test errors from mincore(2)"); } ATF_TC_BODY(mincore_err, tc) { char *map, *vec; map = mmap(NULL, page, PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); vec = malloc(page); ATF_REQUIRE(vec != NULL); ATF_REQUIRE(map != MAP_FAILED); #ifdef __NetBSD__ errno = 0; ATF_REQUIRE_ERRNO(EINVAL, mincore(map, 0, vec) == -1); #endif errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, mincore(0, page, vec) == -1); errno = 0; ATF_REQUIRE_ERRNO(EFAULT, mincore(map, page, (void *)-1) == -1); free(vec); ATF_REQUIRE(munmap(map, page) == 0); } ATF_TC_WITH_CLEANUP(mincore_resid); ATF_TC_HEAD(mincore_resid, tc) { atf_tc_set_md_var(tc, "descr", "Test page residency with mincore(2)"); -#ifdef __FreeBSD__ atf_tc_set_md_var(tc, "require.user", "root"); -#endif } ATF_TC_BODY(mincore_resid, tc) { void *addr, *addr2, *addr3, *buf; size_t npgs = 0, resident; struct stat st; int fd, rv; struct rlimit rlim; ATF_REQUIRE(getrlimit(RLIMIT_MEMLOCK, &rlim) == 0); -#ifdef __FreeBSD__ /* * Bump the mlock limit to unlimited so the rest of the testcase * passes instead of failing on the mlock call. */ rlim.rlim_max = RLIM_INFINITY; -#endif rlim.rlim_cur = rlim.rlim_max; ATF_REQUIRE(setrlimit(RLIMIT_MEMLOCK, &rlim) == 0); (void)memset(&st, 0, sizeof(struct stat)); fd = open(path, O_RDWR | O_CREAT, 0700); buf = malloc(page * 5); ATF_REQUIRE(fd >= 0); ATF_REQUIRE(buf != NULL); rv = write(fd, buf, page * 5); ATF_REQUIRE(rv >= 0); ATF_REQUIRE(fd >= 0); ATF_REQUIRE(fstat(fd, &st) == 0); addr = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_FILE | MAP_SHARED, fd, (off_t) 0); ATF_REQUIRE(addr != MAP_FAILED); (void)close(fd); npgs = st.st_size / page; if (st.st_size % page != 0) npgs++; (void)check_residency(addr, npgs); rv = mlock(addr, npgs * page); if (rv == -1 && errno == EAGAIN) atf_tc_skip("hit process resource limits"); ATF_REQUIRE(munmap(addr, st.st_size) == 0); npgs = 128; #ifdef __FreeBSD__ addr = mmap(NULL, npgs * page, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, (off_t)0); #else addr = mmap(NULL, npgs * page, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_WIRED, -1, (off_t)0); #endif if (addr == MAP_FAILED) atf_tc_skip("could not mmap wired anonymous test area, system " "might be low on memory"); #ifdef __FreeBSD__ if (mlock(addr, npgs * page) == -1 && errno != ENOMEM) atf_tc_skip("could not wire anonymous test area, system might " "be low on memory"); #endif ATF_REQUIRE(check_residency(addr, npgs) == npgs); ATF_REQUIRE(munmap(addr, npgs * page) == 0); npgs = 128; addr = mmap(NULL, npgs * page, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, (off_t)0); ATF_REQUIRE(addr != MAP_FAILED); /* * Check that the in-core pages match the locked pages. */ ATF_REQUIRE(check_residency(addr, npgs) == 0); errno = 0; if (mlockall(MCL_CURRENT|MCL_FUTURE) != 0 && errno != ENOMEM) atf_tc_fail("mlockall(2) failed"); if (errno == ENOMEM) atf_tc_skip("mlockall() exceeded process resource limits"); resident = check_residency(addr, npgs); if (resident < npgs) atf_tc_fail("mlockall(MCL_FUTURE) succeeded, still only " "%zu pages of the newly mapped %zu pages are resident", resident, npgs); addr2 = mmap(NULL, npgs * page, PROT_READ, MAP_ANON, -1, (off_t)0); addr3 = mmap(NULL, npgs * page, PROT_NONE, MAP_ANON, -1, (off_t)0); if (addr2 == MAP_FAILED || addr3 == MAP_FAILED) atf_tc_skip("could not mmap more anonymous test pages with " "mlockall(MCL_FUTURE) in effect, system " "might be low on memory"); ATF_REQUIRE(check_residency(addr2, npgs) == npgs); ATF_REQUIRE(check_residency(addr3, npgs) == 0); ATF_REQUIRE(mprotect(addr3, npgs * page, PROT_READ) == 0); ATF_REQUIRE(check_residency(addr, npgs) == npgs); ATF_REQUIRE(check_residency(addr2, npgs) == npgs); (void)munlockall(); ATF_REQUIRE(madvise(addr2, npgs * page, MADV_FREE) == 0); #ifdef __NetBSD__ ATF_REQUIRE(check_residency(addr2, npgs) == 0); #endif (void)memset(addr, 0, npgs * page); ATF_REQUIRE(madvise(addr, npgs * page, MADV_FREE) == 0); #ifdef __NetBSD__ ATF_REQUIRE(check_residency(addr, npgs) == 0); #endif (void)munmap(addr, npgs * page); (void)munmap(addr2, npgs * page); (void)munmap(addr3, npgs * page); (void)unlink(path); -#ifdef __FreeBSD__ free(buf); -#endif } ATF_TC_CLEANUP(mincore_resid, tc) { (void)unlink(path); } ATF_TC(mincore_shmseg); ATF_TC_HEAD(mincore_shmseg, tc) { atf_tc_set_md_var(tc, "descr", "residency of shared memory"); } ATF_TC_BODY(mincore_shmseg, tc) { size_t npgs = 128; void *addr = NULL; int shmid; shmid = shmget(IPC_PRIVATE, npgs * page, IPC_CREAT | S_IRUSR | S_IWUSR); ATF_REQUIRE(shmid != -1); addr = shmat(shmid, NULL, 0); ATF_REQUIRE(addr != NULL); ATF_REQUIRE(check_residency(addr, npgs) == 0); (void)memset(addr, 0xff, npgs * page); ATF_REQUIRE(check_residency(addr, npgs) == npgs); ATF_REQUIRE(madvise(addr, npgs * page, MADV_FREE) == 0); /* * NOTE! Even though we have MADV_FREE'd the range, * there is another reference (the kernel's) to the * object which owns the pages. In this case, the * kernel does not simply free the pages, as haphazardly * freeing pages when there are still references to * an object can cause data corruption (say, the other * referencer doesn't expect the pages to be freed, * and is surprised by the subsequent ZFOD). * * Because of this, we simply report the number of * pages still resident, for information only. */ npgs = check_residency(addr, npgs); (void)fprintf(stderr, "%zu pages still resident\n", npgs); ATF_REQUIRE(shmdt(addr) == 0); ATF_REQUIRE(shmctl(shmid, IPC_RMID, NULL) == 0); } ATF_TP_ADD_TCS(tp) { page = sysconf(_SC_PAGESIZE); ATF_REQUIRE(page >= 0); ATF_TP_ADD_TC(tp, mincore_err); ATF_TP_ADD_TC(tp, mincore_resid); ATF_TP_ADD_TC(tp, mincore_shmseg); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c (revision 313439) @@ -1,376 +1,376 @@ /* $NetBSD: t_mlock.c,v 1.6 2016/08/09 12:02:44 kre Exp $ */ /*- * Copyright (c) 2012 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_mlock.c,v 1.6 2016/08/09 12:02:44 kre Exp $"); #ifdef __FreeBSD__ -#include +#include /* NetBSD requires sys/param.h for sysctl(3), unlike FreeBSD */ #endif #include #include #include #include #include #include #include #include #include #include #ifdef __FreeBSD__ #include #define _KMEMUSER #include void set_vm_max_wired(int); void restore_vm_max_wired(void); #endif static long page = 0; ATF_TC(mlock_clip); ATF_TC_HEAD(mlock_clip, tc) { atf_tc_set_md_var(tc, "descr", "Test with mlock(2) that UVM only " "clips if the clip address is within the entry (PR kern/44788)"); } ATF_TC_BODY(mlock_clip, tc) { void *buf; buf = malloc(page); ATF_REQUIRE(buf != NULL); if (page < 1024) atf_tc_skip("page size too small"); for (size_t i = page; i >= 1; i = i - 1024) { (void)mlock(buf, page - i); (void)munlock(buf, page - i); } free(buf); } #ifdef __FreeBSD__ ATF_TC_WITH_CLEANUP(mlock_err); #else ATF_TC(mlock_err); #endif ATF_TC_HEAD(mlock_err, tc) { atf_tc_set_md_var(tc, "descr", "Test error conditions in mlock(2) and munlock(2)"); #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(mlock_err, tc) { #ifdef __NetBSD__ unsigned long vmin = 0; size_t len = sizeof(vmin); #endif #if !defined(__aarch64__) && !defined(__riscv__) void *invalid_ptr; #endif int null_errno = ENOMEM; /* error expected for NULL */ void *buf; #ifdef __FreeBSD__ #ifdef VM_MIN_ADDRESS if ((uintptr_t)VM_MIN_ADDRESS > 0) null_errno = EINVAL; /* NULL is not inside user VM */ #endif /* Set max_wired really really high to avoid EAGAIN */ set_vm_max_wired(INT_MAX); #else if (sysctlbyname("vm.minaddress", &vmin, &len, NULL, 0) != 0) atf_tc_fail("failed to read vm.minaddress"); /* * Any bad address must return ENOMEM (for lock & unlock) */ errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, mlock(NULL, page) == -1); if (vmin > 0) null_errno = EINVAL; /* NULL is not inside user VM */ #endif errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, mlock((char *)0, page) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, mlock((char *)-1, page) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, munlock(NULL, page) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, munlock((char *)0, page) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, munlock((char *)-1, page) == -1); buf = malloc(page); ATF_REQUIRE(buf != NULL); /* * unlocking memory that is not locked is an error... */ errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, munlock(buf, page) == -1); /* There is no sbrk on AArch64 and RISC-V */ #if !defined(__aarch64__) && !defined(__riscv__) /* * These are permitted to fail (EINVAL) but do not on NetBSD */ ATF_REQUIRE(mlock((void *)(((uintptr_t)buf) + page/3), page/5) == 0); ATF_REQUIRE(munlock((void *)(((uintptr_t)buf) + page/3), page/5) == 0); (void)free(buf); /* * Try to create a pointer to an unmapped page - first after current * brk will likely do. */ invalid_ptr = (void*)(((uintptr_t)sbrk(0)+page) & ~(page-1)); printf("testing with (hopefully) invalid pointer %p\n", invalid_ptr); errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, mlock(invalid_ptr, page) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, munlock(invalid_ptr, page) == -1); #endif } #ifdef __FreeBSD__ ATF_TC_CLEANUP(mlock_err, tc) { restore_vm_max_wired(); } #endif ATF_TC(mlock_limits); ATF_TC_HEAD(mlock_limits, tc) { atf_tc_set_md_var(tc, "descr", "Test system limits with mlock(2)"); } ATF_TC_BODY(mlock_limits, tc) { struct rlimit res; void *buf; pid_t pid; int sta; buf = malloc(page); ATF_REQUIRE(buf != NULL); pid = fork(); ATF_REQUIRE(pid >= 0); if (pid == 0) { for (ssize_t i = page; i >= 2; i -= 100) { res.rlim_cur = i - 1; res.rlim_max = i - 1; (void)fprintf(stderr, "trying to lock %zd bytes " "with %zu byte limit\n", i, (size_t)res.rlim_cur); if (setrlimit(RLIMIT_MEMLOCK, &res) != 0) _exit(EXIT_FAILURE); errno = 0; #ifdef __FreeBSD__ /* * NetBSD doesn't conform to POSIX with ENOMEM requirement; * FreeBSD does. * * See: NetBSD PR # kern/48962 for more details. */ if (mlock(buf, i) != -1 || errno != ENOMEM) { #else if (mlock(buf, i) != -1 || errno != EAGAIN) { #endif (void)munlock(buf, i); _exit(EXIT_FAILURE); } } _exit(EXIT_SUCCESS); } (void)wait(&sta); if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) atf_tc_fail("mlock(2) locked beyond system limits"); free(buf); } #ifdef __FreeBSD__ ATF_TC_WITH_CLEANUP(mlock_mmap); #else ATF_TC(mlock_mmap); #endif ATF_TC_HEAD(mlock_mmap, tc) { atf_tc_set_md_var(tc, "descr", "Test mlock(2)-mmap(2) interaction"); #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(mlock_mmap, tc) { #ifdef __NetBSD__ static const int flags = MAP_ANON | MAP_PRIVATE | MAP_WIRED; #else static const int flags = MAP_ANON | MAP_PRIVATE; #endif void *buf; #ifdef __FreeBSD__ /* Set max_wired really really high to avoid EAGAIN */ set_vm_max_wired(INT_MAX); #endif /* * Make a wired RW mapping and check that mlock(2) * does not fail for the (already locked) mapping. */ buf = mmap(NULL, page, PROT_READ | PROT_WRITE, flags, -1, 0); ATF_REQUIRE(buf != MAP_FAILED); #ifdef __FreeBSD__ /* * The duplicate mlock call is added to ensure that the call works * as described above without MAP_WIRED support. */ ATF_REQUIRE(mlock(buf, page) == 0); #endif ATF_REQUIRE(mlock(buf, page) == 0); ATF_REQUIRE(munlock(buf, page) == 0); ATF_REQUIRE(munmap(buf, page) == 0); ATF_REQUIRE(munlock(buf, page) != 0); /* * But it should be impossible to mlock(2) a PROT_NONE mapping. */ buf = mmap(NULL, page, PROT_NONE, flags, -1, 0); ATF_REQUIRE(buf != MAP_FAILED); #ifdef __FreeBSD__ ATF_REQUIRE_ERRNO(ENOMEM, mlock(buf, page) != 0); #else ATF_REQUIRE(mlock(buf, page) != 0); #endif ATF_REQUIRE(munmap(buf, page) == 0); } #ifdef __FreeBSD__ ATF_TC_CLEANUP(mlock_mmap, tc) { restore_vm_max_wired(); } #endif #ifdef __FreeBSD__ ATF_TC_WITH_CLEANUP(mlock_nested); #else ATF_TC(mlock_nested); #endif ATF_TC_HEAD(mlock_nested, tc) { atf_tc_set_md_var(tc, "descr", "Test that consecutive mlock(2) calls succeed"); #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(mlock_nested, tc) { const size_t maxiter = 100; void *buf; #ifdef __FreeBSD__ /* Set max_wired really really high to avoid EAGAIN */ set_vm_max_wired(INT_MAX); #endif buf = malloc(page); ATF_REQUIRE(buf != NULL); for (size_t i = 0; i < maxiter; i++) ATF_REQUIRE(mlock(buf, page) == 0); ATF_REQUIRE(munlock(buf, page) == 0); free(buf); } #ifdef __FreeBSD__ ATF_TC_CLEANUP(mlock_nested, tc) { restore_vm_max_wired(); } #endif ATF_TP_ADD_TCS(tp) { page = sysconf(_SC_PAGESIZE); ATF_REQUIRE(page >= 0); ATF_TP_ADD_TC(tp, mlock_clip); ATF_TP_ADD_TC(tp, mlock_err); ATF_TP_ADD_TC(tp, mlock_limits); ATF_TP_ADD_TC(tp, mlock_mmap); ATF_TP_ADD_TC(tp, mlock_nested); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c (revision 313439) @@ -1,605 +1,598 @@ -/* $NetBSD: t_mmap.c,v 1.10 2017/01/10 22:36:29 christos Exp $ */ +/* $NetBSD: t_mmap.c,v 1.12 2017/01/16 16:31:05 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.12 2017/01/16 16:31:05 christos Exp $"); #include +#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: head/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c (revision 313439) @@ -1,362 +1,359 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_msgrcv.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_msgrcv.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_msgrcv.c (revision 313439) @@ -1,346 +1,343 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c (revision 313439) @@ -1,342 +1,339 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_msync.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_msync.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_msync.c (revision 313439) @@ -1,248 +1,235 @@ -/* $NetBSD: t_msync.c,v 1.2 2012/03/16 06:15:17 matt Exp $ */ +/* $NetBSD: t_msync.c,v 1.3 2017/01/14 20:52:42 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_msync.c,v 1.2 2012/03/16 06:15:17 matt Exp $"); +__RCSID("$NetBSD: t_msync.c,v 1.3 2017/01/14 20:52:42 christos Exp $"); #include #include #include #include #include #include #include #include static long page = 0; static const off_t off = 512; static const char path[] = "msync"; static const char *msync_sync(const char *, int); static const char * msync_sync(const char *garbage, int flags) { char *buf, *map = MAP_FAILED; const char *str = NULL; - size_t i, len; - ssize_t tot; + size_t len; int fd, rv; /* * Create a temporary file, write * one page to it, and map the file. */ buf = malloc(page); if (buf == NULL) return NULL; - for (i = 0; i < (size_t)page; i++) - buf[i] = 'x'; + memset(buf, 'x', page); fd = open(path, O_RDWR | O_CREAT, 0700); if (fd < 0) { - str = "failed to open"; - goto out; + free(buf); + return "failed to open"; } - tot = 0; - - while (tot < page) { - - rv = write(fd, buf, sizeof(buf)); - - if (rv < 0) { - str = "failed to write"; - goto out; - } - - tot += rv; - } + ATF_REQUIRE_MSG(write(fd, buf, page) != -1, "write(2) failed: %s", + strerror(errno)); map = mmap(NULL, page, PROT_READ | PROT_WRITE, MAP_FILE|MAP_PRIVATE, fd, 0); if (map == MAP_FAILED) { str = "failed to map"; goto out; } /* * Seek to an arbitrary offset and * write garbage to this position. */ if (lseek(fd, off, SEEK_SET) != off) { str = "failed to seek"; goto out; } len = strlen(garbage); rv = write(fd, garbage, len); if (rv != (ssize_t)len) { str = "failed to write garbage"; goto out; } /* * Synchronize the mapping and verify * that garbage is at the given offset. */ if (msync(map, page, flags) != 0) { str = "failed to msync"; goto out; } if (memcmp(map + off, garbage, len) != 0) { str = "msync did not synchronize"; goto out; } out: free(buf); (void)close(fd); (void)unlink(path); if (map != MAP_FAILED) (void)munmap(map, page); return str; } ATF_TC(msync_async); ATF_TC_HEAD(msync_async, tc) { atf_tc_set_md_var(tc, "descr", "Test of msync(2), MS_ASYNC"); } ATF_TC_BODY(msync_async, tc) { const char *str; str = msync_sync("garbage", MS_ASYNC); if (str != NULL) atf_tc_fail("%s", str); } ATF_TC(msync_err); ATF_TC_HEAD(msync_err, tc) { atf_tc_set_md_var(tc, "descr", "Test error conditions in msync(2)"); } ATF_TC_BODY(msync_err, tc) { char *map = MAP_FAILED; /* * Test that invalid flags error out. */ #ifdef __FreeBSD__ errno = 0; ATF_REQUIRE_ERRNO(EINVAL, msync_sync("error", -1) != NULL); errno = 0; ATF_REQUIRE_ERRNO(EINVAL, msync_sync("error", INT_MAX) != NULL); #else ATF_REQUIRE(msync_sync("error", -1) != NULL); ATF_REQUIRE(msync_sync("error", INT_MAX) != NULL); #endif errno = 0; /* * Map a page and then unmap to get an unmapped address. */ map = mmap(NULL, page, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); ATF_REQUIRE(map != MAP_FAILED); (void)munmap(map, page); ATF_REQUIRE(msync(map, page, MS_SYNC) != 0); #ifdef __FreeBSD__ ATF_REQUIRE(errno == ENOMEM); #else ATF_REQUIRE(errno == EFAULT); #endif } ATF_TC(msync_invalidate); ATF_TC_HEAD(msync_invalidate, tc) { atf_tc_set_md_var(tc, "descr", "Test of msync(2), MS_INVALIDATE"); } ATF_TC_BODY(msync_invalidate, tc) { const char *str; str = msync_sync("garbage", MS_INVALIDATE); if (str != NULL) atf_tc_fail("%s", str); } ATF_TC(msync_sync); ATF_TC_HEAD(msync_sync, tc) { atf_tc_set_md_var(tc, "descr", "Test of msync(2), MS_SYNC"); } ATF_TC_BODY(msync_sync, tc) { const char *str; str = msync_sync("garbage", MS_SYNC); if (str != NULL) atf_tc_fail("%s", str); } ATF_TP_ADD_TCS(tp) { page = sysconf(_SC_PAGESIZE); ATF_REQUIRE(page >= 0); ATF_REQUIRE(page > off); ATF_TP_ADD_TC(tp, msync_async); ATF_TP_ADD_TC(tp, msync_err); ATF_TP_ADD_TC(tp, msync_invalidate); ATF_TP_ADD_TC(tp, msync_sync); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/sys/t_pipe.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_pipe.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_pipe.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/sys/t_posix_fadvise.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_posix_fadvise.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_posix_fadvise.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/sys/t_revoke.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_revoke.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_revoke.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/sys/t_select.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_select.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_select.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c (revision 313439) @@ -1,260 +1,240 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/sys/t_stat.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_stat.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_stat.c (revision 313439) @@ -1,424 +1,419 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c (revision 313439) @@ -1,330 +1,326 @@ -/* $NetBSD: t_timer_create.c,v 1.4 2012/03/18 07:00:52 jruoho Exp $ */ +/* $NetBSD: t_timer_create.c,v 1.5 2017/01/16 16:32:13 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 static timer_t t; static bool fail = true; static void -#ifdef __FreeBSD__ timer_signal_handler(int signo, siginfo_t *si, void *osi __unused) -#else -timer_signal_handler(int signo, siginfo_t *si, void *osi) -#endif { timer_t *tp; tp = si->si_value.sival_ptr; if (*tp == t && signo == SIGALRM) fail = false; (void)fprintf(stderr, "%s: %s\n", __func__, strsignal(signo)); } static void timer_signal_create(clockid_t cid, bool expire) { struct itimerspec tim; struct sigaction act; struct sigevent evt; sigset_t set; t = 0; fail = true; (void)memset(&evt, 0, sizeof(struct sigevent)); (void)memset(&act, 0, sizeof(struct sigaction)); (void)memset(&tim, 0, sizeof(struct itimerspec)); /* * Set handler. */ act.sa_flags = SA_SIGINFO; act.sa_sigaction = timer_signal_handler; ATF_REQUIRE(sigemptyset(&set) == 0); ATF_REQUIRE(sigemptyset(&act.sa_mask) == 0); /* * Block SIGALRM while configuring the timer. */ ATF_REQUIRE(sigaction(SIGALRM, &act, NULL) == 0); ATF_REQUIRE(sigaddset(&set, SIGALRM) == 0); ATF_REQUIRE(sigprocmask(SIG_SETMASK, &set, NULL) == 0); /* * Create the timer (SIGEV_SIGNAL). */ evt.sigev_signo = SIGALRM; evt.sigev_value.sival_ptr = &t; evt.sigev_notify = SIGEV_SIGNAL; ATF_REQUIRE(timer_create(cid, &evt, &t) == 0); /* * Start the timer. After this, unblock the signal. */ tim.it_value.tv_sec = expire ? 5 : 1; tim.it_value.tv_nsec = 0; ATF_REQUIRE(timer_settime(t, 0, &tim, NULL) == 0); (void)sigprocmask(SIG_UNBLOCK, &set, NULL); (void)sleep(2); if (expire) { if (!fail) atf_tc_fail("timer fired too soon"); } else { if (fail) atf_tc_fail("timer failed to fire"); } ATF_REQUIRE(timer_delete(t) == 0); } #ifdef __FreeBSD__ static void timer_callback(union sigval value) { timer_t *tp; tp = value.sival_ptr; if (*tp == t) fail = false; } static void timer_thread_create(clockid_t cid, bool expire) { struct itimerspec tim; struct sigevent evt; t = 0; fail = true; (void)memset(&evt, 0, sizeof(struct sigevent)); (void)memset(&tim, 0, sizeof(struct itimerspec)); /* * Create the timer (SIGEV_THREAD). */ evt.sigev_notify_function = timer_callback; evt.sigev_value.sival_ptr = &t; evt.sigev_notify = SIGEV_THREAD; ATF_REQUIRE(timer_create(cid, &evt, &t) == 0); /* * Start the timer. */ tim.it_value.tv_sec = expire ? 5 : 1; tim.it_value.tv_nsec = 0; ATF_REQUIRE(timer_settime(t, 0, &tim, NULL) == 0); (void)sleep(2); if (expire) { if (!fail) atf_tc_fail("timer fired too soon"); } else { if (fail) atf_tc_fail("timer failed to fire"); } ATF_REQUIRE(timer_delete(t) == 0); } #endif ATF_TC(timer_create_err); ATF_TC_HEAD(timer_create_err, tc) { atf_tc_set_md_var(tc, "descr", "Check errors from timer_create(2) (PR lib/42434"); } ATF_TC_BODY(timer_create_err, tc) { struct sigevent ev; (void)memset(&ev, 0, sizeof(struct sigevent)); errno = 0; ev.sigev_signo = -1; ev.sigev_notify = SIGEV_SIGNAL; ATF_REQUIRE_ERRNO(EINVAL, timer_create(CLOCK_REALTIME, &ev, &t) == -1); errno = 0; ev.sigev_signo = SIGUSR1; ev.sigev_notify = SIGEV_THREAD + 100; ATF_REQUIRE_ERRNO(EINVAL, timer_create(CLOCK_REALTIME, &ev, &t) == -1); } ATF_TC(timer_create_real); ATF_TC_HEAD(timer_create_real, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_REALTIME and sigevent(3), " "SIGEV_SIGNAL"); } ATF_TC_BODY(timer_create_real, tc) { timer_signal_create(CLOCK_REALTIME, false); } ATF_TC(timer_create_mono); ATF_TC_HEAD(timer_create_mono, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_MONOTONIC and sigevent(3), " "SIGEV_SIGNAL"); } ATF_TC_BODY(timer_create_mono, tc) { timer_signal_create(CLOCK_MONOTONIC, false); } ATF_TC(timer_create_real_expire); ATF_TC_HEAD(timer_create_real_expire, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_REALTIME and sigevent(3), " "SIGEV_SIGNAL, with expiration"); } ATF_TC_BODY(timer_create_real_expire, tc) { timer_signal_create(CLOCK_REALTIME, true); } ATF_TC(timer_create_mono_expire); ATF_TC_HEAD(timer_create_mono_expire, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_MONOTONIC and sigevent(3), " "SIGEV_SIGNAL, with expiration"); } ATF_TC_BODY(timer_create_mono_expire, tc) { timer_signal_create(CLOCK_MONOTONIC, true); } ATF_TC(timer_thread_create_real); ATF_TC_HEAD(timer_thread_create_real, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_REALTIME and sigevent(3), " "SIGEV_THREAD"); } #ifdef __FreeBSD__ ATF_TC_BODY(timer_thread_create_real, tc) { timer_thread_create(CLOCK_REALTIME, false); } ATF_TC(timer_thread_create_mono); ATF_TC_HEAD(timer_thread_create_mono, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_MONOTONIC and sigevent(3), " "SIGEV_THREAD"); } ATF_TC_BODY(timer_thread_create_mono, tc) { timer_thread_create(CLOCK_MONOTONIC, false); } ATF_TC(timer_thread_create_real_expire); ATF_TC_HEAD(timer_thread_create_real_expire, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_REALTIME and sigevent(3), " "SIGEV_THREAD, with expiration"); } ATF_TC_BODY(timer_thread_create_real_expire, tc) { timer_thread_create(CLOCK_REALTIME, true); } ATF_TC(timer_thread_create_mono_expire); ATF_TC_HEAD(timer_thread_create_mono_expire, tc) { atf_tc_set_md_var(tc, "descr", "Checks timer_create(2) with CLOCK_MONOTONIC and sigevent(3), " "SIGEV_THREAD, with expiration"); } ATF_TC_BODY(timer_thread_create_mono_expire, tc) { timer_thread_create(CLOCK_MONOTONIC, true); } #endif ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, timer_create_err); ATF_TP_ADD_TC(tp, timer_create_real); ATF_TP_ADD_TC(tp, timer_create_mono); ATF_TP_ADD_TC(tp, timer_create_real_expire); ATF_TP_ADD_TC(tp, timer_create_mono_expire); #ifdef __FreeBSD__ ATF_TP_ADD_TC(tp, timer_thread_create_real); ATF_TP_ADD_TC(tp, timer_thread_create_mono); ATF_TP_ADD_TC(tp, timer_thread_create_real_expire); ATF_TP_ADD_TC(tp, timer_thread_create_mono_expire); #endif return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/sys/t_truncate.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_truncate.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_truncate.c (revision 313439) @@ -1,188 +1,179 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_umask.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_umask.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_umask.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libc/sys/t_unlink.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_unlink.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_unlink.c (revision 313439) @@ -1,169 +1,162 @@ -/* $NetBSD: t_unlink.c,v 1.2 2014/04/21 18:05:17 martin Exp $ */ +/* $NetBSD: t_unlink.c,v 1.4 2017/01/14 20:55:26 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.4 2017/01/14 20:55:26 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: head/contrib/netbsd-tests/lib/libc/sys/t_wait.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_wait.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_wait.c (revision 313439) @@ -1,323 +1,320 @@ -/* $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: head/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c (revision 313439) @@ -1,345 +1,342 @@ /* $NetBSD: t_wait_noproc.c,v 1.5 2016/11/09 17:50:19 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_wait_noproc.c,v 1.5 2016/11/09 17:50:19 kamil Exp $"); -#ifdef __FreeBSD__ -#include /* For NBBY -- it's in sys/types.h on NetBSD */ -#endif #include #include #include #include #include #ifndef TWAIT_OPTION #define TWAIT_OPTION 0 #endif #if TWAIT_OPTION == 0 ATF_TC(wait); ATF_TC_HEAD(wait, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait(2) returns ECHILD for no child"); } ATF_TC_BODY(wait, tc) { ATF_REQUIRE_ERRNO(ECHILD, wait(NULL) == -1); } #endif ATF_TC(waitpid); ATF_TC_HEAD(waitpid, tc) { atf_tc_set_md_var(tc, "descr", "Test that waitpid(2) returns ECHILD for WAIT_ANY and option %s", ___STRING(TWAIT_OPTION)); } ATF_TC_BODY(waitpid, tc) { ATF_REQUIRE_ERRNO(ECHILD, waitpid(WAIT_ANY, NULL, TWAIT_OPTION) == -1); } ATF_TC(waitid); ATF_TC_HEAD(waitid, tc) { atf_tc_set_md_var(tc, "descr", "Test that waitid(2) returns ECHILD for P_ALL and option %s", ___STRING(TWAIT_OPTION)); } ATF_TC_BODY(waitid, tc) { ATF_REQUIRE_ERRNO(ECHILD, waitid(P_ALL, 0, NULL, WTRAPPED | WEXITED | TWAIT_OPTION) == -1); } ATF_TC(wait3); ATF_TC_HEAD(wait3, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait3(2) returns ECHILD for no child"); } ATF_TC_BODY(wait3, tc) { ATF_REQUIRE_ERRNO(ECHILD, wait3(NULL, TWAIT_OPTION, NULL) == -1); } ATF_TC(wait4); ATF_TC_HEAD(wait4, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait4(2) returns ECHILD for WAIT_ANY and option %s", ___STRING(TWAIT_OPTION)); } ATF_TC_BODY(wait4, tc) { ATF_REQUIRE_ERRNO(ECHILD, wait4(WAIT_ANY, NULL, TWAIT_OPTION, NULL) == -1); } ATF_TC(wait6); ATF_TC_HEAD(wait6, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait6(2) returns ECHILD for P_ALL and option %s", ___STRING(TWAIT_OPTION)); } ATF_TC_BODY(wait6, tc) { ATF_REQUIRE_ERRNO(ECHILD, wait6(P_ALL, 0, NULL, WTRAPPED | WEXITED | TWAIT_OPTION, NULL, NULL) == -1); } /* * Generator of valid combinations of options * Usage: i = 0; while ((o = get_options_wait6(i++)) != -1) {} */ static int get_options6(size_t pos) { int rv = 0; size_t n; /* * waitid(2) must specify at least one of WEXITED, WUNTRACED, * WSTOPPED, WTRAPPED or WCONTINUED. Single option WNOWAIT * isn't valid. */ const int matrix[] = { WNOWAIT, /* First in order to blacklist it easily */ WEXITED, WUNTRACED, WSTOPPED, /* SUS compatibility, equal to WUNTRACED */ WTRAPPED, WCONTINUED }; const size_t M = (1 << __arraycount(matrix)) - 1; /* Skip empty and sole WNOWAIT option */ pos+=2; if (pos > M) return -1; for (n = 0; n < __arraycount(matrix); n++) { if (pos & __BIT(n)) rv |= matrix[n]; } return rv; } /* * Generator of valid combinations of options * Usage: i = 0; while ((o = get_options_wait4(i++)) != -1) {} */ static int get_options4(size_t pos) { int rv = 0; size_t n; const int special[] = { 0, #ifdef __NetBSD__ WALLSIG, WALTSIG, __WALL, /* Linux compatibility, equal to WALLSIG */ __WCLONE /* Linux compatibility, equal to WALTSIG */ #endif }; const int matrix[] = { WNOWAIT, WEXITED, WUNTRACED, WSTOPPED, /* SUS compatibility, equal to WUNTRACED */ WTRAPPED, WCONTINUED }; const size_t M = (1 << __arraycount(special)) - 1; if (pos < __arraycount(special)) return special[pos]; pos -= __arraycount(special); ++pos; /* Don't start with empty mask */ if (pos > M) return -1; for (n = 0; n < __arraycount(special); n++) { if (pos & __BIT(n)) rv |= matrix[n]; } return rv; } ATF_TC(waitpid_options); ATF_TC_HEAD(waitpid_options, tc) { atf_tc_set_md_var(tc, "descr", "Test that waitpid(2) returns ECHILD for WAIT_ANY and valid " "combination of options with%s WNOHANG", TWAIT_OPTION == 0 ? "out" : ""); } ATF_TC_BODY(waitpid_options, tc) { size_t i = 0; int o; while((o = get_options4(i++)) != -1) { printf("Testing waitpid(2) with options %x\n", o); ATF_REQUIRE_ERRNO(ECHILD, waitpid(WAIT_ANY, NULL, o | TWAIT_OPTION) == -1); } } ATF_TC(waitid_options); ATF_TC_HEAD(waitid_options, tc) { atf_tc_set_md_var(tc, "descr", "Test that waitid(2) returns ECHILD for P_ALL and valid " "combination of options with%s WNOHANG", TWAIT_OPTION == 0 ? "out" : ""); } ATF_TC_BODY(waitid_options, tc) { size_t i = 0; int o; while((o = get_options6(i++)) != -1) { printf("Testing waitid(2) with options %x\n", o); ATF_REQUIRE_ERRNO(ECHILD, waitid(P_ALL, 0, NULL, o | TWAIT_OPTION) == -1); } } ATF_TC(wait3_options); ATF_TC_HEAD(wait3_options, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait3(2) returns ECHILD for no child"); } ATF_TC_BODY(wait3_options, tc) { size_t i = 0; int o; while((o = get_options4(i++)) != -1) { printf("Testing wait3(2) with options %x\n", o); ATF_REQUIRE_ERRNO(ECHILD, wait3(NULL, o | TWAIT_OPTION, NULL) == -1); } } ATF_TC(wait4_options); ATF_TC_HEAD(wait4_options, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait4(2) returns ECHILD for WAIT_ANY and option %s", ___STRING(TWAIT_OPTION)); } ATF_TC_BODY(wait4_options, tc) { size_t i = 0; int o; while((o = get_options4(i++)) != -1) { printf("Testing wait4(2) with options %x\n", o); ATF_REQUIRE_ERRNO(ECHILD, wait4(WAIT_ANY, NULL, o | TWAIT_OPTION, NULL) == -1); } } ATF_TC(wait6_options); ATF_TC_HEAD(wait6_options, tc) { atf_tc_set_md_var(tc, "descr", "Test that wait6(2) returns ECHILD for P_ALL and option %s", ___STRING(TWAIT_OPTION)); } ATF_TC_BODY(wait6_options, tc) { size_t i = 0; int o; while((o = get_options6(i++)) != -1) { printf("Testing wait6(2) with options %x\n", o); ATF_REQUIRE_ERRNO(ECHILD, wait6(P_ALL, 0, NULL, o | TWAIT_OPTION, NULL, NULL) == -1); } } ATF_TP_ADD_TCS(tp) { #if TWAIT_OPTION == 0 ATF_TP_ADD_TC(tp, wait); #endif ATF_TP_ADD_TC(tp, waitpid); ATF_TP_ADD_TC(tp, waitid); ATF_TP_ADD_TC(tp, wait3); ATF_TP_ADD_TC(tp, wait4); ATF_TP_ADD_TC(tp, wait6); ATF_TP_ADD_TC(tp, waitpid_options); ATF_TP_ADD_TC(tp, waitid_options); ATF_TP_ADD_TC(tp, wait3_options); ATF_TP_ADD_TC(tp, wait4_options); ATF_TP_ADD_TC(tp, wait6_options); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/sys/t_write.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_write.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libc/sys/t_write.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libm/t_ilogb.c =================================================================== --- head/contrib/netbsd-tests/lib/libm/t_ilogb.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libm/t_ilogb.c (revision 313439) @@ -1,130 +1,130 @@ -/* $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: head/contrib/netbsd-tests/lib/libm/t_pow.c =================================================================== --- head/contrib/netbsd-tests/lib/libm/t_pow.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libm/t_pow.c (revision 313439) @@ -1,670 +1,666 @@ -/* $NetBSD: t_pow.c,v 1.4 2015/09/08 05:24:27 dholland Exp $ */ +/* $NetBSD: t_pow.c,v 1.5 2017/01/20 21:15:56 maya 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_pow.c,v 1.4 2015/09/08 05:24:27 dholland Exp $"); +__RCSID("$NetBSD: t_pow.c,v 1.5 2017/01/20 21:15:56 maya Exp $"); #include #include -#ifdef __FreeBSD__ -#define isinff isinf -#endif - /* * pow(3) */ ATF_TC(pow_nan_x); ATF_TC_HEAD(pow_nan_x, tc) { atf_tc_set_md_var(tc, "descr", "Test pow(NaN, y) == NaN"); } ATF_TC_BODY(pow_nan_x, tc) { const double x = 0.0L / 0.0L; ATF_CHECK(isnan(pow(x, 2.0)) != 0); } ATF_TC(pow_nan_y); ATF_TC_HEAD(pow_nan_y, tc) { atf_tc_set_md_var(tc, "descr", "Test pow(x, NaN) == NaN"); } ATF_TC_BODY(pow_nan_y, tc) { const double y = 0.0L / 0.0L; ATF_CHECK(isnan(pow(2.0, y)) != 0); } ATF_TC(pow_inf_neg_x); ATF_TC_HEAD(pow_inf_neg_x, tc) { atf_tc_set_md_var(tc, "descr", "Test pow(-Inf, y) == +-Inf || +-0.0"); } ATF_TC_BODY(pow_inf_neg_x, tc) { const double x = -1.0L / 0.0L; double z; /* * If y is odd, y > 0, and x is -Inf, -Inf is returned. * If y is even, y > 0, and x is -Inf, +Inf is returned. */ z = pow(x, 3.0); if (isinf(z) == 0 || signbit(z) == 0) atf_tc_fail_nonfatal("pow(-Inf, 3.0) != -Inf"); z = pow(x, 4.0); if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("pow(-Inf, 4.0) != +Inf"); /* * If y is odd, y < 0, and x is -Inf, -0.0 is returned. * If y is even, y < 0, and x is -Inf, +0.0 is returned. */ z = pow(x, -3.0); if (fabs(z) > 0.0 || signbit(z) == 0) atf_tc_fail_nonfatal("pow(-Inf, -3.0) != -0.0"); z = pow(x, -4.0); if (fabs(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("pow(-Inf -4.0) != +0.0"); } ATF_TC(pow_inf_neg_y); ATF_TC_HEAD(pow_inf_neg_y, tc) { atf_tc_set_md_var(tc, "descr", "Test pow(x, -Inf) == +Inf || +0.0"); } ATF_TC_BODY(pow_inf_neg_y, tc) { const double y = -1.0L / 0.0L; double z; /* * If |x| < 1 and y is -Inf, +Inf is returned. * If |x| > 1 and y is -Inf, +0.0 is returned. */ z = pow(0.1, y); if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("pow(0.1, -Inf) != +Inf"); z = pow(1.1, y); if (fabs(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("pow(1.1, -Inf) != +0.0"); } ATF_TC(pow_inf_pos_x); ATF_TC_HEAD(pow_inf_pos_x, tc) { atf_tc_set_md_var(tc, "descr", "Test pow(+Inf, y) == +Inf || +0.0"); } ATF_TC_BODY(pow_inf_pos_x, tc) { const double x = 1.0L / 0.0L; double z; /* * For y < 0, if x is +Inf, +0.0 is returned. * For y > 0, if x is +Inf, +Inf is returned. */ z = pow(x, -2.0); if (fabs(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("pow(+Inf, -2.0) != +0.0"); z = pow(x, 2.0); if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("pow(+Inf, 2.0) != +Inf"); } ATF_TC(pow_inf_pos_y); ATF_TC_HEAD(pow_inf_pos_y, tc) { atf_tc_set_md_var(tc, "descr", "Test pow(x, +Inf) == +Inf || +0.0"); } ATF_TC_BODY(pow_inf_pos_y, tc) { const double y = 1.0L / 0.0L; double z; /* * If |x| < 1 and y is +Inf, +0.0 is returned. * If |x| > 1 and y is +Inf, +Inf is returned. */ z = pow(0.1, y); if (fabs(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("pow(0.1, +Inf) != +0.0"); z = pow(1.1, y); if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("pow(1.1, +Inf) != +Inf"); } ATF_TC(pow_one_neg_x); ATF_TC_HEAD(pow_one_neg_x, tc) { atf_tc_set_md_var(tc, "descr", "Test pow(-1.0, +-Inf) == 1.0"); } ATF_TC_BODY(pow_one_neg_x, tc) { const double infp = 1.0L / 0.0L; const double infn = -1.0L / 0.0L; /* * If x is -1.0, and y is +-Inf, 1.0 shall be returned. */ ATF_REQUIRE(isinf(infp) != 0); ATF_REQUIRE(isinf(infn) != 0); if (pow(-1.0, infp) != 1.0) { atf_tc_expect_fail("PR lib/45372"); atf_tc_fail_nonfatal("pow(-1.0, +Inf) != 1.0"); } if (pow(-1.0, infn) != 1.0) { atf_tc_expect_fail("PR lib/45372"); atf_tc_fail_nonfatal("pow(-1.0, -Inf) != 1.0"); } } ATF_TC(pow_one_pos_x); ATF_TC_HEAD(pow_one_pos_x, tc) { atf_tc_set_md_var(tc, "descr", "Test pow(1.0, y) == 1.0"); } ATF_TC_BODY(pow_one_pos_x, tc) { const double y[] = { 0.0, 0.1, 2.0, -3.0, 99.0, 99.99, 9999999.9 }; const double z = 0.0L / 0.0L; size_t i; /* * For any value of y (including NaN), * if x is 1.0, 1.0 shall be returned. */ if (pow(1.0, z) != 1.0) atf_tc_fail_nonfatal("pow(1.0, NaN) != 1.0"); for (i = 0; i < __arraycount(y); i++) { if (pow(1.0, y[i]) != 1.0) atf_tc_fail_nonfatal("pow(1.0, %0.01f) != 1.0", y[i]); } } ATF_TC(pow_zero_x); ATF_TC_HEAD(pow_zero_x, tc) { atf_tc_set_md_var(tc, "descr", "Test pow(+-0.0, y) == +-0.0 || HUGE"); } ATF_TC_BODY(pow_zero_x, tc) { double z; /* * If x is +0.0 or -0.0, y > 0, and y * is an odd integer, x is returned. */ z = pow(+0.0, 3.0); if (fabs(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("pow(+0.0, 3.0) != +0.0"); z = pow(-0.0, 3.0); if (fabs(z) > 0.0 || signbit(z) == 0) atf_tc_fail_nonfatal("pow(-0.0, 3.0) != -0.0"); /* * If y > 0 and not an odd integer, * if x is +0.0 or -0.0, +0.0 is returned. */ z = pow(+0.0, 4.0); if (fabs(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("pow(+0.0, 4.0) != +0.0"); z = pow(-0.0, 4.0); if (fabs(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("pow(-0.0, 4.0) != +0.0"); /* * If y < 0 and x is +0.0 or -0.0, either +-HUGE_VAL, * +-HUGE_VALF, or +-HUGE_VALL shall be returned. */ z = pow(+0.0, -4.0); if (z != HUGE_VAL) { atf_tc_fail_nonfatal("pow(+0.0, -4.0) != HUGE_VAL"); } z = pow(-0.0, -4.0); if (z != HUGE_VAL) { atf_tc_fail_nonfatal("pow(-0.0, -4.0) != HUGE_VAL"); } z = pow(+0.0, -5.0); if (z != HUGE_VAL) { atf_tc_fail_nonfatal("pow(+0.0, -5.0) != HUGE_VAL"); } z = pow(-0.0, -5.0); if (z != -HUGE_VAL) atf_tc_fail_nonfatal("pow(-0.0, -5.0) != -HUGE_VAL"); } ATF_TC(pow_zero_y); ATF_TC_HEAD(pow_zero_y, tc) { atf_tc_set_md_var(tc, "descr", "Test pow(x, +-0.0) == 1.0"); } ATF_TC_BODY(pow_zero_y, tc) { const double x[] = { 0.1, -3.0, 77.0, 99.99, 101.0000001 }; const double z = 0.0L / 0.0L; size_t i; /* * For any value of x (including NaN), * if y is +0.0 or -0.0, 1.0 is returned. */ if (pow(z, +0.0) != 1.0) atf_tc_fail_nonfatal("pow(NaN, +0.0) != 1.0"); if (pow(z, -0.0) != 1.0) atf_tc_fail_nonfatal("pow(NaN, -0.0) != 1.0"); for (i = 0; i < __arraycount(x); i++) { if (pow(x[i], +0.0) != 1.0) atf_tc_fail_nonfatal("pow(%0.01f, +0.0) != 1.0", x[i]); if (pow(x[i], -0.0) != 1.0) atf_tc_fail_nonfatal("pow(%0.01f, -0.0) != 1.0", x[i]); } } /* * powf(3) */ ATF_TC(powf_nan_x); ATF_TC_HEAD(powf_nan_x, tc) { atf_tc_set_md_var(tc, "descr", "Test powf(NaN, y) == NaN"); } ATF_TC_BODY(powf_nan_x, tc) { const float x = 0.0L / 0.0L; ATF_CHECK(isnanf(powf(x, 2.0)) != 0); } ATF_TC(powf_nan_y); ATF_TC_HEAD(powf_nan_y, tc) { atf_tc_set_md_var(tc, "descr", "Test powf(x, NaN) == NaN"); } ATF_TC_BODY(powf_nan_y, tc) { const float y = 0.0L / 0.0L; ATF_CHECK(isnanf(powf(2.0, y)) != 0); } ATF_TC(powf_inf_neg_x); ATF_TC_HEAD(powf_inf_neg_x, tc) { atf_tc_set_md_var(tc, "descr", "Test powf(-Inf, y) == +-Inf || +-0.0"); } ATF_TC_BODY(powf_inf_neg_x, tc) { const float x = -1.0L / 0.0L; float z; /* * If y is odd, y > 0, and x is -Inf, -Inf is returned. * If y is even, y > 0, and x is -Inf, +Inf is returned. */ z = powf(x, 3.0); - if (isinff(z) == 0 || signbit(z) == 0) + if (isinf(z) == 0 || signbit(z) == 0) atf_tc_fail_nonfatal("powf(-Inf, 3.0) != -Inf"); z = powf(x, 4.0); - if (isinff(z) == 0 || signbit(z) != 0) + if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(-Inf, 4.0) != +Inf"); /* * If y is odd, y < 0, and x is -Inf, -0.0 is returned. * If y is even, y < 0, and x is -Inf, +0.0 is returned. */ z = powf(x, -3.0); if (fabsf(z) > 0.0 || signbit(z) == 0) { atf_tc_expect_fail("PR lib/45372"); atf_tc_fail_nonfatal("powf(-Inf, -3.0) != -0.0"); } z = powf(x, -4.0); if (fabsf(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(-Inf -4.0) != +0.0"); } ATF_TC(powf_inf_neg_y); ATF_TC_HEAD(powf_inf_neg_y, tc) { atf_tc_set_md_var(tc, "descr", "Test powf(x, -Inf) == +Inf || +0.0"); } ATF_TC_BODY(powf_inf_neg_y, tc) { const float y = -1.0L / 0.0L; float z; /* * If |x| < 1 and y is -Inf, +Inf is returned. * If |x| > 1 and y is -Inf, +0.0 is returned. */ z = powf(0.1, y); - if (isinff(z) == 0 || signbit(z) != 0) + if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(0.1, -Inf) != +Inf"); z = powf(1.1, y); if (fabsf(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(1.1, -Inf) != +0.0"); } ATF_TC(powf_inf_pos_x); ATF_TC_HEAD(powf_inf_pos_x, tc) { atf_tc_set_md_var(tc, "descr", "Test powf(+Inf, y) == +Inf || +0.0"); } ATF_TC_BODY(powf_inf_pos_x, tc) { const float x = 1.0L / 0.0L; float z; /* * For y < 0, if x is +Inf, +0.0 is returned. * For y > 0, if x is +Inf, +Inf is returned. */ z = powf(x, -2.0); if (fabsf(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(+Inf, -2.0) != +0.0"); z = powf(x, 2.0); - if (isinff(z) == 0 || signbit(z) != 0) + if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(+Inf, 2.0) != +Inf"); } ATF_TC(powf_inf_pos_y); ATF_TC_HEAD(powf_inf_pos_y, tc) { atf_tc_set_md_var(tc, "descr", "Test powf(x, +Inf) == +Inf || +0.0"); } ATF_TC_BODY(powf_inf_pos_y, tc) { const float y = 1.0L / 0.0L; float z; /* * If |x| < 1 and y is +Inf, +0.0 is returned. * If |x| > 1 and y is +Inf, +Inf is returned. */ z = powf(0.1, y); if (fabsf(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(0.1, +Inf) != +0.0"); z = powf(1.1, y); - if (isinff(z) == 0 || signbit(z) != 0) + if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(1.1, +Inf) != +Inf"); } ATF_TC(powf_one_neg_x); ATF_TC_HEAD(powf_one_neg_x, tc) { atf_tc_set_md_var(tc, "descr", "Test powf(-1.0, +-Inf) == 1.0"); } ATF_TC_BODY(powf_one_neg_x, tc) { const float infp = 1.0L / 0.0L; const float infn = -1.0L / 0.0L; /* * If x is -1.0, and y is +-Inf, 1.0 shall be returned. */ - ATF_REQUIRE(isinff(infp) != 0); - ATF_REQUIRE(isinff(infn) != 0); + ATF_REQUIRE(isinf(infp) != 0); + ATF_REQUIRE(isinf(infn) != 0); if (powf(-1.0, infp) != 1.0) { atf_tc_expect_fail("PR lib/45372"); atf_tc_fail_nonfatal("powf(-1.0, +Inf) != 1.0"); } if (powf(-1.0, infn) != 1.0) { atf_tc_expect_fail("PR lib/45372"); atf_tc_fail_nonfatal("powf(-1.0, -Inf) != 1.0"); } } ATF_TC(powf_one_pos_x); ATF_TC_HEAD(powf_one_pos_x, tc) { atf_tc_set_md_var(tc, "descr", "Test powf(1.0, y) == 1.0"); } ATF_TC_BODY(powf_one_pos_x, tc) { const float y[] = { 0.0, 0.1, 2.0, -3.0, 99.0, 99.99, 9999999.9 }; const float z = 0.0L / 0.0L; size_t i; /* * For any value of y (including NaN), * if x is 1.0, 1.0 shall be returned. */ if (powf(1.0, z) != 1.0) atf_tc_fail_nonfatal("powf(1.0, NaN) != 1.0"); for (i = 0; i < __arraycount(y); i++) { if (powf(1.0, y[i]) != 1.0) atf_tc_fail_nonfatal("powf(1.0, %0.01f) != 1.0", y[i]); } } ATF_TC(powf_zero_x); ATF_TC_HEAD(powf_zero_x, tc) { atf_tc_set_md_var(tc, "descr", "Test powf(+-0.0, y) == +-0.0 || HUGE"); } ATF_TC_BODY(powf_zero_x, tc) { float z; /* * If x is +0.0 or -0.0, y > 0, and y * is an odd integer, x is returned. */ z = powf(+0.0, 3.0); if (fabsf(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(+0.0, 3.0) != +0.0"); z = powf(-0.0, 3.0); if (fabsf(z) > 0.0 || signbit(z) == 0) atf_tc_fail_nonfatal("powf(-0.0, 3.0) != -0.0"); /* * If y > 0 and not an odd integer, * if x is +0.0 or -0.0, +0.0 is returned. */ z = powf(+0.0, 4.0); if (fabsf(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(+0.0, 4.0) != +0.0"); z = powf(-0.0, 4.0); if (fabsf(z) > 0.0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(-0.0, 4.0) != +0.0"); /* * If y < 0 and x is +0.0 or -0.0, either +-HUGE_VAL, * +-HUGE_VALF, or +-HUGE_VALL shall be returned. */ z = powf(+0.0, -4.0); if (z != HUGE_VALF) { atf_tc_expect_fail("PR port-amd64/45391"); atf_tc_fail_nonfatal("powf(+0.0, -4.0) != HUGE_VALF"); } z = powf(-0.0, -4.0); if (z != HUGE_VALF) { atf_tc_expect_fail("PR port-amd64/45391"); atf_tc_fail_nonfatal("powf(-0.0, -4.0) != HUGE_VALF"); } z = powf(+0.0, -5.0); if (z != HUGE_VALF) { atf_tc_expect_fail("PR port-amd64/45391"); atf_tc_fail_nonfatal("powf(+0.0, -5.0) != HUGE_VALF"); } z = powf(-0.0, -5.0); if (z != -HUGE_VALF) atf_tc_fail_nonfatal("powf(-0.0, -5.0) != -HUGE_VALF"); } ATF_TC(powf_zero_y); ATF_TC_HEAD(powf_zero_y, tc) { atf_tc_set_md_var(tc, "descr", "Test powf(x, +-0.0) == 1.0"); } ATF_TC_BODY(powf_zero_y, tc) { const float x[] = { 0.1, -3.0, 77.0, 99.99, 101.0000001 }; const float z = 0.0L / 0.0L; size_t i; /* * For any value of x (including NaN), * if y is +0.0 or -0.0, 1.0 is returned. */ if (powf(z, +0.0) != 1.0) atf_tc_fail_nonfatal("powf(NaN, +0.0) != 1.0"); if (powf(z, -0.0) != 1.0) atf_tc_fail_nonfatal("powf(NaN, -0.0) != 1.0"); for (i = 0; i < __arraycount(x); i++) { if (powf(x[i], +0.0) != 1.0) atf_tc_fail_nonfatal("powf(%0.01f, +0.0) != 1.0",x[i]); if (powf(x[i], -0.0) != 1.0) atf_tc_fail_nonfatal("powf(%0.01f, -0.0) != 1.0",x[i]); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, pow_nan_x); ATF_TP_ADD_TC(tp, pow_nan_y); ATF_TP_ADD_TC(tp, pow_inf_neg_x); ATF_TP_ADD_TC(tp, pow_inf_neg_y); ATF_TP_ADD_TC(tp, pow_inf_pos_x); ATF_TP_ADD_TC(tp, pow_inf_pos_y); ATF_TP_ADD_TC(tp, pow_one_neg_x); ATF_TP_ADD_TC(tp, pow_one_pos_x); ATF_TP_ADD_TC(tp, pow_zero_x); ATF_TP_ADD_TC(tp, pow_zero_y); ATF_TP_ADD_TC(tp, powf_nan_x); ATF_TP_ADD_TC(tp, powf_nan_y); ATF_TP_ADD_TC(tp, powf_inf_neg_x); ATF_TP_ADD_TC(tp, powf_inf_neg_y); ATF_TP_ADD_TC(tp, powf_inf_pos_x); ATF_TP_ADD_TC(tp, powf_inf_pos_y); ATF_TP_ADD_TC(tp, powf_one_neg_x); ATF_TP_ADD_TC(tp, powf_one_pos_x); ATF_TP_ADD_TC(tp, powf_zero_x); ATF_TP_ADD_TC(tp, powf_zero_y); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libm/t_precision.c =================================================================== --- head/contrib/netbsd-tests/lib/libm/t_precision.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libm/t_precision.c (revision 313439) @@ -1,79 +1,84 @@ /* $NetBSD: t_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $ */ /*- * Copyright (c) 2013 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_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $"); #include #include #include ATF_TC(t_precision); ATF_TC_HEAD(t_precision, tc) { atf_tc_set_md_var(tc, "descr", "Basic precision test for double and long double"); } volatile double x = 1; #if __HAVE_LONG_DOUBLE volatile long double y = 1; #endif ATF_TC_BODY(t_precision, tc) { +#ifdef __FreeBSD__ +#ifdef __i386__ + atf_tc_expect_fail("the __HAVE_LONG_DOUBLE checks fail on i386"); +#endif +#endif x += DBL_EPSILON; ATF_CHECK(x != 1.0); x -= 1; ATF_CHECK(x == DBL_EPSILON); x = 2; x += DBL_EPSILON; ATF_CHECK(x == 2.0); #if __HAVE_LONG_DOUBLE y += LDBL_EPSILON; ATF_CHECK(y != 1.0L); y -= 1; ATF_CHECK(y == LDBL_EPSILON); y = 2; y += LDBL_EPSILON; ATF_CHECK(y == 2.0L); #endif } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, t_precision); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libm/t_scalbn.c =================================================================== --- head/contrib/netbsd-tests/lib/libm/t_scalbn.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libm/t_scalbn.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libposix/t_rename.c =================================================================== --- head/contrib/netbsd-tests/lib/libposix/t_rename.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libposix/t_rename.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/libpthread/h_common.h =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/h_common.h (revision 313438) +++ head/contrib/netbsd-tests/lib/libpthread/h_common.h (revision 313439) @@ -1,18 +1,18 @@ #ifndef H_COMMON_H #define H_COMMON_H #include #define PTHREAD_REQUIRE(x) \ do { \ - int ret = (x); \ - ATF_REQUIRE_MSG(ret == 0, "%s: %s", #x, strerror(ret)); \ + 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)); \ + int _ret = (x); \ + ATF_REQUIRE_MSG(_ret == (v), "%s: %s", #x, strerror(_ret)); \ } while (0) #endif // H_COMMON_H Index: head/contrib/netbsd-tests/lib/libpthread/t_condwait.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/t_condwait.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libpthread/t_condwait.c (revision 313439) @@ -1,153 +1,145 @@ -/* $NetBSD: t_condwait.c,v 1.4 2013/04/12 17:18:11 christos Exp $ */ +/* $NetBSD: t_condwait.c,v 1.5 2017/01/16 16:29:19 christos Exp $ */ /* * Copyright (c) 2013 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_condwait.c,v 1.4 2013/04/12 17:18:11 christos Exp $"); +__RCSID("$NetBSD: t_condwait.c,v 1.5 2017/01/16 16:29:19 christos Exp $"); +#include #include #include #include #include #include #include #include #include #include "isqemu.h" -#ifdef __FreeBSD__ -#include - #include "h_common.h" -#endif #define WAITTIME 2 /* Timeout wait secound */ static const int debug = 1; static void * run(void *param) { struct timespec ts, to, te; clockid_t clck; pthread_condattr_t attr; pthread_cond_t cond; pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; int ret = 0; clck = *(clockid_t *)param; -#ifdef __FreeBSD__ PTHREAD_REQUIRE(pthread_condattr_init(&attr)); PTHREAD_REQUIRE(pthread_condattr_setclock(&attr, clck)); -#else - pthread_condattr_init(&attr); - pthread_condattr_setclock(&attr, clck); /* MONOTONIC or MONOTONIC */ -#endif pthread_cond_init(&cond, &attr); ATF_REQUIRE_EQ((ret = pthread_mutex_lock(&m)), 0); ATF_REQUIRE_EQ(clock_gettime(clck, &ts), 0); to = ts; if (debug) printf("started: %lld.%09ld sec\n", (long long)to.tv_sec, to.tv_nsec); ts.tv_sec += WAITTIME; /* Timeout wait */ switch (ret = pthread_cond_timedwait(&cond, &m, &ts)) { case ETIMEDOUT: /* Timeout */ ATF_REQUIRE_EQ(clock_gettime(clck, &te), 0); timespecsub(&te, &to, &to); if (debug) { printf("timeout: %lld.%09ld sec\n", (long long)te.tv_sec, te.tv_nsec); printf("elapsed: %lld.%09ld sec\n", (long long)to.tv_sec, to.tv_nsec); } if (isQEMU()) { double to_seconds = to.tv_sec + 1e-9 * to.tv_nsec; ATF_REQUIRE(to_seconds >= WAITTIME * 0.9); /* Loose upper limit because of qemu timing bugs */ ATF_REQUIRE(to_seconds < WAITTIME * 2.5); } else { ATF_REQUIRE_EQ(to.tv_sec, WAITTIME); } break; default: ATF_REQUIRE_MSG(0, "pthread_cond_timedwait: %s", strerror(ret)); } ATF_REQUIRE_MSG(!(ret = pthread_mutex_unlock(&m)), "pthread_mutex_unlock: %s", strerror(ret)); pthread_exit(&ret); } static void cond_wait(clockid_t clck, const char *msg) { pthread_t child; if (debug) printf( "**** %s clock wait starting\n", msg); ATF_REQUIRE_EQ(pthread_create(&child, NULL, run, &clck), 0); ATF_REQUIRE_EQ(pthread_join(child, NULL), 0); /* wait for terminate */ if (debug) printf( "**** %s clock wait ended\n", msg); } ATF_TC(cond_wait_real); ATF_TC_HEAD(cond_wait_real, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_cond_timedwait " "with CLOCK_REALTIME"); } ATF_TC_BODY(cond_wait_real, tc) { cond_wait(CLOCK_REALTIME, "CLOCK_REALTIME"); } ATF_TC(cond_wait_mono); ATF_TC_HEAD(cond_wait_mono, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_cond_timedwait " "with CLOCK_MONOTONIC"); } ATF_TC_BODY(cond_wait_mono, tc) { cond_wait(CLOCK_MONOTONIC, "CLOCK_MONOTONIC"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, cond_wait_real); ATF_TP_ADD_TC(tp, cond_wait_mono); return 0; } Index: head/contrib/netbsd-tests/lib/libpthread/t_detach.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/t_detach.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libpthread/t_detach.c (revision 313439) @@ -1,109 +1,96 @@ -/* $NetBSD: t_detach.c,v 1.1 2011/03/24 13:52:04 jruoho Exp $ */ +/* $NetBSD: t_detach.c,v 1.2 2017/01/16 16:29:54 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_detach.c,v 1.1 2011/03/24 13:52:04 jruoho Exp $"); +__RCSID("$NetBSD: t_detach.c,v 1.2 2017/01/16 16:29:54 christos Exp $"); -#include #include +#include +#include #include #include "h_common.h" -#ifdef __FreeBSD__ -#include -#endif - static void *func(void *); static void * func(void *arg) { -#ifdef __FreeBSD__ sleep(2); -#endif return NULL; } ATF_TC(pthread_detach); ATF_TC_HEAD(pthread_detach, tc) { atf_tc_set_md_var(tc, "descr", "A test of pthread_detach(3)"); } ATF_TC_BODY(pthread_detach, tc) { const int state = PTHREAD_CREATE_JOINABLE; pthread_attr_t attr; pthread_t t; int rv; /* * Create a joinable thread. */ PTHREAD_REQUIRE(pthread_attr_init(&attr)); PTHREAD_REQUIRE(pthread_attr_setdetachstate(&attr, state)); PTHREAD_REQUIRE(pthread_create(&t, &attr, func, NULL)); /* * Detach the thread and try to * join it; EINVAL should follow. */ PTHREAD_REQUIRE(pthread_detach(t)); -#ifdef __FreeBSD__ sleep(1); -#endif rv = pthread_join(t, NULL); ATF_REQUIRE(rv == EINVAL); -#ifdef __FreeBSD__ sleep(3); -#endif /* * As usual, ESRCH should follow if * we try to detach an invalid thread. */ -#ifdef __NetBSD__ - rv = pthread_cancel(NULL); -#else rv = pthread_cancel(t); -#endif ATF_REQUIRE(rv == ESRCH); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, pthread_detach); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libpthread/t_fork.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/t_fork.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libpthread/t_fork.c (revision 313439) @@ -1,115 +1,107 @@ -/* $NetBSD: t_fork.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $ */ +/* $NetBSD: t_fork.c,v 1.2 2017/01/16 16:28:27 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_fork.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $"); +__RCSID("$NetBSD: t_fork.c,v 1.2 2017/01/16 16:28:27 christos Exp $"); /* * Written by Love Hörnquist Åstrand , March 2003. * Public domain. */ #include #include #include #include #include #include #include #include #include #include #include "h_common.h" static pid_t parent; static int thread_survived = 0; static void * print_pid(void *arg) { sleep(3); thread_survived = 1; if (parent != getpid()) { -#ifdef __FreeBSD__ _exit(1); -#else - exit(1); -#endif } return NULL; } ATF_TC(fork); ATF_TC_HEAD(fork, tc) { atf_tc_set_md_var(tc, "descr", "Checks that child process doesn't get threads"); } ATF_TC_BODY(fork, tc) { pthread_t p; pid_t fork_pid; parent = getpid(); PTHREAD_REQUIRE(pthread_create(&p, NULL, print_pid, NULL)); fork_pid = fork(); ATF_REQUIRE(fork_pid != -1); if (fork_pid) { int status; PTHREAD_REQUIRE(pthread_join(p, NULL)); ATF_REQUIRE_MSG(thread_survived, "thread did not survive in parent"); waitpid(fork_pid, &status, 0); ATF_REQUIRE_MSG(WIFEXITED(status), "child died wrongly"); ATF_REQUIRE_EQ_MSG(WEXITSTATUS(status), 0, "thread survived in child"); } else { sleep(5); -#ifdef __FreeBSD__ _exit(thread_survived ? 1 : 0); -#else - exit(thread_survived ? 1 : 0); -#endif } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fork); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libpthread/t_fpu.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/t_fpu.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libpthread/t_fpu.c (revision 313439) @@ -1,171 +1,152 @@ -/* $NetBSD: t_fpu.c,v 1.2 2013/01/27 14:47:37 mbalmer Exp $ */ +/* $NetBSD: t_fpu.c,v 1.3 2017/01/16 16:27:43 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_fpu.c,v 1.2 2013/01/27 14:47:37 mbalmer Exp $"); +__RCSID("$NetBSD: t_fpu.c,v 1.3 2017/01/16 16:27:43 christos Exp $"); /* * This is adapted from part of csw/cstest of the MPD implementation by * the University of Arizona CS department (http://www.cs.arizona.edu/sr/) * which is in the public domain: * * "The MPD system is in the public domain and you may use and distribute it * as you wish. We ask that you retain credits referencing the University * of Arizona and that you identify any changes you make. * * We can't provide a warranty with MPD; it's up to you to determine its * suitability and reliability for your needs. We would like to hear of * any problems you encounter but we cannot promise a timely correction." * * It was changed to use pthread_create() and sched_yield() instead of * the internal MPD context switching primitives by Ignatios Souvatzis * . */ +#include #include #include #include #include +#include #include #include #include -#ifdef __FreeBSD__ -#include -#include -#endif - #include "h_common.h" #define N_RECURSE 10 static void recurse(void); int recursion_depth = 0; pthread_mutex_t recursion_depth_lock; static void * stir(void *p) { double *q = (double *)p; double x = *q++; double y = *q++; double z = *q++; for (;;) { x = sin ((y = cos (x + y + .4)) - (z = cos (x + z + .6))); -#ifdef __FreeBSD__ ATF_REQUIRE_MSG(sched_yield() == 0, "sched_yield failed: %s", strerror(errno)); -#else - PTHREAD_REQUIRE(sched_yield()); -#endif } } static double mul3(double x, double y, double z) { -#ifdef __FreeBSD__ ATF_REQUIRE_MSG(sched_yield() == 0, "sched_yield failed: %s", strerror(errno)); -#else - PTHREAD_REQUIRE(sched_yield()); -#endif return x * y * z; } static void * bar(void *p) { double d; int rc; d = mul3(mul3(2., 3., 5.), mul3(7., 11., 13.), mul3(17., 19., 23.)); ATF_REQUIRE_EQ(d, 223092870.); PTHREAD_REQUIRE(pthread_mutex_lock(&recursion_depth_lock)); rc = recursion_depth++; PTHREAD_REQUIRE(pthread_mutex_unlock(&recursion_depth_lock)); if (rc < N_RECURSE) recurse(); else atf_tc_pass(); /* NOTREACHED */ return NULL; } static void recurse(void) { pthread_t s2; -#ifdef __FreeBSD__ PTHREAD_REQUIRE(pthread_create(&s2, 0, bar, 0)); -#else - pthread_create(&s2, 0, bar, 0); -#endif sleep(20); /* XXX must be long enough for our slowest machine */ } ATF_TC(fpu); ATF_TC_HEAD(fpu, tc) { atf_tc_set_md_var(tc, "descr", "Checks that thread context switches will leave the " "floating point computations unharmed"); } ATF_TC_BODY(fpu, tc) { double stirseed[] = { 1.7, 3.2, 2.4 }; pthread_t s5; printf("Testing threaded floating point computations...\n"); PTHREAD_REQUIRE(pthread_mutex_init(&recursion_depth_lock, 0)); -#ifdef __FreeBSD__ PTHREAD_REQUIRE(pthread_create(&s5, 0, stir, stirseed)); -#else - pthread_create(&s5, 0, stir, stirseed); -#endif recurse(); atf_tc_fail("exiting from main"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fpu); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libpthread/t_join.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/t_join.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libpthread/t_join.c (revision 313439) @@ -1,181 +1,177 @@ /* $NetBSD: t_join.c,v 1.8 2012/03/12 20:17:16 joerg Exp $ */ /*- * Copyright (c) 2010 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_join.c,v 1.8 2012/03/12 20:17:16 joerg Exp $"); #include #include #include #include -#ifdef __FreeBSD__ -#include -#endif - #include "h_common.h" #ifdef CHECK_STACK_ALIGNMENT extern int check_stack_alignment(void); #endif #define STACKSIZE 65536 static bool error; static void *threadfunc1(void *); static void *threadfunc2(void *); ATF_TC(pthread_join); ATF_TC_HEAD(pthread_join, tc) { atf_tc_set_md_var(tc, "descr", "Checks basic error conditions in pthread_join(3)"); } ATF_TC_BODY(pthread_join, tc) { pthread_t thread; PTHREAD_REQUIRE(pthread_create(&thread, NULL, threadfunc1, NULL)); PTHREAD_REQUIRE(pthread_join(thread, NULL)); } static void * threadfunc1(void *arg) { pthread_t thread[25]; pthread_t caller; void *val = NULL; uintptr_t i; int rv; pthread_attr_t attr; caller = pthread_self(); #ifdef CHECK_STACK_ALIGNMENT /* * Check alignment of thread stack, if supported. */ ATF_REQUIRE(check_stack_alignment()); #endif /* * The behavior is undefined, but should error * out, if we try to join the calling thread. */ rv = pthread_join(caller, NULL); /* * The specification recommends EDEADLK. */ ATF_REQUIRE(rv != 0); ATF_REQUIRE_EQ(rv, EDEADLK); ATF_REQUIRE(pthread_attr_init(&attr) == 0); for (i = 0; i < __arraycount(thread); i++) { error = true; ATF_REQUIRE(pthread_attr_setstacksize(&attr, STACKSIZE * (i + 1)) == 0); rv = pthread_create(&thread[i], &attr, threadfunc2, (void *)i); ATF_REQUIRE_EQ(rv, 0); /* * Check join and exit condition. */ PTHREAD_REQUIRE(pthread_join(thread[i], &val)); ATF_REQUIRE_EQ(error, false); ATF_REQUIRE(val != NULL); ATF_REQUIRE(val == (void *)(i + 1)); /* * Once the thread has returned, ESRCH should * again follow if we try to join it again. */ rv = pthread_join(thread[i], NULL); ATF_REQUIRE_EQ(rv, ESRCH); /* * Try to detach the exited thread. */ rv = pthread_detach(thread[i]); ATF_REQUIRE(rv != 0); } ATF_REQUIRE(pthread_attr_destroy(&attr) == 0); pthread_exit(NULL); return NULL; } static void * threadfunc2(void *arg) { static uintptr_t i = 0; uintptr_t j; pthread_attr_t attr; size_t stacksize; j = (uintptr_t)arg; #ifdef __FreeBSD__ pthread_attr_init(&attr); #endif ATF_REQUIRE(pthread_attr_get_np(pthread_self(), &attr) == 0); ATF_REQUIRE(pthread_attr_getstacksize(&attr, &stacksize) == 0); ATF_REQUIRE(stacksize == STACKSIZE * (j + 1)); ATF_REQUIRE(pthread_attr_destroy(&attr) == 0); if (i++ == j) error = false; pthread_exit((void *)i); return NULL; } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, pthread_join); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libpthread/t_mutex.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/t_mutex.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libpthread/t_mutex.c (revision 313439) @@ -1,753 +1,747 @@ -/* $NetBSD: t_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $ */ +/* $NetBSD: t_mutex.c,v 1.15 2017/01/16 16:23: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_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $"); +__RCSID("$NetBSD: t_mutex.c,v 1.15 2017/01/16 16:23:41 christos Exp $"); -#ifdef __FreeBSD__ #include /* For timespecadd */ #include /* For UINT16_MAX */ -#endif #include #include #include #include #include #include #include #include #include #include "h_common.h" static pthread_mutex_t mutex; static pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER; static int global_x; #ifdef TIMEDMUTEX /* This code is used for verifying non-timed specific code */ static struct timespec ts_lengthy = { .tv_sec = UINT16_MAX, .tv_nsec = 0 }; /* This code is used for verifying timed-only specific code */ static struct timespec ts_shortlived = { .tv_sec = 0, .tv_nsec = 120 }; static int mutex_lock(pthread_mutex_t *m, const struct timespec *ts) { struct timespec ts_wait; ATF_REQUIRE(clock_gettime(CLOCK_REALTIME, &ts_wait) != -1); timespecadd(&ts_wait, ts, &ts_wait); return pthread_mutex_timedlock(m, &ts_wait); } #else #define mutex_lock(a, b) pthread_mutex_lock(a) #endif static void * mutex1_threadfunc(void *arg) { int *param; printf("2: Second thread.\n"); param = arg; printf("2: Locking mutex\n"); mutex_lock(&mutex, &ts_lengthy); printf("2: Got mutex. *param = %d\n", *param); ATF_REQUIRE_EQ(*param, 20); (*param)++; pthread_mutex_unlock(&mutex); return param; } ATF_TC(mutex1); ATF_TC_HEAD(mutex1, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexes"); } ATF_TC_BODY(mutex1, tc) { int x; pthread_t new; void *joinval; printf("1: Mutex-test 1\n"); PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); x = 1; PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex1_threadfunc, &x)); printf("1: Before changing the value.\n"); sleep(2); x = 20; printf("1: Before releasing the mutex.\n"); sleep(2); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); printf("1: After releasing the mutex.\n"); PTHREAD_REQUIRE(pthread_join(new, &joinval)); PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (int) was %d\n", x, *(int *)joinval); ATF_REQUIRE_EQ(x, 21); ATF_REQUIRE_EQ(*(int *)joinval, 21); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } static void * mutex2_threadfunc(void *arg) { long count = *(int *)arg; printf("2: Second thread (%p). Count is %ld\n", pthread_self(), count); while (count--) { PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } return (void *)count; } ATF_TC(mutex2); ATF_TC_HEAD(mutex2, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexes"); #ifdef __NetBSD__ #if defined(__powerpc__) atf_tc_set_md_var(tc, "timeout", "40"); #endif #endif } ATF_TC_BODY(mutex2, tc) { int count, count2; pthread_t new; void *joinval; printf("1: Mutex-test 2\n"); #ifdef __NetBSD__ #if defined(__powerpc__) atf_tc_expect_timeout("PR port-powerpc/44387"); #endif #endif PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); global_x = 0; count = count2 = 10000000; PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex2_threadfunc, &count2)); printf("1: Thread %p\n", pthread_self()); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); while (count--) { PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } PTHREAD_REQUIRE(pthread_join(new, &joinval)); PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (long) was %ld\n", global_x, (long)joinval); ATF_REQUIRE_EQ(global_x, 20000000); #ifdef __NetBSD__ #if defined(__powerpc__) /* XXX force a timeout in ppc case since an un-triggered race otherwise looks like a "failure" */ /* We sleep for longer than the timeout to make ATF not complain about unexpected success */ sleep(41); #endif #endif } static void * mutex3_threadfunc(void *arg) { long count = *(int *)arg; printf("2: Second thread (%p). Count is %ld\n", pthread_self(), count); while (count--) { PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); } return (void *)count; } ATF_TC(mutex3); ATF_TC_HEAD(mutex3, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexes using a static " "initializer"); #ifdef __NetBSD__ #if defined(__powerpc__) atf_tc_set_md_var(tc, "timeout", "40"); #endif #endif } ATF_TC_BODY(mutex3, tc) { int count, count2; pthread_t new; void *joinval; printf("1: Mutex-test 3\n"); #ifdef __NetBSD__ #if defined(__powerpc__) atf_tc_expect_timeout("PR port-powerpc/44387"); #endif #endif global_x = 0; count = count2 = 10000000; PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex3_threadfunc, &count2)); printf("1: Thread %p\n", pthread_self()); PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); while (count--) { PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); } PTHREAD_REQUIRE(pthread_join(new, &joinval)); PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (long) was %ld\n", global_x, (long)joinval); ATF_REQUIRE_EQ(global_x, 20000000); #ifdef __NetBSD__ #if defined(__powerpc__) /* XXX force a timeout in ppc case since an un-triggered race otherwise looks like a "failure" */ /* We sleep for longer than the timeout to make ATF not complain about unexpected success */ sleep(41); #endif #endif } static void * mutex4_threadfunc(void *arg) { int *param; printf("2: Second thread.\n"); param = arg; printf("2: Locking mutex\n"); PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("2: Got mutex. *param = %d\n", *param); (*param)++; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); return param; } ATF_TC(mutex4); ATF_TC_HEAD(mutex4, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexes"); } ATF_TC_BODY(mutex4, tc) { int x; pthread_t new; pthread_mutexattr_t mattr; void *joinval; printf("1: Mutex-test 4\n"); PTHREAD_REQUIRE(pthread_mutexattr_init(&mattr)); PTHREAD_REQUIRE(pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE)); PTHREAD_REQUIRE(pthread_mutex_init(&mutex, &mattr)); PTHREAD_REQUIRE(pthread_mutexattr_destroy(&mattr)); x = 1; PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex4_threadfunc, &x)); printf("1: Before recursively acquiring the mutex.\n"); PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Before releasing the mutex once.\n"); sleep(2); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); printf("1: After releasing the mutex once.\n"); x = 20; printf("1: Before releasing the mutex twice.\n"); sleep(2); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); printf("1: After releasing the mutex twice.\n"); PTHREAD_REQUIRE(pthread_join(new, &joinval)); PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (int) was %d\n", x, *(int *)joinval); ATF_REQUIRE_EQ(x, 21); ATF_REQUIRE_EQ(*(int *)joinval, 21); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } #ifdef __NetBSD__ static pthread_mutexattr_t attr5; static pthread_mutex_t mutex5; static int min_fifo_prio, max_fifo_prio; static void * child_func(void* arg) { int res; printf("child is waiting\n"); res = _sched_protect(-2); ATF_REQUIRE_EQ_MSG(res, -1, "sched_protect returned %d", res); ATF_REQUIRE_EQ(errno, ENOENT); PTHREAD_REQUIRE(mutex_lock(&mutex5, &ts_lengthy)); printf("child is owning resource\n"); res = _sched_protect(-2); ATF_REQUIRE_EQ(res, max_fifo_prio); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex5)); printf("child is done\n"); return 0; } ATF_TC(mutex5); ATF_TC_HEAD(mutex5, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexes for priority setting"); atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(mutex5, tc) { int res; struct sched_param param; pthread_t child; min_fifo_prio = sched_get_priority_min(SCHED_FIFO); max_fifo_prio = sched_get_priority_max(SCHED_FIFO); printf("min prio for FIFO = %d\n", min_fifo_prio); param.sched_priority = min_fifo_prio; /* = 0 OTHER, 1 FIFO, 2 RR, -1 NONE */ res = sched_setscheduler(getpid(), SCHED_FIFO, ¶m); printf("previous policy used = %d\n", res); res = sched_getscheduler(getpid()); ATF_REQUIRE_EQ_MSG(res, SCHED_FIFO, "sched %d != FIFO %d", res, SCHED_FIFO); PTHREAD_REQUIRE(pthread_mutexattr_init(&attr5)); PTHREAD_REQUIRE(pthread_mutexattr_setprotocol(&attr5, PTHREAD_PRIO_PROTECT)); PTHREAD_REQUIRE(pthread_mutexattr_setprioceiling(&attr5, max_fifo_prio)); PTHREAD_REQUIRE(pthread_mutex_init(&mutex5, &attr5)); PTHREAD_REQUIRE(mutex_lock(&mutex5, &ts_lengthy)); printf("enter critical section for main\n"); PTHREAD_REQUIRE(pthread_create(&child, NULL, child_func, NULL)); printf("main starts to sleep\n"); sleep(10); printf("main completes\n"); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex5)); PTHREAD_REQUIRE(pthread_join(child, NULL)); } static pthread_mutex_t mutex6; static int start = 0; static uintmax_t high_cnt = 0, low_cnt = 0, MAX_LOOP = 100000000; static void * high_prio(void* arg) { struct sched_param param; int policy; param.sched_priority = min_fifo_prio + 10; pthread_t childid = pthread_self(); PTHREAD_REQUIRE(pthread_setschedparam(childid, 1, ¶m)); PTHREAD_REQUIRE(pthread_getschedparam(childid, &policy, ¶m)); printf("high protect = %d, prio = %d\n", _sched_protect(-2), param.sched_priority); ATF_REQUIRE_EQ(policy, 1); printf("high prio = %d\n", param.sched_priority); sleep(1); long tmp = 0; for (int i = 0; i < 20; i++) { while (high_cnt < MAX_LOOP) { tmp += (123456789 % 1234) * (987654321 % 54321); high_cnt += 1; } high_cnt = 0; sleep(1); } PTHREAD_REQUIRE(mutex_lock(&mutex6, &ts_lengthy)); if (start == 0) start = 2; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex6)); return 0; } static void * low_prio(void* arg) { struct sched_param param; int policy; param.sched_priority = min_fifo_prio; pthread_t childid = pthread_self(); int res = _sched_protect(max_fifo_prio); ATF_REQUIRE_EQ(res, 0); PTHREAD_REQUIRE(pthread_setschedparam(childid, 1, ¶m)); PTHREAD_REQUIRE(pthread_getschedparam(childid, &policy, ¶m)); printf("low protect = %d, prio = %d\n", _sched_protect(-2), param.sched_priority); ATF_REQUIRE_EQ(policy, 1); printf("low prio = %d\n", param.sched_priority); sleep(1); long tmp = 0; for (int i = 0; i < 20; i++) { while (low_cnt < MAX_LOOP) { tmp += (123456789 % 1234) * (987654321 % 54321); low_cnt += 1; } low_cnt = 0; sleep(1); } PTHREAD_REQUIRE(mutex_lock(&mutex6, &ts_lengthy)); if (start == 0) start = 1; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex6)); return 0; } ATF_TC(mutex6); ATF_TC_HEAD(mutex6, tc) { atf_tc_set_md_var(tc, "descr", "Checks scheduling for priority ceiling"); atf_tc_set_md_var(tc, "require.user", "root"); } /* * 1. main thread sets itself to be a realtime task and launched two tasks, * one has higher priority and the other has lower priority. * 2. each child thread(low and high priority thread) sets its scheduler and * priority. * 3. each child thread did several rounds of computation, after each round it * sleep 1 second. * 4. the child thread with low priority will call _sched_protect to increase * its protect priority. * 5. We verify the thread with low priority runs first. * * Why does it work? From the main thread, we launched the high * priority thread first. This gives this thread the benefit of * starting first. The low priority thread did not call _sched_protect(2). * The high priority thread should finish the task first. After each * round of computation, we call sleep, to put the task into the * sleep queue, and wake up again after the timer expires. This * gives the scheduler the chance to decide which task to run. So, * the thread with real high priority will always block the thread * with real low priority. * */ ATF_TC_BODY(mutex6, tc) { struct sched_param param; int res; pthread_t high, low; min_fifo_prio = sched_get_priority_min(SCHED_FIFO); max_fifo_prio = sched_get_priority_max(SCHED_FIFO); PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); printf("min_fifo_prio = %d, max_fifo_info = %d\n", min_fifo_prio, max_fifo_prio); param.sched_priority = min_fifo_prio; res = sched_setscheduler(getpid(), SCHED_FIFO, ¶m); printf("previous policy used = %d\n", res); res = sched_getscheduler(getpid()); ATF_REQUIRE_EQ(res, 1); PTHREAD_REQUIRE(pthread_create(&high, NULL, high_prio, NULL)); PTHREAD_REQUIRE(pthread_create(&low, NULL, low_prio, NULL)); sleep(5); PTHREAD_REQUIRE(pthread_join(low, NULL)); PTHREAD_REQUIRE(pthread_join(high, NULL)); ATF_REQUIRE_EQ(start, 1); } #endif ATF_TC(mutexattr1); ATF_TC_HEAD(mutexattr1, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexattr"); } ATF_TC_BODY(mutexattr1, tc) { pthread_mutexattr_t mattr; int protocol, target; PTHREAD_REQUIRE(pthread_mutexattr_init(&mattr)); target = PTHREAD_PRIO_NONE; PTHREAD_REQUIRE(pthread_mutexattr_setprotocol(&mattr, target)); PTHREAD_REQUIRE(pthread_mutexattr_getprotocol(&mattr, &protocol)); ATF_REQUIRE_EQ(protocol, target); /* target = PTHREAD_PRIO_INHERIT; PTHREAD_REQUIRE(pthread_mutexattr_setprotocol(&mattr, target)); PTHREAD_REQUIRE(pthread_mutexattr_getprotocol(&mattr, &protocol)); ATF_REQUIRE_EQ(protocol, target); */ target = PTHREAD_PRIO_PROTECT; PTHREAD_REQUIRE(pthread_mutexattr_setprotocol(&mattr, target)); PTHREAD_REQUIRE(pthread_mutexattr_getprotocol(&mattr, &protocol)); ATF_REQUIRE_EQ(protocol, target); } ATF_TC(mutexattr2); ATF_TC_HEAD(mutexattr2, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexattr"); } ATF_TC_BODY(mutexattr2, tc) { pthread_mutexattr_t mattr; #ifdef __FreeBSD__ atf_tc_expect_fail("fails on i == 0 with: " "pthread_mutexattr_setprioceiling(&mattr, i): Invalid argument " "-- PR # 211802"); #endif PTHREAD_REQUIRE(pthread_mutexattr_init(&mattr)); int max_prio = sched_get_priority_max(SCHED_FIFO); int min_prio = sched_get_priority_min(SCHED_FIFO); for (int i = min_prio; i <= max_prio; i++) { int prioceiling; -#ifdef __FreeBSD__ int protocol; PTHREAD_REQUIRE(pthread_mutexattr_getprotocol(&mattr, &protocol)); printf("priority: %d\nprotocol: %d\n", i, protocol); -#endif PTHREAD_REQUIRE(pthread_mutexattr_setprioceiling(&mattr, i)); PTHREAD_REQUIRE(pthread_mutexattr_getprioceiling(&mattr, &prioceiling)); -#ifdef __FreeBSD__ printf("prioceiling: %d\n", prioceiling); -#endif ATF_REQUIRE_EQ(i, prioceiling); } } #ifdef TIMEDMUTEX ATF_TC(timedmutex1); ATF_TC_HEAD(timedmutex1, tc) { atf_tc_set_md_var(tc, "descr", "Checks timeout on selflock"); } ATF_TC_BODY(timedmutex1, tc) { printf("Timed mutex-test 1\n"); PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); printf("Before acquiring mutex\n"); PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); printf("Before endeavor to reacquire timed-mutex (timeout expected)\n"); PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived), ETIMEDOUT); printf("Unlocking mutex\n"); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } ATF_TC(timedmutex2); ATF_TC_HEAD(timedmutex2, tc) { atf_tc_set_md_var(tc, "descr", "Checks timeout on selflock with timedlock"); } ATF_TC_BODY(timedmutex2, tc) { printf("Timed mutex-test 2\n"); PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); printf("Before acquiring mutex with timedlock\n"); PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("Before endeavor to reacquire timed-mutex (timeout expected)\n"); PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived), ETIMEDOUT); printf("Unlocking mutex\n"); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } ATF_TC(timedmutex3); ATF_TC_HEAD(timedmutex3, tc) { atf_tc_set_md_var(tc, "descr", "Checks timeout on selflock in a new thread"); } static void * timedmtx_thrdfunc(void *arg) { printf("Before endeavor to reacquire timed-mutex (timeout expected)\n"); PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived), ETIMEDOUT); return NULL; } ATF_TC_BODY(timedmutex3, tc) { pthread_t new; printf("Timed mutex-test 3\n"); PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); printf("Before acquiring mutex with timedlock\n"); PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); printf("Before creating new thread\n"); PTHREAD_REQUIRE(pthread_create(&new, NULL, timedmtx_thrdfunc, NULL)); printf("Before joining the mutex\n"); PTHREAD_REQUIRE(pthread_join(new, NULL)); printf("Unlocking mutex\n"); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } ATF_TC(timedmutex4); ATF_TC_HEAD(timedmutex4, tc) { atf_tc_set_md_var(tc, "descr", "Checks timeout on selflock with timedlock in a new thread"); } ATF_TC_BODY(timedmutex4, tc) { pthread_t new; printf("Timed mutex-test 4\n"); PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); printf("Before acquiring mutex with timedlock\n"); PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("Before creating new thread\n"); PTHREAD_REQUIRE(pthread_create(&new, NULL, timedmtx_thrdfunc, NULL)); printf("Before joining the mutex\n"); PTHREAD_REQUIRE(pthread_join(new, NULL)); printf("Unlocking mutex\n"); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } #endif ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, mutex1); ATF_TP_ADD_TC(tp, mutex2); ATF_TP_ADD_TC(tp, mutex3); ATF_TP_ADD_TC(tp, mutex4); #ifdef __NetBSD__ ATF_TP_ADD_TC(tp, mutex5); ATF_TP_ADD_TC(tp, mutex6); #endif ATF_TP_ADD_TC(tp, mutexattr1); ATF_TP_ADD_TC(tp, mutexattr2); #ifdef TIMEDMUTEX ATF_TP_ADD_TC(tp, timedmutex1); ATF_TP_ADD_TC(tp, timedmutex2); ATF_TP_ADD_TC(tp, timedmutex3); ATF_TP_ADD_TC(tp, timedmutex4); #endif return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libpthread/t_once.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/t_once.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libpthread/t_once.c (revision 313439) @@ -1,200 +1,199 @@ /* $NetBSD: t_once.c,v 1.1 2010/07/16 15:42:53 jmmv 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_once.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $"); +#ifdef __FreeBSD__ +#include /* For itimer*, etc. */ +#endif #include #include #include #include #include #include "h_common.h" static pthread_once_t once = PTHREAD_ONCE_INIT; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static int x; #define NTHREADS 25 - -#ifdef __FreeBSD__ -#include -#endif static void ofunc(void) { printf("Variable x has value %d\n", x); x++; } ATF_TC(once1); ATF_TC_HEAD(once1, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_once()"); } ATF_TC_BODY(once1, tc) { printf("1: Test 1 of pthread_once()\n"); PTHREAD_REQUIRE(pthread_once(&once, ofunc)); PTHREAD_REQUIRE(pthread_once(&once, ofunc)); printf("1: X has value %d\n",x ); ATF_REQUIRE_EQ(x, 1); } static void once2_ofunc(void) { x++; printf("ofunc: Variable x has value %d\n", x); x++; } static void * once2_threadfunc(void *arg) { int num; PTHREAD_REQUIRE(pthread_once(&once, once2_ofunc)); num = *(int *)arg; printf("Thread %d sees x with value %d\n", num, x); ATF_REQUIRE_EQ(x, 2); return NULL; } ATF_TC(once2); ATF_TC_HEAD(once2, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_once()"); } ATF_TC_BODY(once2, tc) { pthread_t threads[NTHREADS]; int id[NTHREADS]; int i; printf("1: Test 2 of pthread_once()\n"); for (i=0; i < NTHREADS; i++) { id[i] = i; PTHREAD_REQUIRE(pthread_create(&threads[i], NULL, once2_threadfunc, &id[i])); } for (i=0; i < NTHREADS; i++) PTHREAD_REQUIRE(pthread_join(threads[i], NULL)); printf("1: X has value %d\n",x ); ATF_REQUIRE_EQ(x, 2); } static void once3_cleanup(void *m) { pthread_mutex_t *mu = m; PTHREAD_REQUIRE(pthread_mutex_unlock(mu)); } static void once3_ofunc(void) { pthread_testcancel(); } static void * once3_threadfunc(void *arg) { PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); pthread_cleanup_push(once3_cleanup, &mutex); PTHREAD_REQUIRE(pthread_once(&once, once3_ofunc)); pthread_cleanup_pop(1); return NULL; } static void handler(int sig, siginfo_t *info, void *ctx) { atf_tc_fail("Signal handler was called; " "main thread deadlocked in pthread_once()"); } ATF_TC(once3); ATF_TC_HEAD(once3, tc) { atf_tc_set_md_var(tc, "descr", "Checks pthread_once()"); } ATF_TC_BODY(once3, tc) { pthread_t thread; struct sigaction act; struct itimerval it; printf("Test 3 of pthread_once() (test versus cancellation)\n"); act.sa_sigaction = handler; sigemptyset(&act.sa_mask); act.sa_flags = SA_SIGINFO; sigaction(SIGALRM, &act, NULL); timerclear(&it.it_value); it.it_value.tv_usec = 500000; timerclear(&it.it_interval); setitimer(ITIMER_REAL, &it, NULL); PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); PTHREAD_REQUIRE(pthread_create(&thread, NULL, once3_threadfunc, NULL)); PTHREAD_REQUIRE(pthread_cancel(thread)); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); PTHREAD_REQUIRE(pthread_join(thread, NULL)); PTHREAD_REQUIRE(pthread_once(&once, ofunc)); /* Cancel timer */ timerclear(&it.it_value); setitimer(ITIMER_REAL, &it, NULL); printf("Test succeeded\n"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, once1); ATF_TP_ADD_TC(tp, once2); ATF_TP_ADD_TC(tp, once3); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libpthread/t_sem.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/t_sem.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libpthread/t_sem.c (revision 313439) @@ -1,310 +1,307 @@ -/* $NetBSD: t_sem.c,v 1.8 2014/11/04 00:20:19 justin Exp $ */ +/* $NetBSD: t_sem.c,v 1.9 2017/01/16 16:22:22 christos Exp $ */ /* * Copyright (c) 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. */ /*- * 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. */ /**************************************************************************** * * Copyright (C) 2000 Jason Evans . * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice(s), this list of conditions and the following disclaimer as * the first lines of this file unmodified other than the possible * addition of one or more copyright notices. * 2. Redistributions in binary form must reproduce the above copyright * notice(s), this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ #include __COPYRIGHT("@(#) Copyright (c) 2008, 2010\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_sem.c,v 1.8 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_sem.c,v 1.9 2017/01/16 16:22:22 christos Exp $"); +#include #include #include #include #include #include #include #include #include #include #include #include "h_common.h" #define NTHREADS 10 #define _LIBC_R_ #define SEM_REQUIRE(x) \ ATF_REQUIRE_EQ_MSG(x, 0, "%s", strerror(errno)) static sem_t sem; - -#ifdef __FreeBSD__ -#include -#endif ATF_TC(named); ATF_TC_HEAD(named, tc) { atf_tc_set_md_var(tc, "descr", "Checks named semaphores"); } ATF_TC_BODY(named, tc) { sem_t *semp; ATF_REQUIRE_MSG(-1 != sysconf(_SC_SEMAPHORES), "%s", strerror(errno)); printf("Test begin\n"); (void) sem_unlink("/foo"); semp = sem_open("/foo", O_CREAT | O_EXCL, 0644, 0); ATF_REQUIRE_MSG(semp != SEM_FAILED, "%s", strerror(errno)); SEM_REQUIRE(sem_close(semp)); SEM_REQUIRE(sem_unlink("/foo")); printf("Test end\n"); } ATF_TC(unnamed); ATF_TC_HEAD(unnamed, tc) { atf_tc_set_md_var(tc, "descr", "Checks unnamed semaphores"); } static void * entry(void * a_arg) { pthread_t self = pthread_self(); sem_t *semp = (sem_t *) a_arg; printf("Thread %p waiting for semaphore...\n", self); sem_wait(semp); printf("Thread %p got semaphore\n", self); return NULL; } ATF_TC_BODY(unnamed, tc) { sem_t sem_a, sem_b; pthread_t threads[NTHREADS]; unsigned i, j; int val; ATF_REQUIRE_MSG(-1 != sysconf(_SC_SEMAPHORES), "%s", strerror(errno)); printf("Test begin\n"); SEM_REQUIRE(sem_init(&sem_b, 0, 0)); SEM_REQUIRE(sem_getvalue(&sem_b, &val)); ATF_REQUIRE_EQ(0, val); SEM_REQUIRE(sem_post(&sem_b)); SEM_REQUIRE(sem_getvalue(&sem_b, &val)); ATF_REQUIRE_EQ(1, val); SEM_REQUIRE(sem_wait(&sem_b)); ATF_REQUIRE_EQ(sem_trywait(&sem_b), -1); ATF_REQUIRE_EQ(errno, EAGAIN); SEM_REQUIRE(sem_post(&sem_b)); SEM_REQUIRE(sem_trywait(&sem_b)); SEM_REQUIRE(sem_post(&sem_b)); SEM_REQUIRE(sem_wait(&sem_b)); SEM_REQUIRE(sem_post(&sem_b)); SEM_REQUIRE(sem_destroy(&sem_b)); SEM_REQUIRE(sem_init(&sem_a, 0, 0)); for (j = 0; j < 2; j++) { for (i = 0; i < NTHREADS; i++) { PTHREAD_REQUIRE(pthread_create(&threads[i], NULL, entry, (void *) &sem_a)); } for (i = 0; i < NTHREADS; i++) { usleep(10000); printf("main loop %u: posting...\n", j+1); SEM_REQUIRE(sem_post(&sem_a)); } for (i = 0; i < NTHREADS; i++) { PTHREAD_REQUIRE(pthread_join(threads[i], NULL)); } } SEM_REQUIRE(sem_destroy(&sem_a)); printf("Test end\n"); } static void sighandler(int signo) { /* printf("signal %d\n", signo); */ ATF_REQUIRE_EQ_MSG(signo, SIGALRM, "unexpected signal"); SEM_REQUIRE(sem_post(&sem)); } static void alarm_ms(const int ms) { struct itimerval timer; timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = 0; timer.it_value.tv_sec = 0; timer.it_value.tv_usec = ms * 1000; ATF_REQUIRE(setitimer(ITIMER_REAL, &timer, NULL) == 0); } static void * threadfunc(void *arg) { int i, ret; printf("Entering loop\n"); for (i = 0; i < 500; ) { if ((i & 1) != 0) { do { ret = sem_wait(&sem); } while (ret == -1 && errno == EINTR); ATF_REQUIRE(ret == 0); } else { ret = sem_trywait(&sem); if (ret == -1) { ATF_REQUIRE(errno == EAGAIN); continue; } } printf("%s: %d\n", __func__, i); alarm_ms(5); i++; } return NULL; } static void before_start_test(const bool use_pthread) { pthread_t t; SEM_REQUIRE(sem_init(&sem, 0, 0)); ATF_REQUIRE(SIG_ERR != signal(SIGALRM, sighandler)); alarm_ms(5); if (use_pthread) { PTHREAD_REQUIRE(pthread_create(&t, NULL, threadfunc, NULL)); PTHREAD_REQUIRE(pthread_join(t, NULL)); } else { threadfunc(NULL); } } ATF_TC(before_start_no_threads); ATF_TC_HEAD(before_start_no_threads, tc) { atf_tc_set_md_var(tc, "descr", "Checks using semaphores without any " "thread running"); atf_tc_set_md_var(tc, "timeout", "40"); } ATF_TC_BODY(before_start_no_threads, tc) { before_start_test(false); } ATF_TC(before_start_one_thread); ATF_TC_HEAD(before_start_one_thread, tc) { atf_tc_set_md_var(tc, "descr", "Checks using semaphores before " "starting one thread"); atf_tc_set_md_var(tc, "timeout", "40"); } ATF_TC_BODY(before_start_one_thread, tc) { before_start_test(true); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, named); ATF_TP_ADD_TC(tp, unnamed); ATF_TP_ADD_TC(tp, before_start_no_threads); ATF_TP_ADD_TC(tp, before_start_one_thread); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c (revision 313438) +++ head/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c (revision 313439) @@ -1,136 +1,126 @@ -/* $NetBSD: t_swapcontext.c,v 1.2 2014/08/25 16:31:15 bouyer Exp $ */ +/* $NetBSD: t_swapcontext.c,v 1.3 2017/01/16 16:27:06 christos Exp $ */ /* * Copyright (c) 2012 Emmanuel Dreyfus. 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"); -#ifdef __FreeBSD__ #include #include -#include -#endif #include -#include #include #include +#include +#include #include #include "h_common.h" #define STACKSIZE 65536 char stack[STACKSIZE]; ucontext_t nctx; ucontext_t octx; void *oself; void *nself; int val1, val2; /* ARGSUSED0 */ static void swapfunc(void *arg) { /* * If the test fails, we are very likely to crash * without the opportunity to report */ nself = (void *)pthread_self(); printf("after swapcontext self = %p\n", nself); ATF_REQUIRE_EQ(oself, nself); printf("Test succeeded\n"); /* Go back in main */ ATF_REQUIRE(swapcontext(&nctx, &octx)); /* NOTREACHED */ return; } /* ARGSUSED0 */ static void * threadfunc(void *arg) { nctx.uc_stack.ss_sp = stack; nctx.uc_stack.ss_size = sizeof(stack); makecontext(&nctx, (void *)*swapfunc, 0); oself = (void *)pthread_self(); printf("before swapcontext self = %p\n", oself); -#ifdef __FreeBSD__ ATF_REQUIRE_MSG(swapcontext(&octx, &nctx) != -1, "swapcontext failed: %s", strerror(errno)); -#else - PTHREAD_REQUIRE(swapcontext(&octx, &nctx)); -#endif /* NOTREACHED */ return NULL; } ATF_TC(swapcontext1); ATF_TC_HEAD(swapcontext1, tc) { atf_tc_set_md_var(tc, "descr", "Testing if swapcontext() " "alters pthread_self()"); } ATF_TC_BODY(swapcontext1, tc) { pthread_t thread; #if defined(__FreeBSD__) && defined(__mips__) /* * MIPS modifies TLS pointer in set_mcontext(), so * swapping contexts obtained from different threads * gives us different pthread_self() return value. */ atf_tc_skip("Platform is not supported."); #endif oself = (void *)&val1; nself = (void *)&val2; printf("Testing if swapcontext() alters pthread_self()\n"); -#ifdef __FreeBSD__ ATF_REQUIRE_MSG(getcontext(&nctx) != -1, "getcontext failed: %s", strerror(errno)); -#else - PTHREAD_REQUIRE(getcontext(&nctx)); -#endif PTHREAD_REQUIRE(pthread_create(&thread, NULL, threadfunc, NULL)); PTHREAD_REQUIRE(pthread_join(thread, NULL)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, swapcontext1); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libpthread_dbg/h_common.h =================================================================== --- head/contrib/netbsd-tests/lib/libpthread_dbg/h_common.h (nonexistent) +++ head/contrib/netbsd-tests/lib/libpthread_dbg/h_common.h (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/lib/libpthread_dbg/t_dummy.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread_dbg/t_dummy.c (nonexistent) +++ head/contrib/netbsd-tests/lib/libpthread_dbg/t_dummy.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/lib/libpthread_dbg/t_threads.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread_dbg/t_threads.c (nonexistent) +++ head/contrib/netbsd-tests/lib/libpthread_dbg/t_threads.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/lib/librefuse/t_refuse_opt.c =================================================================== --- head/contrib/netbsd-tests/lib/librefuse/t_refuse_opt.c (nonexistent) +++ head/contrib/netbsd-tests/lib/librefuse/t_refuse_opt.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/lib/librt/t_sem.c =================================================================== --- head/contrib/netbsd-tests/lib/librt/t_sem.c (revision 313438) +++ head/contrib/netbsd-tests/lib/librt/t_sem.c (revision 313439) @@ -1,181 +1,183 @@ -/* $NetBSD: t_sem.c,v 1.2 2010/11/08 13:05:49 njoly Exp $ */ +/* $NetBSD: t_sem.c,v 1.3 2017/01/14 20:58:20 christos Exp $ */ /* * Copyright (c) 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. */ /* * Copyright (C) 2000 Jason Evans . * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice(s), this list of conditions and the following disclaimer as * the first lines of this file unmodified other than the possible * addition of one or more copyright notices. * 2. Redistributions in binary form must reproduce the above copyright * notice(s), this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __COPYRIGHT("@(#) Copyright (c) 2008, 2010\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_sem.c,v 1.2 2010/11/08 13:05:49 njoly Exp $"); +__RCSID("$NetBSD: t_sem.c,v 1.3 2017/01/14 20:58:20 christos Exp $"); #include #include #include #include #include #include #include #define NCHILDREN 10 -ATF_TC(basic); +ATF_TC_WITH_CLEANUP(basic); ATF_TC_HEAD(basic, tc) { atf_tc_set_md_var(tc, "descr", "Checks basic functionality of POSIX " "semaphores"); } ATF_TC_BODY(basic, tc) { int val; sem_t *sem_b; if (sysconf(_SC_SEMAPHORES) == -1) atf_tc_skip("POSIX semaphores not supported"); -#ifdef __FreeBSD__ - sem_unlink("/sem_b"); -#endif sem_b = sem_open("/sem_b", O_CREAT | O_EXCL, 0644, 0); ATF_REQUIRE(sem_b != SEM_FAILED); ATF_REQUIRE_EQ(sem_getvalue(sem_b, &val), 0); ATF_REQUIRE_EQ(val, 0); ATF_REQUIRE_EQ(sem_post(sem_b), 0); ATF_REQUIRE_EQ(sem_getvalue(sem_b, &val), 0); ATF_REQUIRE_EQ(val, 1); ATF_REQUIRE_EQ(sem_wait(sem_b), 0); ATF_REQUIRE_EQ(sem_trywait(sem_b), -1); ATF_REQUIRE_EQ(errno, EAGAIN); ATF_REQUIRE_EQ(sem_post(sem_b), 0); ATF_REQUIRE_EQ(sem_trywait(sem_b), 0); ATF_REQUIRE_EQ(sem_post(sem_b), 0); ATF_REQUIRE_EQ(sem_wait(sem_b), 0); ATF_REQUIRE_EQ(sem_post(sem_b), 0); ATF_REQUIRE_EQ(sem_close(sem_b), 0); ATF_REQUIRE_EQ(sem_unlink("/sem_b"), 0); } +ATF_TC_CLEANUP(basic, tc) +{ + (void)sem_unlink("/sem_b"); +} -ATF_TC(child); +ATF_TC_WITH_CLEANUP(child); ATF_TC_HEAD(child, tc) { atf_tc_set_md_var(tc, "descr", "Checks using semaphores to synchronize " "parent with multiple child processes"); } ATF_TC_BODY(child, tc) { pid_t children[NCHILDREN]; unsigned i, j; sem_t *sem_a; int status; pid_t pid; - if (sysconf(_SC_SEMAPHORES) == -1) + if (sysconf(_SC_SEMAPHORES) == -1) atf_tc_skip("POSIX semaphores not supported"); -#ifdef __FreeBSD__ - sem_unlink("/sem_a"); -#endif sem_a = sem_open("/sem_a", O_CREAT | O_EXCL, 0644, 0); ATF_REQUIRE(sem_a != SEM_FAILED); for (j = 1; j <= 2; j++) { for (i = 0; i < NCHILDREN; i++) { switch ((pid = fork())) { case -1: atf_tc_fail("fork() returned -1"); case 0: printf("PID %d waiting for semaphore...\n", getpid()); ATF_REQUIRE_MSG(sem_wait(sem_a) == 0, "sem_wait failed; iteration %d", j); printf("PID %d got semaphore\n", getpid()); _exit(0); default: children[i] = pid; break; } } for (i = 0; i < NCHILDREN; i++) { sleep(1); printf("main loop %d: posting...\n", j); ATF_REQUIRE_EQ(sem_post(sem_a), 0); } for (i = 0; i < NCHILDREN; i++) { ATF_REQUIRE_EQ(waitpid(children[i], &status, 0), children[i]); ATF_REQUIRE(WIFEXITED(status)); ATF_REQUIRE_EQ(WEXITSTATUS(status), 0); } } ATF_REQUIRE_EQ(sem_close(sem_a), 0); ATF_REQUIRE_EQ(sem_unlink("/sem_a"), 0); +} +ATF_TC_CLEANUP(child, tc) +{ + (void)sem_unlink("/sem_a"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, basic); ATF_TP_ADD_TC(tp, child); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/librumpclient/t_fd.c =================================================================== --- head/contrib/netbsd-tests/lib/librumpclient/t_fd.c (revision 313438) +++ head/contrib/netbsd-tests/lib/librumpclient/t_fd.c (revision 313439) @@ -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: head/contrib/netbsd-tests/lib/semaphore/sem.c =================================================================== --- head/contrib/netbsd-tests/lib/semaphore/sem.c (revision 313438) +++ head/contrib/netbsd-tests/lib/semaphore/sem.c (revision 313439) @@ -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: head/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-cleared.c =================================================================== --- head/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-cleared.c (revision 313438) +++ head/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-cleared.c (revision 313439) @@ -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: head/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-false.c =================================================================== --- head/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-false.c (revision 313438) +++ head/contrib/netbsd-tests/libexec/ld.elf_so/t_dlerror-false.c (revision 313439) @@ -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: head/contrib/netbsd-tests/libexec/ld.elf_so/t_dlinfo.c =================================================================== --- head/contrib/netbsd-tests/libexec/ld.elf_so/t_dlinfo.c (revision 313438) +++ head/contrib/netbsd-tests/libexec/ld.elf_so/t_dlinfo.c (revision 313439) @@ -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: head/contrib/netbsd-tests/libexec/ld.elf_so/t_ifunc.c =================================================================== --- head/contrib/netbsd-tests/libexec/ld.elf_so/t_ifunc.c (revision 313438) +++ head/contrib/netbsd-tests/libexec/ld.elf_so/t_ifunc.c (revision 313439) @@ -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: head/contrib/netbsd-tests/modules/t_builtin.c =================================================================== --- head/contrib/netbsd-tests/modules/t_builtin.c (revision 313438) +++ head/contrib/netbsd-tests/modules/t_builtin.c (revision 313439) @@ -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: head/contrib/netbsd-tests/net/bpf/t_bpf.c =================================================================== --- head/contrib/netbsd-tests/net/bpf/t_bpf.c (revision 313438) +++ head/contrib/netbsd-tests/net/bpf/t_bpf.c (revision 313439) @@ -1,177 +1,211 @@ -/* $NetBSD: t_bpf.c,v 1.5 2012/08/14 19:40:30 alnsn Exp $ */ +/* $NetBSD: t_bpf.c,v 1.7 2017/02/01 08:04:49 ozaki-r 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.7 2017/02/01 08:04:49 ozaki-r 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_TC(bpf_ioctl_BLEN); +ATF_TC_HEAD(bpf_ioctl_BLEN, tc) +{ + + atf_tc_set_md_var(tc, "descr", "Checks behaviors of BIOCGBLEN and " + "BIOCSBLEN"); +} + +ATF_TC_BODY(bpf_ioctl_BLEN, tc) +{ + struct ifreq ifr; + int ifnum, bpfd; + u_int blen = 0; + + 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, BIOCGBLEN, &blen)); + ATF_REQUIRE(blen != 0); + blen = 100; + RL(rump_sys_ioctl(bpfd, BIOCSBLEN, &blen)); + RL(rump_sys_ioctl(bpfd, BIOCGBLEN, &blen)); + ATF_REQUIRE_EQ(blen, 100); + + RL(rump_sys_ioctl(bpfd, BIOCSETIF, &ifr)); + + ATF_REQUIRE_EQ_MSG(rump_sys_ioctl(bpfd, BIOCSBLEN, &blen), -1, + "Don't allow to change buflen after binding bpf to an interface"); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, bpfwriteleak); #if (SIZE_MAX > UINT_MAX) ATF_TP_ADD_TC(tp, bpfwritetrunc); #endif + ATF_TP_ADD_TC(tp, bpf_ioctl_BLEN); return atf_no_error(); } Index: head/contrib/netbsd-tests/net/bpf/t_mbuf.c =================================================================== --- head/contrib/netbsd-tests/net/bpf/t_mbuf.c (revision 313438) +++ head/contrib/netbsd-tests/net/bpf/t_mbuf.c (revision 313439) @@ -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: head/contrib/netbsd-tests/net/bpfilter/t_bpfilter.c =================================================================== --- head/contrib/netbsd-tests/net/bpfilter/t_bpfilter.c (revision 313438) +++ head/contrib/netbsd-tests/net/bpfilter/t_bpfilter.c (revision 313439) @@ -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: head/contrib/netbsd-tests/net/bpfjit/t_bpfjit.c =================================================================== --- head/contrib/netbsd-tests/net/bpfjit/t_bpfjit.c (revision 313438) +++ head/contrib/netbsd-tests/net/bpfjit/t_bpfjit.c (revision 313439) @@ -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: head/contrib/netbsd-tests/net/bpfjit/t_cop.c =================================================================== --- head/contrib/netbsd-tests/net/bpfjit/t_cop.c (revision 313438) +++ head/contrib/netbsd-tests/net/bpfjit/t_cop.c (revision 313439) @@ -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: head/contrib/netbsd-tests/net/bpfjit/t_extmem.c =================================================================== --- head/contrib/netbsd-tests/net/bpfjit/t_extmem.c (revision 313438) +++ head/contrib/netbsd-tests/net/bpfjit/t_extmem.c (revision 313439) @@ -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: head/contrib/netbsd-tests/net/bpfjit/t_mbuf.c =================================================================== --- head/contrib/netbsd-tests/net/bpfjit/t_mbuf.c (revision 313438) +++ head/contrib/netbsd-tests/net/bpfjit/t_mbuf.c (revision 313439) @@ -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: head/contrib/netbsd-tests/net/carp/t_basic.c =================================================================== --- head/contrib/netbsd-tests/net/carp/t_basic.c (revision 313438) +++ head/contrib/netbsd-tests/net/carp/t_basic.c (nonexistent) @@ -1,221 +0,0 @@ -/* $NetBSD: t_basic.c,v 1.5 2011/06/26 13:13:31 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 $"); -#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" - -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(); -} Property changes on: head/contrib/netbsd-tests/net/carp/t_basic.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/contrib/netbsd-tests/net/carp/t_basic.sh =================================================================== --- head/contrib/netbsd-tests/net/carp/t_basic.sh (nonexistent) +++ head/contrib/netbsd-tests/net/carp/t_basic.sh (revision 313439) @@ -0,0 +1,165 @@ +# $NetBSD: t_basic.sh,v 1.1 2017/01/16 08:18:11 ozaki-r Exp $ +# +# Copyright (c) 2017 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. +# + +SOCK_CLIENT=unix://carp_client +SOCK_MASTER=unix://carp_master +SOCK_BACKUP=unix://carp_backup +BUS=bus_carp +IP_CLIENT=10.1.1.240 +IP_MASTER=10.1.1.1 +IP_BACKUP=10.1.1.2 +IP_CARP=10.1.1.100 +TIMEOUT=3 + +atf_test_case carp_handover cleanup + +carp_handover_head() +{ + + atf_set "descr" "Tests for CARP handover" + atf_set "require.progs" "rump_server" +} + +setup_carp() +{ + local sock=$1 + local master=$2 + local carpif= ip= advskew= + + if $master; then + carpif=carp0 + ip=$IP_MASTER + advskew=0 + else + carpif=carp1 + ip=$IP_BACKUP + advskew=200 + fi + + export RUMP_SERVER=$sock + atf_check -s exit:0 rump.ifconfig $carpif create + atf_check -s exit:0 rump.ifconfig shmif0 $ip/24 up + atf_check -s exit:0 rump.ifconfig $carpif \ + vhid 175 advskew $advskew advbase 1 pass s3cret \ + $IP_CARP netmask 255.255.255.0 + atf_check -s exit:0 rump.ifconfig -w 10 +} + +wait_handover() +{ + local i=0 + + export RUMP_SERVER=$SOCK_CLIENT + + while [ $i -ne 5 ]; do + $DEBUG && echo "Trying ping $IP_CARP" + rump.ping -n -w 1 -c 1 $IP_CARP >/dev/null + if [ $? = 0 ]; then + $DEBUG && echo "Passed ping $IP_CARP" + break; + fi + $DEBUG && echo "Failed ping $IP_CARP" + i=$((i + 1)) + done + + if [ $i -eq 5 ]; then + atf_fail "Failed to failover (5 sec)" + fi +} + +carp_handover_body() +{ + + rump_server_start $SOCK_CLIENT + rump_server_start $SOCK_MASTER + rump_server_start $SOCK_BACKUP + + rump_server_add_iface $SOCK_CLIENT shmif0 $BUS + rump_server_add_iface $SOCK_MASTER shmif0 $BUS + rump_server_add_iface $SOCK_BACKUP shmif0 $BUS + + setup_carp $SOCK_MASTER true + setup_carp $SOCK_BACKUP false + + export RUMP_SERVER=$SOCK_CLIENT + atf_check -s exit:0 rump.ifconfig shmif0 $IP_CLIENT/24 up + atf_check -s exit:0 rump.ifconfig -w 10 + + # Check that the primary addresses are up + atf_check -s exit:0 -o ignore \ + rump.ping -n -w $TIMEOUT -c 1 $IP_MASTER + atf_check -s exit:0 -o ignore \ + rump.ping -n -w $TIMEOUT -c 1 $IP_BACKUP + + # Give carp a while to croak + sleep 4 + + # Check state + export RUMP_SERVER=$SOCK_MASTER + $DEBUG && rump.ifconfig + atf_check -s exit:0 -o match:'carp: MASTER carpdev shmif0' \ + rump.ifconfig carp0 + export RUMP_SERVER=$SOCK_BACKUP + $DEBUG && rump.ifconfig + atf_check -s exit:0 -o match:'carp: BACKUP carpdev shmif0' \ + rump.ifconfig carp1 + export RUMP_SERVER=$SOCK_CLIENT + + # Check that the shared IP works + atf_check -s exit:0 -o ignore \ + rump.ping -n -w $TIMEOUT -c 1 $IP_CARP + + # KILLING SPREE + env RUMP_SERVER=$SOCK_MASTER rump.halt + sleep 1 + + # Check that primary is now dead + atf_check -s not-exit:0 -o ignore \ + rump.ping -n -w $TIMEOUT -c 1 $IP_MASTER + + # Do it in installments. carp will cluck meanwhile + wait_handover + + # Check state + export RUMP_SERVER=$SOCK_BACKUP + $DEBUG && rump.ifconfig + atf_check -s exit:0 -o match:'carp: MASTER carpdev shmif0' \ + rump.ifconfig carp1 +} + +carp_handover_cleanup() +{ + + $DEBUG && dump + cleanup +} + +atf_init_test_cases() +{ + + atf_add_test_case carp_handover +} Property changes on: head/contrib/netbsd-tests/net/carp/t_basic.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: head/contrib/netbsd-tests/net/config/netconfig.c =================================================================== --- head/contrib/netbsd-tests/net/config/netconfig.c (revision 313438) +++ head/contrib/netbsd-tests/net/config/netconfig.c (revision 313439) @@ -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: head/contrib/netbsd-tests/net/icmp/t_forward.c =================================================================== --- head/contrib/netbsd-tests/net/icmp/t_forward.c (revision 313438) +++ head/contrib/netbsd-tests/net/icmp/t_forward.c (revision 313439) @@ -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: head/contrib/netbsd-tests/net/icmp/t_ping.c =================================================================== --- head/contrib/netbsd-tests/net/icmp/t_ping.c (revision 313438) +++ head/contrib/netbsd-tests/net/icmp/t_ping.c (revision 313439) @@ -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: head/contrib/netbsd-tests/net/if/t_ifconfig.sh =================================================================== --- head/contrib/netbsd-tests/net/if/t_ifconfig.sh (revision 313438) +++ head/contrib/netbsd-tests/net/if/t_ifconfig.sh (revision 313439) @@ -1,333 +1,333 @@ -# $NetBSD: t_ifconfig.sh,v 1.14 2016/10/01 22:15:04 kre Exp $ +# $NetBSD: t_ifconfig.sh,v 1.15 2017/01/20 08:35:33 ozaki-r Exp $ # # Copyright (c) 2015 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. # RUMP_SERVER1=unix://./r1 RUMP_SERVER2=unix://./r2 RUMP_FLAGS=\ "-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif" RUMP_FLAGS="${RUMP_FLAGS} -lrumpdev" TIMEOUT=3 anycast="[Aa][Nn][Yy][Cc][Aa][Ss][Tt]" deprecated="[Dd][Ee][Pp][Rr][Ee][Cc][Aa][Tt][Ee][Dd]" atf_test_case ifconfig_create_destroy cleanup ifconfig_create_destroy_head() { atf_set "descr" "tests of ifconfig create and destroy" atf_set "require.progs" "rump_server" } ifconfig_create_destroy_body() { atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1} export RUMP_SERVER=${RUMP_SERVER1} # Create and destroy (no address) atf_check -s exit:0 rump.ifconfig shmif0 create atf_check -s exit:0 rump.ifconfig shmif0 destroy # Create and destroy (with an IPv4 address) atf_check -s exit:0 rump.ifconfig shmif0 create atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.1/24 atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig shmif0 destroy # Create and destroy (with an IPv6 address) atf_check -s exit:0 rump.ifconfig shmif0 create atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1 atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig shmif0 destroy unset RUMP_SERVER } ifconfig_create_destroy_cleanup() { RUMP_SERVER=${RUMP_SERVER1} rump.halt } atf_test_case ifconfig_options cleanup ifconfig_options_head() { atf_set "descr" "tests of ifconfig options" atf_set "require.progs" "rump_server" } ifconfig_options_body() { export RUMP_SERVER=${RUMP_SERVER1} atf_check -s exit:0 rump_server $RUMP_FLAGS $RUMP_SERVER1 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr bus1 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet 10.0.0.1/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 fc00::1/64 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up atf_check -s exit:0 -o ignore rump.ifconfig -w 10 $DEBUG && rump.ifconfig shmif0 # ifconfig [-N] interface address_family # -N resolves hostnames atf_check -s exit:0 -o match:'inet 127.0.0.1' rump.ifconfig lo0 inet atf_check -s exit:0 -o match:'inet localhost' rump.ifconfig -N lo0 inet atf_check -s exit:0 -o match:'inet6 ::1' rump.ifconfig lo0 inet6 atf_check -s exit:0 -o match:'inet6 localhost' rump.ifconfig -N lo0 inet6 atf_check -s not-exit:0 -e match:'not supported' rump.ifconfig lo0 atalk atf_check -s not-exit:0 -e match:'not supported' rump.ifconfig -N lo0 atalk atf_check -s exit:0 -o ignore rump.ifconfig lo0 link atf_check -s exit:0 -o ignore rump.ifconfig -N lo0 link # ifconfig [-hLmNvz] interface # -h -v shows statistics in human readable format atf_check -s exit:0 -o ignore rump.ifconfig -h -v lo0 # -L shows IPv6 lifetime atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 fc00::2 \ pltime 100 $DEBUG && rump.ifconfig -L shmif0 atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0 atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0 # -m shows all of the supported media (not supported in shmif) $DEBUG && rump.ifconfig -m shmif0 atf_check -s exit:0 -o ignore rump.ifconfig -m shmif0 atf_check -s exit:0 -o match:'localhost' rump.ifconfig -N lo0 atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -v lo0 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT localhost # -z clears and shows statistics at that point atf_check -s exit:0 -o match:'2 packets' rump.ifconfig -z lo0 atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -v lo0 # ifconfig -a [-bdhLNmsuvz] # -a shows all interfaces in the system $DEBUG && rump.ifconfig -a atf_check -s exit:0 -o match:'shmif0' -o match:'lo0' rump.ifconfig -a # -a -b shows only broadcast interfaces atf_check -s exit:0 -o match:'shmif0' -o not-match:'lo0' rump.ifconfig -a -b # -a -d shows only down interfaces atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -a -d atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig -a -d atf_check -s exit:0 -o match:'pltime' rump.ifconfig -a -L atf_check -s exit:0 -o match:'vltime' rump.ifconfig -a -L atf_check -s exit:0 -o match:'localhost' rump.ifconfig -a -N atf_check -s exit:0 -o ignore rump.ifconfig -a -m # -a -s shows only interfaces connected to a network # (shmif is always connected) $DEBUG && rump.ifconfig -a -s atf_check -s exit:0 -o ignore rump.ifconfig -a -s # -a -u shows only up interfaces atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -a -u atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig -a -u atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -a -v atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT localhost atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down atf_check -s exit:0 -o match:'2 packets' rump.ifconfig -a -z atf_check -s exit:0 -o not-match:'2 packets' rump.ifconfig -a -v atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -a -v atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up # ifconfig -l [-bdsu] # -l shows only inteface names atf_check -s exit:0 -o match:'lo0' rump.ifconfig -l atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -l atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -l -b atf_check -s exit:0 -o not-match:'lo0' rump.ifconfig -l -b atf_check -s exit:0 -o ignore rump.ifconfig -l -d atf_check -s exit:0 -o match:'lo0' rump.ifconfig -l -s atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -l -s atf_check -s exit:0 -o match:'lo0' rump.ifconfig -l -u atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -l -u # ifconfig -s interface # -s interface exists with 0 / 1 if connected / disconnected atf_check -s exit:0 -o empty rump.ifconfig -s lo0 atf_check -s exit:0 -o empty rump.ifconfig -s shmif0 # ifconfig -C # -C shows all of the interface cloners available on the system - atf_check -s exit:0 -o match:'shmif lo carp' rump.ifconfig -C + atf_check -s exit:0 -o match:'shmif carp lo' rump.ifconfig -C unset RUMP_SERVER } ifconfig_options_cleanup() { env RUMP_SERVER=${RUMP_SERVER1} rump.halt } atf_test_case ifconfig_parameters cleanup ifconfig_parameters_head() { atf_set "descr" "tests of interface parameters" atf_set "require.progs" "rump_server" } ifconfig_parameters_body() { local interval= atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1} atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER2} export RUMP_SERVER=${RUMP_SERVER1} atf_check -s exit:0 rump.ifconfig shmif0 create atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.1/24 atf_check -s exit:0 rump.ifconfig shmif0 up unset RUMP_SERVER export RUMP_SERVER=${RUMP_SERVER2} atf_check -s exit:0 rump.ifconfig shmif0 create atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.2/24 atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.0.3/24 alias atf_check -s exit:0 rump.ifconfig shmif0 up unset RUMP_SERVER export RUMP_SERVER=${RUMP_SERVER1} # active atf_check -s exit:0 rump.ifconfig shmif0 link b2:a0:75:00:00:01 active atf_check -s exit:0 -o match:'address:.b2:a0:75:00:00:01' \ rump.ifconfig shmif0 # down, up atf_check -s exit:0 rump.ifconfig shmif0 down atf_check -s not-exit:0 -o ignore -e ignore rump.ping -c 1 \ -w $TIMEOUT -n 192.168.0.2 atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig -w 10 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT -n 192.168.0.2 # alias atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1/24 alias atf_check -s exit:0 -o match:'192.168.1.1/24' rump.ifconfig shmif0 atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1/24 -alias atf_check -s exit:0 -o not-match:'192.168.1.1/24' rump.ifconfig shmif0 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2 atf_check -s exit:0 -o match:'fc00::1' rump.ifconfig shmif0 inet6 atf_check -s exit:0 -o match:'fc00::2' rump.ifconfig shmif0 inet6 # delete atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1 alias atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1 delete atf_check -s exit:0 -o not-match:'192.168.1.1' rump.ifconfig shmif0 inet atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.0.1 delete atf_check -s exit:0 -o not-match:'192.168.0.1' rump.ifconfig shmif0 inet atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1 delete atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2 delete atf_check -s exit:0 -o not-match:'fc00::1' rump.ifconfig shmif0 inet6 atf_check -s exit:0 -o not-match:'fc00::2' rump.ifconfig shmif0 inet6 # can delete inactive link atf_check -s exit:0 rump.ifconfig shmif0 link b2:a0:75:00:00:02 atf_check -s exit:0 rump.ifconfig shmif0 link b2:a0:75:00:00:02 delete # cannot delete active link atf_check -s not-exit:0 -e match:'SIOCDLIFADDR: Device busy' \ rump.ifconfig shmif0 link b2:a0:75:00:00:01 delete atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.0.1/24 # arp atf_check -s exit:0 rump.ifconfig shmif0 -arp atf_check -s not-exit:0 -o ignore -e ignore \ rump.ping -c 1 -w $TIMEOUT -n 192.168.0.3 atf_check -s exit:0 -o not-match:'192.168.0.3' rump.arp -an # The entry shouldn't appear in the routing table anymore atf_check -s exit:0 -o not-match:'192.168.0.3' rump.netstat -nr # netmask atf_check -s exit:0 rump.ifconfig shmif0 inet 172.16.0.1 netmask 255.255.255.0 alias atf_check -s exit:0 -o match:'172.16.0/24' rump.netstat -rn -f inet atf_check -s exit:0 rump.ifconfig shmif0 inet 172.16.0.1 delete # broadcast (does it not work?) atf_check -s exit:0 rump.ifconfig shmif0 inet 172.16.0.1 \ broadcast 255.255.255.255 alias atf_check -s exit:0 -o match:'broadcast 255.255.255.255' \ rump.ifconfig shmif0 inet # metric (external only) atf_check -s exit:0 rump.ifconfig shmif0 metric 10 atf_check -s exit:0 rump.ifconfig shmif0 metric 0 # prefixlen atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1 prefixlen 70 atf_check -s exit:0 -o match:'fc00::/70' rump.netstat -rn -f inet6 # anycast atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2 anycast atf_check -s exit:0 -o match:"fc00::2.+$anycast" rump.ifconfig shmif0 inet6 # deprecated atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 deprecated # Not deprecated immediately. Need to wait nd6_timer that does it is scheduled. interval=$(sysctl -n net.inet6.icmp6.nd6_prune) atf_check -s exit:0 sleep $((interval + 1)) atf_check -s exit:0 -o match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 -deprecated atf_check -s exit:0 -o not-match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6 # pltime atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 pltime 3 atf_check -s exit:0 -o not-match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6 atf_check -s exit:0 sleep 5 atf_check -s exit:0 -o match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6 # eui64 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00:1::0 eui64 atf_check -s exit:0 -o match:'fc00:1::' rump.ifconfig shmif0 inet6 unset RUMP_SERVER } ifconfig_parameters_cleanup() { env RUMP_SERVER=${RUMP_SERVER1} rump.halt env RUMP_SERVER=${RUMP_SERVER2} rump.halt } atf_init_test_cases() { atf_add_test_case ifconfig_create_destroy atf_add_test_case ifconfig_options atf_add_test_case ifconfig_parameters } Index: head/contrib/netbsd-tests/net/if_loop/t_pr.c =================================================================== --- head/contrib/netbsd-tests/net/if_loop/t_pr.c (revision 313438) +++ head/contrib/netbsd-tests/net/if_loop/t_pr.c (revision 313439) @@ -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: head/contrib/netbsd-tests/net/if_tun/t_tun.sh =================================================================== --- head/contrib/netbsd-tests/net/if_tun/t_tun.sh (nonexistent) +++ head/contrib/netbsd-tests/net/if_tun/t_tun.sh (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/net/if_vlan/t_vlan.sh =================================================================== --- head/contrib/netbsd-tests/net/if_vlan/t_vlan.sh (nonexistent) +++ head/contrib/netbsd-tests/net/if_vlan/t_vlan.sh (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/net/ndp/t_ra.sh =================================================================== --- head/contrib/netbsd-tests/net/ndp/t_ra.sh (revision 313438) +++ head/contrib/netbsd-tests/net/ndp/t_ra.sh (revision 313439) @@ -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: head/contrib/netbsd-tests/net/net/t_raw.c =================================================================== --- head/contrib/netbsd-tests/net/net/t_raw.c (revision 313438) +++ head/contrib/netbsd-tests/net/net/t_raw.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/modautoload/t_modautoload.c =================================================================== --- head/contrib/netbsd-tests/rump/modautoload/t_modautoload.c (revision 313438) +++ head/contrib/netbsd-tests/rump/modautoload/t_modautoload.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/rumpkern/t_kern.c =================================================================== --- head/contrib/netbsd-tests/rump/rumpkern/t_kern.c (revision 313438) +++ head/contrib/netbsd-tests/rump/rumpkern/t_kern.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c =================================================================== --- head/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c (revision 313438) +++ head/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/rumpkern/t_modcmd.c =================================================================== --- head/contrib/netbsd-tests/rump/rumpkern/t_modcmd.c (revision 313438) +++ head/contrib/netbsd-tests/rump/rumpkern/t_modcmd.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/rumpkern/t_modlinkset.c =================================================================== --- head/contrib/netbsd-tests/rump/rumpkern/t_modlinkset.c (revision 313438) +++ head/contrib/netbsd-tests/rump/rumpkern/t_modlinkset.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/rumpkern/t_signals.c =================================================================== --- head/contrib/netbsd-tests/rump/rumpkern/t_signals.c (revision 313438) +++ head/contrib/netbsd-tests/rump/rumpkern/t_signals.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/rumpkern/t_threads.c =================================================================== --- head/contrib/netbsd-tests/rump/rumpkern/t_threads.c (revision 313438) +++ head/contrib/netbsd-tests/rump/rumpkern/t_threads.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/rumpkern/t_tsleep.c =================================================================== --- head/contrib/netbsd-tests/rump/rumpkern/t_tsleep.c (revision 313438) +++ head/contrib/netbsd-tests/rump/rumpkern/t_tsleep.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/rumpkern/t_vm.c =================================================================== --- head/contrib/netbsd-tests/rump/rumpkern/t_vm.c (revision 313438) +++ head/contrib/netbsd-tests/rump/rumpkern/t_vm.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/rumpvfs/t_basic.c =================================================================== --- head/contrib/netbsd-tests/rump/rumpvfs/t_basic.c (revision 313438) +++ head/contrib/netbsd-tests/rump/rumpvfs/t_basic.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/rumpvfs/t_etfs.c =================================================================== --- head/contrib/netbsd-tests/rump/rumpvfs/t_etfs.c (revision 313438) +++ head/contrib/netbsd-tests/rump/rumpvfs/t_etfs.c (revision 313439) @@ -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: head/contrib/netbsd-tests/rump/rumpvfs/t_p2kifs.c =================================================================== --- head/contrib/netbsd-tests/rump/rumpvfs/t_p2kifs.c (revision 313438) +++ head/contrib/netbsd-tests/rump/rumpvfs/t_p2kifs.c (revision 313439) @@ -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: head/contrib/netbsd-tests/sys/uvm/t_uvm_physseg.c =================================================================== --- head/contrib/netbsd-tests/sys/uvm/t_uvm_physseg.c (nonexistent) +++ head/contrib/netbsd-tests/sys/uvm/t_uvm_physseg.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/sys/uvm/t_uvm_physseg_load.c =================================================================== --- head/contrib/netbsd-tests/sys/uvm/t_uvm_physseg_load.c (nonexistent) +++ head/contrib/netbsd-tests/sys/uvm/t_uvm_physseg_load.c (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh =================================================================== --- head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh (revision 313438) +++ head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh (revision 313439) @@ -1,267 +1,248 @@ -# $NetBSD: t_grep.sh,v 1.2 2013/05/17 15:39:17 christos Exp $ +# $NetBSD: t_grep.sh,v 1.3 2017/01/14 20:43:52 christos Exp $ # # Copyright (c) 2008, 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. # atf_test_case basic basic_head() { atf_set "descr" "Checks basic functionality" } basic_body() { atf_check -o file:"$(atf_get_srcdir)/d_basic.out" -x \ 'jot 10000 | grep 123' } atf_test_case binary binary_head() { atf_set "descr" "Checks handling of binary files" } binary_body() { - # Begin FreeBSD - # - # Generate stable output instead of depending on uname to match the - # branded OS name of /bin/sh - if true; then dd if=/dev/zero count=1 of=test.file echo -n "foobar" >> test.file atf_check -o file:"$(atf_get_srcdir)/d_binary.out" grep foobar test.file - else - # End FreeBSD - atf_check -o file:"$(atf_get_srcdir)/d_binary.out" grep $(uname) /bin/sh - # Begin FreeBSD - fi - # End FreeBSD } atf_test_case recurse recurse_head() { atf_set "descr" "Checks recursive searching" } recurse_body() { mkdir -p recurse/a/f recurse/d echo -e "cod\ndover sole\nhaddock\nhalibut\npilchard" > recurse/d/fish echo -e "cod\nhaddock\nplaice" > recurse/a/f/favourite-fish - # Begin FreeBSD - if true; then - atf_check -o file:"$(atf_get_srcdir)/d_recurse.out" -x "grep -r haddock recurse | sort" - else - # End FreeBSD - atf_check -o file:"$(atf_get_srcdir)/d_recurse.out" grep -r haddock recurse - # Begin FreeBSD - fi - # End FreeBSD + atf_check -o file:"$(atf_get_srcdir)/d_recurse.out" -x "grep -r haddock recurse | sort" } atf_test_case recurse_symlink recurse_symlink_head() { atf_set "descr" "Checks symbolic link recursion" } recurse_symlink_body() { mkdir -p test/c/d (cd test/c/d && ln -s ../d .) echo "Test string" > test/c/match atf_check -o file:"$(atf_get_srcdir)/d_recurse_symlink.out" \ -e file:"$(atf_get_srcdir)/d_recurse_symlink.err" \ grep -r string test } atf_test_case word_regexps word_regexps_head() { atf_set "descr" "Checks word-regexps" } word_regexps_body() { atf_check -o file:"$(atf_get_srcdir)/d_word_regexps.out" \ grep -w separated $(atf_get_srcdir)/d_input } atf_test_case begin_end begin_end_head() { atf_set "descr" "Checks handling of line beginnings and ends" } begin_end_body() { atf_check -o file:"$(atf_get_srcdir)/d_begin_end_a.out" \ grep ^Front "$(atf_get_srcdir)/d_input" atf_check -o file:"$(atf_get_srcdir)/d_begin_end_b.out" \ grep ending$ "$(atf_get_srcdir)/d_input" } atf_test_case ignore_case ignore_case_head() { atf_set "descr" "Checks ignore-case option" } ignore_case_body() { atf_check -o file:"$(atf_get_srcdir)/d_ignore_case.out" \ grep -i Upper "$(atf_get_srcdir)/d_input" } atf_test_case invert invert_head() { atf_set "descr" "Checks selecting non-matching lines with -v option" } invert_body() { atf_check -o file:"$(atf_get_srcdir)/d_invert.out" \ grep -v fish "$(atf_get_srcdir)/d_invert.in" } atf_test_case whole_line whole_line_head() { atf_set "descr" "Checks whole-line matching with -x flag" } whole_line_body() { atf_check -o file:"$(atf_get_srcdir)/d_whole_line.out" \ grep -x matchme "$(atf_get_srcdir)/d_input" } atf_test_case negative negative_head() { atf_set "descr" "Checks handling of files with no matches" } negative_body() { atf_check -s ne:0 grep "not a hope in hell" "$(atf_get_srcdir)/d_input" } atf_test_case context context_head() { atf_set "descr" "Checks displaying context with -A, -B and -C flags" } context_body() { cp $(atf_get_srcdir)/d_context_*.* . atf_check -o file:d_context_a.out grep -C2 bamboo d_context_a.in atf_check -o file:d_context_b.out grep -A3 tilt d_context_a.in atf_check -o file:d_context_c.out grep -B4 Whig d_context_a.in atf_check -o file:d_context_d.out grep -C1 pig d_context_a.in d_context_b.in } atf_test_case file_exp file_exp_head() { atf_set "descr" "Checks reading expressions from file" } file_exp_body() { atf_check -o file:"$(atf_get_srcdir)/d_file_exp.out" -x \ 'jot 21 -1 1.00 | grep -f '"$(atf_get_srcdir)"'/d_file_exp.in' } atf_test_case egrep egrep_head() { atf_set "descr" "Checks matching special characters with egrep" } egrep_body() { atf_check -o file:"$(atf_get_srcdir)/d_egrep.out" \ egrep '\?|\*$$' "$(atf_get_srcdir)/d_input" } atf_test_case zgrep zgrep_head() { atf_set "descr" "Checks handling of gzipped files with zgrep" } zgrep_body() { cp "$(atf_get_srcdir)/d_input" . gzip d_input || atf_fail "gzip failed" atf_check -o file:"$(atf_get_srcdir)/d_zgrep.out" zgrep -h line d_input.gz } atf_test_case nonexistent nonexistent_head() { atf_set "descr" "Checks that -s flag suppresses error" \ "messages about nonexistent files" } nonexistent_body() { atf_check -s ne:0 grep -s foobar nonexistent } atf_test_case context2 context2_head() { atf_set "descr" "Checks displaying context with -z flag" } context2_body() { printf "haddock\000cod\000plaice\000" > test1 printf "mackeral\000cod\000crab\000" > test2 atf_check -o file:"$(atf_get_srcdir)/d_context2_a.out" \ grep -z -A1 cod test1 test2 atf_check -o file:"$(atf_get_srcdir)/d_context2_b.out" \ grep -z -B1 cod test1 test2 atf_check -o file:"$(atf_get_srcdir)/d_context2_c.out" \ grep -z -C1 cod test1 test2 } atf_init_test_cases() { atf_add_test_case basic atf_add_test_case binary atf_add_test_case recurse atf_add_test_case recurse_symlink atf_add_test_case word_regexps atf_add_test_case begin_end atf_add_test_case ignore_case atf_add_test_case invert atf_add_test_case whole_line atf_add_test_case negative atf_add_test_case context atf_add_test_case file_exp atf_add_test_case egrep atf_add_test_case zgrep atf_add_test_case nonexistent atf_add_test_case context2 } Index: head/contrib/netbsd-tests/usr.bin/mixerctl/t_mixerctl.sh =================================================================== --- head/contrib/netbsd-tests/usr.bin/mixerctl/t_mixerctl.sh (nonexistent) +++ head/contrib/netbsd-tests/usr.bin/mixerctl/t_mixerctl.sh (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/usr.bin/uniq/d_basic.in =================================================================== --- head/contrib/netbsd-tests/usr.bin/uniq/d_basic.in (nonexistent) +++ head/contrib/netbsd-tests/usr.bin/uniq/d_basic.in (revision 313439) @@ -0,0 +1,4 @@ +1 +12 +1 +1 Property changes on: head/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: head/contrib/netbsd-tests/usr.bin/uniq/d_basic.out =================================================================== --- head/contrib/netbsd-tests/usr.bin/uniq/d_basic.out (nonexistent) +++ head/contrib/netbsd-tests/usr.bin/uniq/d_basic.out (revision 313439) @@ -0,0 +1,3 @@ +1 +12 +1 Index: head/contrib/netbsd-tests/usr.bin/uniq/d_counts.out =================================================================== --- head/contrib/netbsd-tests/usr.bin/uniq/d_counts.out (nonexistent) +++ head/contrib/netbsd-tests/usr.bin/uniq/d_counts.out (revision 313439) @@ -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: head/contrib/netbsd-tests/usr.bin/uniq/d_input.in =================================================================== --- head/contrib/netbsd-tests/usr.bin/uniq/d_input.in (nonexistent) +++ head/contrib/netbsd-tests/usr.bin/uniq/d_input.in (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/usr.bin/uniq/d_show_duplicates.out =================================================================== --- head/contrib/netbsd-tests/usr.bin/uniq/d_show_duplicates.out (nonexistent) +++ head/contrib/netbsd-tests/usr.bin/uniq/d_show_duplicates.out (revision 313439) @@ -0,0 +1 @@ +#05 foo0 bar0 foo1 bar1 Index: head/contrib/netbsd-tests/usr.bin/uniq/d_show_uniques.out =================================================================== --- head/contrib/netbsd-tests/usr.bin/uniq/d_show_uniques.out (nonexistent) +++ head/contrib/netbsd-tests/usr.bin/uniq/d_show_uniques.out (revision 313439) @@ -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: head/contrib/netbsd-tests/usr.bin/uniq/t_uniq.sh =================================================================== --- head/contrib/netbsd-tests/usr.bin/uniq/t_uniq.sh (nonexistent) +++ head/contrib/netbsd-tests/usr.bin/uniq/t_uniq.sh (revision 313439) @@ -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: head/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: head/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh =================================================================== --- head/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh (revision 313438) +++ head/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh (revision 313439) @@ -1,436 +1,436 @@ -# $NetBSD: t_mtree.sh,v 1.6 2013/02/05 16:49:42 christos Exp $ +# $NetBSD: t_mtree.sh,v 1.7 2017/01/14 20:45:16 christos Exp $ # # Copyright (c) 2009, 2012 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. # # Postprocess mtree output, canonicalising portions that # are expected to differ from one run to another. # h_postprocess() { sed -e ' /^# user: /s/:.*/: x/ /^# machine: /s/:.*/: x/ /^# tree: /s/:.*/: x/ /^# date: /s/:.*/: x/ ' \ -e '/type=dir/s/ size=[0-9]*//' } h_check() { diff -Nru "$1" "$2" || atf_fail "files $1 and $2 differ" } atf_test_case mtree_create atf_test_case netbsd6_create create_head() { atf_set "descr" "Create a specfile describing a directory tree" } create_setup() { # create some directories rm -fr create mkdir -p create/a/1 create/a/2 create/b # create some files for file in create/top.file.1 \ create/a/a.file.1 \ create/a/a.file.2 \ create/a/1/a1.file.1 \ create/b/b.file.1 \ create/b/b.file.2 do echo "$file" >$file done # hard link to file in same dir ln create/b/b.file.1 create/b/b.hardlink.1 # hard link to file in another dir ln create/b/b.file.2 create/a/a.hardlink.b2 # symlink to file ln -s a.file.1 create/a.symlink.1 # symlink to dir ln -s b create/top.symlink.b # dangling symlink ln -s nonexistent create/top.dangling } create_body() { create_setup # run mtree and check output ( cd create && mtree -F ${FLAVOR} -c -k type,nlink,link,size,sha256 ) >output.raw \ || atf_fail "mtree exit status $?" h_postprocess output h_check "$(atf_get_srcdir)/${FLAVOR}_d_create.out" output } mtree_create_head() { FLAVOR=mtree create_head } netbsd6_create_head() { FLAVOR=netbsd6 create_head } mtree_create_body() { FLAVOR=mtree create_body } netbsd6_create_body() { FLAVOR=netbsd6 create_body } atf_test_case mtree_check atf_test_case netbsd6_check check_head() { atf_set "descr" "Check a directory tree against a specfile" } check_body() { # we use the same directory tree and specfile as in the "create" test create_setup # run mtree and check output ( cd create && mtree -F ${FLAVOR} ) <"$(atf_get_srcdir)/${FLAVOR}_d_create.out" >output \ || atf_fail "mtree exit status $?" h_check /dev/null output } mtree_check_head() { FLAVOR=mtree check_head } netbsd6_check_head() { FLAVOR=netbsd6 check_head } mtree_check_body() { FLAVOR=mtree check_body } netbsd6_check_body() { FLAVOR=netbsd6 check_body } atf_test_case mtree_convert_C atf_test_case netbsd6_convert_C convert_C_head() { atf_set "descr" "Convert a specfile to mtree -C format, unsorted" } convert_C_body() { mtree -F ${FLAVOR} -C -K all <"$(atf_get_srcdir)/d_convert.in" >output h_check "$(atf_get_srcdir)/d_convert_C.out" output } mtree_convert_C_head() { FLAVOR=mtree convert_C_head } netbsd6_convert_C_head() { FLAVOR=netbsd6 convert_C_head } mtree_convert_C_body() { FLAVOR=mtree convert_C_body } netbsd6_convert_C_body() { FLAVOR=netbsd6 convert_C_body } atf_test_case mtree_convert_C_S atf_test_case netbsd6_convert_C_S convert_C_S_head() { atf_set "descr" "Convert a specfile to mtree -C format, sorted" } convert_C_S_body() { mtree -F ${FLAVOR} -C -S -K all <"$(atf_get_srcdir)/d_convert.in" >output h_check "$(atf_get_srcdir)/d_convert_C_S.out" output } mtree_convert_C_S_head() { FLAVOR=mtree convert_C_S_head } netbsd6_convert_C_S_head() { FLAVOR=netbsd6 convert_C_S_head } mtree_convert_C_S_body() { FLAVOR=mtree convert_C_S_body } netbsd6_convert_C_S_body() { FLAVOR=netbsd6 convert_C_S_body } atf_test_case mtree_convert_D atf_test_case netbsd6_convert_D convert_D_head() { atf_set "descr" "Convert a specfile to mtree -D format, unsorted" } convert_D_body() { mtree -F ${FLAVOR} -D -K all <"$(atf_get_srcdir)/d_convert.in" >output h_check "$(atf_get_srcdir)/d_convert_D.out" output } mtree_convert_D_head() { FLAVOR=mtree convert_D_head } netbsd6_convert_D_head() { FLAVOR=netbsd6 convert_D_head } mtree_convert_D_body() { FLAVOR=mtree convert_D_body } netbsd6_convert_D_body() { FLAVOR=netbsd6 convert_D_body } atf_test_case mtree_convert_D_S atf_test_case netbsd6_convert_D_S convert_D_S_head() { atf_set "descr" "Convert a specfile to mtree -D format, sorted" } convert_D_S_body() { mtree -F ${FLAVOR} -D -S -K all <"$(atf_get_srcdir)/d_convert.in" >output h_check "$(atf_get_srcdir)/d_convert_D_S.out" output } mtree_convert_D_S_head() { FLAVOR=mtree convert_D_S_head } netbsd6_convert_D_S_head() { FLAVOR=netbsd6 convert_D_S_head } mtree_convert_D_S_body() { FLAVOR=mtree convert_D_S_body } netbsd6_convert_D_S_body() { FLAVOR=netbsd6 convert_D_S_body } atf_test_case mtree_ignore atf_test_case netbs6_ignore ignore_head() { atf_set "descr" "Test that -d ignores symlinks (PR bin/41061)" } ignore_body() { # Kyua 0.11 and above point TMPDIR to our work directory and atf-check # generates a temporary file, which confuses mtree. Put the mtree files # into a subdirectory. # # See https://github.com/jmmv/kyua/issues/133 for details. mkdir root && cd root mkdir newdir mtree -F ${FLAVOR} -c | mtree -F ${FLAVOR} -Ck uid,gid,mode > mtree.spec ln -s newdir otherdir # This yields "extra: otherdir" even with -d. # (PR bin/41061) atf_check -s ignore -o empty -e empty -x "mtree -F ${FLAVOR} -d < mtree.spec" # Delete the symlink and re-verify. # rm otherdir atf_check -s ignore -o empty -e empty -x "mtree -F ${FLAVOR} -d < mtree.spec" } mtree_ignore_head() { FLAVOR=mtree ignore_head } netbsd6_ignore_head() { FLAVOR=netbsd6 ignore_head } mtree_ignore_body() { FLAVOR=mtree ignore_body } netbsd6_ignore_body() { # Kyua 0.11 and above point TMPDIR to our work directory and atf-check # generates a temporary file, which confuses mtree. Put the mtree files # into a subdirectory. # # See https://github.com/jmmv/kyua/issues/133 for details. mkdir root && cd root FLAVOR=netbsd6 ignore_body } atf_test_case mtree_merge atf_test_case netbsd6_merge merge_head() { atf_set "descr" "Merge records of different type" } merge_body() { mtree -F ${FLAVOR} -C -M -K all <"$(atf_get_srcdir)/d_merge.in" >output h_check "$(atf_get_srcdir)/d_merge_C_M.out" output # same again, with sorting mtree -F ${FLAVOR} -C -M -S -K all <"$(atf_get_srcdir)/d_merge.in" >output h_check "$(atf_get_srcdir)/d_merge_C_M_S.out" output } mtree_merge_head() { FLAVOR=mtree merge_head } netbsd6_merge_head() { FLAVOR=netbsd6 merge_head } mtree_merge_body() { FLAVOR=mtree merge_body } netbsd6_merge_body() { FLAVOR=netbsd6 merge_body } atf_test_case mtree_nonemptydir atf_test_case netbsd6_nonemptydir nonemptydir_head() { atf_set "descr" "Test that new non-empty " \ "directories are recorded (PR bin/25693)" } nonemptydir_body() { mkdir testdir cd testdir mtree -F ${FLAVOR} -c > mtree.spec if [ ! -f mtree.spec ]; then atf_fail "mtree failed" fi touch bar atf_check -s ignore -o save:output -x "mtree -F ${FLAVOR} -f mtree.spec" if [ ! -n "$(egrep "extra: bar" output)" ]; then atf_fail "mtree did not record changes (PR bin/25693)" fi } mtree_nonemptydir_head() { FLAVOR=mtree nonemptydir_head } netbsd6_nonemptydir_head() { FLAVOR=netbsd6 nonemptydir_head } mtree_nonemptydir_body() { FLAVOR=mtree nonemptydir_body } netbsd6_nonemptydir_body() { FLAVOR=netbsd6 nonemptydir_body } atf_init_test_cases() { atf_add_test_case mtree_create atf_add_test_case mtree_check atf_add_test_case mtree_convert_C atf_add_test_case mtree_convert_C_S atf_add_test_case mtree_convert_D atf_add_test_case mtree_convert_D_S atf_add_test_case mtree_ignore atf_add_test_case mtree_merge atf_add_test_case mtree_nonemptydir atf_add_test_case netbsd6_create atf_add_test_case netbsd6_check atf_add_test_case netbsd6_convert_C atf_add_test_case netbsd6_convert_C_S atf_add_test_case netbsd6_convert_D atf_add_test_case netbsd6_convert_D_S atf_add_test_case netbsd6_ignore atf_add_test_case netbsd6_merge atf_add_test_case netbsd6_nonemptydir } Index: head/contrib/netbsd-tests =================================================================== --- head/contrib/netbsd-tests (revision 313438) +++ head/contrib/netbsd-tests (revision 313439) Property changes on: head/contrib/netbsd-tests ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,2 ## Merged /vendor/NetBSD/tests/dist:r311967-311969,311971-313245 Merged /projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests:r312125-313435 Index: head/etc/mtree/BSD.tests.dist =================================================================== --- head/etc/mtree/BSD.tests.dist (revision 313438) +++ head/etc/mtree/BSD.tests.dist (revision 313439) @@ -1,698 +1,700 @@ # $FreeBSD$ # # Please see the file src/etc/mtree/README before making changes to this file. # /set type=dir uname=root gname=wheel mode=0755 . bin cat .. date .. dd .. expr .. ls .. mv .. pax .. pkill .. sh builtins .. errors .. execution .. expansion .. parameters .. parser .. set-e .. .. sleep .. test .. .. cddl lib .. sbin .. usr.bin .. usr.sbin dtrace common aggs .. arithmetic .. arrays .. assocs .. begin .. bitfields .. buffering .. builtinvar .. cg .. clauses .. cpc .. decls .. drops .. dtraceUtil .. end .. enum .. error .. exit .. fbtprovider .. funcs .. grammar .. include .. inline .. io .. ip .. java_api .. json .. lexer .. llquantize .. mdb .. mib .. misc .. multiaggs .. offsetof .. operators .. pid .. plockstat .. pointers .. pragma .. predicates .. preprocessor .. print .. printa .. printf .. privs .. probes .. proc .. profile-n .. providers .. raise .. rates .. safety .. scalars .. sched .. scripting .. sdt .. sizeof .. speculation .. stability .. stack .. stackdepth .. stop .. strlen .. strtoll .. struct .. sugar .. syscall .. sysevent .. tick-n .. trace .. tracemem .. translators .. typedef .. types .. uctf .. union .. usdt .. ustack .. vars .. version .. .. .. zfsd .. .. .. etc rc.d .. .. games .. gnu lib .. usr.bin diff .. .. .. lib atf libatf-c detail .. .. libatf-c++ detail .. .. test-programs .. .. libarchive .. libc c063 .. db .. gen execve .. posix_spawn .. .. hash data .. .. iconv .. inet .. locale .. net getaddrinfo data .. .. .. nss .. regex data .. .. resolv .. rpc .. ssp .. setjmp .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcasper services cap_dns .. cap_grp .. cap_pwd .. cap_sysctl .. .. .. libcrypt .. libdevdctl .. libmp .. libnv .. libpam .. libproc .. librt .. libthr dlopen .. .. libutil .. libxo .. msun .. .. libexec atf atf-check .. atf-sh .. .. rtld-elf .. .. sbin dhclient .. devd .. growfs .. ifconfig .. mdconfig .. .. secure lib .. libexec .. usr.bin .. usr.sbin .. .. share examples tests atf .. plain .. .. .. .. sys acl .. aio .. fifo .. file .. fs tmpfs .. .. geom class concat .. eli .. gate .. gpt .. mirror .. nop .. raid3 .. shsec .. stripe .. uzip etalon .. .. .. .. kern acct .. execve .. pipe .. .. kqueue libkqueue .. .. mac bsdextended .. portacl .. .. mqueue .. netinet .. opencrypto .. pjdfstest chflags .. chmod .. chown .. ftruncate .. granular .. link .. mkdir .. mkfifo .. mknod .. open .. rename .. rmdir .. symlink .. truncate .. unlink .. .. posixshm .. sys .. vfs .. vm .. .. usr.bin apply .. basename .. bmake archives fmt_44bsd .. fmt_44bsd_mod .. fmt_oldbsd .. .. basic t0 .. t1 .. t2 .. t3 .. .. execution ellipsis .. empty .. joberr .. plus .. .. shell builtin .. meta .. path .. path_select .. replace .. select .. .. suffixes basic .. src_wild1 .. src_wild2 .. .. syntax directive-t0 .. enl .. funny-targets .. semi .. .. sysmk t0 2 1 .. .. mk .. .. t1 2 1 .. .. mk .. .. t2 2 1 .. .. mk .. .. .. variables modifier_M .. modifier_t .. opt_V .. t0 .. .. .. bsdcat .. calendar .. cmp .. cpio .. col .. comm .. cut .. dirname .. file2c .. grep .. gzip .. ident .. join .. jot .. lastcomm .. limits .. m4 .. mkimg .. ncal .. opensm .. printf .. sdiff .. sed regress.multitest.out .. .. soelim .. tail .. tar .. timeout .. tr .. truncate .. units .. uudecode .. uuencode .. + uniq + .. xargs .. xinstall .. xo .. yacc yacc .. .. .. usr.sbin chown .. etcupdate .. extattr .. fstyp .. makefs .. newsyslog .. nmtree .. pw .. rpcbind .. sa .. .. .. # vim: set expandtab ts=4 sw=4: Index: head/lib/libc/tests/hash/Makefile =================================================================== --- head/lib/libc/tests/hash/Makefile (revision 313438) +++ head/lib/libc/tests/hash/Makefile (revision 313439) @@ -1,40 +1,39 @@ # $FreeBSD$ PACKAGE= tests .include NETBSD_ATF_TESTS_C= .if ${MK_OPENSSL} != "no" # XXX: doesn't compile #NETBSD_ATF_TESTS_C+= hmac_test NETBSD_ATF_TESTS_C+= sha2_test .endif NETBSD_ATF_TESTS_SH= hash_test BINDIR= ${TESTSDIR} PROGS+= h_hash FILESGROUPS+= ${PACKAGE}DATA_FILES ${PACKAGE}DATA_FILESPACKAGE= tests ${PACKAGE}DATA_FILESDIR= ${TESTSDIR}/data ${PACKAGE}DATA_FILES+= data/md5test-in ${PACKAGE}DATA_FILES+= data/md5test-out ${PACKAGE}DATA_FILES+= data/sha1test-in ${PACKAGE}DATA_FILES+= data/sha1test-out ${PACKAGE}DATA_FILES+= data/sha1test2-out LIBADD+= md LIBADD.sha2_test+= crypto -CFLAGS.sha2_test+= -I${SRCTOP}/crypto/openssh/openbsd-compat -CFLAGS.sha2_test+= -I${SRCTOP}/crypto/openssh +CFLAGS.h_hash+= -I${SRCTOP}/lib/libnetbsd .include "../Makefile.netbsd-tests" .include Index: head/lib/libc/tests/regex/Makefile =================================================================== --- head/lib/libc/tests/regex/Makefile (revision 313438) +++ head/lib/libc/tests/regex/Makefile (revision 313439) @@ -1,62 +1,63 @@ # $FreeBSD$ .include PACKAGE= tests BINDIR= ${TESTSDIR} -IMPLEMENTATION?= -DREGEX_SPENCER +# SKIP_LEFTASSOC -> these testcases fail on FreeBSD. +IMPLEMENTATION?= -DREGEX_SPENCER -DSKIP_LEFTASSOC CFLAGS.h_regex+=-I${TESTSRC} -I${.CURDIR:H:H}/regex PROGS+= h_regex SRCS.h_regex= main.c split.c debug.c NETBSD_ATF_TESTS_SH= regex_test ${PACKAGE}FILES+= README FILESGROUPS+= ${PACKAGE}DATA_FILES ${PACKAGE}DATA_FILESPACKAGE=${PACKAGE} ${PACKAGE}DATA_FILESDIR= ${TESTSDIR}/data ${PACKAGE}DATA_FILES+= data/anchor.in ${PACKAGE}DATA_FILES+= data/backref.in ${PACKAGE}DATA_FILES+= data/basic.in ${PACKAGE}DATA_FILES+= data/bracket.in ${PACKAGE}DATA_FILES+= data/c_comments.in ${PACKAGE}DATA_FILES+= data/complex.in ${PACKAGE}DATA_FILES+= data/error.in ${PACKAGE}DATA_FILES+= data/meta.in ${PACKAGE}DATA_FILES+= data/nospec.in ${PACKAGE}DATA_FILES+= data/paren.in ${PACKAGE}DATA_FILES+= data/regress.in ${PACKAGE}DATA_FILES+= data/repet_bounded.in ${PACKAGE}DATA_FILES+= data/repet_multi.in ${PACKAGE}DATA_FILES+= data/repet_ordinary.in ${PACKAGE}DATA_FILES+= data/startend.in ${PACKAGE}DATA_FILES+= data/subexp.in ${PACKAGE}DATA_FILES+= data/subtle.in ${PACKAGE}DATA_FILES+= data/word_bound.in ${PACKAGE}DATA_FILES+= data/zero.in #${PACKAGE}DATA_FILES+= data/att/README ${PACKAGE}DATA_FILES+= data/att/basic.dat ${PACKAGE}DATA_FILES+= data/att/categorization.dat ${PACKAGE}DATA_FILES+= data/att/forcedassoc.dat ${PACKAGE}DATA_FILES+= data/att/leftassoc.dat ${PACKAGE}DATA_FILES+= data/att/nullsubexpr.dat ${PACKAGE}DATA_FILES+= data/att/repetition.dat ${PACKAGE}DATA_FILES+= data/att/rightassoc.dat NETBSD_ATF_TESTS_C= exhaust_test NETBSD_ATF_TESTS_C+= regex_att_test .for t in ${NETBSD_ATF_TESTS_C} CFLAGS.$t+= -I${TESTSRC} ${IMPLEMENTATION} .endfor .include "../Makefile.netbsd-tests" LIBADD.regex_att_test+= util .include Index: head/tests/sys/fs/tmpfs/Makefile =================================================================== --- head/tests/sys/fs/tmpfs/Makefile (revision 313438) +++ head/tests/sys/fs/tmpfs/Makefile (revision 313439) @@ -1,56 +1,61 @@ # $FreeBSD$ PACKAGE= tests FILESYSTEM?= ${.CURDIR:T} TESTSDIR= ${TESTSBASE}/sys/fs/${FILESYSTEM} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/fs/${FILESYSTEM} # XXX: uses /dev/MAKEDEV to create pseudo /dev/{null,zero} character devices #NETBSD_ATF_TESTS_SH+= devices_test NETBSD_ATF_TESTS_SH+= create_test NETBSD_ATF_TESTS_SH+= read_write_test NETBSD_ATF_TESTS_SH+= dots_test NETBSD_ATF_TESTS_SH+= exec_test NETBSD_ATF_TESTS_SH+= link_test NETBSD_ATF_TESTS_SH+= mkdir_test NETBSD_ATF_TESTS_SH+= mknod_test NETBSD_ATF_TESTS_SH+= mount_test # XXX: need to replace `mknod ... p` with something more sensible #NETBSD_ATF_TESTS_SH+= pipes_test NETBSD_ATF_TESTS_SH+= trail_slash_test NETBSD_ATF_TESTS_SH+= readdir_test NETBSD_ATF_TESTS_SH+= remove_test NETBSD_ATF_TESTS_SH+= rename_test NETBSD_ATF_TESTS_SH+= rmdir_test NETBSD_ATF_TESTS_SH+= setattr_test NETBSD_ATF_TESTS_SH+= sizes_test NETBSD_ATF_TESTS_SH+= sockets_test NETBSD_ATF_TESTS_SH+= statvfs_test NETBSD_ATF_TESTS_SH+= symlink_test NETBSD_ATF_TESTS_SH+= times_test NETBSD_ATF_TESTS_SH+= truncate_test NETBSD_ATF_TESTS_SH+= vnd_test NETBSD_ATF_TESTS_SH+= vnode_leak_test ${PACKAGE}FILES+= h_funcs.subr ${PACKAGE}FILESDIR= ${TESTSDIR} PROGS+= h_tools BINDIR.h_tools= ${TESTSDIR} +ATF_TESTS_SH_SED_mknod_test= \ + -e 's,mknod pipe p,mkfifo pipe,g' \ + -e 's,mknod dir/pipe p,mkfifo dir/pipe,g' + ATF_TESTS_SH_SED_mount_test= \ -e 's,-o -g,-o gid=,g' \ -e 's,-o -m,-o mode=,g' \ -e 's,-o -s,-o size=,g' \ -e 's,-o -u,-o uid=,g' \ -e 's,mount_${FILESYSTEM},mount -t ${FILESYSTEM},g' +ATF_TESTS_SH_SED_readdir_test= -e 's,mknod fifo p,mkfifo fifo,g' ATF_TESTS_SH_SED_sizes_test= -e 's,-o -s,-o size=,g' ATF_TESTS_SH_SED_statvfs_test= -e 's,-o -s,-o size=,g' ATF_TESTS_SH_SED_vnode_leak_test= -e 's,-o -s,-o size=,g' .include .include Index: head/usr.bin/uniq/Makefile =================================================================== --- head/usr.bin/uniq/Makefile (revision 313438) +++ head/usr.bin/uniq/Makefile (revision 313439) @@ -1,6 +1,12 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ +.include + PROG= uniq + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif .include Index: head/usr.bin/uniq/tests/Makefile =================================================================== --- head/usr.bin/uniq/tests/Makefile (nonexistent) +++ head/usr.bin/uniq/tests/Makefile (revision 313439) @@ -0,0 +1,16 @@ +# $FreeBSD$ + +PACKAGE= tests + +NETBSD_ATF_TESTS_SH= uniq_test + +${PACKAGE}FILES+= d_basic.in +${PACKAGE}FILES+= d_basic.out +${PACKAGE}FILES+= d_counts.out +${PACKAGE}FILES+= d_input.in +${PACKAGE}FILES+= d_show_duplicates.out +${PACKAGE}FILES+= d_show_uniques.out + +.include + +.include Property changes on: head/usr.bin/uniq/tests/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/usr.bin/uniq/tests/Makefile.depend =================================================================== --- head/usr.bin/uniq/tests/Makefile.depend (nonexistent) +++ head/usr.bin/uniq/tests/Makefile.depend (revision 313439) @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif Property changes on: head/usr.bin/uniq/tests/Makefile.depend ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head =================================================================== --- head (revision 313438) +++ head (revision 313439) Property changes on: head ___________________________________________________________________ Modified: svn:mergeinfo ## -0,1 +0,1 ## Reverse-merged /head:r312194 Merged /projects/netbsd-tests-upstream-01-2017:r312125-313435