sabctools 8.2.2__tar.gz → 8.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. {sabctools-8.2.2/sabctools.egg-info → sabctools-8.2.4}/PKG-INFO +1 -1
  2. {sabctools-8.2.2 → sabctools-8.2.4/sabctools.egg-info}/PKG-INFO +1 -1
  3. {sabctools-8.2.2 → sabctools-8.2.4}/sabctools.egg-info/SOURCES.txt +1 -9
  4. {sabctools-8.2.2 → sabctools-8.2.4}/setup.py +6 -5
  5. {sabctools-8.2.2 → sabctools-8.2.4}/src/sabctools.h +1 -1
  6. {sabctools-8.2.2 → sabctools-8.2.4}/src/unlocked_ssl.cc +6 -4
  7. sabctools-8.2.2/tests/test.py +0 -22
  8. sabctools-8.2.2/tests/test_crc32.py +0 -80
  9. sabctools-8.2.2/tests/test_decoder.py +0 -115
  10. sabctools-8.2.2/tests/test_encoder.py +0 -7
  11. sabctools-8.2.2/tests/test_sparse.py +0 -45
  12. sabctools-8.2.2/tests/test_unlocked_ssl.py +0 -340
  13. sabctools-8.2.2/tests/test_utils.py +0 -16
  14. sabctools-8.2.2/tests/testsupport.py +0 -184
  15. {sabctools-8.2.2 → sabctools-8.2.4}/LICENSE.md +0 -0
  16. {sabctools-8.2.2 → sabctools-8.2.4}/MANIFEST.in +0 -0
  17. {sabctools-8.2.2 → sabctools-8.2.4}/README.md +0 -0
  18. {sabctools-8.2.2 → sabctools-8.2.4}/pyproject.toml +0 -0
  19. {sabctools-8.2.2 → sabctools-8.2.4}/sabctools.egg-info/dependency_links.txt +0 -0
  20. {sabctools-8.2.2 → sabctools-8.2.4}/sabctools.egg-info/top_level.txt +0 -0
  21. {sabctools-8.2.2 → sabctools-8.2.4}/setup.cfg +0 -0
  22. {sabctools-8.2.2 → sabctools-8.2.4}/src/__init__.py +0 -0
  23. {sabctools-8.2.2 → sabctools-8.2.4}/src/crc32.cc +0 -0
  24. {sabctools-8.2.2 → sabctools-8.2.4}/src/crc32.h +0 -0
  25. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/AUTHORS +0 -0
  26. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/COPYING +0 -0
  27. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/ChangeLog +0 -0
  28. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/INSTALL +0 -0
  29. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/LICENSE +0 -0
  30. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/Makefile +0 -0
  31. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/Makefile.am +0 -0
  32. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/Makefile.in +0 -0
  33. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/Makefile.win +0 -0
  34. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/NEWS +0 -0
  35. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/README +0 -0
  36. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/aclocal.m4 +0 -0
  37. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/autogen.sh +0 -0
  38. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/base_types.h +0 -0
  39. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/crc32c_sse4.cc +0 -0
  40. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/crc32c_sse4.h +0 -0
  41. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/crc32c_sse4_intrin.h +0 -0
  42. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/crc_casts.h +0 -0
  43. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/generic_crc.h +0 -0
  44. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/gf_util.h +0 -0
  45. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/multiword_128_64_gcc_amd64_sse2.cc +0 -0
  46. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/multiword_64_64_cl_i386_mmx.cc +0 -0
  47. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/multiword_64_64_gcc_amd64_asm.cc +0 -0
  48. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/multiword_64_64_gcc_i386_mmx.cc +0 -0
  49. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/multiword_64_64_intrinsic_i386_mmx.cc +0 -0
  50. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/platform.h +0 -0
  51. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/protected_crc.h +0 -0
  52. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/rolling_crc.h +0 -0
  53. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/std_headers.h +0 -0
  54. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/code/uint128_sse2.h +0 -0
  55. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/config.h.in +0 -0
  56. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/configure +0 -0
  57. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/configure.ac +0 -0
  58. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/depcomp +0 -0
  59. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/examples/interface.cc +0 -0
  60. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/examples/interface.h +0 -0
  61. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/examples/usage.cc +0 -0
  62. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/install-sh +0 -0
  63. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/missing +0 -0
  64. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/tests/aligned_alloc.h +0 -0
  65. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/tests/bob_jenkins_rng.h +0 -0
  66. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/tests/rdtsc.h +0 -0
  67. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/tests/set_hi_pri.c +0 -0
  68. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/tests/unittest.cc +0 -0
  69. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/tests/unittest.h +0 -0
  70. {sabctools-8.2.2 → sabctools-8.2.4}/src/crcutil-1.0/tests/unittest_helper.h +0 -0
  71. {sabctools-8.2.2 → sabctools-8.2.4}/src/py.typed +0 -0
  72. {sabctools-8.2.2 → sabctools-8.2.4}/src/sabctools.cc +0 -0
  73. {sabctools-8.2.2 → sabctools-8.2.4}/src/sabctools.pyi +0 -0
  74. {sabctools-8.2.2 → sabctools-8.2.4}/src/sparse.cc +0 -0
  75. {sabctools-8.2.2 → sabctools-8.2.4}/src/sparse.h +0 -0
  76. {sabctools-8.2.2 → sabctools-8.2.4}/src/unlocked_ssl.h +0 -0
  77. {sabctools-8.2.2 → sabctools-8.2.4}/src/utils.cc +0 -0
  78. {sabctools-8.2.2 → sabctools-8.2.4}/src/utils.h +0 -0
  79. {sabctools-8.2.2 → sabctools-8.2.4}/src/yenc.cc +0 -0
  80. {sabctools-8.2.2 → sabctools-8.2.4}/src/yenc.h +0 -0
  81. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/common.h +0 -0
  82. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/crc.cc +0 -0
  83. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/crc.h +0 -0
  84. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/crc_arm.cc +0 -0
  85. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/crc_arm_pmull.cc +0 -0
  86. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/crc_common.h +0 -0
  87. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/crc_folding.cc +0 -0
  88. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/crc_folding_256.cc +0 -0
  89. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/crc_riscv.cc +0 -0
  90. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder.cc +0 -0
  91. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder.h +0 -0
  92. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder_avx.cc +0 -0
  93. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder_avx2.cc +0 -0
  94. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder_avx2_base.h +0 -0
  95. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder_common.h +0 -0
  96. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder_neon.cc +0 -0
  97. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder_neon64.cc +0 -0
  98. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder_rvv.cc +0 -0
  99. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder_sse2.cc +0 -0
  100. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder_sse_base.h +0 -0
  101. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder_ssse3.cc +0 -0
  102. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/decoder_vbmi2.cc +0 -0
  103. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder.cc +0 -0
  104. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder.h +0 -0
  105. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder_avx.cc +0 -0
  106. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder_avx2.cc +0 -0
  107. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder_avx_base.h +0 -0
  108. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder_common.h +0 -0
  109. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder_neon.cc +0 -0
  110. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder_rvv.cc +0 -0
  111. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder_sse2.cc +0 -0
  112. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder_sse_base.h +0 -0
  113. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder_ssse3.cc +0 -0
  114. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/encoder_vbmi2.cc +0 -0
  115. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/hedley.h +0 -0
  116. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/platform.cc +0 -0
  117. {sabctools-8.2.2 → sabctools-8.2.4}/src/yencode/stdint.h +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sabctools
3
- Version: 8.2.2
3
+ Version: 8.2.4
4
4
  Summary: C implementations of functions for use within SABnzbd
5
5
  Home-page: https://github.com/sabnzbd/sabctools/
6
6
  Author: Safihre
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sabctools
3
- Version: 8.2.2
3
+ Version: 8.2.4
4
4
  Summary: C implementations of functions for use within SABnzbd
5
5
  Home-page: https://github.com/sabnzbd/sabctools/
6
6
  Author: Safihre
@@ -104,12 +104,4 @@ src/yencode/encoder_ssse3.cc
104
104
  src/yencode/encoder_vbmi2.cc
105
105
  src/yencode/hedley.h
106
106
  src/yencode/platform.cc
107
- src/yencode/stdint.h
108
- tests/test.py
109
- tests/test_crc32.py
110
- tests/test_decoder.py
111
- tests/test_encoder.py
112
- tests/test_sparse.py
113
- tests/test_unlocked_ssl.py
114
- tests/test_utils.py
115
- tests/testsupport.py
107
+ src/yencode/stdint.h
@@ -122,14 +122,15 @@ class SABCToolsBuild(build_ext):
122
122
  log.info("==> C++11 flag not available")
123
123
 
124
124
  # Verify specific flags for ARM chips
125
- # macOS M1 do not need any flags, they support everything
125
+ # macOS ARM does not need any flags, they support everything
126
126
  if IS_ARM and not IS_MACOS:
127
127
  if not autoconf_check(self.compiler, define_check="__aarch64__"):
128
128
  log.info("==> __aarch64__ not available, disabling 64bit extensions")
129
129
  IS_AARCH64 = False
130
+ if autoconf_check(self.compiler, flag_check="-march=armv8-a+crc+crypto"):
131
+ gcc_arm_crc_pmull_flags.append("-march=armv8-a+crc+crypto")
130
132
  if autoconf_check(self.compiler, flag_check="-march=armv8-a+crc"):
131
133
  gcc_arm_crc_flags.append("-march=armv8-a+crc")
132
- gcc_arm_crc_pmull_flags.append("-march=armv8-a+crc+crypto")
133
134
  # Resolve problems on armv7, see issue #56
134
135
  if not IS_AARCH64:
135
136
  gcc_arm_crc_flags.append("-fno-lto")
@@ -313,7 +314,7 @@ class SABCToolsBuild(build_ext):
313
314
  "src/unlocked_ssl.cc",
314
315
  ],
315
316
  "gcc_flags": ["-Wno-unused-parameter", "-Wno-missing-field-initializers"],
316
- "msvc_x86_libraries": ["ws2_32"],
317
+ "msvc_libraries": ["ws2_32"],
317
318
  },
318
319
  {
319
320
  "sources": [
@@ -344,8 +345,8 @@ class SABCToolsBuild(build_ext):
344
345
  if self.compiler.compiler_type == "msvc":
345
346
  if IS_X86 and "msvc_x86_flags" in source_files:
346
347
  args["extra_postargs"] += source_files["msvc_x86_flags"]
347
- if IS_X86 and "msvc_x86_libraries" in source_files:
348
- ext.libraries += source_files["msvc_x86_libraries"]
348
+ if "msvc_libraries" in source_files:
349
+ ext.libraries += source_files["msvc_libraries"]
349
350
  else:
350
351
  if "gcc_flags" in source_files:
351
352
  args["extra_postargs"] += source_files["gcc_flags"]
@@ -22,6 +22,6 @@
22
22
  #include <string.h>
23
23
 
24
24
  /* Version information */
25
- #define SABCTOOLS_VERSION "8.2.2"
25
+ #define SABCTOOLS_VERSION "8.2.4"
26
26
 
27
27
  PyMODINIT_FUNC PyInit_sabctools(void);
@@ -99,11 +99,13 @@ void openssl_init() {
99
99
  if(!SSLWantReadError) goto cleanup;
100
100
 
101
101
  #if defined(_WIN32) || defined(__CYGWIN__)
102
+ #ifdef _M_ARM64
103
+ HMODULE windows_openssl_handle = GetModuleHandle(TEXT("libssl-3-arm64.dll"));
104
+ #else
102
105
  HMODULE windows_openssl_handle = GetModuleHandle(TEXT("libssl-3.dll"));
103
- if(!windows_openssl_handle) {
104
- windows_openssl_handle = GetModuleHandle(TEXT("libssl-1_1.dll"));
105
- if(!windows_openssl_handle) goto cleanup;
106
- }
106
+ if(!windows_openssl_handle) windows_openssl_handle = GetModuleHandle(TEXT("libssl-1_1.dll"));
107
+ #endif
108
+ if(!windows_openssl_handle) goto cleanup;
107
109
 
108
110
  *(void**)&SSL_read_ex = GetProcAddress(windows_openssl_handle, "SSL_read_ex");
109
111
  *(void**)&SSL_get_error = GetProcAddress(windows_openssl_handle, "SSL_get_error");
@@ -1,22 +0,0 @@
1
- import time
2
- import ssl
3
- import sabctools
4
- import socket
5
- import time
6
-
7
-
8
- hostname = "eunews.frugalusenet.com"
9
- context = ssl.create_default_context()
10
-
11
- print(sabctools.openssl_linked)
12
-
13
- buffer = bytearray(100)
14
- bufferview = memoryview(buffer)
15
-
16
- with socket.create_connection((hostname, 563)) as sock:
17
- with context.wrap_socket(sock, server_hostname=hostname) as ssock:
18
- ssock.setblocking(False)
19
- time.sleep(1)
20
- print(ssock.version())
21
- print(sabctools.unlocked_ssl_recv_into(ssock._sslobj, bufferview[99:]))
22
- print(buffer)
@@ -1,80 +0,0 @@
1
- import pytest
2
- import sabctools
3
-
4
-
5
- @pytest.mark.parametrize(
6
- "crc1,crc2,len2,expected",
7
- [
8
- (0, 0, 0, 0),
9
- (4294967295, 0, 0, 4294967295),
10
- (0, 4294967295, 0, 4294967295),
11
- (4294967295, 4294967295, 0, 0),
12
- (4, 16, 256, 2385497022),
13
- (100, 200, 300, 1009376567),
14
- (0, 0, 18446744073709551615, 0),
15
- (4294967295, 4294967295, 18446744073709551615, 0),
16
- (0, 100, 1234567890123, 100),
17
- (100, 0, 1234567890123, 1829446317),
18
- ],
19
- )
20
- def test_crc32_combine_expected(crc1, crc2, len2, expected):
21
- assert sabctools.crc32_combine(crc1, crc2, len2) == expected
22
-
23
-
24
- @pytest.mark.parametrize(
25
- "crc1,crc2,expected",
26
- [
27
- (0, 0, 0),
28
- (4294967295, 0, 0),
29
- (0, 4294967295, 0),
30
- (4294967295, 4294967295, 1048090088),
31
- (100, 200, 4155012749),
32
- ],
33
- )
34
- def test_crc32_multiply_expected(crc1, crc2, expected):
35
- assert sabctools.crc32_multiply(crc1, crc2) == expected
36
-
37
-
38
- @pytest.mark.parametrize(
39
- "crc1,zeroes,expected",
40
- [
41
- (0, 0, 0),
42
- (4294967295, 0, 4294967295),
43
- (4294967295, 4294967295, 4294967295),
44
- (100, 200, 1523530880),
45
- (0, 18446744073709551615, 0),
46
- (4294967295, 18446744073709551615, 4294967295),
47
- (100, 1234567890123, 980217485),
48
- ],
49
- )
50
- def test_crc32_zero_unpad_expected(crc1, zeroes, expected):
51
- assert sabctools.crc32_zero_unpad(crc1, zeroes) == expected
52
-
53
-
54
- @pytest.mark.parametrize(
55
- "n,expected",
56
- [
57
- (0, 2147483648),
58
- (1, 1073741824),
59
- (8, 8388608),
60
- (30, 2),
61
- (31, 1),
62
- (4294967295, 2147483648),
63
- (4294967296, 1073741824), # 1
64
- ],
65
- )
66
- def test_crc32_xpown_expected(n, expected):
67
- assert sabctools.crc32_xpown(n) == expected
68
-
69
-
70
- @pytest.mark.parametrize(
71
- "n,expected",
72
- [
73
- (0, 2147483648),
74
- (1, 8388608),
75
- (4294967295, 2147483648),
76
- (4294967296, 8388608), # 1
77
- ],
78
- )
79
- def test_crc32_xpow8n_expected(n, expected):
80
- assert sabctools.crc32_xpow8n(n) == expected
@@ -1,115 +0,0 @@
1
- import sys
2
- import pytest
3
- import glob
4
- from tests.testsupport import *
5
-
6
-
7
- def test_regular():
8
- data_plain = read_plain_yenc_file("test_regular.yenc")
9
- assert python_yenc(data_plain) == sabctools_yenc_wrapper(data_plain)
10
- data_plain = read_plain_yenc_file("test_regular_2.yenc")
11
- assert python_yenc(data_plain) == sabctools_yenc_wrapper(data_plain)
12
-
13
-
14
- def test_bytes_compat():
15
- data_plain = read_plain_yenc_file("test_regular.yenc")
16
- assert python_yenc(data_plain) == sabctools.yenc_decode(memoryview(bytes(data_plain)))
17
-
18
-
19
- def test_partial():
20
- data_plain = read_plain_yenc_file("test_partial.yenc")
21
- decoded_data, filename, filesize, begin, size, crc_correct = sabctools_yenc_wrapper(data_plain)
22
- assert filename == "90E2Sdvsmds0801dvsmds90E.part06.rar"
23
- assert filesize == 49152000
24
- assert begin == 15360000
25
- assert size == 384000
26
- assert crc_correct is None
27
- assert len(decoded_data) == 549
28
-
29
-
30
- def test_special_chars():
31
- data_plain = read_plain_yenc_file("test_special_chars.yenc")
32
- # We only compare the data and the filename
33
- assert python_yenc(data_plain) == sabctools_yenc_wrapper(data_plain)
34
-
35
- data_plain = read_plain_yenc_file("test_special_utf8_chars.yenc")
36
- # We only compare the data and the filename
37
- assert python_yenc(data_plain) == sabctools_yenc_wrapper(data_plain)
38
-
39
-
40
- def test_bad_crc():
41
- data_plain = read_plain_yenc_file("test_bad_crc.yenc")
42
- # We only compare the data and the filename
43
- assert python_yenc(data_plain) == sabctools_yenc_wrapper(data_plain)
44
-
45
-
46
- def test_bad_crc_end():
47
- data_plain = read_plain_yenc_file("test_bad_crc_end.yenc")
48
- with pytest.raises(ValueError) as excinfo:
49
- sabctools_yenc_wrapper(data_plain)
50
- assert "Invalid CRC in footer" in str(excinfo.value)
51
-
52
-
53
- def test_no_filename():
54
- data_plain = read_plain_yenc_file("test_no_name.yenc")
55
- with pytest.raises(ValueError) as excinfo:
56
- sabctools_yenc_wrapper(data_plain)
57
- assert "Could not find yEnc filename" in str(excinfo.value)
58
-
59
-
60
- def test_padded_crc():
61
- data_plain = read_plain_yenc_file("test_padded_crc.yenc")
62
- assert python_yenc(data_plain) == sabctools_yenc_wrapper(data_plain)
63
-
64
-
65
- def test_end_after_filename():
66
- data_plain = read_plain_yenc_file("test_end_after_filename.yenc")
67
- with pytest.raises(ValueError):
68
- sabctools_yenc_wrapper(data_plain)
69
-
70
-
71
- def test_empty():
72
- with pytest.raises(ValueError) as excinfo:
73
- sabctools.yenc_decode(memoryview(bytearray(b"")))
74
- assert "Invalid data length" in str(excinfo.value)
75
-
76
-
77
- def test_ref_counts():
78
- """Note that sys.getrefcount itself adds another reference!"""
79
- # Test regular case
80
- data_plain = read_plain_yenc_file("test_regular.yenc")
81
- data_out, filename, filesize, begin, end, crc_correct = sabctools_yenc_wrapper(data_plain)
82
-
83
- assert sys.getrefcount(data_plain) == 2
84
- assert sys.getrefcount(data_out) == 2
85
- assert sys.getrefcount(filename) == 2
86
- assert sys.getrefcount(begin) == 2
87
- assert sys.getrefcount(end) == 2
88
- assert sys.getrefcount(crc_correct) == 2
89
-
90
- # Test simple error case
91
- fake_inp = memoryview(bytearray(b"1234"))
92
- assert sys.getrefcount(fake_inp) == 2
93
- with pytest.raises(ValueError):
94
- sabctools.yenc_decode(fake_inp)
95
- assert sys.getrefcount(fake_inp) == 2
96
-
97
- # Test further processing
98
- data_plain = read_plain_yenc_file("test_bad_crc_end.yenc")
99
- with pytest.raises(ValueError):
100
- sabctools_yenc_wrapper(data_plain)
101
- assert sys.getrefcount(data_plain) == 2
102
-
103
-
104
- def test_crc_pickles():
105
- all_crc_fails = glob.glob("tests/yencfiles/crc_*")
106
- for fname in all_crc_fails:
107
- data_plain = read_pickle(fname)
108
- assert python_yenc(data_plain) == sabctools_yenc_wrapper(data_plain)
109
-
110
-
111
- def test_small_file_pickles():
112
- all_pickles = glob.glob("tests/yencfiles/small_file*")
113
- for fname in all_pickles:
114
- data_plain = read_pickle(fname)
115
- assert python_yenc(data_plain) == sabctools_yenc_wrapper(data_plain)
@@ -1,7 +0,0 @@
1
- from tests.testsupport import *
2
-
3
-
4
- def test_encoder():
5
- output, crc = sabctools.yenc_encode(b"Hello world!")
6
- assert output == b"r\x8f\x96\x96\x99J\xa1\x99\x9c\x96\x8eK"
7
- assert crc == 0x1B851995
@@ -1,45 +0,0 @@
1
- import os
2
- import subprocess
3
- import sys
4
- import tempfile
5
- import pytest
6
- from typing import IO
7
-
8
- from tests.testsupport import *
9
-
10
-
11
- def test_sparse():
12
- file = tempfile.NamedTemporaryFile(delete=False)
13
- try:
14
- sabctools.sparse(file, 100)
15
- assert os.path.getsize(file.name) == 100
16
- assert is_sparse(file) is True
17
- finally:
18
- file.close()
19
- os.unlink(file.name)
20
-
21
- @pytest.mark.parametrize(
22
- "length,position",
23
- [
24
- (1024, 0),
25
- (1024, 512),
26
- (1024, 4096),
27
- ],
28
- )
29
- def test_sparse_position_expected(length, position):
30
- with tempfile.TemporaryFile() as file:
31
- file.seek(position)
32
- sabctools.sparse(file, length)
33
- assert file.tell() == position
34
-
35
- def is_sparse(file: IO) -> bool:
36
- """Is the file sparse?
37
- On Windows this closes the file"""
38
- if sys.platform == "win32":
39
- file.close()
40
- return b"This file is set as sparse" in subprocess.run(
41
- ["fsutil", "sparse", "queryflag", file.name],
42
- capture_output=True
43
- ).stdout
44
-
45
- return os.stat(file.name).st_blocks * 512 < os.path.getsize(file.name)