3
0

ls.tests 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. #!/bin/sh
  2. # Copyright 2010 by Denys Vlasenko
  3. # Licensed under GPLv2, see file LICENSE in this source tree.
  4. . ./testing.sh
  5. test -f "$bindir/.config" && . "$bindir/.config"
  6. rm -rf ls.testdir 2>/dev/null
  7. mkdir ls.testdir || exit 1
  8. # testing "test name" "command" "expected result" "file input" "stdin"
  9. # With Unicode provided by libc locale, I'm not sure this test can pass.
  10. # I suspect we might fail to skip exactly correct number of bytes
  11. # over broked unicode sequences.
  12. test x"$CONFIG_UNICODE_SUPPORT" = x"y" \
  13. && test x"$CONFIG_UNICODE_USING_LOCALE" != x"y" \
  14. && test x"$CONFIG_SUBST_WCHAR" = x"63" \
  15. && test x"$CONFIG_LAST_SUPPORTED_WCHAR" = x"767" \
  16. && test x"$CONFIG_FEATURE_LS_SORTFILES" = x"y" \
  17. && testing "ls unicode test with codepoints limited to 767" \
  18. "(cd ls.testdir && sh ../ls.mk_uni_tests) && ls -1 ls.testdir" \
  19. '0001_1__Some_correct_UTF-8_text___________________________________________|
  20. 0002_2__Boundary_condition_test_cases_____________________________________|
  21. 0003_2.1__First_possible_sequence_of_a_certain_length_____________________|
  22. 0004_2.1.2__2_bytes__U-00000080_:________"?"______________________________|
  23. 0005_2.1.3__3_bytes__U-00000800_:________"?"______________________________|
  24. 0006_2.1.4__4_bytes__U-00010000_:________"?"______________________________|
  25. 0007_2.1.5__5_bytes__U-00200000_:________"?"______________________________|
  26. 0008_2.1.6__6_bytes__U-04000000_:________"?"______________________________|
  27. 0009_2.2__Last_possible_sequence_of_a_certain_length______________________|
  28. 0010_2.2.1__1_byte___U-0000007F_:________"?"______________________________|
  29. 0011_2.2.2__2_bytes__U-000007FF_:________"?"______________________________|
  30. 0012_2.2.3__3_bytes__U-0000FFFF_:________"?"______________________________|
  31. 0013_2.2.4__4_bytes__U-001FFFFF_:________"?"______________________________|
  32. 0014_2.2.5__5_bytes__U-03FFFFFF_:________"?"______________________________|
  33. 0015_2.2.6__6_bytes__U-7FFFFFFF_:________"?"______________________________|
  34. 0016_2.3__Other_boundary_conditions_______________________________________|
  35. 0017_2.3.1__U-0000D7FF_=_ed_9f_bf_=_"?"___________________________________|
  36. 0018_2.3.2__U-0000E000_=_ee_80_80_=_"?"___________________________________|
  37. 0019_2.3.3__U-0000FFFD_=_ef_bf_bd_=_"?"___________________________________|
  38. 0020_2.3.4__U-0010FFFF_=_f4_8f_bf_bf_=_"?"________________________________|
  39. 0021_2.3.5__U-00110000_=_f4_90_80_80_=_"?"________________________________|
  40. 0022_3__Malformed_sequences_______________________________________________|
  41. 0023_3.1__Unexpected_continuation_bytes___________________________________|
  42. 0024_3.1.1__First_continuation_byte_0x80:_"?"_____________________________|
  43. 0025_3.1.2__Last__continuation_byte_0xbf:_"?"_____________________________|
  44. 0026_3.1.3__2_continuation_bytes:_"??"____________________________________|
  45. 0027_3.1.4__3_continuation_bytes:_"???"___________________________________|
  46. 0028_3.1.5__4_continuation_bytes:_"????"__________________________________|
  47. 0029_3.1.6__5_continuation_bytes:_"?????"_________________________________|
  48. 0030_3.1.7__6_continuation_bytes:_"??????"________________________________|
  49. 0031_3.1.8__7_continuation_bytes:_"???????"_______________________________|
  50. 0032_3.1.9__Sequence_of_all_64_possible_continuation_bytes__0x80-0xbf_:___|
  51. 0033____"????????????????_________________________________________________|
  52. 0034_____????????????????_________________________________________________|
  53. 0035_____????????????????_________________________________________________|
  54. 0036_____????????????????"________________________________________________|
  55. 0037_3.2__Lonely_start_characters_________________________________________|
  56. 0038_3.2.1__All_32_first_bytes_of_2-byte_sequences__0xc0-0xdf_,___________|
  57. 0039________each_followed_by_a_space_character:___________________________|
  58. 0040____"?_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?__________________________________|
  59. 0041_____?_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?_"________________________________|
  60. 0042_3.2.2__All_16_first_bytes_of_3-byte_sequences__0xe0-0xef_,___________|
  61. 0043________each_followed_by_a_space_character:___________________________|
  62. 0044____"?_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?_"________________________________|
  63. 0045_3.2.3__All_8_first_bytes_of_4-byte_sequences__0xf0-0xf7_,____________|
  64. 0046________each_followed_by_a_space_character:___________________________|
  65. 0047____"?_?_?_?_?_?_?_?_"________________________________________________|
  66. 0048_3.2.4__All_4_first_bytes_of_5-byte_sequences__0xf8-0xfb_,____________|
  67. 0049________each_followed_by_a_space_character:___________________________|
  68. 0050____"?_?_?_?_"________________________________________________________|
  69. 0051_3.2.5__All_2_first_bytes_of_6-byte_sequences__0xfc-0xfd_,____________|
  70. 0052________each_followed_by_a_space_character:___________________________|
  71. 0053____"?_?_"____________________________________________________________|
  72. 0054_3.3__Sequences_with_last_continuation_byte_missing___________________|
  73. 0055_3.3.1__2-byte_sequence_with_last_byte_missing__U+0000_:_____"?"______|
  74. 0056_3.3.2__3-byte_sequence_with_last_byte_missing__U+0000_:_____"?"______|
  75. 0057_3.3.3__4-byte_sequence_with_last_byte_missing__U+0000_:_____"?"______|
  76. 0058_3.3.4__5-byte_sequence_with_last_byte_missing__U+0000_:_____"?"______|
  77. 0059_3.3.5__6-byte_sequence_with_last_byte_missing__U+0000_:_____"?"______|
  78. 0060_3.3.6__2-byte_sequence_with_last_byte_missing__U-000007FF_:_"?"______|
  79. 0061_3.3.7__3-byte_sequence_with_last_byte_missing__U-0000FFFF_:_"?"______|
  80. 0062_3.3.8__4-byte_sequence_with_last_byte_missing__U-001FFFFF_:_"?"______|
  81. 0063_3.3.9__5-byte_sequence_with_last_byte_missing__U-03FFFFFF_:_"?"______|
  82. 0064_3.3.10_6-byte_sequence_with_last_byte_missing__U-7FFFFFFF_:_"?"______|
  83. 0065_3.4__Concatenation_of_incomplete_sequences___________________________|
  84. 0066____"??????????"______________________________________________________|
  85. 0067_3.5__Impossible_bytes________________________________________________|
  86. 0068_3.5.1__fe_=_"?"______________________________________________________|
  87. 0069_3.5.2__ff_=_"?"______________________________________________________|
  88. 0070_3.5.3__fe_fe_ff_ff_=_"????"__________________________________________|
  89. 0071_4__Overlong_sequences________________________________________________|
  90. 0072_4.1__Examples_of_an_overlong_ASCII_character_________________________|
  91. 0073_4.1.1_U+002F_=_c0_af_____________=_"?"_______________________________|
  92. 0074_4.1.2_U+002F_=_e0_80_af__________=_"?"_______________________________|
  93. 0075_4.1.3_U+002F_=_f0_80_80_af_______=_"?"_______________________________|
  94. 0076_4.1.4_U+002F_=_f8_80_80_80_af____=_"?"_______________________________|
  95. 0077_4.1.5_U+002F_=_fc_80_80_80_80_af_=_"?"_______________________________|
  96. 0078_4.2__Maximum_overlong_sequences______________________________________|
  97. 0079_4.2.1__U-0000007F_=_c1_bf_____________=_"?"__________________________|
  98. 0080_4.2.2__U-000007FF_=_e0_9f_bf__________=_"?"__________________________|
  99. 0081_4.2.3__U-0000FFFF_=_f0_8f_bf_bf_______=_"?"__________________________|
  100. 0082_4.2.4__U-001FFFFF_=_f8_87_bf_bf_bf____=_"?"__________________________|
  101. 0083_4.2.5__U-03FFFFFF_=_fc_83_bf_bf_bf_bf_=_"?"__________________________|
  102. 0084_4.3__Overlong_representation_of_the_NUL_character____________________|
  103. 0085_4.3.1__U+0000_=_c0_80_____________=_"?"______________________________|
  104. 0086_4.3.2__U+0000_=_e0_80_80__________=_"?"______________________________|
  105. 0087_4.3.3__U+0000_=_f0_80_80_80_______=_"?"______________________________|
  106. 0088_4.3.4__U+0000_=_f8_80_80_80_80____=_"?"______________________________|
  107. 0089_4.3.5__U+0000_=_fc_80_80_80_80_80_=_"?"______________________________|
  108. 0090_5__Illegal_code_positions____________________________________________|
  109. 0091_5.1_Single_UTF-16_surrogates_________________________________________|
  110. 0092_5.1.1__U+D800_=_ed_a0_80_=_"?"_______________________________________|
  111. 0093_5.1.2__U+DB7F_=_ed_ad_bf_=_"?"_______________________________________|
  112. 0094_5.1.3__U+DB80_=_ed_ae_80_=_"?"_______________________________________|
  113. 0095_5.1.4__U+DBFF_=_ed_af_bf_=_"?"_______________________________________|
  114. 0096_5.1.5__U+DC00_=_ed_b0_80_=_"?"_______________________________________|
  115. 0097_5.1.6__U+DF80_=_ed_be_80_=_"?"_______________________________________|
  116. 0098_5.1.7__U+DFFF_=_ed_bf_bf_=_"?"_______________________________________|
  117. 0099_5.2_Paired_UTF-16_surrogates_________________________________________|
  118. 0100_5.2.1__U+D800_U+DC00_=_ed_a0_80_ed_b0_80_=_"??"______________________|
  119. 0101_5.2.2__U+D800_U+DFFF_=_ed_a0_80_ed_bf_bf_=_"??"______________________|
  120. 0102_5.2.3__U+DB7F_U+DC00_=_ed_ad_bf_ed_b0_80_=_"??"______________________|
  121. 0103_5.2.4__U+DB7F_U+DFFF_=_ed_ad_bf_ed_bf_bf_=_"??"______________________|
  122. 0104_5.2.5__U+DB80_U+DC00_=_ed_ae_80_ed_b0_80_=_"??"______________________|
  123. 0105_5.2.6__U+DB80_U+DFFF_=_ed_ae_80_ed_bf_bf_=_"??"______________________|
  124. 0106_5.2.7__U+DBFF_U+DC00_=_ed_af_bf_ed_b0_80_=_"??"______________________|
  125. 0107_5.2.8__U+DBFF_U+DFFF_=_ed_af_bf_ed_bf_bf_=_"??"______________________|
  126. 0108_5.3_Other_illegal_code_positions_____________________________________|
  127. 0109_5.3.1__U+FFFE_=_ef_bf_be_=_"?"_______________________________________|
  128. 0110_5.3.2__U+FFFF_=_ef_bf_bf_=_"?"_______________________________________|
  129. ' "" ""
  130. # Currently fails on "0080_4.2.2__U-000007FF_=_e0_9f_bf" line
  131. test x"$CONFIG_UNICODE_SUPPORT" = x"y" \
  132. && test x"$CONFIG_UNICODE_USING_LOCALE" != x"y" \
  133. && test x"$CONFIG_SUBST_WCHAR" = x"63" \
  134. && test x"$CONFIG_LAST_SUPPORTED_WCHAR" = x"0" \
  135. && testing "ls unicode test with unlimited codepoints" \
  136. "(cd ls.testdir && sh ../ls.mk_uni_tests) && ls -1 ls.testdir" \
  137. '0001_1__Some_correct_UTF-8_text___________________________________________|
  138. 0002_2__Boundary_condition_test_cases_____________________________________|
  139. 0003_2.1__First_possible_sequence_of_a_certain_length_____________________|
  140. 0004_2.1.2__2_bytes__U-00000080_:________"?"______________________________|
  141. 0005_2.1.3__3_bytes__U-00000800_:________"ࠀ"______________________________|
  142. 0006_2.1.4__4_bytes__U-00010000_:________"𐀀"______________________________|
  143. 0007_2.1.5__5_bytes__U-00200000_:________"?"______________________________|
  144. 0008_2.1.6__6_bytes__U-04000000_:________"?"______________________________|
  145. 0009_2.2__Last_possible_sequence_of_a_certain_length______________________|
  146. 0010_2.2.1__1_byte___U-0000007F_:________"?"______________________________|
  147. 0011_2.2.2__2_bytes__U-000007FF_:________"߿"______________________________|
  148. 0012_2.2.3__3_bytes__U-0000FFFF_:________"?"______________________________|
  149. 0013_2.2.4__4_bytes__U-001FFFFF_:________"?"______________________________|
  150. 0014_2.2.5__5_bytes__U-03FFFFFF_:________"?"______________________________|
  151. 0015_2.2.6__6_bytes__U-7FFFFFFF_:________"?"______________________________|
  152. 0016_2.3__Other_boundary_conditions_______________________________________|
  153. 0017_2.3.1__U-0000D7FF_=_ed_9f_bf_=_"퟿"___________________________________|
  154. 0018_2.3.2__U-0000E000_=_ee_80_80_=_"?"___________________________________|
  155. 0019_2.3.3__U-0000FFFD_=_ef_bf_bd_=_"�"___________________________________|
  156. 0020_2.3.4__U-0010FFFF_=_f4_8f_bf_bf_=_"?"________________________________|
  157. 0021_2.3.5__U-00110000_=_f4_90_80_80_=_"?"________________________________|
  158. 0022_3__Malformed_sequences_______________________________________________|
  159. 0023_3.1__Unexpected_continuation_bytes___________________________________|
  160. 0024_3.1.1__First_continuation_byte_0x80:_"?"_____________________________|
  161. 0025_3.1.2__Last__continuation_byte_0xbf:_"?"_____________________________|
  162. 0026_3.1.3__2_continuation_bytes:_"??"____________________________________|
  163. 0027_3.1.4__3_continuation_bytes:_"???"___________________________________|
  164. 0028_3.1.5__4_continuation_bytes:_"????"__________________________________|
  165. 0029_3.1.6__5_continuation_bytes:_"?????"_________________________________|
  166. 0030_3.1.7__6_continuation_bytes:_"??????"________________________________|
  167. 0031_3.1.8__7_continuation_bytes:_"???????"_______________________________|
  168. 0032_3.1.9__Sequence_of_all_64_possible_continuation_bytes__0x80-0xbf_:___|
  169. 0033____"????????????????_________________________________________________|
  170. 0034_____????????????????_________________________________________________|
  171. 0035_____????????????????_________________________________________________|
  172. 0036_____????????????????"________________________________________________|
  173. 0037_3.2__Lonely_start_characters_________________________________________|
  174. 0038_3.2.1__All_32_first_bytes_of_2-byte_sequences__0xc0-0xdf_,___________|
  175. 0039________each_followed_by_a_space_character:___________________________|
  176. 0040____"?_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?__________________________________|
  177. 0041_____?_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?_"________________________________|
  178. 0042_3.2.2__All_16_first_bytes_of_3-byte_sequences__0xe0-0xef_,___________|
  179. 0043________each_followed_by_a_space_character:___________________________|
  180. 0044____"?_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?_"________________________________|
  181. 0045_3.2.3__All_8_first_bytes_of_4-byte_sequences__0xf0-0xf7_,____________|
  182. 0046________each_followed_by_a_space_character:___________________________|
  183. 0047____"?_?_?_?_?_?_?_?_"________________________________________________|
  184. 0048_3.2.4__All_4_first_bytes_of_5-byte_sequences__0xf8-0xfb_,____________|
  185. 0049________each_followed_by_a_space_character:___________________________|
  186. 0050____"?_?_?_?_"________________________________________________________|
  187. 0051_3.2.5__All_2_first_bytes_of_6-byte_sequences__0xfc-0xfd_,____________|
  188. 0052________each_followed_by_a_space_character:___________________________|
  189. 0053____"?_?_"____________________________________________________________|
  190. 0054_3.3__Sequences_with_last_continuation_byte_missing___________________|
  191. 0055_3.3.1__2-byte_sequence_with_last_byte_missing__U+0000_:_____"?"______|
  192. 0056_3.3.2__3-byte_sequence_with_last_byte_missing__U+0000_:_____"?"______|
  193. 0057_3.3.3__4-byte_sequence_with_last_byte_missing__U+0000_:_____"?"______|
  194. 0058_3.3.4__5-byte_sequence_with_last_byte_missing__U+0000_:_____"?"______|
  195. 0059_3.3.5__6-byte_sequence_with_last_byte_missing__U+0000_:_____"?"______|
  196. 0060_3.3.6__2-byte_sequence_with_last_byte_missing__U-000007FF_:_"?"______|
  197. 0061_3.3.7__3-byte_sequence_with_last_byte_missing__U-0000FFFF_:_"?"______|
  198. 0062_3.3.8__4-byte_sequence_with_last_byte_missing__U-001FFFFF_:_"?"______|
  199. 0063_3.3.9__5-byte_sequence_with_last_byte_missing__U-03FFFFFF_:_"?"______|
  200. 0064_3.3.10_6-byte_sequence_with_last_byte_missing__U-7FFFFFFF_:_"?"______|
  201. 0065_3.4__Concatenation_of_incomplete_sequences___________________________|
  202. 0066____"??????????"______________________________________________________|
  203. 0067_3.5__Impossible_bytes________________________________________________|
  204. 0068_3.5.1__fe_=_"?"______________________________________________________|
  205. 0069_3.5.2__ff_=_"?"______________________________________________________|
  206. 0070_3.5.3__fe_fe_ff_ff_=_"????"__________________________________________|
  207. 0071_4__Overlong_sequences________________________________________________|
  208. 0072_4.1__Examples_of_an_overlong_ASCII_character_________________________|
  209. 0073_4.1.1_U+002F_=_c0_af_____________=_"?"_______________________________|
  210. 0074_4.1.2_U+002F_=_e0_80_af__________=_"?"_______________________________|
  211. 0075_4.1.3_U+002F_=_f0_80_80_af_______=_"?"_______________________________|
  212. 0076_4.1.4_U+002F_=_f8_80_80_80_af____=_"?"_______________________________|
  213. 0077_4.1.5_U+002F_=_fc_80_80_80_80_af_=_"?"_______________________________|
  214. 0078_4.2__Maximum_overlong_sequences______________________________________|
  215. 0079_4.2.1__U-0000007F_=_c1_bf_____________=_"?"__________________________|
  216. 0080_4.2.2__U-000007FF_=_e0_9f_bf__________=_"?"__________________________|
  217. 0081_4.2.3__U-0000FFFF_=_f0_8f_bf_bf_______=_"?"__________________________|
  218. 0082_4.2.4__U-001FFFFF_=_f8_87_bf_bf_bf____=_"?"__________________________|
  219. 0083_4.2.5__U-03FFFFFF_=_fc_83_bf_bf_bf_bf_=_"?"__________________________|
  220. 0084_4.3__Overlong_representation_of_the_NUL_character____________________|
  221. 0085_4.3.1__U+0000_=_c0_80_____________=_"?"______________________________|
  222. 0086_4.3.2__U+0000_=_e0_80_80__________=_"?"______________________________|
  223. 0087_4.3.3__U+0000_=_f0_80_80_80_______=_"?"______________________________|
  224. 0088_4.3.4__U+0000_=_f8_80_80_80_80____=_"?"______________________________|
  225. 0089_4.3.5__U+0000_=_fc_80_80_80_80_80_=_"?"______________________________|
  226. 0090_5__Illegal_code_positions____________________________________________|
  227. 0091_5.1_Single_UTF-16_surrogates_________________________________________|
  228. 0092_5.1.1__U+D800_=_ed_a0_80_=_"?"_______________________________________|
  229. 0093_5.1.2__U+DB7F_=_ed_ad_bf_=_"?"_______________________________________|
  230. 0094_5.1.3__U+DB80_=_ed_ae_80_=_"?"_______________________________________|
  231. 0095_5.1.4__U+DBFF_=_ed_af_bf_=_"?"_______________________________________|
  232. 0096_5.1.5__U+DC00_=_ed_b0_80_=_"?"_______________________________________|
  233. 0097_5.1.6__U+DF80_=_ed_be_80_=_"?"_______________________________________|
  234. 0098_5.1.7__U+DFFF_=_ed_bf_bf_=_"?"_______________________________________|
  235. 0099_5.2_Paired_UTF-16_surrogates_________________________________________|
  236. 0100_5.2.1__U+D800_U+DC00_=_ed_a0_80_ed_b0_80_=_"??"______________________|
  237. 0101_5.2.2__U+D800_U+DFFF_=_ed_a0_80_ed_bf_bf_=_"??"______________________|
  238. 0102_5.2.3__U+DB7F_U+DC00_=_ed_ad_bf_ed_b0_80_=_"??"______________________|
  239. 0103_5.2.4__U+DB7F_U+DFFF_=_ed_ad_bf_ed_bf_bf_=_"??"______________________|
  240. 0104_5.2.5__U+DB80_U+DC00_=_ed_ae_80_ed_b0_80_=_"??"______________________|
  241. 0105_5.2.6__U+DB80_U+DFFF_=_ed_ae_80_ed_bf_bf_=_"??"______________________|
  242. 0106_5.2.7__U+DBFF_U+DC00_=_ed_af_bf_ed_b0_80_=_"??"______________________|
  243. 0107_5.2.8__U+DBFF_U+DFFF_=_ed_af_bf_ed_bf_bf_=_"??"______________________|
  244. 0108_5.3_Other_illegal_code_positions_____________________________________|
  245. 0109_5.3.1__U+FFFE_=_ef_bf_be_=_"?"_______________________________________|
  246. 0110_5.3.2__U+FFFF_=_ef_bf_bf_=_"?"_______________________________________|
  247. ' "" ""
  248. # Clean up
  249. rm -rf ls.testdir 2>/dev/null
  250. exit $FAILCOUNT