package compiler and linker metadata toolkit

basic.sh 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. #!/usr/bin/env atf-sh
  2. . $(atf_get_srcdir)/test_env.sh
  3. tests_init \
  4. noargs \
  5. libs \
  6. libs_cflags \
  7. libs_cflags_version \
  8. libs_cflags_version_multiple \
  9. libs_cflags_version_alt \
  10. libs_cflags_version_different \
  11. libs_cflags_version_different_bad \
  12. exists_nonexitent \
  13. nonexitent \
  14. exists_version \
  15. exists_version_bad \
  16. exists_version_bad2 \
  17. exists_version_bad3 \
  18. exists \
  19. exists2 \
  20. exists3 \
  21. exists_version_alt \
  22. uninstalled_bad \
  23. uninstalled \
  24. libs_intermediary \
  25. libs_circular1 \
  26. libs_circular2 \
  27. libs_circular_directpc \
  28. libs_static \
  29. pkg_config_path \
  30. nolibs \
  31. nocflags \
  32. arbitary_path
  33. noargs_body()
  34. {
  35. export PKG_CONFIG_PATH="${selfdir}/lib1"
  36. atf_check -s exit:1 -e ignore pkgconf
  37. }
  38. libs_body()
  39. {
  40. export PKG_CONFIG_PATH="${selfdir}/lib1"
  41. atf_check \
  42. -o inline:"-L/test/lib -lfoo \n" \
  43. pkgconf --libs foo
  44. }
  45. libs_cflags_body()
  46. {
  47. export PKG_CONFIG_PATH="${selfdir}/lib1"
  48. atf_check \
  49. -o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
  50. pkgconf --cflags --libs foo
  51. }
  52. atf_test_case basic_libs_cflags_version
  53. libs_cflags_version_body()
  54. {
  55. export PKG_CONFIG_PATH="${selfdir}/lib1"
  56. atf_check \
  57. -o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
  58. pkgconf --cflags --libs 'foo > 1.2'
  59. }
  60. libs_cflags_version_multiple_body()
  61. {
  62. export PKG_CONFIG_PATH="${selfdir}/lib1"
  63. atf_check \
  64. -o inline:"-I/test/include/foo -fPIC -L/test/lib -lbar -lfoo \n" \
  65. pkgconf --cflags --libs 'foo > 1.2 bar >= 1.3'
  66. }
  67. libs_cflags_version_multiple_coma_body()
  68. {
  69. export PKG_CONFIG_PATH="${selfdir}/lib1"
  70. atf_check \
  71. -o inline:"-I/test/include/foo -fPIC -L/test/lib -lbar -lfoo \n" \
  72. pkgconf --cflags --libs 'foo > 1.2,bar >= 1.3'
  73. }
  74. libs_cflags_version_alt_body()
  75. {
  76. export PKG_CONFIG_PATH="${selfdir}/lib1"
  77. atf_check \
  78. -o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
  79. pkgconf --cflags --libs 'foo' '>' '1.2'
  80. }
  81. libs_cflags_version_different_body()
  82. {
  83. export PKG_CONFIG_PATH="${selfdir}/lib1"
  84. atf_check \
  85. -o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
  86. pkgconf --cflags --libs 'foo' '!=' '1.3.0'
  87. }
  88. atf_test_case basic_libs_cflags_version_different_bad
  89. libs_cflags_version_different_bad_body()
  90. {
  91. export PKG_CONFIG_PATH="${selfdir}/lib1"
  92. atf_check \
  93. -s exit:1 \
  94. -e inline:"Package dependency requirement 'foo != 1.2.3' could not be satisfied.\nPackage 'foo' has version '1.2.3', required version is '!= 1.2.3'\n" \
  95. pkgconf --cflags --libs 'foo' '!=' '1.2.3'
  96. }
  97. exists_nonexitent_body()
  98. {
  99. export PKG_CONFIG_PATH="${selfdir}/lib1"
  100. atf_check \
  101. -s exit:1 \
  102. pkgconf --exists nonexistant
  103. }
  104. nonexitent_body()
  105. {
  106. export PKG_CONFIG_PATH="${selfdir}/lib1"
  107. atf_check \
  108. -s exit:1 \
  109. pkgconf nonexistant
  110. }
  111. exists_version_body()
  112. {
  113. export PKG_CONFIG_PATH="${selfdir}/lib1"
  114. atf_check \
  115. pkgconf --exists 'foo > 1.2'
  116. }
  117. exists_version_bad_body()
  118. {
  119. export PKG_CONFIG_PATH="${selfdir}/lib1"
  120. atf_check \
  121. -s exit:1 \
  122. pkgconf --exists 'foo > 1.2.3'
  123. }
  124. exists_version_alt_body()
  125. {
  126. export PKG_CONFIG_PATH="${selfdir}/lib1"
  127. atf_check \
  128. pkgconf --exists 'foo' '>' '1.2'
  129. }
  130. uninstalled_bad_body()
  131. {
  132. export PKG_CONFIG_PATH="${selfdir}/lib1"
  133. atf_check \
  134. -s exit:1 \
  135. pkgconf --uninstalled 'foo'
  136. }
  137. uninstalled_body()
  138. {
  139. export PKG_CONFIG_PATH="${selfdir}/lib1"
  140. atf_check \
  141. pkgconf --uninstalled 'omg'
  142. }
  143. exists_version_bad2_body()
  144. {
  145. export PKG_CONFIG_PATH="${selfdir}/lib1"
  146. atf_check \
  147. -s exit:1 \
  148. pkgconf --exists 'foo >= '
  149. }
  150. exists_version_bad3_body()
  151. {
  152. export PKG_CONFIG_PATH="${selfdir}/lib1"
  153. atf_check \
  154. -s exit:1 \
  155. pkgconf --exists 'tilde <= 1.0.0'
  156. }
  157. exists_body()
  158. {
  159. export PKG_CONFIG_PATH="${selfdir}/lib1"
  160. atf_check \
  161. pkgconf --exists 'tilde = 1.0.0~rc1'
  162. }
  163. exists2_body()
  164. {
  165. export PKG_CONFIG_PATH="${selfdir}/lib1"
  166. atf_check \
  167. pkgconf --exists 'tilde >= 1.0.0'
  168. }
  169. exists3_body()
  170. {
  171. export PKG_CONFIG_PATH="${selfdir}/lib1"
  172. atf_check \
  173. pkgconf --exists '' 'foo'
  174. }
  175. libs_intermediary_body()
  176. {
  177. export PKG_CONFIG_PATH="${selfdir}/lib1"
  178. atf_check \
  179. -o inline:"-lintermediary-1 -lintermediary-2 -lfoo -lbar -lbaz \n" \
  180. pkgconf --libs intermediary-1 intermediary-2
  181. }
  182. libs_circular1_body()
  183. {
  184. export PKG_CONFIG_PATH="${selfdir}/lib1"
  185. atf_check \
  186. -o inline:"-lcircular-1 -lcircular-2 -lcircular-3 \n" \
  187. pkgconf --libs circular-1
  188. }
  189. libs_circular2_body()
  190. {
  191. export PKG_CONFIG_PATH="${selfdir}/lib1"
  192. atf_check \
  193. -o inline:"-lcircular-3 -lcircular-1 -lcircular-2 \n" \
  194. pkgconf --libs circular-3
  195. }
  196. libs_circular_directpc_body()
  197. {
  198. atf_check \
  199. -o inline:"-lcircular-1 -lcircular-2 -lcircular-3 \n" \
  200. pkgconf --libs ${selfdir}/lib1/circular-3.pc
  201. }
  202. libs_static_body()
  203. {
  204. export PKG_CONFIG_PATH="${selfdir}/lib1"
  205. atf_check \
  206. -o inline:"/libfoo.a -pthread \n" \
  207. pkgconf --libs static-archive-libs
  208. }
  209. pkg_config_path_body()
  210. {
  211. export PKG_CONFIG_PATH="${selfdir}/lib1${PATH_SEP}${selfdir}/lib2"
  212. atf_check \
  213. -o inline:"-L/test/lib -lfoo \n" \
  214. pkgconf --libs foo
  215. atf_check \
  216. -o inline:"-L/test/lib -lbar -lfoo \n" \
  217. pkgconf --libs bar
  218. }
  219. nolibs_body()
  220. {
  221. export PKG_CONFIG_PATH="${selfdir}/lib1"
  222. atf_check \
  223. -o inline:" \n" \
  224. pkgconf --libs nolib
  225. }
  226. nocflags_body()
  227. {
  228. export PKG_CONFIG_PATH="${selfdir}/lib1"
  229. atf_check \
  230. -o inline:" \n" \
  231. pkgconf --cflags nocflag
  232. }
  233. arbitary_path_body()
  234. {
  235. cp ${selfdir}/lib1/foo.pc .
  236. atf_check \
  237. -o inline:"-L/test/lib -lfoo \n" \
  238. pkgconf --libs foo.pc
  239. }