pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Tests for *.exe binaries which are sparse files+cleanup+misc, 2025-03-18
Posted by Anonymous on Tue 18th Mar 2025 18:28
raw | new post

  1. From 6bbd6456f71987867be0023865034c7754553558 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 18 Mar 2025 13:48:38 +0100
  4. Subject: [PATCH 1/7] cygwin,tests: Add tests for sparse file *.exe
  5.  
  6. Add tests for sparse file *.exe.
  7.  
  8. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  9. ---
  10. cygwin/Makefile.install              |   1 +
  11.  tests/sparsefiles/testsparseexe1.ksh | 171 +++++++++++++++++++++++++++
  12.  2 files changed, 172 insertions(+)
  13.  create mode 100644 tests/sparsefiles/testsparseexe1.ksh
  14.  
  15. diff --git a/cygwin/Makefile.install b/cygwin/Makefile.install
  16. index 1a1005a..b5b3de9 100644
  17. --- a/cygwin/Makefile.install
  18. +++ b/cygwin/Makefile.install
  19. @@ -122,6 +122,7 @@ installdest:
  20.         fi
  21.         cp $(PROJECT_BASEDIR_DIR)/tests/nfsbuildtest/nfsbuildtest.ksh93 $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc/nfsbuildtest.ksh93
  22.         cp $(PROJECT_BASEDIR_DIR)/tests/sparsefiles/testsparsefile1.ksh $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/sparsefiles/testsparsefile1.ksh
  23. +       cp $(PROJECT_BASEDIR_DIR)/tests/sparsefiles/testsparseexe1.ksh $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/sparsefiles/testsparseexe1.ksh
  24.         cp $(PROJECT_BASEDIR_DIR)/tests/fstest_make_numtree1/fstest_make_numtree1.ksh93 $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc/fstest_make_numtree1.ksh93
  25.         cp $(PROJECT_BASEDIR_DIR)/tests/wintartests/wintartest_comparewinvsgnu001.bash $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc/wintartest_comparewinvsgnu001.bash
  26.         cp $(PROJECT_BASEDIR_DIR)/tests/wintartests/wintartest_seq001.bash $(DESTDIR)/$(CYGWIN_BASEPATH)/usr/share/msnfs41client/tests/misc/wintartest_seq001.bash
  27. diff --git a/tests/sparsefiles/testsparseexe1.ksh b/tests/sparsefiles/testsparseexe1.ksh
  28. new file mode 100644
  29. index 0000000..ccc8d70
  30. --- /dev/null
  31. +++ b/tests/sparsefiles/testsparseexe1.ksh
  32. @@ -0,0 +1,171 @@
  33. +#!/bin/ksh93
  34. +
  35. +#
  36. +# MIT License
  37. +#
  38. +# Copyright (c) 2025 Roland Mainz <roland.mainz@nrubsig.org>
  39. +#
  40. +# Permission is hereby granted, free of charge, to any person obtaining a copy
  41. +# of this software and associated documentation files (the "Software"), to deal
  42. +# in the Software without restriction, including without limitation the rights
  43. +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  44. +# copies of the Software, and to permit persons to whom the Software is
  45. +# furnished to do so, subject to the following conditions:
  46. +#
  47. +# The above copyright notice and this permission notice shall be included in all
  48. +# copies or substantial portions of the Software.
  49. +#
  50. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  51. +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  52. +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  53. +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  54. +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  55. +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  56. +# SOFTWARE.
  57. +#
  58. +
  59. +#
  60. +# testsparseexe1.ksh - test whether sparse file *.exe work
  61. +#
  62. +# Written by Roland Mainz <roland.mainz@nrubsig.org>
  63. +#
  64. +
  65. +integer nulldata_array_size=1024*1024*64
  66. +
  67. +function generate_test_src
  68. +{
  69. +    printf '#include <stdio.h>\n'
  70. +    printf '#include <stdlib.h>\n'
  71. +
  72. +    printf '\nint main(int ac, char *av[])\n'
  73. +    printf '{\n'
  74. +
  75. +    printf 'volatile char nulldata_array[%d] = {\n' nulldata_array_size
  76. +    for ((i = nulldata_array_size ; i >= 64 ; i-= 64 )) ; do
  77. +        printf '\t0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n'
  78. +        printf '\t0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n'
  79. +    done
  80. +    if (( i > 0 )) ; then
  81. +        printf '\t'
  82. +        for (( ; i > 0 ; i-- )) ; do
  83. +            printf '0,'
  84. +        done
  85. +        printf '\n'
  86. +    fi
  87. +    printf '};\n'
  88. +
  89. +    printf '\tlong long sum = 0LL;\n'
  90. +    printf '\tsize_t i;\n'
  91. +    printf '\tfor (i = 0 ; i < %d ; i++) {\n' nulldata_array_size
  92. +    printf '\t\tsum += nulldata_array[i];'
  93. +    printf '\t}\n'
  94. +    printf '\t(void)printf("sum = %%lld\\n", sum);\n'
  95. +    printf '\treturn 0;\n'
  96. +    printf '}\n'
  97. +
  98. +    return 0
  99. +}
  100. +
  101. +
  102. +function test_sparseexe1
  103. +{
  104. +    #set -o xtrace
  105. +    set -o errexit
  106. +    set -o nounset
  107. +
  108. +    compound res
  109. +    integer res.errors=0
  110. +
  111. +    printf '#### %s: Begin...\n' "$0"
  112. +
  113. +    rm -f \
  114. +        'sparseexe_orig.exe' \
  115. +        'sparseexe_sparse.exe' \
  116. +        'sparseexe.c'
  117. +
  118. +    print '# generate source...'
  119. +    generate_test_src | cat >'sparseexe.c'
  120. +
  121. +    print '# compile source...'
  122. +    gcc -Wl,--stack,$((1024*1024*256)) -Wall -g 'sparseexe.c' -o 'sparseexe_orig.exe'
  123. +
  124. +    print $'# copy *.exe, and turn all sections with long sequences of \'\\0\'-bytes into "holes" ...'
  125. +    # explicitly use /usr/bin/cp and not the AST cp builtin
  126. +    /usr/bin/cp --sparse=always 'sparseexe_orig.exe' 'sparseexe_sparse.exe'
  127. +
  128. +    print '# collect data...'
  129. +    integer res.sparseexe_orig_blocks=$(stat --printf '%b\n' 'sparseexe_orig.exe')
  130. +    integer res.sparseexe_sparse_blocks=$(stat --printf '%b\n' 'sparseexe_sparse.exe')
  131. +    integer res.sparseexe_orig_filesize=$(stat --printf '%s\n' 'sparseexe_orig.exe')
  132. +    integer res.sparseexe_sparse_filesize=$(stat --printf '%s\n' 'sparseexe_sparse.exe')
  133. +
  134. +    compound res.testrun=(
  135. +        typeset stderr=''
  136. +        typeset stdout=''
  137. +        integer res=-1
  138. +    )
  139. +
  140. +    set +o errexit
  141. +
  142. +    res.testrun.stderr="${ { res.testrun.stdout="${ ./sparseexe_sparse.exe ; (( res.testrun.res=$? )) ; }" ; } 2>&1 ; }"
  143. +
  144. +    print '# print results...'
  145. +    print -v res
  146. +    ls -ls 'sparseexe_orig.exe' 'sparseexe_sparse.exe'
  147. +
  148. +    if (( res.testrun.res == 0 )) ; then
  149. +        printf 'test file return exit code 0: OK\n'
  150. +    else
  151. +        printf 'ERROR: test file return exit code %d\n' res.testrun.res
  152. +        (( res.errors++ ))
  153. +    fi
  154. +
  155. +    if [[ "${res.testrun.stdout}" == ~(E)sum\ =\ 0 ]] ; then
  156. +        printf 'test file stdout %s: OK\n' "${res.testrun.stdout}"
  157. +    else
  158. +        printf 'ERROR: test file stdout output %q, expected "sum = 0"\n' "${res.testrun.stdout}"
  159. +        (( res.errors++ ))
  160. +    fi
  161. +
  162. +    if [[ "${res.testrun.stderr}" == '' ]] ; then
  163. +        printf 'test file stderr empty: OK\n'
  164. +    else
  165. +        printf 'ERROR: test file stderr output %q\n' "${res.testrun.stderr}"
  166. +        (( res.errors++ ))
  167. +    fi
  168. +
  169. +    if (( res.sparseexe_orig_filesize == res.sparseexe_sparse_filesize )) ; then
  170. +        printf 'test file sizes: OK\n'
  171. +    else
  172. +        printf '# ERROR: sparseexe_orig.exe and sparseexe_sparse.exe file size differ\n'
  173. +        (( res.errors++ ))
  174. +    fi
  175. +
  176. +    if (( (res.sparseexe_orig_blocks/10.) > res.sparseexe_sparse_blocks )) ; then
  177. +        printf 'test file number of blocks: OK, sparseexe_sparse.exe has less filesystem blocks\n'
  178. +    else
  179. +        printf '# ERROR: sparseexe_sparse.exe consumes too many filesystem blocks\n'
  180. +        (( res.errors++ ))
  181. +    fi
  182. +
  183. +    if (( res.errors == 0 )) ; then
  184. +        printf '#### %s: All tests OK\n' "$0"
  185. +        exit 0
  186. +    else
  187. +        printf '#### %s tests FAILED\n' res.errors
  188. +        return 1
  189. +    fi
  190. +
  191. +    # not reached
  192. +}
  193. +
  194. +#
  195. +# main
  196. +#
  197. +builtin cat
  198. +builtin rm
  199. +
  200. +test_sparseexe1
  201. +
  202. +# EOF.
  203. +
  204. --
  205. 2.45.1
  206.  
  207. From e7bff874067628b393b9e304a61f3801b9f09a2f Mon Sep 17 00:00:00 2001
  208. From: Roland Mainz <roland.mainz@nrubsig.org>
  209. Date: Tue, 18 Mar 2025 14:20:31 +0100
  210. Subject: [PATCH 2/7] daemon: Add |BITMAP4_MAXCOUNT| to define the size of
  211.  |bitmap4.arr|
  212.  
  213. Add |BITMAP4_MAXCOUNT| to define the size of |bitmap4.arr| instead
  214. of a hardcoded integer.
  215.  
  216. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  217. ---
  218. daemon/nfs41_types.h |  3 ++-
  219.  daemon/nfs41_xdr.c   | 14 ++++++++------
  220.  2 files changed, 10 insertions(+), 7 deletions(-)
  221.  
  222. diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
  223. index c589baf..804cee8 100644
  224. --- a/daemon/nfs41_types.h
  225. +++ b/daemon/nfs41_types.h
  226. @@ -89,9 +89,10 @@ typedef struct __multi_addr4 {
  227.      uint32_t        count;
  228.  } multi_addr4;
  229.  
  230. +#define BITMAP4_MAXCOUNT (3)
  231.  typedef struct __bitmap4 {
  232.      uint32_t        count;
  233. -    uint32_t        arr[3];
  234. +    uint32_t        arr[BITMAP4_MAXCOUNT];
  235.  } bitmap4;
  236.  
  237.  typedef struct __nfstime4 {
  238. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  239. index c4b0c0f..bbf2153 100644
  240. --- a/daemon/nfs41_xdr.c
  241. +++ b/daemon/nfs41_xdr.c
  242. @@ -54,9 +54,10 @@ bool_t xdr_bitmap4(
  243.      uint32_t i;
  244.  
  245.      if (xdr->x_op == XDR_ENCODE) {
  246. -        if (bitmap->count > 3) {
  247. -            eprintf("encode_bitmap4: count (%d) must be <= 3\n",
  248. -                bitmap->count);
  249. +        if (bitmap->count > BITMAP4_MAXCOUNT) {
  250. +            eprintf("encode_bitmap4: count (%d) must be <= %d\n",
  251. +                bitmap->count,
  252. +                BITMAP4_MAXCOUNT);
  253.              return FALSE;
  254.          }
  255.          if (!xdr_u_int32_t(xdr, &bitmap->count))
  256. @@ -69,9 +70,10 @@ bool_t xdr_bitmap4(
  257.      } else if (xdr->x_op == XDR_DECODE) {
  258.          if (!xdr_u_int32_t(xdr, &bitmap->count))
  259.              return FALSE;
  260. -        if (bitmap->count > 3) {
  261. -            eprintf("decode_bitmap4: count (%d) must be <= 3\n",
  262. -                bitmap->count);
  263. +        if (bitmap->count > BITMAP4_MAXCOUNT) {
  264. +            eprintf("decode_bitmap4: count (%d) must be <= %d\n",
  265. +                bitmap->count,
  266. +                BITMAP4_MAXCOUNT);
  267.              return FALSE;
  268.          }
  269.  
  270. --
  271. 2.45.1
  272.  
  273. From dc214c885fcf935bd2d317d60f2e65166523fb35 Mon Sep 17 00:00:00 2001
  274. From: Roland Mainz <roland.mainz@nrubsig.org>
  275. Date: Tue, 18 Mar 2025 14:35:44 +0100
  276. Subject: [PATCH 3/7] cygwin: nfs_umount.exe should also use the SegmentHeap
  277.  allocator
  278.  
  279. nfs_umount.exe should also use the SegmentHeap allocator
  280.  
  281. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  282. ---
  283. cygwin/devel/msnfs41client.bash | 2 ++
  284.  1 file changed, 2 insertions(+)
  285.  
  286. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  287. index e812c83..4a391dd 100755
  288. --- a/cygwin/devel/msnfs41client.bash
  289. +++ b/cygwin/devel/msnfs41client.bash
  290. @@ -167,6 +167,8 @@ function nfsclient_install
  291.         regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfsd.exe/FrontEndHeapDebugOptions' 0x08
  292.         regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_mount.exe'
  293.         regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_mount.exe/FrontEndHeapDebugOptions' 0x08
  294. +       regtool add '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_umount.exe'
  295. +       regtool -i set '/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/nfs_umount.exe/FrontEndHeapDebugOptions' 0x08
  296.  
  297.         if ! $use_secureboot ; then
  298.                 # make sure we can load the kernel driver
  299. --
  300. 2.45.1
  301.  
  302. From c424ce32dbc2c853947f0cd9700a49415acb1b36 Mon Sep 17 00:00:00 2001
  303. From: Martin Wege <martin.l.wege@gmail.com>
  304. Date: Tue, 18 Mar 2025 15:25:14 +0100
  305. Subject: [PATCH 4/7] daemon: Add |mempcpy()| implementation
  306.  
  307. Add |mempcpy()| implementation.
  308.  
  309. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  310. ---
  311. daemon/acl.c  | 6 ++++--
  312.  daemon/util.h | 7 +++++++
  313.  2 files changed, 11 insertions(+), 2 deletions(-)
  314.  
  315. diff --git a/daemon/acl.c b/daemon/acl.c
  316. index c098ba7..2021d78 100644
  317. --- a/daemon/acl.c
  318. +++ b/daemon/acl.c
  319. @@ -1115,7 +1115,9 @@ add_domain:
  320.       */
  321.      EASSERT(!isdigit(who_out[0]));
  322.  
  323. -    (void)memcpy(who_out+who_size, "@", sizeof(char));
  324. +    char *wp;
  325. +
  326. +    wp = mempcpy(who_out+who_size, "@", sizeof(char));
  327.  
  328.  #ifdef NFS41_DRIVER_WS2022_HACKS
  329.      /* Fixup |domain| for Windows Sever 2022 NFSv4.1 server */
  330. @@ -1133,7 +1135,7 @@ add_domain:
  331.              (int)who_size+1, who_out, domain));
  332.      }
  333.  #endif /* NFS41_DRIVER_WS2022_HACKS */
  334. -    (void)memcpy(who_out+who_size+1, domain, strlen(domain)+1);
  335. +    (void)memcpy(wp, domain, strlen(domain)+1);
  336.  
  337.  /* no_add_domain: */
  338.      status = ERROR_SUCCESS;
  339. diff --git a/daemon/util.h b/daemon/util.h
  340. index 3498725..242dfb9 100644
  341. --- a/daemon/util.h
  342. +++ b/daemon/util.h
  343. @@ -57,6 +57,13 @@ typedef ULONGLONG util_reltimestamp;
  344.  
  345.  char *stpcpy(char *restrict s1, const char *restrict s2);
  346.  
  347. +static __inline
  348. +void *mempcpy(void *restrict dest, const void *restrict src, size_t n)
  349. +{
  350. +    (void)memcpy(dest, src, n);
  351. +    return (void *)((char *)dest + n);
  352. +}
  353. +
  354.  int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
  355.  int safe_write(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
  356.  int get_name(unsigned char **pos, uint32_t *remaining, const char **out_name);
  357. --
  358. 2.45.1
  359.  
  360. From 4c63db6124e98c77e5218173e3386fa68642e736 Mon Sep 17 00:00:00 2001
  361. From: Cedric Blancher <cedric.blancher@gmail.com>
  362. Date: Tue, 18 Mar 2025 17:48:59 +0100
  363. Subject: [PATCH 5/7] tests: nfsbuildtest bash build does not work with Windows
  364.  10/32bit+Cygwin 3.3/32bit+gcc 11.3.0
  365.  
  366. nfsbuildtest bash build does not work on Windows 10/32bit,
  367. Cygwin 3.3/32bit with gcc (GCC) 11.3.0 - gcc fails because
  368. -std gnu17 support was buggy with that version of gcc.
  369.  
  370. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  371. ---
  372. tests/nfsbuildtest/nfsbuildtest.ksh93 | 8 ++++++--
  373.  1 file changed, 6 insertions(+), 2 deletions(-)
  374.  
  375. diff --git a/tests/nfsbuildtest/nfsbuildtest.ksh93 b/tests/nfsbuildtest/nfsbuildtest.ksh93
  376. index 17eaef3..f211850 100644
  377. --- a/tests/nfsbuildtest/nfsbuildtest.ksh93
  378. +++ b/tests/nfsbuildtest/nfsbuildtest.ksh93
  379. @@ -302,8 +302,12 @@ function bash_build
  380.                 (set -o xtrace ; sed -i "s/\/bin\/sh/\/bin\/ksh93/g" $(find . -name 'configure') )
  381.         fi
  382.  
  383. -       # workaround for gcc 15.0 used in Cygwin 3.6
  384. -       export CFLAGS="-std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int"
  385. +       if is_cygwin && (( (cygwin_vers.major*1000+cygwin_vers.minor) >= 3005 )) ; then
  386. +               # workaround for gcc 15.0 used in Cygwin 3.6
  387. +               export CFLAGS="-std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int"
  388. +       else
  389. +               export CFLAGS="-std=gnu99"
  390. +       fi
  391.  
  392.         if $config_use_posix_ksh93_builtins ; then
  393.                 CONFIG_SHELL=/usr/bin/ksh93 ksh93 ./configure "${configure_options[@]}"
  394. --
  395. 2.45.1
  396.  
  397. From ffc838db9844ddcc57c44572b0744878f4b3e63e Mon Sep 17 00:00:00 2001
  398. From: Cedric Blancher <cedric.blancher@gmail.com>
  399. Date: Tue, 18 Mar 2025 18:25:05 +0100
  400. Subject: [PATCH 6/7] cygwin,tests: Modify tests to work without
  401.  lssparse.exe+fallocate.exe (both require Cygwin 3.6)
  402.  
  403. Modify tests to work without lssparse.exe+fallocate.exe.
  404.  
  405. lssparse.exe and fallocate.exe require Cygwin 3.6 (which
  406. introduced lseek(..., SEEK_HOLE, ...) and lseek(..., SEEK_DATA, ...)),
  407. and are therefore not available on Cygwin 3.3/32bit (which was the
  408. last Cygwin release supporting 32bit kernels).
  409.  
  410. Note that the Win32 API FSCTL_QUERY_ALLOCATED_RANGES and
  411. "fsutil sparse ..." work fine on Windows 32bit kernels, just
  412. Cygwin 3.3 has no sparse file API in lseek().
  413.  
  414. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  415. ---
  416. cygwin/Makefile.install               |  3 --
  417.  tests/lssparse/Makefile               |  8 ++--
  418.  tests/sparsefiles/testsparsefile1.ksh | 63 ++++++++++++++++++++++++---
  419.  3 files changed, 60 insertions(+), 14 deletions(-)
  420.  
  421. diff --git a/cygwin/Makefile.install b/cygwin/Makefile.install
  422. index b5b3de9..e274aa5 100644
  423. --- a/cygwin/Makefile.install
  424. +++ b/cygwin/Makefile.install
  425. @@ -104,11 +104,8 @@ installdest:
  426.                 (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && ln -sf winfsinfo.i686.exe winfsinfo.exe) \
  427.         fi
  428.         cp "$(PROJECT_BASEDIR_DIR)/tests/lssparse/lssparse.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/lssparse.x86_64.exe
  429. -       cp "$(PROJECT_BASEDIR_DIR)/tests/lssparse/lssparse.i686.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/lssparse.i686.exe
  430.         if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  431.                 (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && ln -sf lssparse.x86_64.exe lssparse.exe) \
  432. -       else \
  433. -               (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && ln -sf lssparse.i686.exe lssparse.exe) \
  434.         fi
  435.         if [[ "$(CYGWIN_BASEPATH)" == *64* ]] ; then \
  436.                 cp "$(PROJECT_BASEDIR_DIR)/tests/winsg/winsg.x86_64.exe" $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/winsg.exe ; \
  437. diff --git a/tests/lssparse/Makefile b/tests/lssparse/Makefile
  438. index 199d5d2..4f92fc1 100644
  439. --- a/tests/lssparse/Makefile
  440. +++ b/tests/lssparse/Makefile
  441. @@ -4,10 +4,11 @@
  442.  
  443.  # POSIX Makefile
  444.  
  445. -all: lssparse.i686.exe lssparse.x86_64.exe lssparse.exe
  446. +all: lssparse.x86_64.exe lssparse.exe
  447.  
  448. -lssparse.i686.exe: lssparse.c
  449. -       gcc -std=gnu17 -Wall -Wextra -DUNICODE=1 -D_UNICODE=1 -I../../include -g lssparse.c -lntdll -o lssparse.i686.exe
  450. +# Cygwin 3.6 does not support 32bit builds anymore
  451. +#lssparse.i686.exe: lssparse.c
  452. +#      gcc -std=gnu17 -Wall -Wextra -DUNICODE=1 -D_UNICODE=1 -I../../include -g lssparse.c -lntdll -o lssparse.i686.exe
  453.  
  454.  lssparse.x86_64.exe: lssparse.c
  455.         gcc -std=gnu17 -Wall -Wextra -DUNICODE=1 -D_UNICODE=1 -I../../include -g lssparse.c -lntdll -o lssparse.x86_64.exe
  456. @@ -17,7 +18,6 @@ lssparse.exe: lssparse.x86_64.exe
  457.  
  458.  clean:
  459.         rm -fv \
  460. -               lssparse.i686.exe \
  461.                 lssparse.x86_64.exe \
  462.                 lssparse.exe \
  463.  # EOF.
  464. diff --git a/tests/sparsefiles/testsparsefile1.ksh b/tests/sparsefiles/testsparsefile1.ksh
  465. index ee45def..d9e2b02 100644
  466. --- a/tests/sparsefiles/testsparsefile1.ksh
  467. +++ b/tests/sparsefiles/testsparsefile1.ksh
  468. @@ -47,7 +47,13 @@ function test_sparse_holeonly_dd
  469.  
  470.      integer fsutil_num_data_sections="$(/cygdrive/c/Windows/system32/fsutil sparse queryrange 'sparse_file_hole_only' | wc -l)"
  471.      integer winfsinfo_num_data_sections="$(winfsinfo fsctlqueryallocatedranges 'sparse_file_hole_only' | wc -l)"
  472. -    integer lssparse_num_data_sections="$(lssparse 'sparse_file_hole_only' | wc -l)"
  473. +    integer lssparse_num_data_sections
  474. +    if $has_lssparse ; then
  475. +        lssparse_num_data_sections="$(lssparse 'sparse_file_hole_only' | wc -l)"
  476. +    else
  477. +        # hack
  478. +        (( lssparse_num_data_sections=winfsinfo_num_data_sections ))
  479. +    fi
  480.  
  481.      #
  482.      # test whether the file is OK
  483. @@ -89,7 +95,13 @@ function test_sparse_holeonly_truncate
  484.  
  485.      integer fsutil_num_data_sections="$(/cygdrive/c/Windows/system32/fsutil sparse queryrange 'sparse_file_hole_only_trunc' | wc -l)"
  486.      integer winfsinfo_num_data_sections="$(winfsinfo fsctlqueryallocatedranges 'sparse_file_hole_only_trunc' | wc -l)"
  487. -    integer lssparse_num_data_sections="$(lssparse 'sparse_file_hole_only_trunc' | wc -l)"
  488. +    integer lssparse_num_data_sections
  489. +    if $has_lssparse ; then
  490. +        lssparse_num_data_sections="$(lssparse 'sparse_file_hole_only_trunc' | wc -l)"
  491. +    else
  492. +        # hack
  493. +        (( lssparse_num_data_sections=winfsinfo_num_data_sections ))
  494. +    fi
  495.  
  496.      #
  497.      # test whether the file is OK
  498. @@ -129,7 +141,13 @@ function test_normal_file
  499.  
  500.      integer fsutil_num_data_sections="$(/cygdrive/c/Windows/system32/fsutil sparse queryrange 'test_normal_file' | wc -l)"
  501.      integer winfsinfo_num_data_sections="$(winfsinfo fsctlqueryallocatedranges 'test_normal_file' | wc -l)"
  502. -    integer lssparse_num_data_sections="$(lssparse 'test_normal_file' | wc -l)"
  503. +    integer lssparse_num_data_sections
  504. +    if $has_lssparse ; then
  505. +        lssparse_num_data_sections="$(lssparse 'test_normal_file' | wc -l)"
  506. +    else
  507. +        # hack
  508. +        (( lssparse_num_data_sections=winfsinfo_num_data_sections ))
  509. +    fi
  510.  
  511.      #
  512.      # test whether the file is OK
  513. @@ -218,8 +236,13 @@ function test_multihole_sparsefile1
  514.  
  515.      integer fsutil_num_data_sections="$(/cygdrive/c/Windows/system32/fsutil sparse queryrange 'mysparsefile' | wc -l)"
  516.      integer winfsinfo_num_data_sections="$(winfsinfo fsctlqueryallocatedranges 'mysparsefile' | wc -l)"
  517. -    integer lssparse_num_data_sections="$(lssparse 'mysparsefile' | wc -l)"
  518. -
  519. +    integer lssparse_num_data_sections
  520. +    if $has_lssparse ; then
  521. +        lssparse_num_data_sections="$(lssparse 'mysparsefile' | wc -l)"
  522. +    else
  523. +        # hack
  524. +        (( lssparse_num_data_sections=winfsinfo_num_data_sections ))
  525. +    fi
  526.  
  527.      #
  528.      # test whether the file is OK
  529. @@ -266,7 +289,13 @@ function test_sparse_punchhole1
  530.  
  531.      integer fsutil_num_data_sections="$(/cygdrive/c/Windows/system32/fsutil sparse queryrange 'sparse_file_punchhole' | wc -l)"
  532.      integer winfsinfo_num_data_sections="$(winfsinfo fsctlqueryallocatedranges 'sparse_file_punchhole' | wc -l)"
  533. -    integer lssparse_num_data_sections="$(lssparse 'sparse_file_punchhole' | wc -l)"
  534. +    integer lssparse_num_data_sections
  535. +    if $has_lssparse ; then
  536. +        lssparse_num_data_sections="$(lssparse 'sparse_file_punchhole' | wc -l)"
  537. +    else
  538. +        # hack
  539. +        (( lssparse_num_data_sections=winfsinfo_num_data_sections ))
  540. +    fi
  541.  
  542.      #
  543.      # test whether the file is OK
  544. @@ -301,6 +330,22 @@ builtin basename
  545.  builtin rm
  546.  builtin wc
  547.  
  548. +typeset has_lssparse
  549. +typeset has_fallocate
  550. +
  551. +if which lssparse.exe 2>'/dev/null' ; then
  552. +    has_lssparse=true
  553. +else
  554. +    printf '#\n# NOTE: Skipping lssparse tests.\n#\n'
  555. +    has_lssparse=false
  556. +fi
  557. +if which fallocate.exe 2>'/dev/null' ; then
  558. +    has_fallocate=true
  559. +else
  560. +    printf '#\n# NOTE: Skipping fallocate tests.\n#\n'
  561. +    has_fallocate=false
  562. +fi
  563. +
  564.  test_sparse_holeonly_dd
  565.  test_sparse_holeonly_truncate
  566.  test_normal_file
  567. @@ -316,7 +361,11 @@ test_multihole_sparsefile1 1024 1 4  true
  568.  # fsutil uses 64 entries per queryrange, so we test this here
  569.  test_multihole_sparsefile1 1024 2 256 false
  570.  
  571. -test_sparse_punchhole1
  572. +if $has_fallocate ; then
  573. +    test_sparse_punchhole1
  574. +else
  575. +    printf '# NOTE: test_sparse_punchhole1 SKIPPED, no fallocate.exe\n'
  576. +fi
  577.  
  578.  printf '#\n# done\n#\n\n'
  579.  
  580. --
  581. 2.45.1
  582.  
  583. From f9e373543d83494d184199267d01187c11deb1d3 Mon Sep 17 00:00:00 2001
  584. From: Roland Mainz <roland.mainz@nrubsig.org>
  585. Date: Tue, 18 Mar 2025 19:18:01 +0100
  586. Subject: [PATCH 7/7] tests: Adjust "testsparseexe1" for Cygwin versions
  587.  without cp --sparse=always support
  588.  
  589. Adjust testsparseexe1.ksh for Cygwin versions without
  590. $ cp --sparse=always ... # support.
  591.  
  592. Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
  593. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  594. ---
  595. tests/sparsefiles/testsparseexe1.ksh | 36 ++++++++++++++++++++--------
  596.  1 file changed, 26 insertions(+), 10 deletions(-)
  597.  
  598. diff --git a/tests/sparsefiles/testsparseexe1.ksh b/tests/sparsefiles/testsparseexe1.ksh
  599. index ccc8d70..5088baf 100644
  600. --- a/tests/sparsefiles/testsparseexe1.ksh
  601. +++ b/tests/sparsefiles/testsparseexe1.ksh
  602. @@ -30,17 +30,15 @@
  603.  # Written by Roland Mainz <roland.mainz@nrubsig.org>
  604.  #
  605.  
  606. -integer nulldata_array_size=1024*1024*64
  607. +integer nulldata_array_size=1024*1024*16
  608.  
  609.  function generate_test_src
  610.  {
  611.      printf '#include <stdio.h>\n'
  612.      printf '#include <stdlib.h>\n'
  613. +    printf '\n'
  614.  
  615. -    printf '\nint main(int ac, char *av[])\n'
  616. -    printf '{\n'
  617. -
  618. -    printf 'volatile char nulldata_array[%d] = {\n' nulldata_array_size
  619. +    printf 'volatile char __attribute__((section(".noinit"))) nulldata_array[%d] = {\n' nulldata_array_size
  620.      for ((i = nulldata_array_size ; i >= 64 ; i-= 64 )) ; do
  621.          printf '\t0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n'
  622.          printf '\t0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n'
  623. @@ -54,6 +52,12 @@ function generate_test_src
  624.      fi
  625.      printf '};\n'
  626.  
  627. +    printf '\nint main(int ac, char *av[])\n'
  628. +    printf '{\n'
  629. +
  630. +    printf '\t(void)ac; /* not used */\n'
  631. +    printf '\t(void)av; /* not used */\n'
  632. +
  633.      printf '\tlong long sum = 0LL;\n'
  634.      printf '\tsize_t i;\n'
  635.      printf '\tfor (i = 0 ; i < %d ; i++) {\n' nulldata_array_size
  636. @@ -87,11 +91,23 @@ function test_sparseexe1
  637.      generate_test_src | cat >'sparseexe.c'
  638.  
  639.      print '# compile source...'
  640. -    gcc -Wl,--stack,$((1024*1024*256)) -Wall -g 'sparseexe.c' -o 'sparseexe_orig.exe'
  641. -
  642. -    print $'# copy *.exe, and turn all sections with long sequences of \'\\0\'-bytes into "holes" ...'
  643. -    # explicitly use /usr/bin/cp and not the AST cp builtin
  644. -    /usr/bin/cp --sparse=always 'sparseexe_orig.exe' 'sparseexe_sparse.exe'
  645. +    gcc -Wall -g 'sparseexe.c' -o 'sparseexe_orig.exe'
  646. +
  647. +    #
  648. +    # HACK: Test for fallocate.exe to determinate whether the system's
  649. +    # /usr/bin/cp.exe has sparse file support (which depends on
  650. +    # SEEK_HOLE+SEEK_DATA.
  651. +    #
  652. +    if which -a 'fallocate.exe' 2>'/dev/null' ; then
  653. +        print $'# copy *.exe via cp --sparse=always, turn all sections with long sequences of \'\\0\'-bytes into "holes" ...'
  654. +        # explicitly use /usr/bin/cp and not the AST cp builtin
  655. +        /usr/bin/cp --sparse=always 'sparseexe_orig.exe' 'sparseexe_sparse.exe'
  656. +    else
  657. +        print $'# copy *.exe via dd conv=sparse, turn all sections with long sequences of \'\\0\'-bytes into "holes" ...'
  658. +        # explicitly use /usr/bin/cp and not the AST cp builtin
  659. +        dd if='sparseexe_orig.exe' of='sparseexe_sparse.exe' conv=sparse
  660. +        chmod a+x 'sparseexe_sparse.exe'
  661. +    fi
  662.  
  663.      print '# collect data...'
  664.      integer res.sparseexe_orig_blocks=$(stat --printf '%b\n' 'sparseexe_orig.exe')
  665. --
  666. 2.45.1

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at