test-functions-source.sh 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  1. # -----------------------------------------------------------------------------
  2. # This file is part of the xPack distribution.
  3. # (https://xpack.github.io)
  4. # Copyright (c) 2020 Liviu Ionescu.
  5. #
  6. # Permission to use, copy, modify, and/or distribute this software
  7. # for any purpose is hereby granted, under the terms of the MIT license.
  8. # -----------------------------------------------------------------------------
  9. # Helper script used in the tests.
  10. # -----------------------------------------------------------------------------
  11. # https://github.com/docker-library/official-images#architectures-other-than-amd64
  12. # - https://hub.docker.com/_/ubuntu
  13. # - https://hub.docker.com/r/i386/ubuntu/
  14. # - https://hub.docker.com/r/arm32v7/ubuntu
  15. # - https://hub.docker.com/_/debian
  16. # - https://hub.docker.com/r/i386/debian
  17. # - https://hub.docker.com/r/arm32v7/debian
  18. # - https://hub.docker.com/_/centos
  19. # - https://hub.docker.com/r/i386/centos
  20. # - https://hub.docker.com/r/opensuse/tumbleweed
  21. # - https://hub.docker.com/_/fedora
  22. # - https://hub.docker.com/_/archlinux
  23. # - https://hub.docker.com/u/manjarolinux
  24. # - https://hub.docker.com/r/gentoo/portage
  25. # "i386/ubuntu:20.04" # Fails to install prerequisites
  26. # "i386/ubuntu:12.04" --skip-gdb-py # Not available
  27. # "i386/centos:8" # not available
  28. # arm32v7/fedora:29 - Error: Failed to synchronize cache for repo 'fedora-modular'
  29. # arm32v7/fedora:27 - Error: Failed to synchronize cache for repo 'fedora-modular'
  30. # arm32v7/fedora:25 - KeyError: 'armv8l'
  31. # Debian versions: 8 jessie, 9 stretch, 10 buster.
  32. function create_stable_data_file()
  33. {
  34. local message="$1"
  35. local branch="$2"
  36. local base_url="$3"
  37. local data_file_path="$4"
  38. # Note: __EOF__ is NOT quoted to allow substitutions.
  39. cat <<__EOF__ > "${data_file_path}"
  40. {
  41. "request": {
  42. "message": "${message}",
  43. "branch": "${branch}",
  44. "config": {
  45. "merge_mode": "replace",
  46. "jobs": [
  47. {
  48. "name": "Ubuntu 12, 14, 16, 18, 20 (Intel 64-bit)",
  49. "os": "linux",
  50. "arch": "amd64",
  51. "dist": "bionic",
  52. "services": [ "docker" ],
  53. "language": "minimal",
  54. "script": [
  55. "env | sort",
  56. "pwd",
  57. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:20.04 ${base_url} ",
  58. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:18.04 ${base_url} ",
  59. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:16.04 ${base_url} ",
  60. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:14.04 ${base_url} ",
  61. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:12.04 ${base_url} "
  62. ]
  63. },
  64. {
  65. "name": "Ubuntu 14, 16, 18 (Intel 32-bit)",
  66. "os": "linux",
  67. "arch": "amd64",
  68. "dist": "bionic",
  69. "services": [ "docker" ],
  70. "language": "minimal",
  71. "script": [
  72. "env | sort",
  73. "pwd",
  74. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/ubuntu:18.04 ${base_url} ",
  75. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/ubuntu:16.04 ${base_url} ",
  76. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/ubuntu:14.04 ${base_url} "
  77. ]
  78. },
  79. {
  80. "name": "Ubuntu 16, 18, 20 (Arm 64-bit)",
  81. "os": "linux",
  82. "arch": "arm64",
  83. "dist": "bionic",
  84. "services": [ "docker" ],
  85. "language": "minimal",
  86. "script": [
  87. "env | sort",
  88. "pwd",
  89. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:20.04 ${base_url} ",
  90. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:18.04 ${base_url} ",
  91. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:16.04 ${base_url} "
  92. ]
  93. },
  94. {
  95. "name": "Ubuntu 16, 18 (Arm 32-bit)",
  96. "os": "linux",
  97. "arch": "arm64",
  98. "dist": "bionic",
  99. "services": [ "docker" ],
  100. "language": "minimal",
  101. "script": [
  102. "env | sort",
  103. "pwd",
  104. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/ubuntu:18.04 ${base_url} ",
  105. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/ubuntu:16.04 ${base_url} "
  106. ]
  107. },
  108. {
  109. "name": "Debian 8, 9, 10 (Intel 64-bit)",
  110. "os": "linux",
  111. "arch": "amd64",
  112. "dist": "bionic",
  113. "services": [ "docker" ],
  114. "language": "minimal",
  115. "script": [
  116. "env | sort",
  117. "pwd",
  118. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:buster ${base_url} ",
  119. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:stretch ${base_url} ",
  120. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:jessie ${base_url} "
  121. ]
  122. },
  123. {
  124. "name": "Debian 8, 9, 10 (Intel 32-bit)",
  125. "os": "linux",
  126. "arch": "amd64",
  127. "dist": "bionic",
  128. "services": [ "docker" ],
  129. "language": "minimal",
  130. "script": [
  131. "env | sort",
  132. "pwd",
  133. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/debian:buster ${base_url} ",
  134. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/debian:stretch ${base_url} ",
  135. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/debian:jessie ${base_url} "
  136. ]
  137. },
  138. {
  139. "name": "Debian 9, 10 (Arm 64-bit)",
  140. "os": "linux",
  141. "arch": "arm64",
  142. "dist": "bionic",
  143. "services": [ "docker" ],
  144. "language": "minimal",
  145. "script": [
  146. "env | sort",
  147. "pwd",
  148. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:buster ${base_url} ",
  149. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:stretch ${base_url} "
  150. ]
  151. },
  152. {
  153. "name": "Debian 9, 10 (Arm 32-bit)",
  154. "os": "linux",
  155. "arch": "arm64",
  156. "dist": "bionic",
  157. "services": [ "docker" ],
  158. "language": "minimal",
  159. "script": [
  160. "env | sort",
  161. "pwd",
  162. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/debian:buster ${base_url} ",
  163. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/debian:stretch ${base_url} "
  164. ]
  165. },
  166. {
  167. "name": "CentOS 7, 8 (Intel 64-bit)",
  168. "os": "linux",
  169. "arch": "amd64",
  170. "dist": "bionic",
  171. "services": [ "docker" ],
  172. "language": "minimal",
  173. "script": [
  174. "env | sort",
  175. "pwd",
  176. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:8 ${base_url} ",
  177. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:7 ${base_url} "
  178. ]
  179. },
  180. {
  181. "name": "CentOS 7 (Intel 32-bit)",
  182. "os": "linux",
  183. "arch": "amd64",
  184. "dist": "bionic",
  185. "services": [ "docker" ],
  186. "language": "minimal",
  187. "script": [
  188. "env | sort",
  189. "pwd",
  190. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/centos:7 ${base_url} "
  191. ]
  192. },
  193. {
  194. "name": "CentOS 7, 8 (Arm 64-bit)",
  195. "os": "linux",
  196. "arch": "arm64",
  197. "dist": "bionic",
  198. "services": [ "docker" ],
  199. "language": "minimal",
  200. "script": [
  201. "env | sort",
  202. "pwd",
  203. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:8 ${base_url} ",
  204. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:7 ${base_url} "
  205. ]
  206. },
  207. {
  208. "name": "OpenSUSE 13, 15 (Intel 64-bit)",
  209. "os": "linux",
  210. "arch": "amd64",
  211. "dist": "bionic",
  212. "services": [ "docker" ],
  213. "language": "minimal",
  214. "script": [
  215. "env | sort",
  216. "pwd",
  217. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh opensuse/leap:15 ${base_url} ",
  218. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh opensuse/amd64:13.2 ${base_url} "
  219. ]
  220. },
  221. {
  222. "name": "OpenSUSE 15 (Arm 64-bit)",
  223. "os": "linux",
  224. "arch": "arm64",
  225. "dist": "bionic",
  226. "services": [ "docker" ],
  227. "language": "minimal",
  228. "script": [
  229. "env | sort",
  230. "pwd",
  231. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh opensuse/leap:15 ${base_url} "
  232. ]
  233. },
  234. {
  235. "name": "Fedora 20, 25, 27, 29, 31 (Intel 64-bit)",
  236. "os": "linux",
  237. "arch": "amd64",
  238. "dist": "bionic",
  239. "services": [ "docker" ],
  240. "language": "minimal",
  241. "script": [
  242. "env | sort",
  243. "pwd",
  244. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:31 ${base_url} ",
  245. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:29 ${base_url} ",
  246. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:27 ${base_url} ",
  247. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:25 ${base_url} ",
  248. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:20 ${base_url} "
  249. ]
  250. },
  251. {
  252. "name": "Fedora 27, 29, 31 (Arm 64-bit)",
  253. "os": "linux",
  254. "arch": "arm64",
  255. "dist": "bionic",
  256. "services": [ "docker" ],
  257. "language": "minimal",
  258. "script": [
  259. "env | sort",
  260. "pwd",
  261. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:31 ${base_url} ",
  262. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:29 ${base_url} ",
  263. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:27 ${base_url} "
  264. ]
  265. },
  266. {
  267. "name": "Raspbian 8, 9 (Arm 32-bit)",
  268. "os": "linux",
  269. "arch": "arm64",
  270. "dist": "bionic",
  271. "services": [ "docker" ],
  272. "language": "minimal",
  273. "script": [
  274. "env | sort",
  275. "pwd",
  276. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 raspbian/stretch ${base_url} ",
  277. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 raspbian/jessie ${base_url} "
  278. ]
  279. },
  280. {
  281. "name": "macOS 10.15 Intel",
  282. "os": "osx",
  283. "arch": "amd64",
  284. "osx_image": "xcode11.5",
  285. "language": "minimal",
  286. "script": [
  287. "env | sort",
  288. "pwd",
  289. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  290. ]
  291. },
  292. {
  293. "name": "macOS 10.14 Intel",
  294. "os": "osx",
  295. "arch": "amd64",
  296. "osx_image": "xcode11.3",
  297. "language": "minimal",
  298. "script": [
  299. "env | sort",
  300. "pwd",
  301. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  302. ]
  303. },
  304. {
  305. "name": "macOS 10.13 Intel",
  306. "os": "osx",
  307. "arch": "amd64",
  308. "osx_image": "xcode10.1",
  309. "language": "minimal",
  310. "script": [
  311. "env | sort",
  312. "pwd",
  313. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  314. ]
  315. },
  316. {
  317. "name": "macOS 10.12 Intel",
  318. "os": "osx",
  319. "arch": "amd64",
  320. "osx_image": "xcode9.2",
  321. "language": "minimal",
  322. "script": [
  323. "env | sort",
  324. "pwd",
  325. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  326. ]
  327. },
  328. {
  329. "name": "macOS 10.11 Intel",
  330. "os": "osx",
  331. "arch": "amd64",
  332. "osx_image": "xcode8",
  333. "language": "minimal",
  334. "script": [
  335. "env | sort",
  336. "pwd",
  337. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  338. ]
  339. },
  340. {
  341. "name": "macOS 10.10 Intel",
  342. "os": "osx",
  343. "arch": "amd64",
  344. "osx_image": "xcode6.4",
  345. "language": "minimal",
  346. "script": [
  347. "env | sort",
  348. "pwd",
  349. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  350. ]
  351. },
  352. {
  353. "name": "Windows 10 (Intel 64-bit)",
  354. "os": "windows",
  355. "arch": "amd64",
  356. "language": "minimal",
  357. "script": [
  358. "env | sort",
  359. "pwd",
  360. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url} "
  361. ]
  362. },
  363. {
  364. "name": "Windows 10 (Intel 32-bit)",
  365. "os": "windows",
  366. "arch": "amd64",
  367. "language": "minimal",
  368. "script": [
  369. "env | sort",
  370. "pwd",
  371. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh --32 ${base_url} "
  372. ]
  373. }
  374. ],
  375. "notifications": {
  376. "email": {
  377. "on_success": "always",
  378. "on_failure": "always"
  379. }
  380. }
  381. }
  382. }
  383. }
  384. __EOF__
  385. }
  386. function create_latest_data_file()
  387. {
  388. local message="$1"
  389. local branch="$2"
  390. local base_url="$3"
  391. local data_file_path="$4"
  392. # Note: __EOF__ is NOT quoted to allow substitutions.
  393. cat <<__EOF__ > "${data_file_path}"
  394. {
  395. "request": {
  396. "message": "${message}",
  397. "branch": "${branch}",
  398. "config": {
  399. "merge_mode": "replace",
  400. "jobs": [
  401. {
  402. "name": "Ubuntu rolling, latest (Intel 64-bit)",
  403. "os": "linux",
  404. "arch": "amd64",
  405. "dist": "bionic",
  406. "services": [ "docker" ],
  407. "language": "minimal",
  408. "script": [
  409. "env | sort",
  410. "pwd",
  411. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:latest ${base_url} ",
  412. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:rolling ${base_url} "
  413. ]
  414. },
  415. {
  416. "name": "Ubuntu rolling, latest (Intel 32-bit)",
  417. "os": "linux",
  418. "arch": "amd64",
  419. "dist": "bionic",
  420. "services": [ "docker" ],
  421. "language": "minimal",
  422. "script": [
  423. "env | sort",
  424. "pwd",
  425. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/ubuntu:latest ${base_url} ",
  426. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/ubuntu:rolling ${base_url} "
  427. ]
  428. },
  429. {
  430. "name": "Ubuntu rolling, latest (Arm 64-bit)",
  431. "os": "linux",
  432. "arch": "arm64",
  433. "dist": "bionic",
  434. "services": [ "docker" ],
  435. "language": "minimal",
  436. "script": [
  437. "env | sort",
  438. "pwd",
  439. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:latest ${base_url} ",
  440. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:rolling ${base_url} "
  441. ]
  442. },
  443. {
  444. "name": "Ubuntu rolling, latest (Arm 32-bit)",
  445. "os": "linux",
  446. "arch": "arm64",
  447. "dist": "bionic",
  448. "services": [ "docker" ],
  449. "language": "minimal",
  450. "script": [
  451. "env | sort",
  452. "pwd",
  453. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/ubuntu:latest ${base_url} ",
  454. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/ubuntu:rolling ${base_url} "
  455. ]
  456. },
  457. {
  458. "name": "Debian latet, testing (Intel 64-bit)",
  459. "os": "linux",
  460. "arch": "amd64",
  461. "dist": "bionic",
  462. "services": [ "docker" ],
  463. "language": "minimal",
  464. "script": [
  465. "env | sort",
  466. "pwd",
  467. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:testing ${base_url} ",
  468. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:latest ${base_url} "
  469. ]
  470. },
  471. {
  472. "name": "Debian testing (Intel 32-bit)",
  473. "os": "linux",
  474. "arch": "amd64",
  475. "dist": "bionic",
  476. "services": [ "docker" ],
  477. "language": "minimal",
  478. "script": [
  479. "env | sort",
  480. "pwd",
  481. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/debian:testing ${base_url} "
  482. ]
  483. },
  484. {
  485. "name": "Debian latest, testing (Arm 64-bit)",
  486. "os": "linux",
  487. "arch": "arm64",
  488. "dist": "bionic",
  489. "services": [ "docker" ],
  490. "language": "minimal",
  491. "script": [
  492. "env | sort",
  493. "pwd",
  494. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:testing ${base_url} ",
  495. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:latest ${base_url} "
  496. ]
  497. },
  498. {
  499. "name": "Debian testing (Arm 32-bit)",
  500. "os": "linux",
  501. "arch": "arm64",
  502. "dist": "bionic",
  503. "services": [ "docker" ],
  504. "language": "minimal",
  505. "script": [
  506. "env | sort",
  507. "pwd",
  508. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/debian:testing ${base_url} "
  509. ]
  510. },
  511. {
  512. "name": "CentOS latest (Intel 64-bit)",
  513. "os": "linux",
  514. "arch": "amd64",
  515. "dist": "bionic",
  516. "services": [ "docker" ],
  517. "language": "minimal",
  518. "script": [
  519. "env | sort",
  520. "pwd",
  521. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:latest ${base_url} "
  522. ]
  523. },
  524. {
  525. "name": "CentOS latest (Intel 32-bit)",
  526. "os": "linux",
  527. "arch": "amd64",
  528. "dist": "bionic",
  529. "services": [ "docker" ],
  530. "language": "minimal",
  531. "script": [
  532. "env | sort",
  533. "pwd",
  534. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/centos:latest ${base_url} "
  535. ]
  536. },
  537. {
  538. "name": "CentOS latest (Arm 64-bit)",
  539. "os": "linux",
  540. "arch": "arm64",
  541. "dist": "bionic",
  542. "services": [ "docker" ],
  543. "language": "minimal",
  544. "script": [
  545. "env | sort",
  546. "pwd",
  547. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:latest ${base_url} "
  548. ]
  549. },
  550. {
  551. "name": "OpenSUSE tumbleweed (Intel 64-bit)",
  552. "os": "linux",
  553. "arch": "amd64",
  554. "dist": "bionic",
  555. "services": [ "docker" ],
  556. "language": "minimal",
  557. "script": [
  558. "env | sort",
  559. "pwd",
  560. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh opensuse/tumbleweed ${base_url} "
  561. ]
  562. },
  563. {
  564. "name": "OpenSUSE tumbleweed (Arm 64-bit)",
  565. "os": "linux",
  566. "arch": "arm64",
  567. "dist": "bionic",
  568. "services": [ "docker" ],
  569. "language": "minimal",
  570. "script": [
  571. "env | sort",
  572. "pwd",
  573. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh opensuse/tumbleweed ${base_url} "
  574. ]
  575. },
  576. {
  577. "name": "Fedora latest, rawhide (Intel 64-bit)",
  578. "os": "linux",
  579. "arch": "amd64",
  580. "dist": "bionic",
  581. "services": [ "docker" ],
  582. "language": "minimal",
  583. "script": [
  584. "env | sort",
  585. "pwd",
  586. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:rawhide ${base_url} ",
  587. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:latest ${base_url} "
  588. ]
  589. },
  590. {
  591. "name": "Fedora latest, rawhide (Arm 64-bit)",
  592. "os": "linux",
  593. "arch": "arm64",
  594. "dist": "bionic",
  595. "services": [ "docker" ],
  596. "language": "minimal",
  597. "script": [
  598. "env | sort",
  599. "pwd",
  600. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:rawhide ${base_url} ",
  601. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:latest ${base_url} "
  602. ]
  603. },
  604. {
  605. "name": "Arch latest (Intel 64-bit)",
  606. "os": "linux",
  607. "arch": "amd64",
  608. "dist": "bionic",
  609. "services": [ "docker" ],
  610. "language": "minimal",
  611. "script": [
  612. "env | sort",
  613. "pwd",
  614. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh archlinux:latest ${base_url} "
  615. ]
  616. },
  617. {
  618. "name": "Manjaro base (Intel 64-bit)",
  619. "os": "linux",
  620. "arch": "amd64",
  621. "dist": "bionic",
  622. "services": [ "docker" ],
  623. "language": "minimal",
  624. "script": [
  625. "env | sort",
  626. "pwd",
  627. "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh manjarolinux/base ${base_url} "
  628. ]
  629. },
  630. {}
  631. ],
  632. "notifications": {
  633. "email": {
  634. "on_success": "always",
  635. "on_failure": "always"
  636. }
  637. }
  638. }
  639. }
  640. }
  641. __EOF__
  642. }
  643. function create_macos_data_file()
  644. {
  645. local message="$1"
  646. local branch="$2"
  647. local base_url="$3"
  648. local data_file_path="$4"
  649. # Note: __EOF__ is NOT quoted to allow substitutions.
  650. cat <<__EOF__ > "${data_file_path}"
  651. {
  652. "request": {
  653. "message": "${message}",
  654. "branch": "${branch}",
  655. "config": {
  656. "merge_mode": "replace",
  657. "jobs": [
  658. {
  659. "name": "macOS 10.15 Intel",
  660. "os": "osx",
  661. "arch": "amd64",
  662. "osx_image": "xcode11.5",
  663. "language": "minimal",
  664. "script": [
  665. "env | sort",
  666. "pwd",
  667. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  668. ]
  669. },
  670. {
  671. "name": "macOS 10.14 Intel",
  672. "os": "osx",
  673. "arch": "amd64",
  674. "osx_image": "xcode11.3",
  675. "language": "minimal",
  676. "script": [
  677. "env | sort",
  678. "pwd",
  679. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  680. ]
  681. },
  682. {
  683. "name": "macOS 10.13 Intel",
  684. "os": "osx",
  685. "arch": "amd64",
  686. "osx_image": "xcode10.1",
  687. "language": "minimal",
  688. "script": [
  689. "env | sort",
  690. "pwd",
  691. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  692. ]
  693. },
  694. {
  695. "name": "macOS 10.12 Intel",
  696. "os": "osx",
  697. "arch": "amd64",
  698. "osx_image": "xcode9.2",
  699. "language": "minimal",
  700. "script": [
  701. "env | sort",
  702. "pwd",
  703. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  704. ]
  705. },
  706. {
  707. "name": "macOS 10.11 Intel",
  708. "os": "osx",
  709. "arch": "amd64",
  710. "osx_image": "xcode8",
  711. "language": "minimal",
  712. "script": [
  713. "env | sort",
  714. "pwd",
  715. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  716. ]
  717. },
  718. {
  719. "name": "macOS 10.10 Intel",
  720. "os": "osx",
  721. "arch": "amd64",
  722. "osx_image": "xcode6.4",
  723. "language": "minimal",
  724. "script": [
  725. "env | sort",
  726. "pwd",
  727. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}"
  728. ]
  729. }
  730. ],
  731. "notifications": {
  732. "email": {
  733. "on_success": "always",
  734. "on_failure": "always"
  735. }
  736. }
  737. }
  738. }
  739. }
  740. __EOF__
  741. }
  742. function create_windows_data_file()
  743. {
  744. local message="$1"
  745. local branch="$2"
  746. local base_url="$3"
  747. local data_file_path="$4"
  748. # Note: __EOF__ is NOT quoted to allow substitutions.
  749. cat <<__EOF__ > "${data_file_path}"
  750. {
  751. "request": {
  752. "message": "${message}",
  753. "branch": "${branch}",
  754. "config": {
  755. "merge_mode": "replace",
  756. "jobs": [
  757. {
  758. "name": "Windows 10 (Intel 64-bit)",
  759. "os": "windows",
  760. "arch": "amd64",
  761. "language": "minimal",
  762. "script": [
  763. "env | sort",
  764. "pwd",
  765. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url} "
  766. ]
  767. },
  768. {
  769. "name": "Windows 10 (Intel 32-bit)",
  770. "os": "windows",
  771. "arch": "amd64",
  772. "language": "minimal",
  773. "script": [
  774. "env | sort",
  775. "pwd",
  776. "DEBUG=${DEBUG} bash tests/scripts/native-test.sh --32 ${base_url} "
  777. ]
  778. }
  779. ],
  780. "notifications": {
  781. "email": {
  782. "on_success": "always",
  783. "on_failure": "always"
  784. }
  785. }
  786. }
  787. }
  788. }
  789. __EOF__
  790. }
  791. # data_file_path
  792. # github_org
  793. # github_repo
  794. function trigger_travis()
  795. {
  796. local github_org="$1"
  797. local github_repo="$2"
  798. local data_file_path="$3"
  799. curl -v -X POST \
  800. -H "Content-Type: application/json" \
  801. -H "Accept: application/json" \
  802. -H "Travis-API-Version: 3" \
  803. -H "Authorization: token ${TRAVIS_ORG_TOKEN}" \
  804. --data-binary @"${data_file_path}" \
  805. https://api.travis-ci.org/repo/${github_org}%2F${github_repo}/requests
  806. }
  807. # -----------------------------------------------------------------------------
  808. # Runs inside a container.
  809. # Set the following variables:
  810. #
  811. # - node_platform={win32,linux,darwin}
  812. # - node_architecture={x64,x32,arm64,arm}
  813. # - bits={32,64}
  814. function detect_architecture()
  815. {
  816. uname -a
  817. uname_platform=$(uname -s | tr '[:upper:]' '[:lower:]')
  818. uname_machine=$(uname -m | tr '[:upper:]' '[:lower:]')
  819. node_platform="${uname_platform}"
  820. # Travis uses Msys2; git for Windows uses mingw-w64.
  821. if [[ "${uname_platform}" == msys_nt* ]] \
  822. || [[ "${uname_platform}" == mingw64_nt* ]] \
  823. || [[ "${uname_platform}" == mingw32_nt* ]]
  824. then
  825. node_platform="win32"
  826. fi
  827. node_architecture=""
  828. bits=""
  829. if [ "${uname_machine}" == "x86_64" ]
  830. then
  831. node_architecture="x64"
  832. bits="64"
  833. elif [ "${uname_machine}" == "i386" -o "${uname_machine}" == "i586" -o "${uname_machine}" == "i686" ]
  834. then
  835. node_architecture="x32"
  836. bits="32"
  837. elif [ "${uname_machine}" == "aarch64" ]
  838. then
  839. node_architecture="arm64"
  840. bits="64"
  841. elif [ "${uname_machine}" == "armv7l" -o "${uname_machine}" == "armv8l" ]
  842. then
  843. node_architecture="arm"
  844. bits="32"
  845. else
  846. echo "${uname_machine} not supported"
  847. exit 1
  848. fi
  849. }
  850. function prepare_env()
  851. {
  852. container_work_folder_path="/Host/Work"
  853. container_repo_folder_path="/Host/repo"
  854. if [ -f "/.dockerenv" -a -d "${container_work_folder_path}" ]
  855. then
  856. work_folder_path="${container_work_folder_path}"
  857. repo_folder_path="${container_repo_folder_path}"
  858. else
  859. work_folder_path="${HOME}/Work"
  860. # On the host, it must be called using the script folder path.
  861. repo_folder_path="$1"
  862. fi
  863. cache_folder_path="${work_folder_path}/cache"
  864. # Extract only the first line
  865. version="$(cat ${repo_folder_path}/scripts/VERSION | sed -e '2,$d')"
  866. if [ -z "${version}" ]
  867. then
  868. echo "Check the version, it cannot be empty."
  869. exit 1
  870. fi
  871. # Always in the user home, even when inside a container.
  872. test_folder_path="${HOME}/tmp/test-${app_lc_name}"
  873. }
  874. # -----------------------------------------------------------------------------
  875. # Requires base_url and lots of other variables.
  876. function install_archive()
  877. {
  878. local archive_extension
  879. local archive_architecture="${node_architecture}"
  880. if [ "${node_platform}" == "win32" ]
  881. then
  882. archive_extension="zip"
  883. if [ "${force_32_bit}" == "y" ]
  884. then
  885. archive_architecture="x32"
  886. fi
  887. else
  888. archive_extension="tar.gz"
  889. fi
  890. archive_name="xpack-${app_lc_name}-${version}-${node_platform}-${archive_architecture}.${archive_extension}"
  891. archive_folder_name="xpack-${app_lc_name}-${version}"
  892. mkdir -pv "${cache_folder_path}"
  893. if [ ! -f "${cache_folder_path}/${archive_name}" ]
  894. then
  895. echo
  896. echo "Downloading ${archive_name}..."
  897. curl -L --fail -o "${cache_folder_path}/${archive_name}" \
  898. "${base_url}/${archive_name}"
  899. echo
  900. fi
  901. app_folder_path="${test_folder_path}/${archive_folder_name}"
  902. rm -rf "${app_folder_path}"
  903. mkdir -pv "${test_folder_path}"
  904. cd "${test_folder_path}"
  905. echo
  906. echo "Extracting ${archive_name}..."
  907. if [[ "${archive_name}" == *.zip ]]
  908. then
  909. unzip -q "${cache_folder_path}/${archive_name}"
  910. else
  911. tar xf "${cache_folder_path}/${archive_name}"
  912. fi
  913. echo ls -lL "${app_folder_path}"
  914. ls -lL "${app_folder_path}"
  915. }
  916. # -----------------------------------------------------------------------------
  917. # $1 = image name
  918. # $2 = base URL
  919. function docker_run_test() {
  920. local image_name="$1"
  921. shift
  922. local base_url="$1"
  923. shift
  924. (
  925. prefix32="${prefix32:-""}"
  926. docker run \
  927. --tty \
  928. --hostname "docker" \
  929. --workdir="/root" \
  930. --env DEBUG=${DEBUG} \
  931. --volume "${work_folder_path}:${container_work_folder_path}" \
  932. --volume "${repo_folder_path}:${container_repo_folder_path}" \
  933. "${image_name}" \
  934. ${prefix32} /bin/bash "${container_repo_folder_path}/tests/scripts/container-test.sh" \
  935. "${image_name}" \
  936. "${base_url}" \
  937. "$@"
  938. )
  939. }
  940. function docker_run_test_32() {
  941. (
  942. prefix32="linux32"
  943. docker_run_test "$@"
  944. )
  945. }
  946. # -----------------------------------------------------------------------------
  947. function show_libs()
  948. {
  949. # Does not include the .exe extension.
  950. local app_path=$1
  951. shift
  952. if [ "${node_platform}" == "win32" ]
  953. then
  954. app_path+='.exe'
  955. fi
  956. if [ "${node_platform}" == "linux" ]
  957. then
  958. echo
  959. echo "readelf -d ${app_path} | egrep -i ..."
  960. readelf -d "${app_path}" | egrep -i '(SONAME)' || true
  961. readelf -d "${app_path}" | egrep -i '(RUNPATH|RPATH)' || true
  962. readelf -d "${app_path}" | egrep -i '(NEEDED)' || true
  963. echo
  964. echo "ldd -v ${app_path}"
  965. ldd -v "${app_path}" 2>&1 || true
  966. elif [ "${node_platform}" == "darwin" ]
  967. then
  968. echo
  969. echo "otool -L ${app_path}"
  970. otool -L "${app_path}"
  971. fi
  972. }
  973. function run_verbose()
  974. {
  975. echo
  976. echo "$@"
  977. "$@" 2>&1
  978. }
  979. function run_app()
  980. {
  981. local app_path=$1
  982. shift
  983. if [ "${node_platform}" == "win32" ]
  984. then
  985. app_path+='.exe'
  986. fi
  987. echo
  988. echo "${app_path} $@"
  989. "${app_path}" "$@" 2>&1
  990. }
  991. function run_app_silent()
  992. {
  993. local app_path=$1
  994. shift
  995. if [ "${node_platform}" == "win32" ]
  996. then
  997. app_path+='.exe'
  998. fi
  999. "${app_path}" "$@" 2>&1
  1000. }
  1001. function do_run()
  1002. {
  1003. local app_path=$1
  1004. shift
  1005. echo
  1006. echo "${app_path} $@"
  1007. "${app_path}" "$@" 2>&1
  1008. }
  1009. function do_expect()
  1010. {
  1011. local app_name="$1"
  1012. local expected="$2"
  1013. show_libs "${app_name}"
  1014. local output="$(run_app_silent "./${app_name}")"
  1015. if [ "x${output}x" == "x${expected}x" ]
  1016. then
  1017. echo "Test ${app_name} ok"
  1018. else
  1019. exit 1
  1020. fi
  1021. }
  1022. function good_bye()
  1023. {
  1024. echo
  1025. echo "All tests completed successfully."
  1026. do_run uname -a
  1027. if [ "${node_platform}" == "linux" ]
  1028. then
  1029. do_run lsb_release -a
  1030. do_run ldd --version
  1031. elif [ "${node_platform}" == "darwin" ]
  1032. then
  1033. do_run sw_vers
  1034. fi
  1035. }
  1036. # -----------------------------------------------------------------------------