* Bug #13941 fixed - Internal timestamps of HDF5 files prevented having a fixed 13/16813/1
Vincent COUVERT [Tue, 7 Jul 2015 13:58:40 +0000 (15:58 +0200)]
                     hash for an unvarying set of saved objects.

This bug was fixed by https://codereview.scilab.org/#/c/16676/.

Ref file added for binary_bit-for-bit.tst (missing in previous commit).

Change-Id: Iee58b8f91190482127dc982a5fe34b00dd9ec9e9

scilab/CHANGES_6.0.X
scilab/modules/hdf5/tests/nonreg_tests/bug_13941.dia.ref [new file with mode: 0644]
scilab/modules/hdf5/tests/nonreg_tests/bug_13941.tst [new file with mode: 0644]
scilab/modules/hdf5/tests/unit_tests/binary_bit-for-bit.dia.ref [new file with mode: 0644]
scilab/modules/hdf5/tests/unit_tests/binary_bit-for-bit.tst

index f154916..c22aeb3 100644 (file)
@@ -125,5 +125,8 @@ Scilab Bug Fixes
 
 * Bug #13838 fixed - Sparse and complex substraction made Scilab crash.
 
+* Bug #13941 fixed - Internal timestamps of HDF5 files prevented having a fixed
+                     hash for an unvarying set of saved objects.
+
 * Bug #13972 fixed - Wildcard ('*') was not managed in printf expressions.
 
diff --git a/scilab/modules/hdf5/tests/nonreg_tests/bug_13941.dia.ref b/scilab/modules/hdf5/tests/nonreg_tests/bug_13941.dia.ref
new file mode 100644 (file)
index 0000000..79b8aae
--- /dev/null
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Vincent COUVERT
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13941 -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13941
+//
+// <-- Short Description -->
+//
+// HDF5: internal timestamps prevent having a fixed hash for an unvarying set of saved objects
+a = 1;
+save(TMPDIR+"/test.sod", "a");
+sleep(1000);  // the timestamp's resolution is 1s
+save(TMPDIR+"/test2.sod", "a");
+assert_checkequal(getmd5(TMPDIR+"/test.sod"), getmd5(TMPDIR+"/test2.sod"));
diff --git a/scilab/modules/hdf5/tests/nonreg_tests/bug_13941.tst b/scilab/modules/hdf5/tests/nonreg_tests/bug_13941.tst
new file mode 100644 (file)
index 0000000..fe66424
--- /dev/null
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Vincent COUVERT
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13941 -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13941
+//
+// <-- Short Description -->
+//
+// HDF5: internal timestamps prevent having a fixed hash for an unvarying set of saved objects
+
+a = 1;
+save(TMPDIR+"/test.sod", "a");
+sleep(1000);  // the timestamp's resolution is 1s
+save(TMPDIR+"/test2.sod", "a");
+assert_checkequal(getmd5(TMPDIR+"/test.sod"), getmd5(TMPDIR+"/test2.sod"));
\ No newline at end of file
diff --git a/scilab/modules/hdf5/tests/unit_tests/binary_bit-for-bit.dia.ref b/scilab/modules/hdf5/tests/unit_tests/binary_bit-for-bit.dia.ref
new file mode 100644 (file)
index 0000000..ec6de96
--- /dev/null
@@ -0,0 +1,111 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Antoine ELIAS
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+clear;
+function writeData(filename, data)
+    save(filename, data);
+endfunction
+function checkBinary(file1, file2)
+    //open 1st file
+    f1 = mopen(file1, "rb");
+    mseek(0, f1, "end");
+    size1 = mtell(f1);
+    mseek(0, f1, "set");
+    //open 2nd file
+    f2 = mopen(file2, "rb");
+    mseek(0, f2, "end");
+    size2 = mtell(f2);
+    mseek(0, f2, "set");
+    //check file sizes
+    if size1 <> size2 then
+        mclose(f1);
+        mclose(f2);
+    end
+    assert_checkequal(size1, size2);
+    //get data for files
+    data1 = mget(size1, "uc", f1);
+    data2 = mget(size2, "uc", f2);
+    mclose(f1);
+    mclose(f2);
+    assert_checkequal(data1, data2);
+    //mdelete(file1);
+    //mdelete(file2);
+    //disp(size(data1, "*"));
+endfunction
+function writeAllData(path, radical)
+    d = matrix(1:100, [10, 10]);
+    data(:,:,1) = d - d * %i;
+    data(:,:,2) = -d;
+    data(:,:,3) = d * 2 + 4*d*%i;
+    data(:,:,4) = -d * 2;
+    data(:,:,5) = d - d * %i;
+    data(:,:,6) = -d
+    data(:,:,7) = d * 2 + 4*d*%i;
+    data(:,:,8) = -d * 2;
+    data(:,:,9) = d - d * %i;
+    data(:,:,10) = -d;
+    //write double
+    d = data;
+    writeData(path + "double" + radical + ".sod", "d");
+    //write string
+    s = string(data);
+    writeData(path + "string" + radical + ".sod", "s");
+    //write boolean
+    b = real(data) > 0;
+    writeData(path + "boolean" + radical + ".sod", "b");
+    //write ints
+    i8 = int8(data);
+    writeData(path + "int8" + radical + ".sod", "i8");
+    i16 = int16(data);
+    writeData(path + "int16" + radical + ".sod", "i16");
+    i32 = int32(data);
+    writeData(path + "int32" + radical + ".sod", "i32");
+    i64 = int64(data);
+    writeData(path + "int64" + radical + ".sod", "i64");
+    ui8 = uint8(data);
+    writeData(path + "uint8" + radical + ".sod", "ui8");
+    ui16 = uint16(data);
+    writeData(path + "uint16" + radical + ".sod", "ui16");
+    ui32 = uint32(data);
+    writeData(path + "uint32" + radical + ".sod", "ui32");
+    ui64 = uint64(data);
+    writeData(path + "uint64" + radical + ".sod", "ui64");
+    //write polynom
+    p = data * %s;
+    writeData(path + "poly" + radical + ".sod", "p");
+    //write list
+    l = list(d,s,b,i8,i16,i32,i64,ui8,ui16,ui32,ui64,p);
+    writeData(path + "list" + radical + ".sod", "l");
+endfunction
+function checkAllData(path, radical1, radical2)
+    //check double
+    checkBinary(path + "double" + radical1 + ".sod", path + "double" + radical2 + ".sod");
+    //check string
+    checkBinary(path + "string" + radical1 + ".sod", path + "string" + radical2 + ".sod");
+    //check boolean
+    checkBinary(path + "boolean" + radical1 + ".sod", path + "boolean" + radical2 + ".sod");
+    //check ints
+    checkBinary(path + "int8" + radical1 + ".sod", path + "int8" + radical2 + ".sod");
+    checkBinary(path + "int16" + radical1 + ".sod", path + "int16" + radical2 + ".sod");
+    checkBinary(path + "int32" + radical1 + ".sod", path + "int32" + radical2 + ".sod");
+    checkBinary(path + "int64" + radical1 + ".sod", path + "int64" + radical2 + ".sod");
+    checkBinary(path + "uint8" + radical1 + ".sod", path + "uint8" + radical2 + ".sod");
+    checkBinary(path + "uint16" + radical1 + ".sod", path + "uint16" + radical2 + ".sod");
+    checkBinary(path + "uint32" + radical1 + ".sod", path + "uint32" + radical2 + ".sod");
+    checkBinary(path + "uint64" + radical1 + ".sod", path + "uint64" + radical2 + ".sod");
+    //check poly
+    checkBinary(path + "poly" + radical1 + ".sod", path + "poly" + radical2 + ".sod");
+    //check list
+    checkBinary(path + "list" + radical1 + ".sod", path + "list" + radical2 + ".sod");
+endfunction
+path = TMPDIR + "/";
+radical1 = "1";
+radical2 = "2";
+writeAllData(path, radical1);
+sleep(2000);
+writeAllData(path, radical2);
+checkAllData(path, radical1, radical2);
index f5d30b1..6c268eb 100644 (file)
@@ -8,7 +8,7 @@
 
 clear;
 function writeData(filename, data)
-    save_new(filename, data);
+    save(filename, data);
 endfunction
 
 function checkBinary(file1, file2)
@@ -44,7 +44,7 @@ function checkBinary(file1, file2)
     //mdelete(file1);
     //mdelete(file2);
 
-    disp(size(data1, "*"));
+    //disp(size(data1, "*"));
 endfunction
 
 function writeAllData(path, radical)