2
1

0001-meson-Make-tests-optional.patch 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. From 3163c49f9f4ad473a00d8a345ee334a028376011 Mon Sep 17 00:00:00 2001
  2. From: Heiko Becker <heirecka@exherbo.org>
  3. Date: Fri, 23 Jul 2021 16:32:46 +0200
  4. Subject: [PATCH] meson: Make tests optional
  5. Now can be disabled with -DSKIP_TESTS=true.
  6. It allows to avoid meson error during build when ip isn't installed.
  7. Closes: #359
  8. Reviewed-by: Petr Vorel <petr.vorel@gmail.com>
  9. Signed-off-by: Heiko Becker <heirecka@exherbo.org>
  10. [ pvorel: Rename variable TEST => SKIP_TESTS, default false, adjust
  11. the description ]
  12. Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
  13. [Retrieved from:
  14. https://github.com/iputils/iputils/commit/3163c49f9f4ad473a00d8a345ee334a028376011]
  15. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  16. ---
  17. meson_options.txt | 3 ++
  18. ping/meson.build | 84 ++-----------------------------------------
  19. ping/test/meson.build | 81 +++++++++++++++++++++++++++++++++++++++++
  20. 3 files changed, 86 insertions(+), 82 deletions(-)
  21. create mode 100644 ping/test/meson.build
  22. diff --git a/meson_options.txt b/meson_options.txt
  23. index ac5f5d98..517667f4 100644
  24. --- a/meson_options.txt
  25. +++ b/meson_options.txt
  26. @@ -72,3 +72,6 @@ option('INSTALL_SYSTEMD_UNITS', type: 'boolean', value: false,
  27. option('USE_GETTEXT', type: 'boolean', value: true,
  28. description: 'Enable I18N')
  29. +
  30. +option('SKIP_TESTS', type: 'boolean', value: false,
  31. + description: 'Skip tests during build')
  32. diff --git a/ping/meson.build b/ping/meson.build
  33. index 1e678ec8..83ea353c 100644
  34. --- a/ping/meson.build
  35. +++ b/ping/meson.build
  36. @@ -27,86 +27,6 @@ if (setcap_ping)
  37. )
  38. endif
  39. -##### TESTS #####
  40. -
  41. -# TODO: ::1 generates DEPRECATION: ":" is not allowed in test name "ping -c1 ::1", it has been replaced with "_"
  42. -
  43. -# GitHub CI does not have working IPv6
  44. -# https://github.com/actions/virtual-environments/issues/668
  45. -ipv6_dst = []
  46. -ipv6_switch = []
  47. -r = run_command('ip', '-6', 'a')
  48. -if r.stdout().strip().contains('::1')
  49. - message('IPv6 enabled')
  50. - ipv6_dst = [ '::1' ]
  51. - ipv6_switch = [ '-6' ]
  52. -else
  53. - message('WARNING: IPv6 disabled')
  54. +if not get_option('SKIP_TESTS')
  55. + subdir('test')
  56. endif
  57. -
  58. -run_as_root = false
  59. -r = run_command('id', '-u')
  60. -if r.stdout().strip().to_int() == 0
  61. - message('running as root')
  62. - run_as_root = true
  63. -else
  64. - message('running as normal user')
  65. -endif
  66. -
  67. -foreach dst : [ 'localhost', '127.0.0.1' ] + ipv6_dst
  68. - foreach switch : [ '', '-4' ] + ipv6_switch
  69. - args = [ '-c1', dst ]
  70. - should_fail = false
  71. -
  72. - if switch != ''
  73. - args = [switch] + args
  74. - if (switch == '-4' and dst == '::1') or (switch == '-6' and dst == '127.0.0.1')
  75. - should_fail = true
  76. - endif
  77. - endif
  78. -
  79. - name = 'ping ' + ' '.join(args)
  80. - test(name, ping, args : args, should_fail : should_fail)
  81. - endforeach
  82. -endforeach
  83. -
  84. -ping_tests_opt = [
  85. - [ '-c1' ],
  86. - [ '-c5', '-i0.1' ],
  87. - [ '-c1', '-I', 'lo' ],
  88. - [ '-c1', '-w1' ],
  89. - [ '-c1', '-W1' ],
  90. - [ '-c1', '-W1.1' ],
  91. -]
  92. -foreach dst : [ '127.0.0.1' ] + ipv6_dst
  93. - foreach args : ping_tests_opt
  94. - args += [ dst ]
  95. - name = 'ping ' + ' '.join(args)
  96. - test(name, ping, args : args)
  97. - endforeach
  98. -endforeach
  99. -
  100. -ping_tests_opt_fail = [
  101. - [ '-c1.1' ],
  102. - [ '-I', 'nonexisting' ],
  103. - [ '-w0.1' ],
  104. - [ '-w0,1' ],
  105. -]
  106. -foreach dst : [ '127.0.0.1' ] + ipv6_dst
  107. - foreach args : ping_tests_opt_fail
  108. - args += [ dst ]
  109. - name = 'ping ' + ' '.join(args)
  110. - test(name, ping, args : args, should_fail : true)
  111. - endforeach
  112. -endforeach
  113. -
  114. -ping_tests_user_fail = [
  115. - [ '-c1', '-i0.001' ], # -c1 required to quit ping when running as root
  116. -]
  117. -foreach dst : [ '127.0.0.1' ] + ipv6_dst
  118. - foreach args : ping_tests_user_fail
  119. - args += [ dst ]
  120. - name = 'ping ' + ' '.join(args)
  121. - test(name, ping, args : args, should_fail : not run_as_root)
  122. - endforeach
  123. -endforeach
  124. diff --git a/ping/test/meson.build b/ping/test/meson.build
  125. new file mode 100644
  126. index 00000000..43aed758
  127. --- /dev/null
  128. +++ b/ping/test/meson.build
  129. @@ -0,0 +1,81 @@
  130. +# TODO: ::1 generates DEPRECATION: ":" is not allowed in test name "ping -c1 ::1", it has been replaced with "_"
  131. +
  132. +# GitHub CI does not have working IPv6
  133. +# https://github.com/actions/virtual-environments/issues/668
  134. +ipv6_dst = []
  135. +ipv6_switch = []
  136. +r = run_command('ip', '-6', 'a')
  137. +if r.stdout().strip().contains('::1')
  138. + message('IPv6 enabled')
  139. + ipv6_dst = [ '::1' ]
  140. + ipv6_switch = [ '-6' ]
  141. +else
  142. + message('WARNING: IPv6 disabled')
  143. +endif
  144. +
  145. +run_as_root = false
  146. +r = run_command('id', '-u')
  147. +if r.stdout().strip().to_int() == 0
  148. + message('running as root')
  149. + run_as_root = true
  150. +else
  151. + message('running as normal user')
  152. +endif
  153. +
  154. +foreach dst : [ 'localhost', '127.0.0.1' ] + ipv6_dst
  155. + foreach switch : [ '', '-4' ] + ipv6_switch
  156. + args = [ '-c1', dst ]
  157. + should_fail = false
  158. +
  159. + if switch != ''
  160. + args = [switch] + args
  161. + if (switch == '-4' and dst == '::1') or (switch == '-6' and dst == '127.0.0.1')
  162. + should_fail = true
  163. + endif
  164. + endif
  165. +
  166. + name = 'ping ' + ' '.join(args)
  167. + test(name, ping, args : args, should_fail : should_fail)
  168. + endforeach
  169. +endforeach
  170. +
  171. +ping_tests_opt = [
  172. + [ '-c1' ],
  173. + [ '-c5', '-i0.1' ],
  174. + [ '-c1', '-I', 'lo' ],
  175. + [ '-c1', '-w1' ],
  176. + [ '-c1', '-W1' ],
  177. + [ '-c1', '-W1.1' ],
  178. +]
  179. +foreach dst : [ '127.0.0.1' ] + ipv6_dst
  180. + foreach args : ping_tests_opt
  181. + args += [ dst ]
  182. + name = 'ping ' + ' '.join(args)
  183. + test(name, ping, args : args)
  184. + endforeach
  185. +endforeach
  186. +
  187. +ping_tests_opt_fail = [
  188. + [ '-c1.1' ],
  189. + [ '-I', 'nonexisting' ],
  190. + [ '-w0.1' ],
  191. + [ '-w0,1' ],
  192. +]
  193. +foreach dst : [ '127.0.0.1' ] + ipv6_dst
  194. + foreach args : ping_tests_opt_fail
  195. + args += [ dst ]
  196. + name = 'ping ' + ' '.join(args)
  197. + test(name, ping, args : args, should_fail : true)
  198. + endforeach
  199. +endforeach
  200. +
  201. +ping_tests_user_fail = [
  202. + [ '-c1', '-i0.001' ], # -c1 required to quit ping when running as root
  203. +]
  204. +foreach dst : [ '127.0.0.1' ] + ipv6_dst
  205. + foreach args : ping_tests_user_fail
  206. + args += [ dst ]
  207. + name = 'ping ' + ' '.join(args)
  208. + test(name, ping, args : args, should_fail : not run_as_root)
  209. + endforeach
  210. +endforeach