Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package liberasurecode for openSUSE:Factory 
checked in at 2021-03-02 12:33:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/liberasurecode (Old)
 and      /work/SRC/openSUSE:Factory/.liberasurecode.new.2378 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "liberasurecode"

Tue Mar  2 12:33:40 2021 rev:6 rq:875807 version:1.6.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/liberasurecode/liberasurecode.changes    
2019-08-06 15:12:16.311735910 +0200
+++ /work/SRC/openSUSE:Factory/.liberasurecode.new.2378/liberasurecode.changes  
2021-03-02 12:45:29.020356917 +0100
@@ -1,0 +2,20 @@
+Sun Feb 28 18:02:44 UTC 2021 - Dirk M??ller <[email protected]>
+
+- update to 1.6.2:
+  * Allow the writing of fragments with the legacy, non-standard CRC-32.
+  This is intended to smooth upgrades from liberasurecode 1.5.0 and
+  earlier in a system with multiple readers and writers.
+
+  See https://bugs.launchpad.net/liberasurecode/+bug/1886088 for more
+  information, including a script you can run on already-written
+  fragments to determine whether you are affected.
+
+  If you are affected:
+  - Upgrade liberasurecode on all systems, restarting processes as needed.
+    Upgraded writers will continue writing CRCs that not-yet-upgraded
+    readers can use.
+  - After liberasurecode is upgraded everywhere, remove the environment
+    variable. zlib CRCs will be used for new writes, and data written with
+    either CRC will still be readable.
+
+-------------------------------------------------------------------

Old:
----
  liberasurecode-1.6.1.tar.gz

New:
----
  liberasurecode-1.6.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ liberasurecode.spec ++++++
--- /var/tmp/diff_new_pack.uLJ9h2/_old  2021-03-02 12:45:29.580357401 +0100
+++ /var/tmp/diff_new_pack.uLJ9h2/_new  2021-03-02 12:45:29.584357404 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package liberasurecode
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %define libsoname liberasurecode1
 Name:           liberasurecode
-Version:        1.6.1
+Version:        1.6.2
 Release:        0
 Summary:        Erasure Code API library with pluggable Erasure Code backends
 License:        BSD-3-Clause
@@ -27,6 +27,7 @@
 Source0:        
https://github.com/openstack/liberasurecode/archive/%{version}/%{name}-%{version}.tar.gz
 BuildRequires:  automake
 BuildRequires:  libtool
+BuildRequires:  pkgconfig
 BuildRequires:  pkgconfig(zlib)
 
 %description
@@ -55,13 +56,13 @@
 %build
 ./autogen.sh
 %configure --disable-static --disable-mmi
-make %{?_smp_mflags}
+%make_build
 
 %install
 %make_install
 
 %check
-make test
+%make_build test
 
 %post -n %{libsoname} -p /sbin/ldconfig
 %postun -n %{libsoname} -p /sbin/ldconfig
@@ -70,7 +71,7 @@
 %if 0%{?suse_version} > 1315
 %license COPYING
 %else
-%doc COPYING
+%license COPYING
 %endif
 %doc ChangeLog README.md
 %{_libdir}/libXorcode.so.*

++++++ liberasurecode-1.6.1.tar.gz -> liberasurecode-1.6.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/liberasurecode-1.6.1/.gitreview 
new/liberasurecode-1.6.2/.gitreview
--- old/liberasurecode-1.6.1/.gitreview 2019-05-24 15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/.gitreview 2020-10-08 23:46:14.000000000 +0200
@@ -1,4 +1,4 @@
 [gerrit]
 host=review.opendev.org
 port=29418
-project=x/liberasurecode.git
+project=openstack/liberasurecode.git
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/liberasurecode-1.6.1/.mailmap 
new/liberasurecode-1.6.2/.mailmap
--- old/liberasurecode-1.6.1/.mailmap   2019-05-24 15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/.mailmap   2020-10-08 23:46:14.000000000 +0200
@@ -3,7 +3,8 @@
 Eric Lambert <[email protected]> <[email protected]>
 Eric Lambert <[email protected]> <[email protected]>
 Tushar Gohad <[email protected]> <[email protected]>
-Kota Tsuyuzaki <[email protected]> <[email protected]>
+Kota Tsuyuzaki <[email protected]> <[email protected]>
+Kota Tsuyuzaki <[email protected]> <[email protected]>
 Alistair Coles <[email protected]> <[email protected]>
 Ond??ej Nov?? <[email protected]> <[email protected]>
 Thiago da Silva <[email protected]> <[email protected]>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/liberasurecode-1.6.1/.zuul.yaml 
new/liberasurecode-1.6.2/.zuul.yaml
--- old/liberasurecode-1.6.1/.zuul.yaml 2019-05-24 15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/.zuul.yaml 2020-10-08 23:46:14.000000000 +0200
@@ -13,12 +13,22 @@
       Build and run test and valgrind-test for liberasurecode.
       This job runs on CentOS-7.
 
+- job:
+    name: liberasurecode-unittests-centos-8
+    parent: liberasurecode-unittests
+    nodeset: centos-8
+    description: |
+      Build and run test and valgrind-test for liberasurecode.
+      This job runs on CentOS-8.
+
 - project:
     check:
       jobs:
         - liberasurecode-unittests
         - liberasurecode-unittests-centos-7
+        - liberasurecode-unittests-centos-8
     gate:
       jobs:
         - liberasurecode-unittests
         - liberasurecode-unittests-centos-7
+        - liberasurecode-unittests-centos-8
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/liberasurecode-1.6.1/AUTHORS 
new/liberasurecode-1.6.2/AUTHORS
--- old/liberasurecode-1.6.1/AUTHORS    2019-05-24 15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/AUTHORS    2020-10-08 23:46:14.000000000 +0200
@@ -16,7 +16,7 @@
 Chris Lamb ([email protected])
 Dirk Mueller ([email protected])
 James Page ([email protected])
-Kota Tsuyuzaki ([email protected])
+Kota Tsuyuzaki ([email protected])
 Pete Zaitcev ([email protected])
 gengchc2 ([email protected])
 Daniel Axtens ([email protected])
@@ -24,3 +24,5 @@
 John Dickinson ([email protected])
 Jim Cheung ([email protected])
 Ond??ej Nov?? ([email protected])
+Corey Bryant ([email protected])
+donnydavis ([email protected])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/liberasurecode-1.6.1/COPYING 
new/liberasurecode-1.6.2/COPYING
--- old/liberasurecode-1.6.1/COPYING    2019-05-24 15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/COPYING    2020-10-08 23:46:14.000000000 +0200
@@ -1,24 +1,23 @@
-/* 
- * Copyright (c) 2014 Tushar Gohad, Kevin M Greenan, Eric Lambert, Mark Storer
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice, 
this
- * list of conditions and the following disclaimer in the documentation and/or
- * other materials provided with the distribution.  THIS SOFTWARE IS PROVIDED 
BY
- * THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright (c) 2014 Tushar Gohad, Kevin M Greenan, Eric Lambert, Mark Storer
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice, this
+list of conditions and the following disclaimer in the documentation and/or
+other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/liberasurecode-1.6.1/ChangeLog 
new/liberasurecode-1.6.2/ChangeLog
--- old/liberasurecode-1.6.1/ChangeLog  2019-05-24 15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/ChangeLog  2020-10-08 23:46:14.000000000 +0200
@@ -1,3 +1,25 @@
+Release 1.6.2
+-------------
+
+ . Allow the writing of fragments with the legacy, non-standard CRC-32.
+   This is intended to smooth upgrades from liberasurecode 1.5.0 and
+   earlier in a system with multiple readers and writers.
+
+   See https://bugs.launchpad.net/liberasurecode/+bug/1886088 for more
+   information, including a script you can run on already-written
+   fragments to determine whether you are affected.
+
+   If you are affected:
+
+    - Before upgrading, ensure every writer will have the environment variable
+      LIBERASURECODE_WRITE_LEGACY_CRC=1 set upon restart.
+    - Upgrade liberasurecode on all systems, restarting processes as needed.
+      Upgraded writers will continue writing CRCs that not-yet-upgraded
+      readers can use.
+    - After liberasurecode is upgraded everywhere, remove the environment
+      variable. zlib CRCs will be used for new writes, and data written with
+      either CRC will still be readable.
+
 Release 1.6.1
 -------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/liberasurecode-1.6.1/include/erasurecode/erasurecode_version.h 
new/liberasurecode-1.6.2/include/erasurecode/erasurecode_version.h
--- old/liberasurecode-1.6.1/include/erasurecode/erasurecode_version.h  
2019-05-24 15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/include/erasurecode/erasurecode_version.h  
2020-10-08 23:46:14.000000000 +0200
@@ -27,7 +27,7 @@
 
 #define _MAJOR 1
 #define _MINOR 6
-#define _REV 1
+#define _REV 2
 #define _VERSION(x, y, z) ((x << 16) | (y << 8) | (z))
 
 #define LIBERASURECODE_VERSION _VERSION(_MAJOR, _MINOR, _REV)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/liberasurecode-1.6.1/roles/install_jerasure/tasks/main.yaml 
new/liberasurecode-1.6.2/roles/install_jerasure/tasks/main.yaml
--- old/liberasurecode-1.6.1/roles/install_jerasure/tasks/main.yaml     
2019-05-24 15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/roles/install_jerasure/tasks/main.yaml     
2020-10-08 23:46:14.000000000 +0200
@@ -9,7 +9,7 @@
       set -e
       set -x
       cd $WORKSPACE
-      git clone http://lab.jerasure.org/jerasure/gf-complete.git
+      git clone https://github.com/ceph/gf-complete.git
       cd gf-complete
       ./autogen.sh
       ./configure
@@ -25,7 +25,7 @@
       set -e
       set -x
       cd $WORKSPACE
-      git clone http://lab.jerasure.org/jerasure/jerasure.git
+      git clone https://github.com/ceph/jerasure.git
       cd jerasure
       autoreconf --force --install
       ./configure
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/liberasurecode-1.6.1/src/erasurecode_helpers.c 
new/liberasurecode-1.6.2/src/erasurecode_helpers.c
--- old/liberasurecode-1.6.1/src/erasurecode_helpers.c  2019-05-24 
15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/src/erasurecode_helpers.c  2020-10-08 
23:46:14.000000000 +0200
@@ -463,6 +463,7 @@
 {
     fragment_header_t* header = (fragment_header_t*) buf;
     char *data = get_data_ptr_from_fragment(buf);
+    char *flag;
 
     assert(NULL != header);
     if (header->magic != LIBERASURECODE_FRAG_HEADER_MAGIC) {
@@ -475,7 +476,12 @@
 
     switch(header->meta.chksum_type) {
         case CHKSUM_CRC32:
-            header->meta.chksum[0] = crc32(0, (unsigned char *) data, 
blocksize);
+            flag = getenv("LIBERASURECODE_WRITE_LEGACY_CRC");
+            if (flag && !(flag[0] == '\0' || (flag[0] == '0' && flag[1] == 
'\0'))) {
+                header->meta.chksum[0] = liberasurecode_crc32_alt(0, data, 
blocksize);
+            } else {
+                header->meta.chksum[0] = crc32(0, (unsigned char *) data, 
blocksize);
+            }
             break;
         case CHKSUM_MD5:
             break;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/liberasurecode-1.6.1/src/erasurecode_postprocessing.c 
new/liberasurecode-1.6.2/src/erasurecode_postprocessing.c
--- old/liberasurecode-1.6.1/src/erasurecode_postprocessing.c   2019-05-24 
15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/src/erasurecode_postprocessing.c   2020-10-08 
23:46:14.000000000 +0200
@@ -32,6 +32,7 @@
 #include "erasurecode_helpers_ext.h"
 #include "erasurecode_log.h"
 #include "erasurecode_stdinc.h"
+#include "alg_sig.h"
 
 void add_fragment_metadata(ec_backend_t be, char *fragment,
         int idx, uint64_t orig_data_size, int blocksize,
@@ -59,8 +60,14 @@
         return;
     }
 
-    header->metadata_chksum = crc32(0, (unsigned char *) &header->meta,
-                                    sizeof(fragment_metadata_t));
+    char *flag = getenv("LIBERASURECODE_WRITE_LEGACY_CRC");
+    if (flag && !(flag[0] == '\0' || (flag[0] == '0' && flag[1] == '\0'))) {
+        header->metadata_chksum = liberasurecode_crc32_alt(
+            0, &header->meta, sizeof(fragment_metadata_t));
+    } else {
+        header->metadata_chksum = crc32(0, (unsigned char *) &header->meta,
+                                        sizeof(fragment_metadata_t));
+    }
 }
 
 int finalize_fragments_after_encode(ec_backend_t instance,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/liberasurecode-1.6.1/test/builtin/rs_vand/liberasurecode_rs_vand_test.c 
new/liberasurecode-1.6.2/test/builtin/rs_vand/liberasurecode_rs_vand_test.c
--- old/liberasurecode-1.6.1/test/builtin/rs_vand/liberasurecode_rs_vand_test.c 
2019-05-24 15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/test/builtin/rs_vand/liberasurecode_rs_vand_test.c 
2020-10-08 23:46:14.000000000 +0200
@@ -31,6 +31,7 @@
 #include <fcntl.h>
 #include <time.h>
 #include <liberasurecode_rs_vand.h>
+#include <sys/stat.h>
 
 int test_make_systematic_matrix(int k, int m)
 {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/liberasurecode-1.6.1/test/libec_slap.c 
new/liberasurecode-1.6.2/test/libec_slap.c
--- old/liberasurecode-1.6.1/test/libec_slap.c  2019-05-24 15:10:22.000000000 
+0200
+++ new/liberasurecode-1.6.2/test/libec_slap.c  2020-10-08 23:46:14.000000000 
+0200
@@ -280,8 +280,12 @@
             }
             j++;
         }
-        create_frags_array_set(&frags,encoded_data, args->k, encoded_parity,
-                               args->m, mask);
+        rc = create_frags_array_set(&frags, encoded_data, args->k, 
+                                    encoded_parity, args->m, mask);
+        if (rc) {
+            fprintf(stderr, "No core\n");
+            exit(2);
+        }
         rc = liberasurecode_decode(desc, frags.array, frags.num_fragments,
                                    encoded_fragment_len, 1,
                                    &out_data, &out_data_len);
@@ -305,8 +309,12 @@
             mi = mi + 1 % (args->k + args->m);
             mask = add_item_to_missing_mask(mask, mi);
         }
-        create_frags_array_set(&frags,encoded_data, args->k, encoded_parity,
-                               args->m, mask);
+        rc = create_frags_array_set(&frags, encoded_data, args->k,
+                                    encoded_parity, args->m, mask);
+        if (rc) {
+            fprintf(stderr, "No core\n");
+            exit(2);
+        }
         rc = liberasurecode_decode(desc, frags.array, frags.num_fragments,
                                    encoded_fragment_len, 1,
                                    &out_data, &out_data_len);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/liberasurecode-1.6.1/test/liberasurecode_test.c 
new/liberasurecode-1.6.2/test/liberasurecode_test.c
--- old/liberasurecode-1.6.1/test/liberasurecode_test.c 2019-05-24 
15:10:22.000000000 +0200
+++ new/liberasurecode-1.6.2/test/liberasurecode_test.c 2020-10-08 
23:46:14.000000000 +0200
@@ -105,10 +105,10 @@
     .ct = CHKSUM_NONE,
 };
 
-struct ec_args *jerasure_rs_vand_test_args[] = { &jerasure_rs_vand_args, 
-                                                 &jerasure_rs_vand_44_args, 
-                                                 &jerasure_rs_vand_1010_args, 
-                                                 &jerasure_rs_vand_48_args, 
+struct ec_args *jerasure_rs_vand_test_args[] = { &jerasure_rs_vand_args,
+                                                 &jerasure_rs_vand_44_args,
+                                                 &jerasure_rs_vand_1010_args,
+                                                 &jerasure_rs_vand_48_args,
                                                  NULL };
 struct ec_args jerasure_rs_cauchy_args = {
     .k = 10,
@@ -143,10 +143,10 @@
     .ct = CHKSUM_NONE,
 };
 
-struct ec_args *jerasure_rs_cauchy_test_args[] = { &jerasure_rs_cauchy_args, 
-                                                   
&jerasure_rs_cauchy_44_args, 
-                                                   
&jerasure_rs_cauchy_48_args, 
-                                                   
&jerasure_rs_cauchy_1010_args, 
+struct ec_args *jerasure_rs_cauchy_test_args[] = { &jerasure_rs_cauchy_args,
+                                                   &jerasure_rs_cauchy_44_args,
+                                                   &jerasure_rs_cauchy_48_args,
+                                                   
&jerasure_rs_cauchy_1010_args,
                                                    NULL };
 
 struct ec_args isa_l_args = {
@@ -170,7 +170,7 @@
     .hd = 11,
 };
 
-struct ec_args *isa_l_test_args[] = { &isa_l_args, 
+struct ec_args *isa_l_test_args[] = { &isa_l_args,
                                       &isa_l_44_args,
                                       &isa_l_1010_args,
                                       NULL };
@@ -385,8 +385,8 @@
     return buf;
 }
 
-static int create_fake_frags_no_meta(char ***array, int num_frags,
-                                     const char *data, int data_len)
+inline static int create_fake_frags_no_meta(char ***array, int num_frags,
+                                            const char data, int data_len)
 {
     // N.B. The difference from creat_frags_arry is to creat new
     // memory allocation and set a copy of data/parity there. The
@@ -404,8 +404,7 @@
     // add data and parity frags
     ptr = *array;
     for (i = 0; i < num_frags; i++) {
-        *ptr = (char *) malloc(data_len);
-        strncpy(*ptr++, data, data_len);
+        *ptr++ = create_buffer(data_len, data);
         _num_frags++;
     }
 
@@ -471,12 +470,18 @@
     uint32_t chksum = metadata->chksum[0];
     uint32_t computed = 0;
     uint32_t size = metadata->size;
+    char *flag;
     switch (args->ct) {
         case CHKSUM_MD5:
             assert(false); //currently only have support crc32
             break;
         case CHKSUM_CRC32:
-            computed = crc32(0, (unsigned char *) fragment_data, size);
+            flag = getenv("LIBERASURECODE_WRITE_LEGACY_CRC");
+            if (flag && !(flag[0] == '\0' || (flag[0] == '0' && flag[1] == 
'\0'))) {
+                computed = liberasurecode_crc32_alt(0, fragment_data, size);
+            } else {
+                computed = crc32(0, (unsigned char *) fragment_data, size);
+            }
             break;
         case CHKSUM_NONE:
             assert(metadata->chksum_mismatch == 0);
@@ -660,7 +665,6 @@
     // fake_data len should be bigger than fragment_header_t for
     // the verifications
     int fake_data_len = 1024;
-    char *fake_data = create_buffer(fake_data_len, 'y');
 
     desc = liberasurecode_instance_create(EC_BACKEND_NULL, &null_args);
     if (-EBACKENDNOTAVAIL == desc) {
@@ -672,9 +676,8 @@
     // test with invalid fragments (no metadata headers)
     num_avail_frags = create_fake_frags_no_meta(&avail_frags, (null_args.k +
                                                 null_args.m),
-                                                fake_data, fake_data_len);
+                                                'y', fake_data_len);
     assert(num_avail_frags > 0);
-    free(fake_data);
 
     rc = liberasurecode_decode(desc, avail_frags, num_avail_frags,
                                fake_data_len, 1,
@@ -697,7 +700,7 @@
 
     // test with num_fragments < (k)
     num_avail_frags = create_fake_frags_no_meta(&avail_frags, (null_args.k - 
1),
-                                                " ", 1);
+                                                ' ', 1);
     assert(num_avail_frags > 0);
     rc = liberasurecode_decode(desc, avail_frags, num_avail_frags,
                                fake_data_len, 1,
@@ -1073,7 +1076,7 @@
 
 /**
  * Note: this test will attempt to reconstruct a single fragment when
- * one or more other fragments are missing (specified by skip).  
+ * one or more other fragments are missing (specified by skip).
  *
  * For example, if skip is [0, 0, 0, 1, 0, 0] and we are reconstructing
  * fragment 5, then it will test the reconstruction of fragment 5 when 3
@@ -1344,6 +1347,24 @@
     free(orig_data);
 }
 
+static void test_write_legacy_fragment_metadata(const ec_backend_id_t be_id, 
struct ec_args *args)
+{
+    // any value except 0 will write legacy crc
+    setenv("LIBERASURECODE_WRITE_LEGACY_CRC", "1", 1);
+    test_get_fragment_metadata(be_id, args);
+    setenv("LIBERASURECODE_WRITE_LEGACY_CRC", "true", 1);
+    test_get_fragment_metadata(be_id, args);
+    // if the value is 0 or unset the value,
+    // it will write non-legacy crc but it's still safe to write the crc
+    setenv("LIBERASURECODE_WRITE_LEGACY_CRC", "0", 1);
+    test_get_fragment_metadata(be_id, args);
+    // even it's "00", it should be assumed as non-legacy
+    setenv("LIBERASURECODE_WRITE_LEGACY_CRC", "00", 1);
+    test_get_fragment_metadata(be_id, args);
+    unsetenv("LIBERASURECODE_WRITE_LEGACY_CRC");
+    test_get_fragment_metadata(be_id, args);
+}
+
 static void test_decode_with_missing_data(const ec_backend_id_t be_id,
                                           struct ec_args *args)
 {
@@ -1858,6 +1879,7 @@
     TEST(test_fragments_needed,                         backend, CHKSUM_NONE), 
\
     TEST(test_get_fragment_metadata,                    backend, CHKSUM_NONE), 
\
     TEST(test_get_fragment_metadata,                    backend, 
CHKSUM_CRC32), \
+    TEST(test_write_legacy_fragment_metadata,           backend, 
CHKSUM_CRC32), \
     TEST(test_verify_stripe_metadata,                   backend, 
CHKSUM_CRC32), \
     TEST(test_verify_stripe_metadata_libec_mismatch,    backend, 
CHKSUM_CRC32), \
     TEST(test_verify_stripe_metadata_magic_mismatch,    backend, 
CHKSUM_CRC32), \

Reply via email to