From b50204b41ee178a4ba72e2160e4dc4db260472d7 Mon Sep 17 00:00:00 2001 From: Vincent Jicquel Date: Fri, 23 Aug 2024 16:18:10 +0200 Subject: [PATCH 1/4] Fix vfs/basic test memory leak --- testsuite/tests/vfs/basic/test.adb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/testsuite/tests/vfs/basic/test.adb b/testsuite/tests/vfs/basic/test.adb index 30d999bb..25b17430 100644 --- a/testsuite/tests/vfs/basic/test.adb +++ b/testsuite/tests/vfs/basic/test.adb @@ -72,7 +72,17 @@ function Test return Integer is Write (W, "first word "); Close (W); W := Write_File (F, Append => True); - Write (W, Interfaces.C.Strings.New_String ("second word")); + + declare + use Interfaces.C.Strings; + + C_String : chars_ptr := + Interfaces.C.Strings.New_String ("second word"); + begin + Write (W, C_String); + Free (C_String); + end; + Close (W); -- Check whether the file exists From 95838fe7cbcf29fe1a20afe238f8ad8dd8eb98fa Mon Sep 17 00:00:00 2001 From: Vincent Jicquel Date: Fri, 23 Aug 2024 17:30:58 +0200 Subject: [PATCH 2/4] Fix promises test memory leak Message was not deallocated. --- testsuite/tests/promises/test.adb | 6 ++++-- testsuite/tests/promises/test_promises_support.adb | 2 +- testsuite/tests/promises/test_promises_support.ads | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/testsuite/tests/promises/test.adb b/testsuite/tests/promises/test.adb index bee58576..4862644d 100644 --- a/testsuite/tests/promises/test.adb +++ b/testsuite/tests/promises/test.adb @@ -24,6 +24,7 @@ with Ada.Text_IO; use Ada.Text_IO; with GNATCOLL.Promises; use GNATCOLL.Promises; with Test_Promises_Support; use Test_Promises_Support; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Test_Assert; @@ -64,7 +65,7 @@ begin and new Convert_Float and new Display_String); Put_Line ("Failing..."); - Message := new String'("Explicit failure"); + Message := To_Unbounded_String ("Explicit failure"); P.Set_Error ("Explicit failure"); A.Assert (A.Assert_Count, 7, "expected number of asserts #2"); @@ -74,7 +75,8 @@ begin and new Fail_On_Float and (new Display_String & new Display_String)); Baseline := 3; - Message := new String'("explicit"); + + Message := To_Unbounded_String ("explicit"); P.Set_Value (3); A.Assert (A.Assert_Count, 11, "expected number of asserts #3"); diff --git a/testsuite/tests/promises/test_promises_support.adb b/testsuite/tests/promises/test_promises_support.adb index 933a49f9..6ab8fcf8 100644 --- a/testsuite/tests/promises/test_promises_support.adb +++ b/testsuite/tests/promises/test_promises_support.adb @@ -80,7 +80,7 @@ package body Test_Promises_Support is pragma Unreferenced (Self); begin Put_Line ("Display_String.Failed because " & Reason); - A.Assert (Reason, Message.all, "expected reason"); + A.Assert (Reason, To_String (Message), "expected reason"); end On_Error; overriding procedure On_Next diff --git a/testsuite/tests/promises/test_promises_support.ads b/testsuite/tests/promises/test_promises_support.ads index 72404a8a..4886962f 100644 --- a/testsuite/tests/promises/test_promises_support.ads +++ b/testsuite/tests/promises/test_promises_support.ads @@ -22,11 +22,12 @@ ------------------------------------------------------------------------------ with GNATCOLL.Promises; use GNATCOLL.Promises; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package Test_Promises_Support is Baseline : Integer := 0; - Message : access String; + Message : Unbounded_String; -- Values that Assert routines should verify package Int_Promises is new Promises (Integer); From 0b43a76a7b1b56e8b8e9c4d968a32ad86abfaf4b Mon Sep 17 00:00:00 2001 From: Vincent Jicquel Date: Fri, 23 Aug 2024 17:49:49 +0200 Subject: [PATCH 3/4] Fix paragraph_filling/text memory leak --- testsuite/tests/paragraph_filling/text/test.adb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/testsuite/tests/paragraph_filling/text/test.adb b/testsuite/tests/paragraph_filling/text/test.adb index f5be952e..2f644cee 100644 --- a/testsuite/tests/paragraph_filling/text/test.adb +++ b/testsuite/tests/paragraph_filling/text/test.adb @@ -35,10 +35,10 @@ function Test return Integer is subtype Acc is GNAT.Strings.String_Access; - S_In : constant Acc := Read_File (Create_From_Base ("in.txt")); - S_Gr : constant Acc := Read_File (Create_From_Base ("greedy.txt")); - S_Pr : constant Acc := Read_File (Create_From_Base ("pretty.txt")); - S_Kn : constant Acc := Read_File (Create_From_Base ("knuth.txt")); + S_In : Acc := Read_File (Create_From_Base ("in.txt")); + S_Gr : Acc := Read_File (Create_From_Base ("greedy.txt")); + S_Pr : Acc := Read_File (Create_From_Base ("pretty.txt")); + S_Kn : Acc := Read_File (Create_From_Base ("knuth.txt")); begin @@ -58,5 +58,10 @@ begin A.Assert (S_Kn.all, ASU.To_String (Knuth_Fill (S_In.all, 60)), "Knuth fill"); + GNAT.Strings.Free (S_In); + GNAT.Strings.Free (S_Gr); + GNAT.Strings.Free (S_Pr); + GNAT.Strings.Free (S_Kn); + return A.Report; end Test; From 54b7e0861f282a3449af763e51fad58ec52fa3d6 Mon Sep 17 00:00:00 2001 From: Vincent Jicquel Date: Fri, 23 Aug 2024 17:52:55 +0200 Subject: [PATCH 4/4] Increase timeout to 500 seconds for the hash test --- testsuite/tests/hash/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/testsuite/tests/hash/test.yaml b/testsuite/tests/hash/test.yaml index fde3f872..c944e34a 100644 --- a/testsuite/tests/hash/test.yaml +++ b/testsuite/tests/hash/test.yaml @@ -1,4 +1,5 @@ description: Basic GNATCOLL.Hash test +timeout: 500 # Default time is not enough for the valgrind run control: - [SKIP, "env.target.machine == 'qemu'", "Not enough disk space on cross qemu configuration"]