You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 3 години
преди 3 години
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. from pathlib import Path
  2. import platform
  3. import pytest
  4. from dds_ci.testing import RepoServer, Project
  5. from dds_ci import proc, toolchain, paths
  6. CRYPTOPP_JSON = {
  7. "packages": {
  8. "cryptopp": {
  9. "8.2.0": {
  10. "remote": {
  11. "git": {
  12. "url": "https://github.com/weidai11/cryptopp.git",
  13. "ref": "CRYPTOPP_8_2_0"
  14. },
  15. "auto-lib": "cryptopp/cryptopp",
  16. "transform": [{
  17. "move": {
  18. "from": ".",
  19. "to": "src/cryptopp",
  20. "include": ["*.c", "*.cpp", "*.h"]
  21. }
  22. }]
  23. }
  24. }
  25. }
  26. }
  27. }
  28. APP_CPP = r'''
  29. #include <cryptopp/osrng.h>
  30. #include <string>
  31. int main() {
  32. std::string arr;
  33. arr.resize(256);
  34. CryptoPP::OS_GenerateRandomBlock(false,
  35. reinterpret_cast<CryptoPP::byte*>(arr.data()),
  36. arr.size());
  37. for (auto b : arr) {
  38. if (b != '\x00') {
  39. return 0;
  40. }
  41. }
  42. return 1;
  43. }
  44. '''
  45. @pytest.mark.skipif(platform.system() == 'FreeBSD', reason='This one has trouble running on FreeBSD')
  46. def test_get_build_use_cryptopp(test_parent_dir: Path, tmp_project: Project, http_repo: RepoServer) -> None:
  47. http_repo.import_json_data(CRYPTOPP_JSON)
  48. tmp_project.dds.repo_add(http_repo.url)
  49. tmp_project.package_json = {
  50. 'name': 'usr-cryptopp',
  51. 'version': '1.0.0',
  52. 'namespace': 'test',
  53. 'depends': ['cryptopp@8.2.0'],
  54. }
  55. tmp_project.library_json = {
  56. 'name': 'use-cryptopp',
  57. 'uses': ['cryptopp/cryptopp'],
  58. }
  59. tc_fname = 'gcc.tc.jsonc' if 'gcc' in toolchain.get_default_test_toolchain().name else 'msvc.tc.jsonc'
  60. tmp_project.write('src/use-cryptopp.main.cpp', APP_CPP)
  61. tmp_project.build(toolchain=test_parent_dir / tc_fname, timeout = 60*10)
  62. proc.check_run([(tmp_project.build_root / 'use-cryptopp').with_suffix(paths.EXE_SUFFIX)])